Example usage for javax.ejb.embeddable EJBContainer PROVIDER

List of usage examples for javax.ejb.embeddable EJBContainer PROVIDER

Introduction

In this page you can find the example usage for javax.ejb.embeddable EJBContainer PROVIDER.

Prototype

String PROVIDER

To view the source code for javax.ejb.embeddable EJBContainer PROVIDER.

Click Source Link

Document

Standard property name for specifying the embeddable container implementation bootstrap class.

Usage

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   ww  w.  j  a v a  2 s.  c o m*/
    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 www  .  j  a v  a  2  s . co 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.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();/*from w w w  .  j  a va2s .c  om*/
    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);
}