Package org.apache.openjpa.conf

Examples of org.apache.openjpa.conf.OpenJPAConfigurationImpl


                            // hacky but avoid to build a full openjpa project/context
                            final PersistenceMetaDataFactory factory = new PersistenceMetaDataFactory();
                            factory.setTypes("org.apache.test.sirona.javaagent.OpenJPATest$ServiceSquareEntity");

                            final MetaDataRepository repos = new MetaDataRepository();
                            repos.setConfiguration(new OpenJPAConfigurationImpl());
                            repos.setMetaDataFactory(factory);

                            final BCClass type = new Project().loadClass(new ByteArrayInputStream(buffer), new URLClassLoader(new URL[0], getParent()));
                            final PCEnhancer enhancer = new PCEnhancer(repos.getConfiguration(), type, repos, this);
                            enhancer.setAddDefaultConstructor(true);
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

        map.put("openjpa.Optimistic", Boolean.FALSE);
        map.put("openjpa.LockTimeout", new Integer(503));

        // use new conf so no unexpected restrictions on type of connection
        // factory
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl(true, false);
        conf.fromProperties(map);
        assertEquals(cfactory, conf.getConnectionFactory());
        assertEquals(cfactory2, conf.getConnectionFactory2());
        assertEquals(false, conf.getOptimistic());
        assertEquals(503, conf.getLockTimeout());

        OpenJPAConfiguration conf2 = new OpenJPAConfigurationImpl(true, false);
        conf2.fromProperties(map);
        assertEquals(conf, conf2);

        Map p = conf.toProperties(false);
        assertTrue(!p.containsKey("openjpa.ConnectionFactory"));
        assertTrue(!p.containsKey("openjpa.ConnectionFactory2"));
        assertEquals("false", p.get("openjpa.Optimistic"));
        assertEquals("503", p.get("openjpa.LockTimeout"));
        assertEquals(p, conf2.toProperties(false));

        map.put("openjpa.LockTimeout", new Integer(504));
        OpenJPAConfiguration conf3 = new OpenJPAConfigurationImpl(true, false);
        conf3.fromProperties(map);
        assertNotEquals(conf, conf3);
    }
View Full Code Here

    }

    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 kodo.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) {
            re.printStackTrace();
            // as expected ... make sure the exception suggests the
            // valid names in the message.
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

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.