Beispiel #1
0
 // @Configuration(groups = "integration.ejb3", afterSuite = true)
 @AfterSuite(alwaysRun = true)
 public static void shutdownEmbeddedJboss() {
   System.err.println("!!! Any errors occurring after this point    !!!");
   System.err.println("!!! occurred during embedded server shutdown !!!");
   System.err.println("!!! and is probably not a real problem.      !!!");
   if (deployer != null) {
     try {
       deployer.stop();
       deployer.destroy();
       deployer = null;
     } catch (Throwable t) {
       System.err.println("Failed to stop embedded deployer");
       t.printStackTrace(System.err);
     }
   }
   EJB3StandaloneBootstrap.shutdown();
 }
Beispiel #2
0
  // @BeforeSuite(groups = {"integration.ejb3","PERF"}) // TODO investigate again
  @BeforeSuite(alwaysRun = true)
  public static void startupEmbeddedJboss() throws Exception {

    // Setting content location to the tmp dir
    System.setProperty(
        ContentSourceManagerBean.FILESYSTEM_PROPERTY, System.getProperty("java.io.tmpdir"));

    System.out.println("Starting ejb3...");
    String deployDir = System.getProperty("deploymentDirectory", "target/classes");
    System.out.println("Loading EJB3 deployments from directory: " + deployDir);
    try {
      EJB3StandaloneBootstrap.boot(null);
      //         EJB3StandaloneBootstrap.scanClasspath();

      System.err.println("...... embedded container booted....");

      deployer = EJB3StandaloneBootstrap.createDeployer();

      deployer.setClassLoader(AbstractEJB3Test.class.getClassLoader());
      System.err.println("...... embedded container classloader set....");

      deployer.getArchivesByResource().add("META-INF/persistence.xml");
      System.err.println("...... embedded container persistence xml deployed....");

      deployer.getArchivesByResource().add("META-INF/ejb-jar.xml");
      System.err.println("...... embedded container ejb-jar xml deployed....");

      EJB3StandaloneBootstrap.deployXmlResource("jboss-jms-beans.xml");
      System.err.println("...... embedded container jboss-jms-beans xml deployed....");

      EJB3StandaloneBootstrap.deployXmlResource("rhq-mdb-beans.xml");
      System.err.println("...... embedded container rhq-mdb-beans xml deployed....");

      /*
       * File core = new File(deployDir, "on-core-domain-ejb.ejb3");      if (!core.exists())
       * System.err.println("Deployment directory does not exist: " + core.getAbsolutePath());
       * deployer.getArchives().add(core.toURI().toURL());
       *
       * File server = new File(deployDir, "on-enterprise-server-ejb.ejb3");      if (!server.exists())
       * System.err.println("Deployment directory does not exist: " + server.getAbsolutePath());
       * deployer.getArchives().add(server.toURI().toURL());
       *
       */

      // deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
      deployer.create();
      System.err.println("...... deployer created....");

      deployer.start();
      System.err.println("...... deployer started....");

      System.err.println("...... start statistics");
      SessionFactory sessionFactory =
          PersistenceUtility.getHibernateSession(getEntityManager()).getSessionFactory();
      stats = sessionFactory.getStatistics();
      stats.setStatisticsEnabled(true);

      System.err.println("...... embedded container initialized and ready for testing....");

    } catch (Throwable t) {
      // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will
      // completely swallow them
      // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
      t.printStackTrace();
      throw new RuntimeException(t);
    }
  }