List of usage examples for javax.ejb.embeddable EJBContainer createEJBContainer
public static EJBContainer createEJBContainer(Map<?, ?> properties)
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;/*from w w w . j a v a 2 s . com*/ try { 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;//from w w w .ja v a 2 s. c o m try { 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.calculator.CalculatorTest.java
@BeforeClass public static void setUp() throws Exception { final Properties properties = new Properties(); properties.setProperty("openejb.embedded.remotable", "true"); //Just for this test we change the default port from 4204 to avoid conflicts properties.setProperty("httpejbd.port", "" + port); container = EJBContainer.createEJBContainer(properties); }
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);/*from ww w .j av a 2 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 www . j a v a2s . co m*/ assertNotNull(dataSource.getConnection()); // closing the context container.close(); }
From source file:org.superbiz.moviefun.MoviesHtmlUnitTest.java
@BeforeClass public static void start() throws IOException { // get a random unused port to use for http requests ServerSocket server = new ServerSocket(0); port = server.getLocalPort();/*w w w . j av a2 s . co m*/ server.close(); webApp = createWebApp(); Properties p = new Properties(); p.setProperty(EJBContainer.APP_NAME, "moviefun"); p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath()); p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, String.valueOf(port)); container = EJBContainer.createEJBContainer(p); }