本文整理汇总了Java中org.apache.cayenne.configuration.server.ServerRuntime.newContext方法的典型用法代码示例。如果您正苦于以下问题:Java ServerRuntime.newContext方法的具体用法?Java ServerRuntime.newContext怎么用?Java ServerRuntime.newContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cayenne.configuration.server.ServerRuntime
的用法示例。
在下文中一共展示了ServerRuntime.newContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testListeners
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testListeners() {
L1 l1 = new L1();
CayenneDataObject o1 = new CayenneDataObject();
o1.setObjectId(new ObjectId("T1"));
o1.writeProperty("name", "n" + 1);
CayenneDataObject o2 = new CayenneDataObject();
o2.setObjectId(new ObjectId("T1"));
o2.writeProperty("name", "n" + 2);
ServerRuntime runtime = runtimeWithListeners(l1);
try {
ObjectContext c = runtime.newContext();
c.registerNewObject(o1);
c.registerNewObject(o2);
c.commitChanges();
} finally {
runtime.shutdown();
}
assertEquals(2, l1.postPersisted.size());
assertTrue(l1.postPersisted.contains(o1));
assertTrue(l1.postPersisted.contains(o2));
}
示例2: testFilters
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testFilters() {
DataChannelFilter f = mock(DataChannelFilter.class);
when(f.onSync(any(), any(), anyInt(), any())).thenReturn(mock(GraphDiff.class));
CayenneDataObject o1 = new CayenneDataObject();
o1.setObjectId(new ObjectId("T1"));
o1.writeProperty("name", "n" + 1);
CayenneDataObject o2 = new CayenneDataObject();
o2.setObjectId(new ObjectId("T1"));
o2.writeProperty("name", "n" + 2);
ServerRuntime runtime = runtimeWithFilters(f);
try {
ObjectContext c = runtime.newContext();
c.registerNewObject(o1);
c.registerNewObject(o2);
c.commitChanges();
} finally {
runtime.shutdown();
}
verify(f).onSync(any(), any(), anyInt(), any());
}
示例3: CayennePersister
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
public CayennePersister(ServerRuntime runtime) {
if (runtime == null) {
throw new NullPointerException("Null runtime");
}
this.runtime = runtime;
this.sharedContext = runtime.newContext();
}