Search in sources :

Example 1 with EJBLocator

use of org.apache.aries.ejb.modelling.EJBLocator in project aries by apache.

the class EJBLocatorFactoryTest method testGetEJBLocator.

@Test
public void testGetEJBLocator() {
    EJBLocator locator = EJBLocatorFactory.getEJBLocator();
    assertNotNull(locator);
    assertTrue(locator.getClass().getName(), locator instanceof OpenEJBLocator);
}
Also used : EJBLocator(org.apache.aries.ejb.modelling.EJBLocator) Test(org.junit.Test)

Example 2 with EJBLocator

use of org.apache.aries.ejb.modelling.EJBLocator in project aries by apache.

the class EJBLocatorFactoryTest method testGetEJBLocatorNoOpenEJB.

@Test
public void testGetEJBLocatorNoOpenEJB() throws Exception {
    Class<?> elf = new ClassLoader(getClass().getClassLoader()) {

        @Override
        public Class<?> loadClass(String className) throws ClassNotFoundException {
            if (className.startsWith("org.apache.openejb"))
                throw new ClassNotFoundException(className);
            if (className.equals(EJBLocatorFactory.class.getName())) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                try {
                    IOUtils.copy(getResourceAsStream(className.replace('.', '/') + ".class"), baos);
                } catch (IOException e) {
                    throw new ClassNotFoundException(className, e);
                }
                return defineClass(className, baos.toByteArray(), 0, baos.size());
            }
            return super.loadClass(className);
        }
    }.loadClass(EJBLocatorFactory.class.getName());
    EJBLocator locator = (EJBLocator) elf.getMethod("getEJBLocator").invoke(null);
    assertNotNull(locator);
    assertTrue(locator.getClass().getName(), locator instanceof EJBLocationUnavailable);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) EJBLocator(org.apache.aries.ejb.modelling.EJBLocator) Test(org.junit.Test)

Example 3 with EJBLocator

use of org.apache.aries.ejb.modelling.EJBLocator in project aries by apache.

the class EJBModellerTest method setup.

@Before
public void setup() {
    modeller = new EJBModeller();
    EJBLocator locator = Skeleton.newMock(EJBLocator.class);
    modeller.setLocator(locator);
    ejbLocator = Skeleton.getSkeleton(locator);
    bundleLocation = Skeleton.newMock(IDirectory.class);
}
Also used : IDirectory(org.apache.aries.util.filesystem.IDirectory) EJBLocator(org.apache.aries.ejb.modelling.EJBLocator) Before(org.junit.Before)

Aggregations

EJBLocator (org.apache.aries.ejb.modelling.EJBLocator)3 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 IDirectory (org.apache.aries.util.filesystem.IDirectory)1 Before (org.junit.Before)1