Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-1345

basic support of Tomcat embedded in tomee-embedded

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.7.2, 7.0.0-M1
    • None
    • None

    Description

      idea is to be able to do:

          @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)) {
                  // tomee-embedded (this "container url" is filtered: name prefix + it is a directory (target/test-classes)
                  final File parent = Files.mkdirs(new File("target/" + getClass().getSimpleName()));
                  final File war = ShrinkWrap.create(WebArchive.class, "the-webapp")
                          .addClass(Foo.class)
                          .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") // activate CDI
                          .as(ExplodedExporter.class)
                          .exportExploded(parent);
      
                  final Context ctx = container.addContext("/", war.getAbsolutePath());
      
                  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());
              }
          }
      

      Attachments

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            romain.manni-bucau Romain Manni-Bucau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: