Exemple #1
0
  protected void doServerSetUp() throws Exception {
    DefaultObjectResolver.setServerUri(getBaseURL());

    server = new Server(PORT);

    ServiceContext.setInTexoTestRun();

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/" + CONTEXTNAME); // $NON-NLS-1$
    server.setHandler(context);

    EntityManagerProvider.getInstance().setUseCurrentEntityManagerPattern(true);

    final XMLRestWebServiceServlet xmlWebServiceServlet = new XMLRestWebServiceServlet();
    context.addServlet(
        new ServletHolder(xmlWebServiceServlet), "/" + XMLWS + "/*"); // $NON-NLS-1$ //$NON-NLS-2$

    final JSONRestWebServiceServlet jsonRestWebServiceServlet = new JSONRestWebServiceServlet();
    context.addServlet(
        new ServletHolder(jsonRestWebServiceServlet),
        "/" + JSONWS + "/*"); // $NON-NLS-1$ //$NON-NLS-2$

    final TestEntityManagerCleanUpServlet testEMServlet = new TestEntityManagerCleanUpServlet();
    context.addServlet(new ServletHolder(testEMServlet), "/testEM"); // $NON-NLS-1$

    final EnumSet<DispatcherType> all =
        EnumSet.of(
            DispatcherType.ASYNC,
            DispatcherType.ERROR,
            DispatcherType.FORWARD,
            DispatcherType.INCLUDE,
            DispatcherType.REQUEST);

    context.addFilter(TestEntityManagerRequestFilter.class, "/*", all); // $NON-NLS-1$
    context.addFilter(CurrentEntityManagerRequestFilter.class, "/*", all); // $NON-NLS-1$

    server.start();
  }
  public BaseWSWebTest(String name) {
    super(name);

    ServiceContext.setInTexoTestRun();
  }