本文整理汇总了Java中org.apache.cayenne.configuration.server.ServerRuntime.getDataDomain方法的典型用法代码示例。如果您正苦于以下问题:Java ServerRuntime.getDataDomain方法的具体用法?Java ServerRuntime.getDataDomain怎么用?Java ServerRuntime.getDataDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cayenne.configuration.server.ServerRuntime
的用法示例。
在下文中一共展示了ServerRuntime.getDataDomain方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateCayenneRuntime_NoName
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testCreateCayenneRuntime_NoName() {
ServerRuntimeFactory factory = new ServerRuntimeFactory();
factory.setDatasource("ds1");
ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
try {
DataDomain domain = runtime.getDataDomain();
assertEquals("cayenne", domain.getName());
assertEquals(1, domain.getDataNodes().size());
assertNotNull(domain.getDefaultNode());
assertEquals("cayenne", domain.getDefaultNode().getName());
} finally {
runtime.shutdown();
}
}
示例2: testCreateCayenneRuntime_Name
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testCreateCayenneRuntime_Name() {
ServerRuntimeFactory factory = new ServerRuntimeFactory();
factory.setConfigs(asList("cayenne-project1.xml"));
factory.setDatasource("ds1");
factory.setName("me");
ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
try {
DataDomain domain = runtime.getDataDomain();
assertEquals("me", domain.getName());
assertEquals(1, domain.getDataNodes().size());
assertNotNull(domain.getDefaultNode());
assertEquals("me", domain.getDefaultNode().getName());
} finally {
runtime.shutdown();
}
}
示例3: testCreateCayenneRuntime_Configs
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testCreateCayenneRuntime_Configs() {
ServerRuntimeFactory factory = new ServerRuntimeFactory();
factory.setDatasource("ds1");
factory.setConfigs(asList("cayenne-project2.xml", "cayenne-project1.xml"));
ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
try {
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));
} finally {
runtime.shutdown();
}
}
示例4: testConfig_ExplicitMaps_SharedDatasource
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testConfig_ExplicitMaps_SharedDatasource() {
ServerRuntime runtime = testFactory.app("--config=classpath:config_explicit_maps.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));
// trigger a DB op
SQLSelect.dataRowQuery("map1", "SELECT * FROM db_entity").select(runtime.newContext());
SQLSelect.dataRowQuery("map2", "SELECT * FROM db_entity2").select(runtime.newContext());
}
示例5: testConfig_ExplicitMaps_DifferentDatasources
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testConfig_ExplicitMaps_DifferentDatasources() {
ServerRuntime runtime = testFactory.app("--config=classpath:config_explicit_maps_2.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));
// trigger a DB op
SQLSelect.dataRowQuery("map1", "SELECT * FROM db_entity").select(runtime.newContext());
SQLSelect.dataRowQuery("map2", "SELECT * FROM db_entity2").select(runtime.newContext());
}
示例6: testDefaultDataSource
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testDefaultDataSource() throws SQLException {
ServerRuntime runtime = testFactory.app("--config=classpath:noconfig.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getDataNode("cayenne"));
try(Connection c = domain.getDataNode("cayenne").getDataSource().getConnection();) {
DatabaseMetaData md = c.getMetaData();
assertEquals("jdbc:derby:target/derby/bqjdbc_noconfig", md.getURL());
}
}
示例7: testUndefinedDataSource
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testUndefinedDataSource() throws SQLException {
ServerRuntime runtime = testFactory.app("--config=classpath:noconfig_2ds.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
try {
runtime.getDataDomain();
}
catch (DataDomainLoadException e) {
assertTrue(e.getCause().getMessage()
.startsWith("Can't map Cayenne DataSource: 'cayenne.datasource' is missing."));
}
}
示例8: testUnmatchedDataSource
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testUnmatchedDataSource() throws SQLException {
ServerRuntime runtime = testFactory.app("--config=classpath:noconfig_2ds_unmatched.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
try {
runtime.getDataDomain();
fail();
}
catch (DataDomainLoadException e) {
String message = e.getCause().getMessage();
assertEquals("No configuration present for DataSource named 'ds3'", message);
}
}
示例9: testDefaultConfig
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testDefaultConfig() {
ServerRuntime runtime = testFactory.app("--config=classpath:defaultconfig.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity"));
// trigger DB op
SQLSelect.dataRowQuery("SELECT * FROM db_entity").select(runtime.newContext());
}
示例10: createCayenneRuntime
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Provides
@Singleton
protected ServerRuntime createCayenneRuntime(ConfigurationFactory configFactory,
DataSourceFactory dataSourceFactory,
BootLogger bootLogger,
ShutdownManager shutdownManager,
Set<Module> customModules,
@CayenneListener Set<Object> listeners,
Set<DataChannelFilter> filters,
CayenneConfigMerger configMerger,
@CayenneConfigs Set<String> injectedCayenneConfigs) {
Collection<Module> extras = extraCayenneModules(customModules, filters);
ServerRuntime runtime = configFactory.config(ServerRuntimeFactory.class, configPrefix)
.createCayenneRuntime(dataSourceFactory, extras,
cayenneConfigs -> configMerger.merge(cayenneConfigs, injectedCayenneConfigs));
shutdownManager.addShutdownHook(() -> {
bootLogger.trace(() -> "shutting down Cayenne...");
runtime.shutdown();
});
// TODO: listeners should be really contributable to Cayenne via DI,
// just like filters...
if (!listeners.isEmpty()) {
DataDomain domain = runtime.getDataDomain();
listeners.forEach(domain::addListener);
}
return runtime;
}
示例11: testCreateCayenneRuntime_NoConfig
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testCreateCayenneRuntime_NoConfig() {
ServerRuntimeFactory factory = new ServerRuntimeFactory();
factory.setDatasource("ds1");
ServerRuntime runtime = factory.createCayenneRuntime(mockDSFactory, Collections.emptyList());
try {
DataDomain domain = runtime.getDataDomain();
assertTrue(domain.getEntityResolver().getDbEntities().isEmpty());
} finally {
runtime.shutdown();
}
}
示例12: testFullConfig
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testFullConfig() {
ServerRuntime runtime = testFactory.app("--config=classpath:fullconfig.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertNotNull(domain.getEntityResolver().getDbEntity("db_entity2"));
// trigger a DB op
SQLSelect.dataRowQuery("SELECT * FROM db_entity2").select(runtime.newContext());
}
示例13: testNoConfig
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testNoConfig() {
ServerRuntime runtime = testFactory.app("--config=classpath:noconfig.yml")
.autoLoadModules()
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertTrue(domain.getEntityResolver().getDbEntities().isEmpty());
}
示例14: testMergeConfigs
import org.apache.cayenne.configuration.server.ServerRuntime; //导入方法依赖的package包/类
@Test
public void testMergeConfigs() {
Module cayenneProjectModule = binder -> CayenneModule.extend(binder).addProject("cayenne-project2.xml");
ServerRuntime runtime = testFactory.app("--config=classpath:noconfig.yml")
.autoLoadModules()
.module(cayenneProjectModule)
.createRuntime()
.getInstance(ServerRuntime.class);
DataDomain domain = runtime.getDataDomain();
assertFalse(domain.getEntityResolver().getDbEntities().isEmpty());
}