Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2015-09-24 21:39:30 +0000
committerBrian Vosburgh2015-09-24 21:39:30 +0000
commit95117c74f4524a53538923c7216e4b5933784300 (patch)
tree4eded8b13a33061b4a23d1e62bd41f44688b9d1c
parent1d62c97e1dada43ee9a58bbc48f540ee34e8a51d (diff)
downloadwebtools.dali-95117c74f4524a53538923c7216e4b5933784300.tar.gz
webtools.dali-95117c74f4524a53538923c7216e4b5933784300.tar.xz
webtools.dali-95117c74f4524a53538923c7216e4b5933784300.zip
[476150] fix tests that fail with move to Java 1.8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JpaNamedContextModel.java14
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0JpaMetadataConversionTests.java17
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java22
3 files changed, 38 insertions, 15 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JpaNamedContextModel.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JpaNamedContextModel.java
index fde61704de..5a9245a85b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JpaNamedContextModel.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JpaNamedContextModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2015 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,7 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context;
+import java.util.Comparator;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.comparator.ComparatorAdapter;
/**
* Named context model. Sorta. :-)
@@ -36,4 +38,14 @@ public interface JpaNamedContextModel
return node.getName();
}
}
+
+ Comparator<JpaNamedContextModel> NAME_COMPARATOR = new NameComparator();
+ class NameComparator
+ extends ComparatorAdapter<JpaNamedContextModel>
+ {
+ @Override
+ public int compare(JpaNamedContextModel model1, JpaNamedContextModel model2) {
+ return model1.getName().compareTo(model2.getName());
+ }
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0JpaMetadataConversionTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0JpaMetadataConversionTests.java
index 7f880fd7dd..7cf64079b7 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0JpaMetadataConversionTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0JpaMetadataConversionTests.java
@@ -15,6 +15,7 @@ import java.util.ListIterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
import org.eclipse.jpt.jpa.core.context.JpaNamedContextModel;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
@@ -190,8 +191,10 @@ public class Generic2_0JpaMetadataConversionTests extends
assertEquals(0, entity.getQueryContainer().getNamedQueriesSize());
// test the mapping file queries have correct values
- ListIterator<OrmNamedQuery> namedQueries= entityMappings.getQueryContainer().getNamedQueries().iterator();
- OrmNamedQuery nq1 = namedQueries.next();
+ Iterable<OrmNamedQuery> queries = entityMappings.getQueryContainer().getNamedQueries();
+ queries = IterableTools.sort(queries, JpaNamedContextModel.NAME_COMPARATOR);
+ Iterator<OrmNamedQuery> queriesIterator = queries.iterator();
+ OrmNamedQuery nq1 = queriesIterator.next();
// test the first mapping file query
assertEquals("nq1", (nq1.getName()));
@@ -212,7 +215,7 @@ public class Generic2_0JpaMetadataConversionTests extends
assertEquals("bbb", nq1hint2.getValue());
// test the second mapping file query
- OrmNamedQuery nq2 = namedQueries.next();
+ OrmNamedQuery nq2 = queriesIterator.next();
assertEquals("nq2", (nq2.getName()));
assertEquals("efgh", (nq2.getQuery()));
assertEquals(1, (nq2.getHintsSize()));
@@ -353,8 +356,10 @@ public class Generic2_0JpaMetadataConversionTests extends
assertEquals(0, mappedSuperclass.getQueryContainer().getNamedQueriesSize());
// test the mapping file queries have correct values
- ListIterator<OrmNamedQuery> namedQueries= entityMappings.getQueryContainer().getNamedQueries().iterator();
- OrmNamedQuery nq1 = namedQueries.next();
+ Iterable<OrmNamedQuery> queries = entityMappings.getQueryContainer().getNamedQueries();
+ queries = IterableTools.sort(queries, JpaNamedContextModel.NAME_COMPARATOR);
+ Iterator<OrmNamedQuery> queriesIterator = queries.iterator();
+ OrmNamedQuery nq1 = queriesIterator.next();
// test the first mapping file query
assertEquals("nq1", (nq1.getName()));
@@ -375,7 +380,7 @@ public class Generic2_0JpaMetadataConversionTests extends
assertEquals("bbb", nq1hint2.getValue());
// test the second mapping file query
- OrmNamedQuery nq2 = namedQueries.next();
+ OrmNamedQuery nq2 = queriesIterator.next();
assertEquals("nq2", (nq2.getName()));
assertEquals("efgh", (nq2.getQuery()));
assertEquals(1, (nq2.getHintsSize()));
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java
index be4ee599b7..78f9d2329a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Oracle. All rights reserved.
+ * Copyright (c) 2013, 2015 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.
@@ -13,7 +13,9 @@ import java.util.Iterator;
import java.util.ListIterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.context.JpaNamedContextModel;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
@@ -160,15 +162,17 @@ public class Generic2_1JpaMetadataConversionTests
EntityMappings entityMappings = getEntityMappings();
PersistenceUnit persistenceUnit = getPersistenceUnit();
- persistenceUnit.convertJavaQueries(entityMappings, progressMonitor);
+ persistenceUnit.convertJavaQueries(entityMappings, this.progressMonitor);
// test Java queries are converted to orm.xml and removed from the Java entity
assertEquals(2, ((QueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueriesSize());
assertEquals(0, ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueriesSize());
// test the mapping file queries have correct values
- ListIterator<OrmNamedStoredProcedureQuery2_1> procedureQueries= ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries().iterator();
- OrmNamedStoredProcedureQuery2_1 procedureQuery1 = procedureQueries.next();
+ Iterable<OrmNamedStoredProcedureQuery2_1> queries = ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries();
+ queries = IterableTools.sort(queries, JpaNamedContextModel.NAME_COMPARATOR);
+ Iterator<OrmNamedStoredProcedureQuery2_1> queriesIterator = queries.iterator();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery1 = queriesIterator.next();
// ----- the first mapping file query -----
@@ -218,7 +222,7 @@ public class Generic2_1JpaMetadataConversionTests
assertEquals("bbb", nq1hint2.getValue());
// ----- the second mapping file query -----
- OrmNamedStoredProcedureQuery2_1 procedureQuery2 = procedureQueries.next();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery2 = queriesIterator.next();
assertEquals("nq2", (procedureQuery2.getName()));
assertEquals("efgh", (procedureQuery2.getProcedureName()));
assertEquals(1, procedureQuery2.getParametersSize());
@@ -307,8 +311,10 @@ public class Generic2_1JpaMetadataConversionTests
assertEquals(0, ((QueryContainer2_1) mappedSuperclass.getQueryContainer()).getNamedStoredProcedureQueriesSize());
// test the mapping file queries have correct values
- ListIterator<OrmNamedStoredProcedureQuery2_1> procedureQueries= ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries().iterator();
- OrmNamedStoredProcedureQuery2_1 procedureQuery1 = procedureQueries.next();
+ Iterable<OrmNamedStoredProcedureQuery2_1> queries = ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries();
+ queries = IterableTools.sort(queries, JpaNamedContextModel.NAME_COMPARATOR);
+ Iterator<OrmNamedStoredProcedureQuery2_1> queriesIterator = queries.iterator();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery1 = queriesIterator.next();
// ----- the first mapping file query -----
@@ -358,7 +364,7 @@ public class Generic2_1JpaMetadataConversionTests
assertEquals("bbb", nq1hint2.getValue());
// ----- the second mapping file query -----
- OrmNamedStoredProcedureQuery2_1 procedureQuery2 = procedureQueries.next();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery2 = queriesIterator.next();
assertEquals("nq2", (procedureQuery2.getName()));
assertEquals("efgh", (procedureQuery2.getProcedureName()));
assertEquals(1, procedureQuery2.getParametersSize());

Back to the top