Examples of OpenJPAEntityManagerFactorySPI


Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

*
*/
public class TestDynamicConfiguration extends SingleEMFTestCase {

    public void testConfigurationIsEqualByValueAndHashCode() {
    OpenJPAEntityManagerFactorySPI emf1 = createEMF();
    assertNotNull(emf1);
    OpenJPAConfiguration conf1 = emf1.getConfiguration();
   
    OpenJPAEntityManagerFactorySPI emf2 = createEMF();
    assertNotNull(emf2);
    OpenJPAConfiguration conf2 = emf2.getConfiguration();
   
    assertFalse(emf1==emf2);
    assertFalse(emf1.equals(emf2));
    assertFalse(conf1==conf2);
    assertEquals(conf1, conf2);
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     * persistence managers.
     */
    public void testFactoryLifecycleListeners() {
        OpenJPAEntityManagerFactory pmf =
            (OpenJPAEntityManagerFactory) getEmf();
        OpenJPAEntityManagerFactorySPI pmfSPI =
            ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(pmf));

        //FIXME jthomas       
        LoadListener listener = new LoadListener() {
            public void afterLoad(LifecycleEvent ev) {
            }

            public void afterRefresh(LifecycleEvent ev) {
            }
        };

        pmfSPI
            .addLifecycleListener(listener, new Class[]{ RuntimeTest4.class });

        try {
            BrokerImpl broker = (BrokerImpl) JPAFacadeHelper.toBroker
                (pmf.createEntityManager());
            MetaDataRepository repos = broker.getConfiguration().
                getMetaDataRepositoryInstance();
            assertTrue("no listeners defined added to Runtimetest4",
                broker.getLifecycleEventManager().hasLoadListeners(
                    new RuntimeTest4("foo"),
                    repos.getMetaData(RuntimeTest4.class, null, true)));
            assertFalse("there should be listeners def for runtimetest1",
                broker.getLifecycleEventManager().hasLoadListeners
                    (new RuntimeTest1(), repos.getMetaData
                        (RuntimeTest1.class, null, true)));
            broker.close();
        } finally {
            pmfSPI.removeLifecycleListener(listener);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

  /**
   * This method ensures that some of the basic MetaData is properly
   * registered after creating an EMF.
   */
  public void testPreloadBasic() {
    OpenJPAEntityManagerFactorySPI emf = null;
    try {
      emf = createNamedEMF(PU_NAME, "openjpa.MetaDataRepository",
          "Preload=true");
      MetaDataRepository mdr = emf.getConfiguration()
          .getMetaDataRepositoryInstance();

      // Check that there is cached metadata in the repo
      ClassMetaData metadata = mdr.getCachedMetaData(MdrTestEntity.class);
      assertNotNull(metadata);
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

      closeEMF(emf);
    }
  }
 
  public void testPreloadCleanUp() {
        OpenJPAEntityManagerFactorySPI emf = null;
        emf = createNamedEMF(PU_NAME, "openjpa.MetaDataRepository", "Preload=true");
        MetaDataRepository repo = emf.getConfiguration().getMetaDataRepositoryInstance();
        emf.createEntityManager();
        closeEMF(emf);
        assertFalse("The PCRegistry should no longer reference the MetaDataRepository.", PCRegistry
            .removeRegisterClassListener(repo));
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

        assertFalse("The PCRegistry should no longer reference the MetaDataRepository.", PCRegistry
            .removeRegisterClassListener(repo));
    }

  public void testXmlMappingPreload() {
        OpenJPAEntityManagerFactorySPI emf = null;
        try {
            emf =
                createNamedEMF("test", "openjpa.MetaDataRepository", "Preload=true", Customer.class,
                    Customer.CustomerKey.class, Order.class, EAddress.class);
            MetaDataRepository mdr = emf.getConfiguration().getMetaDataRepositoryInstance();

            assertNotNull(mdr.getCachedXMLMetaData(Address.class));
            assertNull(mdr.getCachedXMLMetaData(Order.class));
           
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

        LOG.info(XLog.STD, "All entities initialized");
        // need to use a pseudo no-op transaction so all entities, datasource
        // and connection pool are initialized one time only
        entityManager.getTransaction().begin();
        OpenJPAEntityManagerFactorySPI spi = (OpenJPAEntityManagerFactorySPI) factory;
        LOG.info("JPA configuration: {0}", spi.getConfiguration().getConnectionProperties());
        entityManager.getTransaction().commit();
        entityManager.close();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

    extends SQLListenerTestCase {

    private boolean enabled = false;

    public void setUp() {
        OpenJPAEntityManagerFactorySPI emf = createEMF();
        DBDictionary dict = ((JDBCConfiguration) emf.getConfiguration())
            .getDBDictionaryInstance();

        // skip if dictionary has no support for XML column type
        if (!dict.supportsXMLColumn)
            return;
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     *            list of persistent types used in testing and/or configuration values in the form
     *            key,value,key,value...
     */
    protected OpenJPAEntityManagerFactorySPI createNamedEMF(final String pu, Object... props) {
        Map<String, Object> map = getPropertiesMap(props);
        OpenJPAEntityManagerFactorySPI oemf = null;
        Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
        config.putAll(map);
        oemf = (OpenJPAEntityManagerFactorySPI) Persistence.createEntityManagerFactory(pu, config);
        if (oemf == null) {
            throw new NullPointerException("Expected an entity manager factory " + "for the persistence unit named: \""
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

     *            list of persistent types used in testing and/or configuration values in the form
     *            key,value,key,value...
     */
    protected OpenJPAEntityManagerFactorySPI createNamedOpenJPAEMF(final String pu,
            String res, Map<String,Object> props) {
        OpenJPAEntityManagerFactorySPI oemf = null;
        Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
        if (props != null)
            config.putAll(props);
        oemf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(pu, res, props);
        if (oemf == null) {
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI

    private DBDictionary dict = null;
    private int lockWaitTime = 2000;

    public void setUp() {
        // Disable tests for any DB that has supportsQueryTimeout==false, like Postgres
        OpenJPAEntityManagerFactorySPI tempEMF = emf;
        if (tempEMF == null) {
            tempEMF = createEMF();
        }
        assertNotNull(tempEMF);
        dict = ((JDBCConfiguration)tempEMF.getConfiguration()).getDBDictionaryInstance();
        assertNotNull(dict);
        if (!dict.supportsQueryTimeout)
            setTestsDisabled(true);
        if (emf == null) {
            closeEMF(tempEMF);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.