0
我試圖單元測試一些使用Blob存儲API的代碼,但是我得到NullPointerException
此代碼:單元測試Blob存儲API
@ContextConfiguration(locations = { "classpath:service/client-config.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class BlobstoreDaoTest {
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
private final LocalBlobstoreServiceTestConfig config =
new LocalBlobstoreServiceTestConfig();
@Autowired
private BlobstoreDao dao;
@Before
public void setUp() {
config.setUp();
helper.setUp();
}
@After
public void tearDown() {
helper.tearDown();
config.tearDown();
}
@Test
public void doTest() {
// Code omitted
}
}
錯誤:
java.lang.NullPointerException
at com.google.appengine.tools.development.testing.LocalBlobstoreServiceTestConfig.setUp(LocalBlobstoreServiceTestConfig.java:52)
助手肩d包含所有的配置,並且只調用它的setUp/tearDown。本地blobstore可能沒有看到數據存儲設置,因爲它在上下文之外。 –