我正在尝试使用Objectify建立本地GAE数据存储区,并希望使用包含车辆颜色的vehicleummary类来保存并加载它:
private Closeable closeable;
private final LocalServiceTestHelper helper = new LocalServiceTestHelper(
new LocalDatastoreServiceTestConfig(),
new LocalMemcacheServiceTestConfig());
@Before
public void setUp() {
helper.setUp();
ObjectifyService.init(new ObjectifyFactory(DatastoreOptions
.newBuilder().setHost("http://localhost:8080")
.setProjectId("my-project").build().getService(),
new AppEngineMemcacheClientService()));
ObjectifyService.register(VehicleSummary.class);
closeable = ObjectifyService.begin();
}
@After
public void tearDown() {
closeable.close();
helper.tearDown();
}
@Test
public void test() {
VehicleSummary veh_summary = new VehicleSummary ("red");
ObjectifyService.ofy().save().entity(veh_summary).now();
}
运行此命令,数据存储区将在返回时进行初始化
AM com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFORMATION: Local Datastore initialized:
Type: High Replication
Storage: In-memory
但行
ObjectifyService.ofy().save().entity(veh_summary).now();
未被覆盖,并且最终中止:
com.google.cloud.datastore.DatastoreException: Deadline exceeded