use of org.apache.openejb.jee.WebApp 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");
}
use of org.apache.openejb.jee.WebApp in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method testFromWebAppContextJta.
/**
* Existing data source "orange-web", jta managed
*
* Application contains a web module with root context path as "orange-web"
*
* Persistence xml like so:
*
* <persistence-unit name="orange-unit" />
*
* 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 in project tomee by apache.
the class WebAppEnvEntryTest method war.
@Module
@Classes(cdi = true, value = { CdiBean.class })
public WebApp war() {
final WebApp webApp = new WebApp().contextRoot("/myapp");
webApp.getEnvEntry().add(new EnvEntry("foo", String.class.getName(), "bar"));
return webApp;
}
use of org.apache.openejb.jee.WebApp in project tomee by apache.
the class WsJMXTest method war.
@Module
@Classes({ AnEjbEndpoint.class, AnPojoEndpoint.class })
public WebApp war() {
final WebApp webapp = new WebApp().contextRoot("app");
Servlet servlet = new Servlet();
servlet.setServletName("toto");
servlet.setServletClass(AnPojoEndpoint.class.getName());
ServletMapping servletMapping = new ServletMapping();
servletMapping.setServletName("pojo");
servletMapping.getUrlPattern().add("/toto");
webapp.getServlet().add(servlet);
webapp.getServletMapping().add(servletMapping);
return webapp;
}
use of org.apache.openejb.jee.WebApp 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;
}
Aggregations