Search in sources :

Example 21 with WebApp

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");
}
Also used : WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) WebApp(org.apache.openejb.jee.WebApp) Test(org.junit.Test)

Example 22 with WebApp

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"));
}
Also used : Persistence(org.apache.openejb.jee.jpa.unit.Persistence) ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) PersistenceUnit(org.apache.openejb.jee.jpa.unit.PersistenceUnit) WebApp(org.apache.openejb.jee.WebApp) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 23 with WebApp

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;
}
Also used : WebApp(org.apache.openejb.jee.WebApp) EnvEntry(org.apache.openejb.jee.EnvEntry) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 24 with 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;
}
Also used : ServletMapping(org.apache.openejb.jee.ServletMapping) Servlet(org.apache.openejb.jee.Servlet) WebApp(org.apache.openejb.jee.WebApp) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 25 with 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;
}
Also used : MyFirstRestClass(org.apache.openejb.server.cxf.rs.beans.MyFirstRestClass) WebModule(org.apache.openejb.config.WebModule) WebApp(org.apache.openejb.jee.WebApp) WebModule(org.apache.openejb.config.WebModule) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Aggregations

WebApp (org.apache.openejb.jee.WebApp)26 AppInfo (org.apache.openejb.assembler.classic.AppInfo)8 Persistence (org.apache.openejb.jee.jpa.unit.Persistence)7 PersistenceUnit (org.apache.openejb.jee.jpa.unit.PersistenceUnit)7 File (java.io.File)6 IOException (java.io.IOException)6 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)6 URL (java.net.URL)5 WebModule (org.apache.openejb.config.WebModule)5 MalformedURLException (java.net.MalformedURLException)4 LinkedHashSet (java.util.LinkedHashSet)4 JarFile (java.util.jar.JarFile)4 EnvEntry (org.apache.openejb.jee.EnvEntry)4 HashSet (java.util.HashSet)3 OpenEJBException (org.apache.openejb.OpenEJBException)3 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)3 EjbJar (org.apache.openejb.jee.EjbJar)3 Classes (org.apache.openejb.testing.Classes)3 Module (org.apache.openejb.testing.Module)3 InputStream (java.io.InputStream)2