use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class SimplePojoTest method war.
@Module
@Classes(cdi = true, value = { MyFirstRestClass.class })
public WebModule war() {
final WebModule webModule = new WebModule(new WebApp(), "/foo", Thread.currentThread().getContextClassLoader(), "", "foo");
webModule.getRestClasses().add(MyFirstRestClass.class.getName());
return webModule;
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method testFromWebAppIdThirdParty.
/**
* Existing data source "orange-id", not controlled by us
* <p/>
* Application contains a web module with id "orange-id"
* <p/>
* Persistence xml like so:
* <p/>
* <persistence-unit name="orange-unit" />
* <p/>
* The orange-unit app should automatically use orange-id data source and the non-jta-datasource should be null
*
* @throws Exception
*/
public void testFromWebAppIdThirdParty() throws Exception {
final ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", null);
assertSame(supplied, resources.get(0));
final PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");
final ClassLoader cl = this.getClass().getClassLoader();
final AppModule app = new AppModule(cl, "orange-app");
app.addPersistenceModule(new PersistenceModule("root", new Persistence(persistenceUnit)));
final WebApp webApp = new WebApp();
webApp.setMetadataComplete(true);
app.getWebModules().add(new WebModule(webApp, "orange-web", cl, null, "orange-id"));
// Create app
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
final PersistenceUnitInfo unitInfo = appInfo.persistenceUnits.get(0);
// Check results
assertEquals(supplied.id, unitInfo.jtaDataSource);
assertNull(unitInfo.nonJtaDataSource);
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method testFromWebAppContextJta.
/**
* Existing data source "orange-web", jta managed
* <p/>
* Application contains a web module with root context path as "orange-web"
* <p/>
* Persistence xml like so:
* <p/>
* <persistence-unit name="orange-unit" />
* <p/>
* The orange-unit app should automatically use orange-web data source and create a new non-JtaManaged datasource
*
* @throws Exception
*/
public void testFromWebAppContextJta() throws Exception {
final ResourceInfo supplied = addDataSource("orange-web", OrangeDriver.class, "jdbc:orange-web:some:stuff", true);
assertSame(supplied, resources.get(0));
final PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");
final ClassLoader cl = this.getClass().getClassLoader();
final AppModule app = new AppModule(cl, "orange-app");
app.addPersistenceModule(new PersistenceModule("root", new Persistence(persistenceUnit)));
final WebApp webApp = new WebApp();
webApp.setMetadataComplete(true);
app.getWebModules().add(new WebModule(webApp, "orange-web", cl, "war", "orange-web"));
// Create app
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
// Check results
final ResourceInfo generated = resources.get(1);
assertEquals(supplied.id + "NonJta", generated.id);
assertEquals(supplied.service, generated.service);
assertEquals(supplied.className, generated.className);
assertEquals(supplied.properties.get("JdbcDriver"), generated.properties.get("JdbcDriver"));
assertEquals(supplied.properties.get("JdbcUrl"), generated.properties.get("JdbcUrl"));
assertEquals("false", generated.properties.get("JtaManaged"));
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method testFromWebAppIdNonJta.
/**
* Existing data source "orange-id", non-jta managed
* <p/>
* Application contains a web module with id "orange-id"
* <p/>
* Persistence xml like so:
* <p/>
* <persistence-unit name="orange-unit" />
* <p/>
* The orange-unit app should automatically use orange-id data source and create a new non-JtaManaged datasource
*
* @throws Exception
*/
public void testFromWebAppIdNonJta() throws Exception {
final ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", false);
assertSame(supplied, resources.get(0));
final PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");
final ClassLoader cl = this.getClass().getClassLoader();
final AppModule app = new AppModule(cl, "orange-app");
app.addPersistenceModule(new PersistenceModule("root", new Persistence(persistenceUnit)));
final WebApp webApp = new WebApp();
webApp.setMetadataComplete(true);
app.getWebModules().add(new WebModule(webApp, "orange-web", cl, "war", "orange-id"));
// Create app
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
// Check results
final ResourceInfo generated = resources.get(1);
assertEquals(supplied.id + "Jta", generated.id);
assertEquals(supplied.service, generated.service);
assertEquals(supplied.className, generated.className);
assertEquals(supplied.properties.get("JdbcDriver"), generated.properties.get("JdbcDriver"));
assertEquals(supplied.properties.get("JdbcUrl"), generated.properties.get("JdbcUrl"));
assertEquals("true", generated.properties.get("JtaManaged"));
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class ConfigurationFactoryTest method testConfigureApplicationWebModule.
@Test
public void testConfigureApplicationWebModule() throws OpenEJBException {
SystemInstance.get().setProperty("openejb.environment.default", "false");
final String moduleId = "testConfigureApplicationWebModule";
final String fileSeparator = System.getProperty("file.separator");
SystemInstance.get().setProperty(ConfigurationFactory.VALIDATION_SKIP_PROPERTY, "false");
SystemInstance.get().setProperty(DeploymentsResolver.SEARCH_CLASSPATH_FOR_DEPLOYMENTS_PROPERTY, "false");
final ConfigurationFactory factory = new ConfigurationFactory();
final WebApp webApp = new WebApp();
// no real classes engaged so disable metadata (annotation) processing
webApp.setMetadataComplete(true);
final WebModule webModule = new WebModule(webApp, null, null, fileSeparator + "some" + fileSeparator + "where.war", moduleId);
final WebAppInfo info = factory.configureApplication(webModule);
assertEquals(moduleId, info.moduleId);
SystemInstance.get().getProperties().remove("openejb.environment.default");
}
Aggregations