Package net.tralfamadore.config

Examples of net.tralfamadore.config.ConfigFile


        assertEquals(jpaEntityManager, jpaEntityManagerProvider.get());
    }

    @Test
    public void testGetWithoutEntityManager() throws Exception {
        final ConfigFile config = new ConfigFile(false);
        config.getPersistenceProperties().put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
        config.getPersistenceProperties().put("javax.persistence.jdbc.url", "jdbc:derby:cmf;create=true");

        new NonStrictExpectations() {{
            CmfContext.getInstance(); result = cmfContext;
            cmfContext.getConfigFile(); result = config;
            Persistence.createEntityManagerFactory(EntityManagerProvider.PERSISTENCE_UNIT_NAME,
                    config.getPersistenceProperties()); result = entityManagerFactory;
            entityManagerFactory.createEntityManager(); result = jpaEntityManager;
        }};

        JpaEntityManagerProvider jpaEntityManagerProvider = new JpaEntityManagerProvider();
        assertEquals(jpaEntityManager, jpaEntityManagerProvider.get());
View Full Code Here


        }};
    }

    @Test
    public void testGetWithoutEntityManagerEmbeddedMem() throws Exception {
        final ConfigFile config = new ConfigFile(false);
        config.getPersistenceProperties().put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
        config.getPersistenceProperties().put("javax.persistence.jdbc.url", "jdbc:derby:memory:cmf;create=true");

        new NonStrictExpectations() {{
            CmfContext.getInstance(); result = cmfContext;
            cmfContext.getConfigFile(); result = config;
            Persistence.createEntityManagerFactory(EntityManagerProvider.PERSISTENCE_UNIT_NAME,
                    config.getPersistenceProperties()); result = entityManagerFactory;
            entityManagerFactory.createEntityManager(); result = jpaEntityManager;
        }};

        JpaEntityManagerProvider jpaEntityManagerProvider = new JpaEntityManagerProvider();
        assertEquals(jpaEntityManager, jpaEntityManagerProvider.get());
View Full Code Here

    }

    @Override
    public EntityManager get() {
        if(em == null) {
            ConfigFile configFile = CmfContext.getInstance().getConfigFile();

            Map<String,String> properties = new HashMap<String,String>();

            for(Map.Entry<String,String> entry : configFile.getPersistenceProperties().entrySet()) {
                properties.put(entry.getKey(), entry.getValue());
            }

            emFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
            em = emFactory.createEntityManager();
View Full Code Here

TOP

Related Classes of net.tralfamadore.config.ConfigFile

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.