List of usage examples for javax.ejb.embeddable EJBContainer close
abstract public void close();
From source file:org.apache.tomee.embedded.EmbeddedTomEEContainerTest.java
@Test public void containerTest() throws Exception { final File war = createWar(); final Properties p = new Properties(); p.setProperty(EJBContainer.APP_NAME, "test"); p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName()); p.put(EJBContainer.MODULES, war.getAbsolutePath()); p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1"); EJBContainer container = null; try {//from w w w .j a v a 2s . com container = EJBContainer.createEJBContainer(p); assertNotNull(container); assertNotNull(container.getContext()); final URL url = new URL("http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/test/index.html"); assertEquals("true", getOk(url, 2)); } finally { if (container != null) { container.close(); } try { FileUtils.forceDelete(war); } catch (final IOException e) { FileUtils.deleteQuietly(war); } } }
From source file:org.apache.tomee.embedded.EmbeddedTomEEContainerTest.java
@Test public void classpath() throws Exception { final Properties p = new Properties(); p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName()); p.setProperty(DeploymentsResolver.CLASSPATH_INCLUDE, ".*tomee-embedded.*"); p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1"); EJBContainer container = null; try {/* w ww . j ava2 s. c o m*/ container = EJBContainer.createEJBContainer(p); assertNotNull(container); assertNotNull(container.getContext()); final ABean bean = ABean.class.cast(container.getContext().lookup("java:global/tomee-embedded/ABean")); assertNotNull(bean); assertEquals("ok", bean.embedded()); } finally { if (container != null) { container.close(); } } }
From source file:org.superbiz.DataSourceCipheredExampleTest.java
@Test public void accessDatasource() throws Exception { // define the datasource Properties properties = new Properties(); properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource"); properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver"); properties.setProperty("ProtectedDatasource.JdbcUrl", DATASOURCE_URL); properties.setProperty("ProtectedDatasource.UserName", USER); properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs"); properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES"); properties.setProperty("ProtectedDatasource.JtaManaged", "true"); // start the context and makes junit test injections EJBContainer container = EJBContainer.createEJBContainer(properties); Context context = container.getContext(); context.bind("inject", this); // test the datasource assertNotNull(dataSource);/*www . ja va2 s . c om*/ assertNotNull(dataSource.getConnection()); // closing the context container.close(); }
From source file:org.superbiz.DataSourceCipheredExampleTest.java
@Test public void accessDatasourceWithMyImplementation() throws Exception { // define the datasource Properties properties = new Properties(); properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource"); properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver"); properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected"); properties.setProperty("ProtectedDatasource.UserName", USER); properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY"); properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse"); properties.setProperty("ProtectedDatasource.JtaManaged", "true"); // start the context and makes junit test injections EJBContainer container = EJBContainer.createEJBContainer(properties); Context context = container.getContext(); context.bind("inject", this); // test the datasource assertNotNull(dataSource);//from w w w . j av a 2 s.c o m assertNotNull(dataSource.getConnection()); // closing the context container.close(); }