You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2014/09/14 15:49:33 UTC

[jira] [Updated] (TOMEE-1345) basic support of Tomcat embedded in tomee-embedded

     [ https://issues.apache.org/jira/browse/TOMEE-1345?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Romain Manni-Bucau updated TOMEE-1345:
--------------------------------------
    Description: 
idea is to be able to do:

{code}
    @Test
    public void run() throws IOException {
        final Configuration configuration = new Configuration().randomHttpPort();
        configuration.setDir(Files.mkdirs(new File("target/" + getClass().getSimpleName() + "-tomcat")).getAbsolutePath());

        try (final Container container = new Container(configuration)) {
            final Context ctx = container.addContext("/", "target/" + getClass().getSimpleName() + "/the-webapp");
            container.copyClasses(ctx, Foo.class)  // tomee-embedded (this "container url" is filtered: name prefix + it is a directory (target/test-classes)
                     .copyResource(ctx, "", "WEB-INF/beans.xml"); // activate CDI

            final Wrapper wrapper = Tomcat.addServlet(ctx, "awesome", AServlet.class.getName());
            ctx.addServletMapping("/awesome", wrapper.getName());

            assertEquals("Awesome", IO.slurp(new URL("http://localhost:" + configuration.getHttpPort() + "/awesome")).trim());
        } catch (final Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
{code}


  was:
idea is to be able to do:

{code}
    @Test
    public void run() throws IOException {
        final Configuration configuration = new Configuration().randomHttpPort();
        configuration.setDir(Files.mkdirs(new File("target/" + getClass().getSimpleName() + "-tomcat")).getAbsolutePath());

        try (final Container container = new Container(configuration)) {
            final Context ctx = container.addContext("/", "target/" + getClass().getSimpleName() + "/the-webapp");
            container.copyClasses(ctx, Foo.class)  // tomee-embedded (this "container url" is filtered: name prefix + it is a directory (target/test-classes)
                     .copyResource(ctx, "", "WEB-INF/beans.xml"); // activate CDI

            final Wrapper wrapper = Tomcat.addServlet(ctx, "awesome", AServlet.class.getName());
            ctx.addServletMapping("/awesome", wrapper.getName());
            ctx.setLoader(new TomEEWebappLoader());

            assertEquals("Awesome", IO.slurp(new URL("http://localhost:" + configuration.getHttpPort() + "/awesome")).trim());
        } catch (final Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
{code}



> basic support of Tomcat embedded in tomee-embedded
> --------------------------------------------------
>
>                 Key: TOMEE-1345
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1345
>             Project: TomEE
>          Issue Type: New Feature
>            Reporter: Romain Manni-Bucau
>
> idea is to be able to do:
> {code}
>     @Test
>     public void run() throws IOException {
>         final Configuration configuration = new Configuration().randomHttpPort();
>         configuration.setDir(Files.mkdirs(new File("target/" + getClass().getSimpleName() + "-tomcat")).getAbsolutePath());
>         try (final Container container = new Container(configuration)) {
>             final Context ctx = container.addContext("/", "target/" + getClass().getSimpleName() + "/the-webapp");
>             container.copyClasses(ctx, Foo.class)  // tomee-embedded (this "container url" is filtered: name prefix + it is a directory (target/test-classes)
>                      .copyResource(ctx, "", "WEB-INF/beans.xml"); // activate CDI
>             final Wrapper wrapper = Tomcat.addServlet(ctx, "awesome", AServlet.class.getName());
>             ctx.addServletMapping("/awesome", wrapper.getName());
>             assertEquals("Awesome", IO.slurp(new URL("http://localhost:" + configuration.getHttpPort() + "/awesome")).trim());
>         } catch (final Exception e) {
>             e.printStackTrace();
>             fail(e.getMessage());
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)