Package org.jpox

Examples of org.jpox.JDOClassLoaderResolver


    /**
     * Test for whether classes are descendents of each other.
     */
    public void testClassesAreDescendents()
    {
        ClassLoaderResolver clr = new JDOClassLoaderResolver(null);
       
        assertTrue("java.util.Collection and java.util.ArrayList should have been direct descendents but weren't",
            ClassUtils.classesAreDescendents(clr, "java.util.Collection", "java.util.ArrayList"));
        assertTrue("java.util.ArrayList and java.util.Collection should have been direct descendents but weren't",
            ClassUtils.classesAreDescendents(clr, "java.util.ArrayList", "java.util.Collection"));
View Full Code Here


public class PluginParserTest extends TestCase
{
    public void testParseExtensionPoint()
    {
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        assertEquals(0,mgr.getExtensionPoints().length);
        Bundle bundle0 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST0.MF",null));
        mgr.registerPluginExtensions(clr.getResource("/org/jpox/samples/plugin/plugin1expoint.xml",null),bundle0);
        assertEquals(2,mgr.getExtensionPoints().length);
        assertNull(mgr.getExtensionPoint("testID"));
        assertNull(mgr.getExtensionPoint("testID2"));
        assertNotNull(mgr.getExtensionPoint("org.jpox.testID"));
        assertNotNull(mgr.getExtensionPoint("org.jpox.testID2"));
        ExtensionPoint point = mgr.getExtensionPoint("org.jpox.testID");
        assertEquals("testID", point.getId());
        assertEquals("org.jpox.testID", point.getUniqueId());
        assertEquals("testName", point.getName());
        assertNotNull(clr.getResource("/org/jpox/samples/plugin/plugin1.xsd",null));
        assertEquals(clr.getResource("/org/jpox/samples/plugin/plugin1.xsd",null), point.getSchema());
        assertEquals(0,point.getExtensions().length);
        mgr.registerPluginExtensions(clr.getResource("/org/jpox/samples/plugin/plugin1.xml",null),bundle0);
        assertEquals(2,point.getExtensions().length);       
        Extension[] exts = point.getExtensions();
        assertEquals(exts[0].getPlugin(),exts[1].getPlugin());
        assertEquals(2,exts[0].getConfigurationElements().length);
       
View Full Code Here

        assertEquals(0,level1[0].getChildren().length);
    }
   
    public void testParseSymbolicName()
    {
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        Bundle bundle1 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST1.MF",null));
        mgr.registerPluginExtensions(clr.getResource("/org/jpox/samples/plugin/plugin1expoint.xml",null),bundle1);
        assertEquals(2,mgr.getExtensionPoints().length);
        assertNull(mgr.getExtensionPoint("testID"));
        assertNull(mgr.getExtensionPoint("testID2"));
        assertNotNull(mgr.getExtensionPoint("org.jpox.plugin.test1.testID"));
        assertNotNull(mgr.getExtensionPoint("org.jpox.plugin.test1.testID2"));

        Bundle bundle2 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST2.MF",null));
        mgr.registerPluginExtensions(clr.getResource("/org/jpox/samples/plugin/plugin1expoint.xml",null),bundle2);
        assertEquals(4,mgr.getExtensionPoints().length);
        assertNotNull(mgr.getExtensionPoint("org.jpox.plugin.test2.testID"));
        assertNotNull(mgr.getExtensionPoint("org.jpox.plugin.test2.testID2"));

        Extension[] ex = mgr.getExtensionPoint("org.jpox.plugin.test2.testID").getExtensions();
View Full Code Here

     * NonManagedPluginRegistry cannot handle multiple versions
     * of the same plugin, so it must raise an exception
     */
    public void testDuplicatedBundleSymbolicNameSameOrDifferentVersion()
    {
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST1.MF",null));
        try
        {
            mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST1-1.MF",null));
          fail("Expected JPOXException");
        }
        catch(JPOXException ex)
        {
          //expected
View Full Code Here

        catch(JPOXUserException e){}
    }

    public void testRequireBundle()
    {
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        assertEquals(0,mgr.getExtensionPoints().length);
        Bundle bundle3 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST3.MF",null));
        Bundle bundle4 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST4.MF",null));
        Bundle bundle5 = mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST5.MF",null));
        assertEquals(1,bundle3.getRequireBundle().size());
        assertEquals("org.jpox.plugin.test4",((Bundle.BundleDescription)bundle3.getRequireBundle().iterator().next()).getBundleSymbolicName());
        assertEquals(0,bundle4.getRequireBundle().size());
        assertEquals(2,bundle5.getRequireBundle().size());
        assertEquals("org.jpox.plugin.test6",((Bundle.BundleDescription)bundle5.getRequireBundle().get(0)).getBundleSymbolicName());
View Full Code Here

            public void close(){}
            public void clearFilters(){}
            public void addFilter(Filter arg0){}
       
        });
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        assertEquals(0,mgr.getExtensionPoints().length);
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST3.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST4.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST5.MF",null));
        mgr.resolveConstraints();
        try
        {
            assertEquals(2,messages.size());
            assertTrue(messages.contains("Bundle \"org.jpox.plugin.test5\" requires \"org.jpox.plugin.test6\" but it cannot be resolved."));
View Full Code Here

            public void close(){}
            public void clearFilters(){}
            public void addFilter(Filter arg0){}
       
        });
        ClassLoaderResolver clr = new JDOClassLoaderResolver();
        NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION");
        assertEquals(0,mgr.getExtensionPoints().length);
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST10.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST11.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST12.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST13.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST14.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST15.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST16.MF",null));
        mgr.registerBundle(clr.getResource("/org/jpox/samples/plugin/MANIFEST17.MF",null));
        mgr.resolveConstraints();
        try
        {
            assertEquals(3,messages.size());
            assertTrue(messages.contains("Bundle \"org.jpox.plugin.test12\" requires \"org.jpox.plugin.test11\" version \"(1.2.0.b2\" but the resolved bundle has version \"1.2.0.b2\" which is outside the expected range."));
View Full Code Here

        EnhancerClassLoader loader = new EnhancerClassLoader();
        loader.defineClass(fullClassName, getBytes(), clr);

        // Create MetaData for the implementation
        ClassMetaData implementationCmd = new BCELClassMetaData((InterfaceMetaData)inputCmd, className, javaClass);
        ClassLoaderResolver genclr = new JDOClassLoaderResolver(loader);
        implementationCmd.populate(genclr, null);
        implementationCmd.initialise();

        //enhance the class
        ClassEnhancer gen = new BCELClassEnhancer(implementationCmd, genclr);
View Full Code Here

        // define the generated class in the classloader so we populate the metadata
        EnhancerClassLoader loader = new EnhancerClassLoader();
        loader.defineClass(fullClassName, getBytes(), clr);

        // Create MetaData for implementation of interface
        ClassLoaderResolver genclr = new JDOClassLoaderResolver(loader);
        ClassMetaData implementationCmd = null;
        if (inputCmd instanceof InterfaceMetaData)
        {
            implementationCmd = new ClassMetaData((InterfaceMetaData)inputCmd, className, true);
        }
View Full Code Here

        this.enhanceClass = enhanceClass;

        // Make sure we have a JPOXRepository
        if (Repository.getRepository() == null || !(Repository.getRepository() instanceof JPOXRepository))
        {
            Repository.setRepository(new JPOXRepository(new JDOClassLoaderResolver()));
        }
        Repository.addClass(enhanceClass);
        classGen = new ClassGen(this.enhanceClass);

        // Copy fields after we have the classGen set
View Full Code Here

TOP

Related Classes of org.jpox.JDOClassLoaderResolver

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.