Search in sources :

Example 21 with ClassLoaderResolverImpl

use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.

the class AnnotationPlusXMLTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // Don't initialise this since the store manager will be undefined due to no URL
    nucleusCtx = new PersistenceNucleusContextImpl("JDO", null);
    metaDataMgr = nucleusCtx.getMetaDataManager();
    clr = new ClassLoaderResolverImpl();
}
Also used : PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 22 with ClassLoaderResolverImpl

use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.

the class AnnotationTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    nucleusCtx = new PersistenceNucleusContextImpl("JDO", null);
    metaDataMgr = new JDOMetaDataManager(nucleusCtx);
    clr = new ClassLoaderResolverImpl();
}
Also used : PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 23 with ClassLoaderResolverImpl

use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.

the class PluginParserTest method testParseExtensionPoint.

public void testParseExtensionPoint() {
    ClassLoaderResolver clr = new ClassLoaderResolverImpl();
    NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION", true);
    assertEquals(0, mgr.getExtensionPoints().length);
    Bundle bundle0 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST0.MF", null));
    mgr.registerExtensionsForPlugin(clr.getResource("/org/datanucleus/samples/plugin/plugin1expoint.xml", null), bundle0);
    assertEquals(2, mgr.getExtensionPoints().length);
    assertNull(mgr.getExtensionPoint("testID"));
    assertNull(mgr.getExtensionPoint("testID2"));
    assertNotNull(mgr.getExtensionPoint("org.datanucleus.testID"));
    assertNotNull(mgr.getExtensionPoint("org.datanucleus.testID2"));
    ExtensionPoint point = mgr.getExtensionPoint("org.datanucleus.testID");
    assertEquals("testID", point.getId());
    assertEquals("org.datanucleus.testID", point.getUniqueId());
    assertEquals("testName", point.getName());
    assertNotNull(clr.getResource("/org/datanucleus/samples/plugin/plugin1.xsd", null));
    assertEquals(clr.getResource("/org/datanucleus/samples/plugin/plugin1.xsd", null), point.getSchema());
    assertEquals(0, point.getExtensions().length);
    mgr.registerExtensionsForPlugin(clr.getResource("/org/datanucleus/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);
    ConfigurationElement[] level1 = exts[0].getConfigurationElements();
    assertEquals(2, level1[0].getChildren().length);
    assertEquals("level1", level1[0].getName());
    assertEquals(1, level1[0].getAttributeNames().length);
    assertEquals("1", level1[0].getAttribute("attr11"));
    assertNull(level1[0].getAttribute("attr11XXX"));
    ConfigurationElement[] level2 = level1[0].getChildren();
    assertEquals(1, level2[0].getChildren().length);
    assertEquals("level2", level2[0].getName());
    assertEquals(2, level2[0].getAttributeNames().length);
    assertEquals("attr21", level2[0].getAttributeNames()[0]);
    assertEquals("attr22", level2[0].getAttributeNames()[1]);
    assertEquals("2211", level2[0].getAttribute("attr21"));
    assertEquals("2221", level2[0].getAttribute("attr22"));
    assertNull(level2[0].getAttribute("attr11XXX"));
    assertEquals(0, level1[1].getChildren().length);
    assertEquals("2", level1[1].getAttribute("attr11"));
    assertEquals(1, exts[1].getConfigurationElements().length);
    level1 = exts[1].getConfigurationElements();
    assertEquals("A", level1[0].getAttribute("attr11"));
    assertEquals(0, level1[0].getChildren().length);
}
Also used : Extension(org.datanucleus.plugin.Extension) ConfigurationElement(org.datanucleus.plugin.ConfigurationElement) NonManagedPluginRegistry(org.datanucleus.plugin.NonManagedPluginRegistry) Bundle(org.datanucleus.plugin.Bundle) ExtensionPoint(org.datanucleus.plugin.ExtensionPoint) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 24 with ClassLoaderResolverImpl

use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.

the class PluginParserTest method testRequireBundle.

public void testRequireBundle() {
    ClassLoaderResolver clr = new ClassLoaderResolverImpl();
    NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION", true);
    assertEquals(0, mgr.getExtensionPoints().length);
    Bundle bundle3 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST3.MF", null));
    Bundle bundle4 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST4.MF", null));
    Bundle bundle5 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST5.MF", null));
    assertEquals(1, bundle3.getRequireBundle().size());
    assertEquals("org.datanucleus.plugin.test4", (bundle3.getRequireBundle().iterator().next()).getBundleSymbolicName());
    assertEquals(0, bundle4.getRequireBundle().size());
    assertEquals(2, bundle5.getRequireBundle().size());
    assertEquals("org.datanucleus.plugin.test6", (bundle5.getRequireBundle().get(0)).getBundleSymbolicName());
    assertEquals("org.datanucleus.plugin.test7", (bundle5.getRequireBundle().get(1)).getBundleSymbolicName());
    assertEquals("org.datanucleus.plugin.test7", (bundle5.getRequireBundle().get(1)).getBundleSymbolicName());
    assertEquals("optional", (bundle5.getRequireBundle().get(1)).getParameter("resolution"));
}
Also used : NonManagedPluginRegistry(org.datanucleus.plugin.NonManagedPluginRegistry) Bundle(org.datanucleus.plugin.Bundle) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Example 25 with ClassLoaderResolverImpl

use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.

the class PluginParserTest method testDuplicatedBundleSymbolicNameSameOrDifferentVersion.

/**
 * NonManagedPluginRegistry cannot handle multiple versions
 * of the same plugin, so it must raise an exception
 */
public void testDuplicatedBundleSymbolicNameSameOrDifferentVersion() {
    ClassLoaderResolver clr = new ClassLoaderResolverImpl();
    NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION", true);
    mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST1.MF", null));
    try {
        mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST1-1.MF", null));
        fail("Expected JPOXException");
    } catch (NucleusException ex) {
    // expected
    }
}
Also used : NonManagedPluginRegistry(org.datanucleus.plugin.NonManagedPluginRegistry) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) NucleusException(org.datanucleus.exceptions.NucleusException) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Aggregations

ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)53 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)35 MetaDataManager (org.datanucleus.metadata.MetaDataManager)31 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)27 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)23 JDOMetaDataManager (org.datanucleus.api.jdo.metadata.JDOMetaDataManager)22 NucleusContext (org.datanucleus.NucleusContext)14 ClassMetaData (org.datanucleus.metadata.ClassMetaData)14 JPAMetaDataManager (org.datanucleus.api.jpa.metadata.JPAMetaDataManager)12 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)10 FetchPlan (org.datanucleus.FetchPlan)7 FetchPlanForClass (org.datanucleus.FetchPlanForClass)7 JDOFetchPlan (org.datanucleus.api.jdo.JDOFetchPlan)7 BitSet (java.util.BitSet)6 NonManagedPluginRegistry (org.datanucleus.plugin.NonManagedPluginRegistry)6 HashSet (java.util.HashSet)3 Properties (java.util.Properties)3 JDOPersistenceManagerFactory (org.datanucleus.api.jdo.JDOPersistenceManagerFactory)3 Bundle (org.datanucleus.plugin.Bundle)3 ArrayList (java.util.ArrayList)2