Package org.apache.openjpa.conf

Examples of org.apache.openjpa.conf.OpenJPAConfigurationImpl


    }

    public void testBeanAccessors()
        throws Exception {
        OpenJPAConfiguration conf = getConfiguration();
        OpenJPAConfigurationImpl simp = (OpenJPAConfigurationImpl) conf.clone();

        Value[] values = simp.getValues();
        PropertyDescriptor[] pds = simp.getPropertyDescriptors();
        List failures = new ArrayList();
        for (int i = 0; i < values.length; i++) {
            try {
                assertNotNull(pds[i].getShortDescription());
                assertNotNull(pds[i].getDisplayName());
View Full Code Here


    /**
     * Tests that invalid plug-in values throw the appropriate exception
     * type.
     */
    public void testInvalidPlugins() {
        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        config.setLog("log3j");
        try {
            config.getLogFactory().getLog("Foo");
            fail("getting the Foo log should have failed");
        } catch (RuntimeException re) {
            // as expected ... make sure the exception suggests the
            // name "log4j" in the message
            assertTrue(-1 != re.getMessage().indexOf("log4j"));
View Full Code Here

    public void testInvalidConfigurationWarnings() {
        Properties props = new Properties();
        props.setProperty("openjpa.MaxxFetchDepth", "1");

        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        // track the messages
        BufferedLogFactory log = new BufferedLogFactory();
        config.setLogFactory(log);

        config.fromProperties(props);

        // make sure we got a warning that contains the string with the
        // bad property name and a hint for the valid property name.
        log.assertLogMessage("*\"openjpa.MaxxFetchDepth\"*");
        log.assertLogMessage("*\"openjpa.MaxFetchDepth\"*");

        log.clear();

        // now make sure we do *not* try to validate sub-configurations (such
        // as openjpa.jdbc.Foo).
        props.clear();
        props.setProperty("openjpa.jdbc.Foo", "XXX");
        props.setProperty("oponjpa", "XXX");
        config.fromProperties(props);
        log.assertNoLogMessage("*\"openjpa.jdbc.Foo\"*");
        log.assertNoLogMessage("*\"oponjpa\"*");
    }
View Full Code Here

    /**
     * Tests that invalid fixed-list values throw the appropriate exception
     * type.
     */
    public void testInvalidNonPluginValues() {
        OpenJPAConfiguration config = new OpenJPAConfigurationImpl();
        try {
            config.setConnectionFactoryMode("aoeu");
            fail("setting the ConnectionFactoryMode to aoeu should fail");
        } catch (RuntimeException re) {
            // as expected ... make sure the exception suggests the
            // valid names in the message.
            assertTrue(-1 != re.getMessage().indexOf("managed"));
View Full Code Here

      List<String> anchors = Configurations.
            getFullyQualifiedAnchorsInPropertiesLocation(opts);
      for (String a : anchors) {
        Options clonedOptions = (Options) opts.clone();
        clonedOptions.setProperty("properties", a);
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Configurations.populateConfiguration(conf, clonedOptions);
        // don't allow connections
        conf.setConnectionUserName(null);
        conf.setConnectionPassword(null);
        conf.setConnectionURL(null);
        conf.setConnectionDriverName(null);
        conf.setConnectionFactoryName(null);
        // set single class resolver
        final ClassLoader tmpLoader = AccessController
            .doPrivileged(J2DoPrivHelper
            .newTemporaryClassLoaderAction(AccessController
            .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
            ));
        conf.setClassResolver(new ClassResolver() {
            public ClassLoader getClassLoader(Class context,
                    ClassLoader env) {
                return tmpLoader;
            }
        });
        conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
        conf.instantiateAll(); // avoid threading issues

        PCClassFileTransformer transformer = new PCClassFileTransformer
            (conf.newMetaDataRepositoryInstance(), clonedOptions,
            tmpLoader);
        inst.addTransformer(transformer);
        conf.close();
      }
    }
View Full Code Here

     */
    public static boolean run(final String[] args, Options opts) {
        return Configurations.runAgainstAllAnchors(opts,
            new Configurations.Runnable() {
            public boolean run(Options opts) throws IOException {
                OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
                try {
                    return PCEnhancer.run(conf, args, opts);
                } finally {
                    conf.close();
                }
            }
        });
    }
View Full Code Here

public class TestEnhancementWithMultiplePUs
    extends PersistenceTestCase {

    public void testExplicitEnhancementWithClassNotInFirstPU()
        throws ClassNotFoundException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Configurations.populateConfiguration(conf, new Options());
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = (ClassLoader) AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        return bc;
    }

    public void testEnhancementOfSecondPUWithClassNotInFirstPU()
        throws IOException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p",
            "META-INF/persistence.xml#second-persistence-unit");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = (ClassLoader) AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        assertTrue(written.contains(className));
    }

    public void testEnhancementOfAllPUsWithinAResource()
        throws IOException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p", "META-INF/persistence.xml");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = (ClassLoader) AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

    @Override
    public boolean beforeConfigurationLoad(Configuration c) {
        if (!(c instanceof OpenJPAConfigurationImpl))
            return false;
       
        OpenJPAConfigurationImpl conf = (OpenJPAConfigurationImpl) c;
        conf.metaFactoryPlugin.setAlias(ALIAS_EJB,
            PersistenceMetaDataFactory.class.getName());
        conf.metaFactoryPlugin.setAlias(SPEC_JPA,
            PersistenceMetaDataFactory.class.getName());
       
        conf.addValue(new EntityManagerFactoryValue());
        return true;
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.conf.OpenJPAConfigurationImpl

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.