Author: dgeraskov
Date: 2012-08-21 05:59:44 -0400 (Tue, 21 Aug 2012)
New Revision: 43123
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaModelTests.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaOrmModelTests.java
Log:
https://issues.jboss.org/browse/JBIDE-12451
Use synchronize method to get JpaProject
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaModelTests.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaModelTests.java 2012-08-21
09:54:37 UTC (rev 43122)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaModelTests.java 2012-08-21
09:59:44 UTC (rev 43123)
@@ -10,19 +10,20 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.*;
import java.util.ArrayList;
import java.util.List;
+import javax.security.auth.login.FailedLoginException;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProject.Reference;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable;
import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
@@ -63,7 +64,7 @@
project =
ResourcesUtils.importProject(Platform.getBundle("org.jboss.tools.hibernate.jpt.core.test"),
PROJECT_PATH, new NullProgressMonitor());
project.refreshLocal(IResource.DEPTH_INFINITE, null);
- jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
+ jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
}
@Test
@@ -94,7 +95,11 @@
assertNotNull("Naming Strategy not found",
cc.getConfiguration().getNamingStrategy());
assertEquals("ns.NamingStrategy",
cc.getConfiguration().getNamingStrategy().getClass().getName());
- jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
+ try {
+ jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
assertNotNull(jpaProject);
JpaRootContextNode rootContextNode = jpaProject.getRootContextNode();
Persistence p = rootContextNode.getPersistenceXml().getPersistence();
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaOrmModelTests.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaOrmModelTests.java 2012-08-21
09:54:37 UTC (rev 43122)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.jpt.core.test/src/org/jboss/tools/hibernate/jpt/core/test/HibernateJpaOrmModelTests.java 2012-08-21
09:59:44 UTC (rev 43123)
@@ -13,6 +13,7 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
import java.util.ArrayList;
import java.util.List;
@@ -23,6 +24,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProject.Reference;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable;
import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
@@ -65,7 +67,7 @@
project =
ResourcesUtils.importProject(Platform.getBundle("org.jboss.tools.hibernate.jpt.core.test"),
PROJECT_PATH, new NullProgressMonitor());
project.refreshLocal(IResource.DEPTH_INFINITE, null);
- jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
+ jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
}
@Test
@@ -95,7 +97,11 @@
assertNotNull("Naming Strategy not found",
cc.getConfiguration().getNamingStrategy());
assertEquals("ns.NamingStrategy",
cc.getConfiguration().getNamingStrategy().getClass().getName());
- jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
+ try {
+ jpaProject = ((Reference) project.getAdapter(Reference.class)).getValue();
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
assertNotNull(jpaProject);
JpaRootContextNode rootContextNode = jpaProject.getRootContextNode();
Persistence p = rootContextNode.getPersistenceXml().getPersistence();