Package javax.ejb.embeddable

Examples of javax.ejb.embeddable.EJBContainer


        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);
        assertNotNull(dataSource.getConnection());

        // closing the context
        container.close();
    }
View Full Code Here


        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);
        assertNotNull(dataSource.getConnection());

        // closing the context
        container.close();
    }
View Full Code Here

        final Map<String, Object> p = new HashMap<String, Object>();
        p.put("MySTATEFUL", "new://Container?type=STATEFUL");
        p.put("MySTATEFUL.Capacity", "2"); //How many instances of Stateful beans can our server hold in memory?
        p.put("MySTATEFUL.Frequency", "1"); //Interval in seconds between checks
        p.put("MySTATEFUL.BulkPassivate", "0"); //No bulkPassivate - just passivate entities whenever it is needed
        final EJBContainer container = EJBContainer.createEJBContainer(p);

        //this is going to track the execution
        ExecutionChannel.getInstance().addObserver(this);

        {
            final Context context = getContext();

            CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
            Assert.assertNotNull(counterA);
            Assert.assertEquals("postConstruct", this.received.remove(0));

            Assert.assertEquals(0, counterA.count());
            Assert.assertEquals("count", this.received.remove(0));

            Assert.assertEquals(1, counterA.increment());
            Assert.assertEquals("increment", this.received.remove(0));

            Assert.assertEquals(0, counterA.reset());
            Assert.assertEquals("reset", this.received.remove(0));

            Assert.assertEquals(1, counterA.increment());
            Assert.assertEquals("increment", this.received.remove(0));

            System.out.println("Waiting 2 seconds...");
            Thread.sleep(2000);

            Assert.assertEquals("preDestroy", this.received.remove(0));

            try {
                counterA.increment();
                Assert.fail("The ejb is not supposed to be there.");
            } catch (javax.ejb.NoSuchEJBException e) {
                //excepted
            }

            context.close();
        }

        {
            final Context context = getContext();

            CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
            Assert.assertEquals("postConstruct", this.received.remove(0));

            Assert.assertEquals(1, counterA.increment());
            Assert.assertEquals("increment", this.received.remove(0));

            ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
            Assert.assertEquals("postConstruct", this.received.remove(0));
            Assert.assertEquals("count", this.received.remove(0));

            ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
            Assert.assertEquals("postConstruct", this.received.remove(0));
            Assert.assertEquals("count", this.received.remove(0));

            System.out.println("Waiting 2 seconds...");
            Thread.sleep(2000);
            Assert.assertEquals("prePassivate", this.received.remove(0));

            context.close();
        }
        container.close();

        Assert.assertEquals("preDestroy", this.received.remove(0));
        Assert.assertEquals("preDestroy", this.received.remove(0));

        Assert.assertTrue(this.received.toString(), this.received.isEmpty());
View Full Code Here

        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");
        try {
            EJBContainer container = EJBContainer.createEJBContainer(p);
            assertNotNull(container);
            assertNotNull(container.getContext());
            URL url = new URL("http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/test/index.html");
            assertEquals("true", IO.readProperties(url).getProperty("ok"));
            container.close();
        } finally {
            try {
                FileUtils.forceDelete(war);
            } catch (IOException e) {
                FileUtils.deleteQuietly(war);
View Full Code Here

    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");
        final EJBContainer container = EJBContainer.createEJBContainer(p);
        assertNotNull(container);
        final ABean bean = ABean.class.cast(container.getContext().lookup("java:global/tomee-embedded/ABean"));
        assertNotNull(bean);
        assertEquals("ok", bean.embedded());
        container.close();
    }
View Full Code Here

    @Test
    public void play() throws Exception {
        Properties properties = new Properties();
        properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
        EJBContainer container = EJBContainer.createEJBContainer(properties);

        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName objectName = new ObjectName(OBJECT_NAME);
        assertEquals(0, server.getAttribute(objectName, "value"));
        server.setAttribute(objectName, new Attribute("value", 3));
        assertEquals(3, server.getAttribute(objectName, "value"));
        assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
        assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));

        container.close();
    }
View Full Code Here

        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");
        try {
            EJBContainer container = EJBContainer.createEJBContainer(p);
            assertNotNull(container);
            assertNotNull(container.getContext());
            URL url = new URL("http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/test/index.html");
            assertEquals("true", IO.readProperties(url).getProperty("ok"));
            container.close();
        } finally {
            try {
                FileUtils.forceDelete(war);
            } catch (IOException e) {
                FileUtils.deleteQuietly(war);
View Full Code Here

    public void execute() throws MojoExecutionException, MojoFailureException {
        MavenLogStreamFactory.setLogger(getLog());
        final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(createClassLoader(oldCl));

        EJBContainer container = null;
        try {
            container = EJBContainer.createEJBContainer(map());
            if (await) {
                final CountDownLatch latch = new CountDownLatch(1);
                Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                    @Override
                    public void run() {
                        latch.countDown();
                    }
                }));
                try {
                    latch.await();
                } catch (InterruptedException e) {
                    // ignored
                }
            }
        } finally {
            if (container != null) {
                container.close();
            }
            Thread.currentThread().setContextClassLoader(oldCl);
        }
    }
View Full Code Here

        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);
        assertNotNull(dataSource.getConnection());

        // closing the context
        container.close();
    }
View Full Code Here

        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);
        assertNotNull(dataSource.getConnection());

        // closing the context
        container.close();
    }
View Full Code Here

TOP

Related Classes of javax.ejb.embeddable.EJBContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.