Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2012-02-10 20:49:25 +0000
committerbvosburgh2012-02-10 20:49:25 +0000
commit4716e39927cfe910fa7424870986a195d608b51f (patch)
tree800ca22e27d3d87fbd1f64968ca69efa5ceba413 /jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt
parent52f37be9bfbf1b7c0d451e99d938725ac497eed0 (diff)
downloadwebtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.gz
webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.xz
webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.zip
rework JpaProjectManager
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt')
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/JptJpaCoreTestsPlugin.java16
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java116
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java176
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/projects/TestJpaProject.java61
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/JavaResourceModelTestCase.java4
6 files changed, 207 insertions, 170 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/JptJpaCoreTestsPlugin.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/JptJpaCoreTestsPlugin.java
index f9168afacd..dd1ef03c55 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/JptJpaCoreTestsPlugin.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/JptJpaCoreTestsPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.tests;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.jpt.common.utility.internal.ReflectionTools;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
@@ -24,8 +25,7 @@ import org.osgi.framework.BundleContext;
@SuppressWarnings("nls")
public class JptJpaCoreTestsPlugin
extends Plugin
-{
-
+{
private static JptJpaCoreTestsPlugin INSTANCE;
public static JptJpaCoreTestsPlugin instance() {
@@ -48,14 +48,18 @@ public class JptJpaCoreTestsPlugin
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
- JpaProjectManager jpaProjectManager = JptJpaCorePlugin.getJpaProjectManager();
- ReflectionTools.executeMethod(jpaProjectManager, "handleEventsSynchronously");
+ JpaProjectManager jpaProjectManager = this.getJpaProjectManager();
+ ReflectionTools.executeMethod(jpaProjectManager, "executeCommandsSynchronously");
+ ReflectionTools.setFieldValue(jpaProjectManager, "test", Boolean.TRUE);
ReflectionTools.executeStaticMethod(JptJpaCorePlugin.class, "doNotFlushPreferences");
}
+ private JpaProjectManager getJpaProjectManager() {
+ return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class);
+ }
+
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
}
-
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
index 2b03132660..a1f71f623d 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -14,6 +14,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jpa.core.JpaFile;
+import org.eclipse.jpt.jpa.core.JpaNode;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.MappingKeys;
@@ -28,7 +29,8 @@ import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
@SuppressWarnings("nls")
-public class JpaFileTests extends ContextModelTestCase
+public class JpaFileTests
+ extends ContextModelTestCase
{
public JpaFileTests(String name) {
super(name);
@@ -43,6 +45,27 @@ public class JpaFileTests extends ContextModelTestCase
getPersistenceXmlResource().save(null);
}
+ private JpaFile getJpaFile(ICompilationUnit cu) {
+ return this.getJpaFile((IFile) cu.getResource());
+ }
+
+ private JpaFile getJpaFile(IFile file) {
+ try {
+ return this.getJpaFile_(file);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private JpaFile getJpaFile_(IFile file) throws InterruptedException {
+ return this.getJpaFileReference(file).getValue();
+ }
+
+ private JpaFile.Reference getJpaFileReference(IFile file) {
+ return (JpaFile.Reference) file.getAdapter(JpaFile.Reference.class);
+ }
+
private ICompilationUnit createTestEntity() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
@@ -60,13 +83,13 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
IFile file = getOrmXmlResource().getFile();
- JpaFile ormXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile ormXmlJpaFile = this.getJpaFile(file);
assertEquals(getEntityMappings(), ormXmlJpaFile.getRootStructureNodes().iterator().next());
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -86,7 +109,7 @@ public class JpaFileTests extends ContextModelTestCase
public void testEntityMappingsRootStructureNodeRemoved() throws Exception {
IFile file = getOrmXmlResource().getFile();
- JpaFile ormXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile ormXmlJpaFile = this.getJpaFile(file);
assertEquals(getEntityMappings(), ormXmlJpaFile.getRootStructureNodes().iterator().next());
JpaXmlResource resource = (JpaXmlResource) ormXmlJpaFile.getResourceModel();
@@ -97,7 +120,7 @@ public class JpaFileTests extends ContextModelTestCase
public void testImpliedEntityMappingsRootStructureNodeRemoved() throws Exception {
IFile file = getOrmXmlResource().getFile();
- JpaFile ormXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile ormXmlJpaFile = this.getJpaFile(file);
assertNull(getPersistenceUnit().getImpliedMappingFileRef());
@@ -113,7 +136,7 @@ public class JpaFileTests extends ContextModelTestCase
public void testEntityMappingsRootStructureNodeRemovedFromResourceModel() throws Exception {
IFile file = getOrmXmlResource().getFile();
- JpaFile ormXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile ormXmlJpaFile = this.getJpaFile(file);
assertEquals(getEntityMappings(), ormXmlJpaFile.getRootStructureNodes().iterator().next());
getOrmXmlResource().getContents().remove(getOrmXmlResource().getRootObject());
@@ -123,7 +146,7 @@ public class JpaFileTests extends ContextModelTestCase
public void testUpdatePersistenceRootStructureNodePersistenceRemoved() throws Exception {
IFile file = getPersistenceXmlResource().getFile();
- JpaFile persistenceXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile persistenceXmlJpaFile = this.getJpaFile(file);
assertEquals(getRootContextNode().getPersistenceXml().getPersistence(), persistenceXmlJpaFile.getRootStructureNodes().iterator().next());
JpaXmlResource resource = (JpaXmlResource) persistenceXmlJpaFile.getResourceModel();
@@ -134,11 +157,11 @@ public class JpaFileTests extends ContextModelTestCase
public void testUpdateOrmJavaRootStructureNodePersistenceRemoved() throws Exception {
IFile file = getPersistenceXmlResource().getFile();
- JpaFile persistenceXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile persistenceXmlJpaFile = this.getJpaFile(file);
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -150,11 +173,11 @@ public class JpaFileTests extends ContextModelTestCase
public void testUpdateJavaRootStructureNodePersistenceRemoved() throws Exception {
IFile file = getPersistenceXmlResource().getFile();
- JpaFile persistenceXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile persistenceXmlJpaFile = this.getJpaFile(file);
ICompilationUnit cu = createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -166,7 +189,7 @@ public class JpaFileTests extends ContextModelTestCase
public void testPersistenceRootStructureNodeRemovedFromResourceModel() throws Exception {
IFile file = getPersistenceXmlResource().getFile();
- JpaFile persistenceXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile persistenceXmlJpaFile = this.getJpaFile(file);
getRootContextNode().getPersistenceXml().getPersistence();
assertEquals(getRootContextNode().getPersistenceXml().getPersistence(), persistenceXmlJpaFile.getRootStructureNodes().iterator().next());
@@ -179,7 +202,7 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -191,7 +214,7 @@ public class JpaFileTests extends ContextModelTestCase
ICompilationUnit cu = createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -203,16 +226,18 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- assertTrue(javaJpaFile.getRootStructureNodes().iterator().next().getParent() instanceof OrmPersistentType);
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertTrue(node.getParent() instanceof OrmPersistentType);
getEntityMappings().removePersistentType(0);
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertTrue(javaJpaFile.getRootStructureNodes().iterator().next().getParent() instanceof ClassRef);
+ node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertTrue(node.getParent() instanceof ClassRef);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
}
@@ -220,54 +245,59 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- assertTrue(javaJpaFile.getRootStructureNodes().iterator().next().getParent() instanceof OrmPersistentType);
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertTrue(node.getParent() instanceof OrmPersistentType);
getXmlEntityMappings().getEntities().remove(0);
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertTrue(javaJpaFile.getRootStructureNodes().iterator().next().getParent() instanceof ClassRef);
+ node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertTrue(node.getParent() instanceof ClassRef);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
}
public void testJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentType javaPersistentType = getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- assertEquals(getEntityMappings().getPersistenceUnit().getSpecifiedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getEntityMappings().getPersistenceUnit().getSpecifiedClassRefs().iterator().next(), node.getParent());
getEntityMappings().getPersistenceUnit().removeSpecifiedClassRef(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
public void testJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception {
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentType javaPersistentType = getJavaPersistentType();
Iterator<JpaStructureNode> rootStructureNodes = javaJpaFile.getRootStructureNodes().iterator();
JpaStructureNode rootStructureNode = rootStructureNodes.next();
assertEquals(javaPersistentType, rootStructureNode);
- assertEquals(getEntityMappings().getPersistenceUnit().getSpecifiedClassRefs().iterator().next(), rootStructureNode.getParent());
+ assertEquals(getEntityMappings().getPersistenceUnit().getSpecifiedClassRefs().iterator().next(), ((JpaNode) rootStructureNode).getParent());
assertFalse(rootStructureNodes.hasNext());
removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
public void testImpliedJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
getJpaProject().setDiscoversAnnotatedClasses(true);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = getPersistenceUnit().getImpliedClassRefs().iterator().next().getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -281,7 +311,7 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -289,14 +319,15 @@ public class JpaFileTests extends ContextModelTestCase
getOrmXmlResource().getContents().remove(getXmlEntityMappings());
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
public void testJavaRootStructureNodesPersistenceUnitRemovedFromResourceModel() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -311,7 +342,7 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -326,7 +357,7 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -334,14 +365,15 @@ public class JpaFileTests extends ContextModelTestCase
getEntityMappings().removePersistentType(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
public void testJavaRootStructureNodesOrmTypeMappingMorphed() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -354,14 +386,15 @@ public class JpaFileTests extends ContextModelTestCase
getEntityMappings().removePersistentType(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
public void testUpdateOrmJavaRootStructureNodeMappingFileRefChanged() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -372,7 +405,7 @@ public class JpaFileTests extends ContextModelTestCase
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
IFile file = getPersistenceXmlResource().getFile();
- JpaFile ormXmlJpaFile = JptJpaCorePlugin.getJpaFile(file);
+ JpaFile ormXmlJpaFile = this.getJpaFile(file);
assertEquals(1, ormXmlJpaFile.getRootStructureNodesSize());
}
@@ -381,7 +414,7 @@ public class JpaFileTests extends ContextModelTestCase
ICompilationUnit cu = createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
assertEquals(getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -395,7 +428,7 @@ public class JpaFileTests extends ContextModelTestCase
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
ICompilationUnit cu = createTestEntity();
- JpaFile javaJpaFile = JptJpaCorePlugin.getJpaFile((IFile) cu.getResource());
+ JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
@@ -405,7 +438,8 @@ public class JpaFileTests extends ContextModelTestCase
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), javaJpaFile.getRootStructureNodes().iterator().next().getParent());
+ JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
//TODO test rootStructureNodes with a static inner class
} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceTests.java
index d7655ef4db..32f258e6c5 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -68,7 +68,7 @@ public class PersistenceTests extends ContextModelTestCase
try {
persistence.addPersistenceUnit();
}
- catch (IllegalStateException e) {
+ catch (IndexOutOfBoundsException e) {
exception = true;
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
index ea45687534..2891c9cea6 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -20,22 +20,26 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jpt.common.core.tests.internal.projects.TestFacetedProject;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject;
import org.eclipse.jpt.common.core.tests.internal.projects.TestPlatformProject;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
import org.eclipse.jpt.jpa.core.JpaFacet;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@SuppressWarnings("nls")
-public class JpaProjectManagerTests extends TestCase {
-
+public class JpaProjectManagerTests
+ extends TestCase
+{
/** carriage return */
public static final String CR = System.getProperty("line.separator");
- protected TestFacetedProject testProject;
+ private TestFacetedProject testProjectHarness;
+
+
public JpaProjectManagerTests(String name) {
super(name);
}
@@ -46,17 +50,20 @@ public class JpaProjectManagerTests extends TestCase {
if (this.debug()) {
this.printName();
}
- this.testProject = this.buildTestProject();
+ this.testProjectHarness = this.buildTestProjectHarness();
}
private boolean debug() {
- Boolean debug = (Boolean) ReflectionTools.getStaticFieldValue(this.getGenericJpaProjectManagerClass(), "DEBUG");
- return debug.booleanValue();
+ return TestTools.debug(this.getGenericJpaProjectManagerClass());
}
// GenericJpaProjectManager is package-private
private Class<?> getGenericJpaProjectManagerClass() {
- return JptJpaCorePlugin.getJpaProjectManager().getClass();
+ return this.getJpaProjectManager().getClass();
+ }
+
+ protected JpaProjectManager getJpaProjectManager() {
+ return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class);
}
private void printName() {
@@ -77,16 +84,40 @@ public class JpaProjectManagerTests extends TestCase {
@Override
protected void tearDown() throws Exception {
- this.testProject.getProject().delete(true, true, null);
- this.testProject = null;
+ this.testProjectHarness.getProject().delete(true, true, null);
+ this.testProjectHarness = null;
super.tearDown();
}
+ private JpaProject getJpaProject() {
+ return this.getJpaProject(this.getProject());
+ }
+
+ private JpaProject getJpaProject(IProject project) {
+ try {
+ return this.getJpaProject_(project);
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private JpaProject getJpaProject_(IProject project) throws InterruptedException {
+ return this.getJpaProjectReference(project).getValue();
+ }
+
+ private JpaProject.Reference getJpaProjectReference(IProject project) {
+ return (JpaProject.Reference) project.getAdapter(JpaProject.Reference.class);
+ }
+
+ private IProject getProject() {
+ return this.testProjectHarness.getProject();
+ }
+
/**
* Builds a project with the java and utility facets installed, and with
* pre-existing entities added.
*/
- private TestFacetedProject buildTestProject() throws Exception {
+ private TestFacetedProject buildTestProjectHarness() throws Exception {
TestJavaProject tjp = TestJavaProject.buildJavaProject(this.getClass().getSimpleName(), true);
tjp.createCompilationUnit("test.pkg", "TestEntity.java", "@Entity public class TestEntity {}");
tjp.createCompilationUnit("test.pkg", "TestEntity2.java", "@Entity public class TestEntity2 {}");
@@ -101,99 +132,94 @@ public class JpaProjectManagerTests extends TestCase {
* make sure the DEBUG constants are 'false' before checking in the code
*/
public void testDEBUG() {
- this.verifyDEBUG(this.getGenericJpaProjectManagerClass());
+ TestTools.assertFalseDEBUG(this.getGenericJpaProjectManagerClass());
}
- private void verifyDEBUG(Class<?> clazz) {
- assertFalse("Recompile with \"DEBUG = false\": " + clazz.getName(),
- ((Boolean) ReflectionTools.getStaticFieldValue(clazz, "DEBUG")).booleanValue());
- }
-
public void testJpaProjectManager() {
- assertNotNull(JptJpaCorePlugin.getJpaProjectManager());
+ assertNotNull(this.getJpaProjectManager());
}
- protected IDataModel buildJpaConfigDataModel() {
+ private IDataModel buildJpaConfigDataModel() {
IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
return dataModel;
}
public void testProjectCloseReopen() throws Exception {
- this.testProject.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
- JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
+ JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
- this.testProject.getProject().close(null);
- assertFalse("Project is not closed", this.testProject.getProject().isOpen());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.getProject().close(null);
+ assertFalse("Project is not closed", this.testProjectHarness.getProject().isOpen());
+ jpaProject = this.getJpaProject();
assertNull("JpaProject is not null", jpaProject);
- this.testProject.getProject().open(null);
- assertTrue(this.testProject.getProject().isOpen());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.getProject().open(null);
+ assertTrue(this.testProjectHarness.getProject().isOpen());
+ jpaProject = this.getJpaProject();
assertNotNull("JpaProject is null", jpaProject);
assertEquals(4, jpaProject.getJpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity2.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
}
public void testProjectDeleteReimport() throws Exception {
- this.testProject.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
- JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
+ JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
- assertEquals(1, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
+ assertEquals(1, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
- this.testProject.getProject().delete(false, true, null);
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.getProject().delete(false, true, null);
+ jpaProject = this.getJpaProject();
assertNull(jpaProject);
- assertEquals(0, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
+ assertEquals(0, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(this.testProject.getProject().getName());
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(this.testProjectHarness.getProject().getName());
project.create(null);
assertEquals(1, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
project.open(null);
assertTrue(project.isOpen());
assertTrue(JpaFacet.isInstalled(project));
- jpaProject = JptJpaCorePlugin.getJpaProject(project);
+ jpaProject = this.getJpaProject(project);
assertNotNull(jpaProject);
assertEquals(4, jpaProject.getJpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity2.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
}
public void testFacetInstallUninstall() throws Exception {
- assertNull(JptJpaCorePlugin.getJpaProject(this.testProject.getProject()));
+ assertNull(this.getJpaProject());
- this.testProject.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
- assertEquals(1, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
+ assertEquals(1, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
assertEquals(4, jpaProject.getJpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity2.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
- this.testProject.uninstallFacet(JpaFacet.ID, "1.0");
- assertEquals(0, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.uninstallFacet(JpaFacet.ID, "1.0");
+ assertEquals(0, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ jpaProject = this.getJpaProject();
assertNull(jpaProject);
}
public void testEditFacetSettingsFileAddThenRemoveJpaFacet() throws Exception {
- assertNull(JptJpaCorePlugin.getJpaProject(this.testProject.getProject()));
+ assertNull(this.getJpaProject());
// add the JPA facet by modifying the facet settings file directly
- IFile facetSettingsFile = this.getFile(this.testProject, ".settings/org.eclipse.wst.common.project.facet.core.xml");
+ IFile facetSettingsFile = this.getFile(this.testProjectHarness, ".settings/org.eclipse.wst.common.project.facet.core.xml");
InputStream inStream = new BufferedInputStream(facetSettingsFile.getContents());
int fileSize = inStream.available();
byte[] buf = new byte[fileSize];
@@ -207,31 +233,31 @@ public class JpaProjectManagerTests extends TestCase {
facetSettingsFile.setContents(new ByteArrayInputStream(newDocument.getBytes()), false, false, null);
- assertEquals(1, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ assertEquals(1, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
// persistence.xml and orm.xml do not get created in this situation (?)
assertEquals(2, jpaProject.getJpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity2.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
// assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/persistence.xml")));
// assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml")));
// now remove the JPA facet
facetSettingsFile.setContents(new ByteArrayInputStream(oldDocument.getBytes()), false, false, null);
- assertEquals(0, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ assertEquals(0, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ jpaProject = this.getJpaProject();
assertNull(jpaProject);
}
public void testEditFacetSettingsFileRemoveThenAddJpaFacet() throws Exception {
- this.testProject.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
- JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ this.testProjectHarness.installFacet(JpaFacet.ID, "1.0", buildJpaConfigDataModel());
+ JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
// remove the JPA facet by modifying the facet settings file directly
- IFile facetSettingsFile = this.getFile(this.testProject, ".settings/org.eclipse.wst.common.project.facet.core.xml");
+ IFile facetSettingsFile = this.getFile(this.testProjectHarness, ".settings/org.eclipse.wst.common.project.facet.core.xml");
InputStream inStream = new BufferedInputStream(facetSettingsFile.getContents());
int fileSize = inStream.available();
byte[] buf = new byte[fileSize];
@@ -244,19 +270,19 @@ public class JpaProjectManagerTests extends TestCase {
String newDocument = oldDocument.replaceAll(oldString, newString);
facetSettingsFile.setContents(new ByteArrayInputStream(newDocument.getBytes()), false, false, null);
- assertEquals(0, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ assertEquals(0, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ jpaProject = this.getJpaProject();
assertNull(jpaProject);
// now add the JPA facet back
facetSettingsFile.setContents(new ByteArrayInputStream(oldDocument.getBytes()), false, false, null);
- assertEquals(1, JptJpaCorePlugin.getJpaProjectManager().getJpaProjectsSize());
- jpaProject = JptJpaCorePlugin.getJpaProject(this.testProject.getProject());
+ assertEquals(1, CollectionTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
+ jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
assertEquals(4, jpaProject.getJpaFilesSize());
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/test/pkg/TestEntity2.java")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
+ assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
}
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/projects/TestJpaProject.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/projects/TestJpaProject.java
index 32ec238dc5..25a39ccccb 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/projects/TestJpaProject.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/projects/TestJpaProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,15 +11,8 @@ package org.eclipse.jpt.jpa.core.tests.internal.projects;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.common.utility.Command;
-import org.eclipse.jpt.common.utility.internal.synchronizers.CallbackSynchronousSynchronizer;
-import org.eclipse.jpt.common.utility.internal.synchronizers.SynchronousSynchronizer;
-import org.eclipse.jpt.common.utility.synchronizers.CallbackSynchronizer;
-import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jpt.jpa.core.JpaFacet;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -31,9 +24,9 @@ import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
* controlled by building a data model and passing it into the constructor.
*/
@SuppressWarnings("nls")
-public class TestJpaProject extends TestJavaProject {
- final JpaProject jpaProject;
-
+public class TestJpaProject
+ extends TestJavaProject
+{
public static final String JPA_JAR_NAME_SYSTEM_PROPERTY = "org.eclipse.jpt.jpa.jar";
public static final String ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY = "org.eclipse.jpt.eclipselink.jar";
@@ -72,38 +65,7 @@ public class TestJpaProject extends TestJavaProject {
if (eclipseLinkJarName() != null) {
this.addJar(eclipseLinkJarName());
}
- this.jpaProject = JptJpaCorePlugin.getJpaProject(this.getProject());
- this.jpaProject.setDiscoversAnnotatedClasses(true);
- this.jpaProject.setContextModelSynchronizer(this.buildSynchronousContextModelSynchronizer());
- this.jpaProject.setUpdateSynchronizer(this.buildSynchronousUpdateSynchronizer());
- }
-
- protected Synchronizer buildSynchronousContextModelSynchronizer() {
- return new SynchronousSynchronizer(this.buildSynchronousContextModelSynchronizerCommand());
- }
-
- protected Command buildSynchronousContextModelSynchronizerCommand() {
- return new SynchronousContextModelSynchronizerCommand();
- }
-
- protected class SynchronousContextModelSynchronizerCommand implements Command {
- public void execute() {
- TestJpaProject.this.jpaProject.synchronizeContextModel(new NullProgressMonitor());
- }
- }
-
- protected CallbackSynchronizer buildSynchronousUpdateSynchronizer() {
- return new CallbackSynchronousSynchronizer(this.buildSynchronousUpdateSynchronizerCommand());
- }
-
- protected Command buildSynchronousUpdateSynchronizerCommand() {
- return new SynchronousUpdateSynchronizerCommand();
- }
-
- protected class SynchronousUpdateSynchronizerCommand implements Command {
- public void execute() {
- TestJpaProject.this.jpaProject.update(new NullProgressMonitor());
- }
+ this.getJpaProject().setDiscoversAnnotatedClasses(true);
}
public static String jpaJarName() {
@@ -122,7 +84,18 @@ public class TestJpaProject extends TestJavaProject {
// ********** public methods **********
public JpaProject getJpaProject() {
- return this.jpaProject;
+ try {
+ return this.getJpaProject_();
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private JpaProject getJpaProject_() throws InterruptedException {
+ return this.getJpaProjectReference().getValue();
}
+ private JpaProject.Reference getJpaProjectReference() {
+ return (JpaProject.Reference) this.getProject().getAdapter(JpaProject.Reference.class);
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/JavaResourceModelTestCase.java
index 3573fa84e0..00701545e0 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/JavaResourceModelTestCase.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/JavaResourceModelTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -24,7 +24,7 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageInfoCompilationUnit;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase;
-import org.eclipse.jpt.common.utility.CommandExecutor;
+import org.eclipse.jpt.common.utility.command.CommandExecutor;
import org.eclipse.jpt.common.utility.internal.BitTools;
import org.eclipse.jpt.common.utility.internal.ReflectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;

Back to the top