Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2010-01-05 05:37:21 +0000
committerbvosburgh2010-01-05 05:37:21 +0000
commit4394bdb502dc33f81b744137cbf8cc618476b917 (patch)
treebdc5a172064ef7cd67227e54fb97e4a6474d01fb /jpa/tests/org.eclipse.jpt.utility.tests/src/org
parent28096602a832fbf503892b83054abcdb951e65d6 (diff)
downloadwebtools.dali-4394bdb502dc33f81b744137cbf8cc618476b917.tar.gz
webtools.dali-4394bdb502dc33f81b744137cbf8cc618476b917.tar.xz
webtools.dali-4394bdb502dc33f81b744137cbf8cc618476b917.zip
utility work
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.utility.tests/src/org')
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ArrayToolsTests.java581
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/AsynchronousCommandExecutorTests.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BagTests.java82
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiFilterTests.java88
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiStringConverterTests.java115
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiTransformerTests.java73
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java21
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanToolsTests.java22
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassNameTests.java356
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java676
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java296
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java19
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandExecutorTests.java21
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandRunnableTests.java55
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CompositeCommandTests.java61
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java48
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java52
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java54
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java56
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReflectionToolsTests.java440
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java15
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java32
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/FilteringIterableTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/JptUtilityIterablesTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/SuperIterableWrapperTests.java (renamed from jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/GenericIterableWrapperTests.java)12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java47
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SuperIteratorWrapperTests.java (renamed from jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GenericIteratorWrapperTests.java)8
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java188
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java11
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java7
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java13
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java7
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java13
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java7
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java16
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java7
64 files changed, 2598 insertions, 1125 deletions
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ArrayToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ArrayToolsTests.java
index 3e94c216b2..5fffd9c88b 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ArrayToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ArrayToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.utility.tests.internal;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -20,6 +21,7 @@ import java.util.Vector;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.Range;
import org.eclipse.jpt.utility.internal.ReverseComparator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
@@ -2855,8 +2857,8 @@ public class ArrayToolsTests extends TestCase {
public void testFillBooleanArrayBoolean() {
boolean[] a1 = new boolean[9];
boolean[] a2 = ArrayTools.fill(a1, true);
- for (boolean b : a1) {
- assertTrue(b);
+ for (boolean x : a1) {
+ assertTrue(x);
}
assertSame(a1, a2);
}
@@ -2868,18 +2870,583 @@ public class ArrayToolsTests extends TestCase {
int to = 6;
boolean[] a3 = ArrayTools.fill(a2, from, to, true);
for (int i = 0; i < a1.length; i++) {
- boolean b = a1[i];
+ boolean x = a1[i];
if (i < from || i >= to) {
- assertFalse(b);
+ assertFalse(x);
} else {
- assertTrue(b);
+ assertTrue(x);
}
}
assertSame(a1, a2);
assertSame(a1, a3);
}
- // TODO
+ public void testFillByteArrayByte() {
+ byte[] a1 = new byte[9];
+ byte[] a2 = ArrayTools.fill(a1, (byte) 77);
+ for (byte x : a1) {
+ assertEquals(77, x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillByteArrayIntIntByte() {
+ byte[] a1 = new byte[9];
+ byte[] a2 = ArrayTools.fill(a1, (byte) 3);
+ int from = 3;
+ int to = 6;
+ byte[] a3 = ArrayTools.fill(a2, from, to, (byte) 77);
+ for (int i = 0; i < a1.length; i++) {
+ byte x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertEquals(77, x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillCharArrayChar() {
+ char[] a1 = new char[9];
+ char[] a2 = ArrayTools.fill(a1, 'c');
+ for (char x : a1) {
+ assertEquals('c', x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillCharArrayIntIntChar() {
+ char[] a1 = new char[9];
+ char[] a2 = ArrayTools.fill(a1, 'a');
+ int from = 3;
+ int to = 6;
+ char[] a3 = ArrayTools.fill(a2, from, to, 'c');
+ for (int i = 0; i < a1.length; i++) {
+ char x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals('a', x);
+ } else {
+ assertEquals('c', x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillDoubleArrayDouble() {
+ double[] a1 = new double[9];
+ double[] a2 = ArrayTools.fill(a1, 77.77);
+ for (double x : a1) {
+ assertEquals(77.77, x, 0.0);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillDoubleArrayIntIntDouble() {
+ double[] a1 = new double[9];
+ double[] a2 = ArrayTools.fill(a1, 3.3);
+ int from = 3;
+ int to = 6;
+ double[] a3 = ArrayTools.fill(a2, from, to, 77.77);
+ for (int i = 0; i < a1.length; i++) {
+ double x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3.3, x, 0.0);
+ } else {
+ assertEquals(77.77, x, 0.0);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillFloatArrayFloat() {
+ float[] a1 = new float[9];
+ float[] a2 = ArrayTools.fill(a1, 77.77f);
+ for (float x : a1) {
+ assertEquals(77.77f, x, 0.0);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillFloatArrayIntIntFloat() {
+ float[] a1 = new float[9];
+ float[] a2 = ArrayTools.fill(a1, 3.3f);
+ int from = 3;
+ int to = 6;
+ float[] a3 = ArrayTools.fill(a2, from, to, 77.77f);
+ for (int i = 0; i < a1.length; i++) {
+ float x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3.3f, x, 0.0);
+ } else {
+ assertEquals(77.77f, x, 0.0);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillIntArrayInt() {
+ int[] a1 = new int[9];
+ int[] a2 = ArrayTools.fill(a1, 77);
+ for (int x : a1) {
+ assertEquals(77, x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillIntArrayIntIntInt() {
+ int[] a1 = new int[9];
+ int[] a2 = ArrayTools.fill(a1, 3);
+ int from = 3;
+ int to = 6;
+ int[] a3 = ArrayTools.fill(a2, from, to, 77);
+ for (int i = 0; i < a1.length; i++) {
+ int x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertEquals(77, x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillObjectArrayObject() {
+ String[] a1 = new String[9];
+ String[] a2 = ArrayTools.fill(a1, "77");
+ for (String x : a1) {
+ assertEquals("77", x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillObjectArrayIntIntObject() {
+ String[] a1 = new String[9];
+ String[] a2 = ArrayTools.fill(a1, "3");
+ int from = 3;
+ int to = 6;
+ String[] a3 = ArrayTools.fill(a2, from, to, "77");
+ for (int i = 0; i < a1.length; i++) {
+ String x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals("3", x);
+ } else {
+ assertEquals("77", x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillLongArrayLong() {
+ long[] a1 = new long[9];
+ long[] a2 = ArrayTools.fill(a1, 77);
+ for (long x : a1) {
+ assertEquals(77, x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillLongArrayIntIntLong() {
+ long[] a1 = new long[9];
+ long[] a2 = ArrayTools.fill(a1, 3);
+ int from = 3;
+ int to = 6;
+ long[] a3 = ArrayTools.fill(a2, from, to, 77);
+ for (int i = 0; i < a1.length; i++) {
+ long x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertEquals(77, x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testFillShortArrayShort() {
+ short[] a1 = new short[9];
+ short[] a2 = ArrayTools.fill(a1, (short) 77);
+ for (short x : a1) {
+ assertEquals(77, x);
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testFillShortArrayIntIntShort() {
+ short[] a1 = new short[9];
+ short[] a2 = ArrayTools.fill(a1, (short) 3);
+ int from = 3;
+ int to = 6;
+ short[] a3 = ArrayTools.fill(a2, from, to, (short) 77);
+ for (int i = 0; i < a1.length; i++) {
+ short x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertEquals(77, x);
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortByteArray() {
+ byte[] a1 = new byte[3];
+ a1[0] = (byte) 33;
+ a1[1] = (byte) 11;
+ a1[2] = (byte) 22;
+ byte[] a2 = ArrayTools.sort(a1);
+ byte last = (byte) 0;
+ for (byte x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortByteArrayIntInt() {
+ byte[] a1 = new byte[9];
+ byte[] a2 = ArrayTools.fill(a1, (byte) 3);
+ a2[3] = (byte) 33;
+ a2[4] = (byte) 11;
+ a2[5] = (byte) 22;
+ int from = 3;
+ int to = 6;
+ byte[] a3 = ArrayTools.sort(a2, from, to);
+ byte last = (byte) 0;
+ for (int i = 0; i < a1.length; i++) {
+ byte x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortCharArray() {
+ char[] a1 = new char[3];
+ a1[0] = 'z';
+ a1[1] = 'b';
+ a1[2] = 'm';
+ char[] a2 = ArrayTools.sort(a1);
+ char last = 'a';
+ for (char x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortCharArrayIntInt() {
+ char[] a1 = new char[9];
+ char[] a2 = ArrayTools.fill(a1, 'c');
+ a2[3] = 'z';
+ a2[4] = 'b';
+ a2[5] = 'm';
+ int from = 3;
+ int to = 6;
+ char[] a3 = ArrayTools.sort(a2, from, to);
+ char last = 'a';
+ for (int i = 0; i < a1.length; i++) {
+ char x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals('c', x);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortDoubleArray() {
+ double[] a1 = new double[3];
+ a1[0] = 33.33;
+ a1[1] = 11.11;
+ a1[2] = 22.22;
+ double[] a2 = ArrayTools.sort(a1);
+ double last = 0;
+ for (double x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortDoubleArrayIntInt() {
+ double[] a1 = new double[9];
+ double[] a2 = ArrayTools.fill(a1, 3.3);
+ a2[3] = 33.33;
+ a2[4] = 11.11;
+ a2[5] = 22.22;
+ int from = 3;
+ int to = 6;
+ double[] a3 = ArrayTools.sort(a2, from, to);
+ double last = 0;
+ for (int i = 0; i < a1.length; i++) {
+ double x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3.3, x, 0.0);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortFloatArray() {
+ float[] a1 = new float[3];
+ a1[0] = 33.33f;
+ a1[1] = 11.11f;
+ a1[2] = 22.22f;
+ float[] a2 = ArrayTools.sort(a1);
+ float last = 0;
+ for (float x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortFloatArrayIntInt() {
+ float[] a1 = new float[9];
+ float[] a2 = ArrayTools.fill(a1, 3.3f);
+ a2[3] = 33.33f;
+ a2[4] = 11.11f;
+ a2[5] = 22.22f;
+ int from = 3;
+ int to = 6;
+ float[] a3 = ArrayTools.sort(a2, from, to);
+ float last = 0;
+ for (int i = 0; i < a1.length; i++) {
+ float x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3.3f, x, 0.0);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortIntArray() {
+ int[] a1 = new int[3];
+ a1[0] = 33;
+ a1[1] = 11;
+ a1[2] = 22;
+ int[] a2 = ArrayTools.sort(a1);
+ int last = 0;
+ for (int x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortIntArrayIntInt() {
+ int[] a1 = new int[9];
+ int[] a2 = ArrayTools.fill(a1, 3);
+ a2[3] = 33;
+ a2[4] = 11;
+ a2[5] = 22;
+ int from = 3;
+ int to = 6;
+ int[] a3 = ArrayTools.sort(a2, from, to);
+ int last = 0;
+ for (int i = 0; i < a1.length; i++) {
+ int x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortObjectArray() {
+ String[] a1 = new String[3];
+ a1[0] = "y";
+ a1[1] = "b";
+ a1[2] = "m";
+ String[] a2 = ArrayTools.sort(a1);
+ String last = "a";
+ for (String x : a1) {
+ assertTrue(last.compareTo(x) < 0);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortObjectArrayComparator() {
+ String[] a1 = new String[3];
+ a1[0] = "y";
+ a1[1] = "b";
+ a1[2] = "m";
+ String[] a2 = ArrayTools.sort(a1, new ReverseComparator<String>());
+ String last = "z";
+ for (String x : a1) {
+ assertTrue(last.compareTo(x) > 0);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortObjectArrayIntInt() {
+ String[] a1 = new String[9];
+ String[] a2 = ArrayTools.fill(a1, "c");
+ a2[3] = "y";
+ a2[4] = "b";
+ a2[5] = "m";
+ int from = 3;
+ int to = 6;
+ String[] a3 = ArrayTools.sort(a2, from, to);
+ String last = "a";
+ for (int i = 0; i < a1.length; i++) {
+ String x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals("c", x);
+ } else {
+ assertTrue(last.compareTo(x) < 0);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortObjectArrayIntIntComparator() {
+ String[] a1 = new String[9];
+ String[] a2 = ArrayTools.fill(a1, "c");
+ a2[3] = "y";
+ a2[4] = "b";
+ a2[5] = "m";
+ int from = 3;
+ int to = 6;
+ String[] a3 = ArrayTools.sort(a2, from, to, new ReverseComparator<String>());
+ String last = "z";
+ for (int i = 0; i < a1.length; i++) {
+ String x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals("c", x);
+ } else {
+ assertTrue(last.compareTo(x) > 0);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortLongArray() {
+ long[] a1 = new long[3];
+ a1[0] = 33;
+ a1[1] = 11;
+ a1[2] = 22;
+ long[] a2 = ArrayTools.sort(a1);
+ long last = 0;
+ for (long x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortLongArrayIntInt() {
+ long[] a1 = new long[9];
+ long[] a2 = ArrayTools.fill(a1, 3);
+ a2[3] = 33;
+ a2[4] = 11;
+ a2[5] = 22;
+ int from = 3;
+ int to = 6;
+ long[] a3 = ArrayTools.sort(a2, from, to);
+ long last = 0;
+ for (int i = 0; i < a1.length; i++) {
+ long x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+ public void testSortShortArray() {
+ short[] a1 = new short[3];
+ a1[0] = (short) 33;
+ a1[1] = (short) 11;
+ a1[2] = (short) 22;
+ short[] a2 = ArrayTools.sort(a1);
+ short last = (short) 0;
+ for (short x : a1) {
+ assertTrue(last < x);
+ last = x;
+ }
+ assertSame(a1, a2);
+ }
+
+ public void testSortShortArrayIntInt() {
+ short[] a1 = new short[9];
+ short[] a2 = ArrayTools.fill(a1, (short) 3);
+ a2[3] = (short) 33;
+ a2[4] = (short) 11;
+ a2[5] = (short) 22;
+ int from = 3;
+ int to = 6;
+ short[] a3 = ArrayTools.sort(a2, from, to);
+ short last = (short) 0;
+ for (int i = 0; i < a1.length; i++) {
+ short x = a1[i];
+ if (i < from || i >= to) {
+ assertEquals(3, x);
+ } else {
+ assertTrue(last < x);
+ last = x;
+ }
+ }
+ assertSame(a1, a2);
+ assertSame(a1, a3);
+ }
+
+
+ // ********** constructor **********
+
+ public void testConstructor() {
+ boolean exCaught = false;
+ try {
+ Object at = ReflectionTools.newInstance(ArrayTools.class);
+ fail("bogus: " + at);
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof InvocationTargetException) {
+ if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
+ exCaught = true;
+ }
+ }
+ }
+ assertTrue(exCaught);
+ }
// ********** utility **********
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/AsynchronousCommandExecutorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/AsynchronousCommandExecutorTests.java
new file mode 100644
index 0000000000..7d06b5e675
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/AsynchronousCommandExecutorTests.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.Command;
+import org.eclipse.jpt.utility.internal.AsynchronousCommandExecutor;
+import org.eclipse.jpt.utility.internal.StatefulCommandExecutor;
+
+public class AsynchronousCommandExecutorTests extends TestCase {
+
+ public AsynchronousCommandExecutorTests(String name) {
+ super(name);
+ }
+
+ public void testExecution() throws Exception {
+ TestCommand command = new TestCommand();
+ StatefulCommandExecutor commandExecutor = new AsynchronousCommandExecutor();
+ commandExecutor.start();
+ commandExecutor.execute(command);
+ commandExecutor.execute(command);
+ commandExecutor.execute(command);
+ Thread.sleep(200); // wait for the command to execute
+ commandExecutor.stop();
+ assertEquals(3, command.count);
+ }
+
+ static class TestCommand implements Command {
+ int count = 0;
+ public void execute() {
+ this.count++;
+ }
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BagTests.java
new file mode 100644
index 0000000000..13c6750ccb
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BagTests.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.Bag;
+import org.eclipse.jpt.utility.internal.HashBag;
+
+@SuppressWarnings("nls")
+public class BagTests extends TestCase {
+
+ public BagTests(String name) {
+ super(name);
+ }
+
+ public void testEmptyBag_iterator() throws Exception {
+ assertFalse(Bag.Empty.instance().iterator().hasNext());
+ }
+
+ public void testEmptyBag_size() throws Exception {
+ assertEquals(0, Bag.Empty.instance().size());
+ }
+
+ public void testEmptyBag_uniqueIterator() throws Exception {
+ assertFalse(Bag.Empty.instance().uniqueIterator().hasNext());
+ }
+
+ public void testEmptyBag_uniqueCount() throws Exception {
+ assertEquals(0, Bag.Empty.instance().uniqueCount());
+ }
+
+ public void testEmptyBag_count() throws Exception {
+ assertEquals(0, Bag.Empty.instance().count("foo"));
+ }
+
+ public void testEmptyBag_entries() throws Exception {
+ assertFalse(Bag.Empty.instance().entries().hasNext());
+ }
+
+ public void testEmptyBag_remove() throws Exception {
+ assertFalse(Bag.Empty.instance().remove("foo", 3));
+ }
+
+ public void testEmptyBag_add() throws Exception {
+ boolean exCaught = false;
+ try {
+ Bag.Empty.instance().add("foo", 3);
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testEmptyBag_equals() throws Exception {
+ assertTrue(Bag.Empty.instance().equals(Bag.Empty.instance()));
+ assertFalse(Bag.Empty.instance().equals("foo"));
+
+ Bag<Object> bag = new HashBag<Object>();
+ assertTrue(Bag.Empty.instance().equals(bag));
+ bag.add("foo");
+ assertFalse(Bag.Empty.instance().equals(bag));
+ }
+
+ public void testEmptyBag_hashCode() throws Exception {
+ assertEquals(0, Bag.Empty.instance().hashCode());
+ }
+
+ public void testEmptyBag_serialization() throws Exception {
+ Bag<?> xxx = TestTools.serialize(Bag.Empty.instance());
+ assertSame(Bag.Empty.instance(), xxx);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiFilterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiFilterTests.java
new file mode 100644
index 0000000000..3663c3cc6e
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiFilterTests.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.BidiFilter;
+
+@SuppressWarnings("nls")
+public class BidiFilterTests extends TestCase {
+
+ public BidiFilterTests(String name) {
+ super(name);
+ }
+
+ public void testNullBidiFilter_accept() throws Exception {
+ assertTrue(BidiFilter.Null.instance().accept("foo"));
+ }
+
+ public void testNullBidiFilter_reverseAccept() throws Exception {
+ assertTrue(BidiFilter.Null.instance().reverseAccept("foo"));
+ }
+
+ public void testNullBidiFilter_toString() throws Exception {
+ assertNotNull(BidiFilter.Null.instance().toString());
+ }
+
+ public void testNullBidiFilter_serialization() throws Exception {
+ BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Null.instance());
+ assertSame(BidiFilter.Null.instance(), xxx);
+ }
+
+ public void testOpaqueBidiFilter_accept() throws Exception {
+ assertFalse(BidiFilter.Opaque.instance().accept("foo"));
+ }
+
+ public void testOpaqueBidiFilter_reverseAccept() throws Exception {
+ assertFalse(BidiFilter.Opaque.instance().reverseAccept("foo"));
+ }
+
+ public void testOpaqueBidiFilter_toString() throws Exception {
+ assertNotNull(BidiFilter.Opaque.instance().toString());
+ }
+
+ public void testOpaqueBidiFilter_serialization() throws Exception {
+ BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Opaque.instance());
+ assertSame(BidiFilter.Opaque.instance(), xxx);
+ }
+
+ public void testDisabledBidiFilter_accept() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiFilter.Disabled.instance().accept("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiFilter_reverseAccept() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiFilter.Disabled.instance().reverseAccept("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiFilter_toString() throws Exception {
+ assertNotNull(BidiFilter.Disabled.instance().toString());
+ }
+
+ public void testDisabledBidiFilter_serialization() throws Exception {
+ BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Disabled.instance());
+ assertSame(BidiFilter.Disabled.instance(), xxx);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiStringConverterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiStringConverterTests.java
new file mode 100644
index 0000000000..ec60348959
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiStringConverterTests.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.BidiStringConverter;
+
+@SuppressWarnings("nls")
+public class BidiStringConverterTests extends TestCase {
+
+ public BidiStringConverterTests(String name) {
+ super(name);
+ }
+
+ public void testDefaultBidiStringConverter_convertToString() throws Exception {
+ assertEquals("foo", BidiStringConverter.Default.instance().convertToString("foo"));
+ assertNull(BidiStringConverter.Default.instance().convertToString(null));
+ }
+
+ public void testDefaultBidiStringConverter_convertToObject() throws Exception {
+ assertEquals("foo", BidiStringConverter.Default.instance().convertToObject("foo"));
+ assertNull(BidiStringConverter.Default.instance().convertToString(null));
+ }
+
+ public void testDefaultBidiStringConverter_toString() throws Exception {
+ assertNotNull(BidiStringConverter.Default.instance().toString());
+ }
+
+ public void testDefaultBidiStringConverter_serialization() throws Exception {
+ BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.Default.instance());
+ assertSame(BidiStringConverter.Default.instance(), xxx);
+ }
+
+ public void testDisabledBidiStringConverter_convertToString() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiStringConverter.Disabled.instance().convertToString("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiStringConverter_convertToObject() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiStringConverter.Disabled.instance().convertToObject("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiStringConverter_toString() throws Exception {
+ assertNotNull(BidiStringConverter.Disabled.instance().toString());
+ }
+
+ public void testDisabledBidiStringConverter_serialization() throws Exception {
+ BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.Disabled.instance());
+ assertSame(BidiStringConverter.Disabled.instance(), xxx);
+ }
+
+ public void testBooleanBidiStringConverter_convertToString() throws Exception {
+ assertEquals("true", BidiStringConverter.BooleanConverter.instance().convertToString(Boolean.TRUE));
+ assertEquals("false", BidiStringConverter.BooleanConverter.instance().convertToString(Boolean.FALSE));
+ assertNull(BidiStringConverter.BooleanConverter.instance().convertToString(null));
+ }
+
+ public void testBooleanBidiStringConverter_convertToObject() throws Exception {
+ assertEquals(Boolean.TRUE, BidiStringConverter.BooleanConverter.instance().convertToObject("true"));
+ assertEquals(Boolean.TRUE, BidiStringConverter.BooleanConverter.instance().convertToObject("TRUE"));
+ assertEquals(Boolean.FALSE, BidiStringConverter.BooleanConverter.instance().convertToObject("false"));
+ assertEquals(Boolean.FALSE, BidiStringConverter.BooleanConverter.instance().convertToObject("xxxx"));
+ assertNull(BidiStringConverter.BooleanConverter.instance().convertToObject(null));
+ }
+
+ public void testBooleanBidiStringConverter_toString() throws Exception {
+ assertNotNull(BidiStringConverter.BooleanConverter.instance().toString());
+ }
+
+ public void testBooleanBidiStringConverter_serialization() throws Exception {
+ BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.BooleanConverter.instance());
+ assertSame(BidiStringConverter.BooleanConverter.instance(), xxx);
+ }
+
+ public void testIntegerBidiStringConverter_convertToString() throws Exception {
+ assertEquals("7", BidiStringConverter.IntegerConverter.instance().convertToString(Integer.valueOf(7)));
+ assertNull(BidiStringConverter.IntegerConverter.instance().convertToString(null));
+ }
+
+ public void testIntegerBidiStringConverter_convertToObject() throws Exception {
+ assertEquals(Integer.valueOf(7), BidiStringConverter.IntegerConverter.instance().convertToObject("7"));
+ assertNull(BidiStringConverter.IntegerConverter.instance().convertToObject(null));
+ }
+
+ public void testIntegerBidiStringConverter_toString() throws Exception {
+ assertNotNull(BidiStringConverter.IntegerConverter.instance().toString());
+ }
+
+ public void testIntegerBidiStringConverter_serialization() throws Exception {
+ BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.IntegerConverter.instance());
+ assertSame(BidiStringConverter.IntegerConverter.instance(), xxx);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiTransformerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiTransformerTests.java
new file mode 100644
index 0000000000..24cfea5866
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BidiTransformerTests.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.BidiTransformer;
+
+@SuppressWarnings("nls")
+public class BidiTransformerTests extends TestCase {
+
+ public BidiTransformerTests(String name) {
+ super(name);
+ }
+
+ public void testNullBidiTransformer_transform() throws Exception {
+ assertEquals("foo", BidiTransformer.Null.instance().transform("foo"));
+ assertNull(BidiTransformer.Null.instance().transform(null));
+ }
+
+ public void testNullBidiTransformer_reverseTransform() throws Exception {
+ assertEquals("foo", BidiTransformer.Null.instance().reverseTransform("foo"));
+ assertNull(BidiTransformer.Null.instance().transform(null));
+ }
+
+ public void testNullBidiTransformer_toString() throws Exception {
+ assertNotNull(BidiTransformer.Null.instance().toString());
+ }
+
+ public void testNullBidiTransformer_serialization() throws Exception {
+ BidiTransformer<?, ?> xxx = TestTools.serialize(BidiTransformer.Null.instance());
+ assertSame(BidiTransformer.Null.instance(), xxx);
+ }
+
+ public void testDisabledBidiTransformer_transform() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiTransformer.Disabled.instance().transform("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiTransformer_reverseTransform() throws Exception {
+ boolean exCaught = false;
+ try {
+ BidiTransformer.Disabled.instance().reverseTransform("foo");
+ fail();
+ } catch (UnsupportedOperationException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testDisabledBidiTransformer_toString() throws Exception {
+ assertNotNull(BidiTransformer.Disabled.instance().toString());
+ }
+
+ public void testDisabledBidiTransformer_serialization() throws Exception {
+ BidiTransformer<?, ?> xxx = TestTools.serialize(BidiTransformer.Disabled.instance());
+ assertSame(BidiTransformer.Disabled.instance(), xxx);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java
index 8f2e9b8492..f669a517ef 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2010 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,8 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.utility.tests.internal;
+import java.lang.reflect.InvocationTargetException;
+
import junit.framework.TestCase;
+
import org.eclipse.jpt.utility.internal.BitTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
public class BitToolsTests extends TestCase {
@@ -240,4 +244,19 @@ public class BitToolsTests extends TestCase {
assertEquals(0xF010, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000, 0x0F01, 0x0F01 }));
}
+ public void testConstructor() {
+ boolean exCaught = false;
+ try {
+ Object at = ReflectionTools.newInstance(BitTools.class);
+ fail("bogus: " + at); //$NON-NLS-1$
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof InvocationTargetException) {
+ if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
+ exCaught = true;
+ }
+ }
+ }
+ assertTrue(exCaught);
+ }
+
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanToolsTests.java
index a1ce2d48b8..817044602a 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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,10 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.utility.tests.internal;
-import org.eclipse.jpt.utility.internal.BooleanTools;
+import java.lang.reflect.InvocationTargetException;
import junit.framework.TestCase;
+import org.eclipse.jpt.utility.internal.BooleanTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
+
public class BooleanToolsTests extends TestCase {
private static final Boolean TRUE = Boolean.TRUE;
private static final Boolean FALSE = Boolean.FALSE;
@@ -68,4 +71,19 @@ public class BooleanToolsTests extends TestCase {
assertEquals(TRUE, BooleanTools.xnor(FALSE, FALSE));
}
+ public void testConstructor() {
+ boolean exCaught = false;
+ try {
+ Object at = ReflectionTools.newInstance(BooleanTools.class);
+ fail("bogus: " + at); //$NON-NLS-1$
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof InvocationTargetException) {
+ if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
+ exCaught = true;
+ }
+ }
+ }
+ assertTrue(exCaught);
+ }
+
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassNameTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassNameTests.java
new file mode 100644
index 0000000000..5588858142
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassNameTests.java
@@ -0,0 +1,356 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.ClassName;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
+
+@SuppressWarnings("nls")
+public class ClassNameTests extends TestCase {
+
+ public ClassNameTests(String name) {
+ super(name);
+ }
+
+ public void testIsArray() {
+ assertFalse(ClassName.isArray(int.class.getName()));
+ assertTrue(ClassName.isArray(int[].class.getName()));
+ assertTrue(ClassName.isArray(int[][].class.getName()));
+
+ assertFalse(ClassName.isArray(java.lang.String.class.getName()));
+ assertTrue(ClassName.isArray(java.lang.String[].class.getName()));
+ assertTrue(ClassName.isArray(java.lang.String[][].class.getName()));
+ }
+
+ public void testGetElementTypeName() {
+ assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector.class.getName()));
+ assertEquals(int.class.getName(), ClassName.getElementTypeName(int.class.getName()));
+ assertEquals(void.class.getName(), ClassName.getElementTypeName(void.class.getName()));
+ assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector[].class.getName()));
+ assertEquals(int.class.getName(), ClassName.getElementTypeName(int[].class.getName()));
+ assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector[][][].class.getName()));
+ assertEquals(int.class.getName(), ClassName.getElementTypeName(int[][][].class.getName()));
+ }
+
+ public void testGetArrayDepth() {
+ assertEquals(0, ClassName.getArrayDepth(java.util.Vector.class.getName()));
+ assertEquals(0, ClassName.getArrayDepth(int.class.getName()));
+ assertEquals(0, ClassName.getArrayDepth(void.class.getName()));
+ assertEquals(1, ClassName.getArrayDepth(java.util.Vector[].class.getName()));
+ assertEquals(1, ClassName.getArrayDepth(int[].class.getName()));
+ assertEquals(3, ClassName.getArrayDepth(java.util.Vector[][][].class.getName()));
+ assertEquals(3, ClassName.getArrayDepth(int[][][].class.getName()));
+ }
+
+ public void testGetComponentTypeName() {
+ assertEquals(null, ClassName.getComponentTypeName(java.lang.Object.class.getName()));
+ assertEquals(java.lang.Object.class.getName(), ClassName.getComponentTypeName(java.lang.Object[].class.getName()));
+ assertEquals(java.lang.Object[].class.getName(), ClassName.getComponentTypeName(java.lang.Object[][].class.getName()));
+
+ assertEquals(null, ClassName.getComponentTypeName(int.class.getName()));
+ assertEquals(int.class.getName(), ClassName.getComponentTypeName(int[].class.getName()));
+ assertEquals(int[].class.getName(), ClassName.getComponentTypeName(int[][].class.getName()));
+ }
+
+ public void testGetSimpleName() throws Exception {
+ assertEquals("Object", ClassName.getSimpleName(java.lang.Object.class.getName()));
+ assertEquals("Object[]", ClassName.getSimpleName(java.lang.Object[].class.getName()));
+ assertEquals("Object[][]", ClassName.getSimpleName(java.lang.Object[][].class.getName()));
+
+ assertEquals("int", ClassName.getSimpleName(int.class.getName()));
+ assertEquals("int[]", ClassName.getSimpleName(int[].class.getName()));
+ assertEquals("int[][]", ClassName.getSimpleName(int[][].class.getName()));
+
+ Object anonObject = new Object() {
+ // anonymous class
+ };
+ assertEquals("", ClassName.getSimpleName(anonObject.getClass().getName()));
+
+ class Local {
+ // anonymous class
+ }
+ Local localObject = new Local();
+ assertEquals("Local", ClassName.getSimpleName(localObject.getClass().getName()));
+ }
+
+ public void testGetPackageName() throws Exception {
+ assertEquals("java.lang", ClassName.getPackageName(java.lang.Object.class.getName()));
+ assertEquals("", ClassName.getPackageName(java.lang.Object[].class.getName()));
+ assertEquals("", ClassName.getPackageName(java.lang.Object[][].class.getName()));
+
+ assertEquals("", ClassName.getPackageName(int.class.getName()));
+ assertEquals("", ClassName.getPackageName(int[].class.getName()));
+ assertEquals("", ClassName.getPackageName(int[][].class.getName()));
+
+ assertEquals("", ClassName.getPackageName(void.class.getName()));
+
+ Object anonObject = new Object() {
+ // anonymous class
+ };
+ assertEquals(anonObject.getClass().getPackage().getName(), ClassName.getPackageName(anonObject.getClass().getName()));
+ }
+
+ public void testIsTopLevel() throws Exception {
+ assertTrue(ClassName.isTopLevel(java.util.Map.class.getName())); // top-level
+ assertFalse(ClassName.isTopLevel(java.util.Map.Entry.class.getName())); // member
+ assertFalse(ClassName.isTopLevel(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
+ assertFalse(ClassName.isTopLevel(Class.forName("java.util.Vector$1").getName())); // anonymous
+
+ Object[] array = new java.util.Map[0]; // top-level
+ assertFalse(ClassName.isTopLevel(array.getClass().getName()));
+ array = new java.util.Map.Entry[0]; // member
+ assertFalse(ClassName.isTopLevel(array.getClass().getName()));
+ Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
+ array = (Object[]) Array.newInstance(localClass, 0);
+ assertFalse(ClassName.isTopLevel(array.getClass().getName()));
+ Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
+ array = (Object[]) Array.newInstance(anonClass, 0);
+ assertFalse(ClassName.isTopLevel(array.getClass().getName()));
+ }
+
+ public void testIsMember() throws Exception {
+ assertFalse(ClassName.isMember(java.util.Map.class.getName())); // top-level
+ assertTrue(ClassName.isMember(java.util.Map.Entry.class.getName())); // member
+ assertFalse(ClassName.isMember(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
+ assertFalse(ClassName.isMember(Class.forName("java.util.Vector$1").getName())); // anonymous
+
+ Object[] array = new java.util.Map[0]; // top-level
+ assertFalse(ClassName.isMember(array.getClass().getName()));
+ array = new java.util.Map.Entry[0]; // member
+ assertFalse(ClassName.isMember(array.getClass().getName()));
+ Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
+ array = (Object[]) Array.newInstance(localClass, 0);
+ assertFalse(ClassName.isMember(array.getClass().getName()));
+ Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
+ array = (Object[]) Array.newInstance(anonClass, 0);
+ assertFalse(ClassName.isMember(array.getClass().getName()));
+
+ // test a few edge cases
+ assertTrue(ClassName.isMember("java.util.Map$a1"));
+ assertTrue(ClassName.isMember("java.util.Map$1aa$aaa")); // member inside local
+ assertTrue(ClassName.isMember("java.util.Map$1$aaa")); // member inside anonymous
+ assertTrue(ClassName.isMember("java.util.Map$a1$aaa$bbb"));
+ assertTrue(ClassName.isMember("java.util.Map$1a1$aaa")); // member inside local
+ assertFalse(ClassName.isMember("java.util.Map$1a"));
+ assertTrue(ClassName.isMember("java.util.Map$a12345$b12345"));
+ assertFalse(ClassName.isMember("java.util.Map$12345a"));
+ assertFalse(ClassName.isMember("java.util.Map$333"));
+ assertFalse(ClassName.isMember("java.util.Map3$333"));
+ }
+
+ public void testIsLocal() throws Exception {
+ class LocalClass {
+ void foo() {
+ System.getProperty("foo");
+ }
+ }
+ new LocalClass().foo();
+ assertFalse(ClassName.isLocal(java.util.Map.class.getName())); // top-level
+ assertFalse(ClassName.isLocal(java.util.Map.Entry.class.getName())); // member
+ assertTrue(ClassName.isLocal(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
+ assertFalse(ClassName.isLocal(Class.forName("java.util.Vector$1").getName())); // anonymous
+
+ Object[] array = new java.util.Map[0]; // top-level
+ assertFalse(ClassName.isLocal(array.getClass().getName()));
+ array = new java.util.Map.Entry[0]; // member
+ assertFalse(ClassName.isLocal(array.getClass().getName()));
+ Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
+ array = (Object[]) Array.newInstance(localClass, 0);
+ assertFalse(ClassName.isLocal(array.getClass().getName()));
+ Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
+ array = (Object[]) Array.newInstance(anonClass, 0);
+ assertFalse(ClassName.isLocal(array.getClass().getName()));
+
+ // test a few edge cases
+ assertFalse(ClassName.isLocal("java.util.Map$a1"));
+ assertFalse(ClassName.isLocal("java.util.Map$a1$aaa$bbb"));
+ assertFalse(ClassName.isLocal("java.util.Map$11$aaa"));
+ assertTrue(ClassName.isLocal("java.util.Map$1a"));
+ assertTrue(ClassName.isLocal("java.util.Map$2abc"));
+ assertTrue(ClassName.isLocal("java.util.Map$2abc1"));
+ assertFalse(ClassName.isLocal("java.util.Map$a12345$b12345"));
+ assertTrue(ClassName.isLocal("java.util.Map$12345$1234a"));
+ assertFalse(ClassName.isLocal("java.util.Map$333"));
+ assertFalse(ClassName.isLocal("java.util.Map3$333"));
+ }
+
+ public void testIsAnonymous() throws Exception {
+ assertFalse(ClassName.isAnonymous(java.util.Map.class.getName())); // top-level
+ assertFalse(ClassName.isAnonymous(java.util.Map.Entry.class.getName())); // member
+ assertFalse(ClassName.isAnonymous(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
+ assertTrue(ClassName.isAnonymous(Class.forName("java.util.Vector$1").getName())); // anonymous
+
+ Object[] array = new java.util.Map[0]; // top-level
+ assertFalse(ClassName.isAnonymous(array.getClass().getName()));
+ array = new java.util.Map.Entry[0]; // member
+ assertFalse(ClassName.isAnonymous(array.getClass().getName()));
+ Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
+ array = (Object[]) Array.newInstance(localClass, 0);
+ assertFalse(ClassName.isAnonymous(array.getClass().getName()));
+ Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
+ array = (Object[]) Array.newInstance(anonClass, 0);
+ assertFalse(ClassName.isAnonymous(array.getClass().getName()));
+
+ // test a few edge cases
+ assertFalse(ClassName.isAnonymous("java.util.Map$a1"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$a1$aaa$bbb"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$1a1$aaa"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$1$a"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$1a"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$a12345$b12345"));
+ assertFalse(ClassName.isAnonymous("java.util.Map$12345$a1234"));
+ assertTrue(ClassName.isAnonymous("java.util.Map$333"));
+ assertTrue(ClassName.isAnonymous("java.util.Map3$333"));
+ }
+
+ public void testIsReference() throws Exception {
+ assertFalse(ClassName.isReference(int.class.getName())); // top-level
+
+ assertTrue(ClassName.isReference(java.util.Map.class.getName())); // top-level
+ assertTrue(ClassName.isReference(java.util.Map.Entry.class.getName())); // member
+ assertTrue(ClassName.isReference(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
+ assertTrue(ClassName.isReference(Class.forName("java.util.Vector$1").getName())); // anonymous
+
+ Object[] array = new java.util.Map[0]; // top-level
+ assertTrue(ClassName.isReference(array.getClass().getName()));
+ array = new java.util.Map.Entry[0]; // member
+ assertTrue(ClassName.isReference(array.getClass().getName()));
+ Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
+ array = (Object[]) Array.newInstance(localClass, 0);
+ assertTrue(ClassName.isReference(array.getClass().getName()));
+ Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
+ array = (Object[]) Array.newInstance(anonClass, 0);
+ assertTrue(ClassName.isReference(array.getClass().getName()));
+ }
+
+ public void testIsPrimitive() {
+ assertTrue(void.class.isPrimitive());
+
+ assertTrue(ClassName.isPrimitive(void.class.getName()));
+ assertTrue(ClassName.isPrimitive(int.class.getName()));
+ assertTrue(ClassName.isPrimitive(float.class.getName()));
+ assertTrue(ClassName.isPrimitive(boolean.class.getName()));
+
+ assertFalse(ClassName.isPrimitive(java.lang.Number.class.getName()));
+ assertFalse(ClassName.isPrimitive(java.lang.String.class.getName()));
+ assertFalse(ClassName.isPrimitive(java.lang.Boolean.class.getName()));
+ assertFalse(ClassName.isPrimitive(java.lang.Integer.class.getName()));
+ }
+
+ public void testIsPrimitiveWrapper() {
+ assertFalse(ClassName.isPrimitiveWrapper(void.class.getName()));
+ assertFalse(ClassName.isPrimitiveWrapper(int.class.getName()));
+ assertFalse(ClassName.isPrimitiveWrapper(float.class.getName()));
+ assertFalse(ClassName.isPrimitiveWrapper(boolean.class.getName()));
+
+ assertFalse(ClassName.isPrimitiveWrapper(java.lang.reflect.Field.class.getName()));
+ assertFalse(ClassName.isPrimitiveWrapper(java.lang.String.class.getName()));
+ assertTrue(ClassName.isPrimitiveWrapper(java.lang.Boolean.class.getName()));
+ assertTrue(ClassName.isPrimitiveWrapper(java.lang.Integer.class.getName()));
+ }
+
+ public void testIsVariablePrimitive() {
+ assertFalse(ClassName.isVariablePrimitive(void.class.getName()));
+
+ assertTrue(ClassName.isVariablePrimitive(int.class.getName()));
+ assertTrue(ClassName.isVariablePrimitive(float.class.getName()));
+ assertTrue(ClassName.isVariablePrimitive(boolean.class.getName()));
+
+ assertFalse(ClassName.isVariablePrimitive(java.lang.Number.class.getName()));
+ assertFalse(ClassName.isVariablePrimitive(java.lang.String.class.getName()));
+ assertFalse(ClassName.isVariablePrimitive(java.lang.Boolean.class.getName()));
+ }
+
+ public void testIsVariablePrimitiveWrapper() {
+ assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Void.class.getName()));
+
+ assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Integer.class.getName()));
+ assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Float.class.getName()));
+ assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Boolean.class.getName()));
+
+ assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Number.class.getName()));
+ assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.String.class.getName()));
+ assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Object.class.getName()));
+ }
+
+ public void testGetWrapperClassName() {
+ assertEquals(java.lang.Void.class.getName(), ClassName.getWrapperClassName(void.class.getName()));
+ assertEquals(java.lang.Integer.class.getName(), ClassName.getWrapperClassName(int.class.getName()));
+ assertEquals(java.lang.Float.class.getName(), ClassName.getWrapperClassName(float.class.getName()));
+ assertEquals(java.lang.Boolean.class.getName(), ClassName.getWrapperClassName(boolean.class.getName()));
+
+ assertNull(ClassName.getWrapperClassName(java.lang.String.class.getName()));
+ }
+
+ public void testGetPrimitiveClassName() {
+ assertEquals(void.class.getName(), ClassName.getPrimitiveClassName(java.lang.Void.class.getName()));
+ assertEquals(int.class.getName(), ClassName.getPrimitiveClassName(java.lang.Integer.class.getName()));
+ assertEquals(float.class.getName(), ClassName.getPrimitiveClassName(java.lang.Float.class.getName()));
+ assertEquals(boolean.class.getName(), ClassName.getPrimitiveClassName(java.lang.Boolean.class.getName()));
+
+ assertNull(ClassName.getPrimitiveClassName(java.lang.String.class.getName()));
+ }
+
+ public void testForCode() {
+ assertEquals("byte", ClassName.forCode('B'));
+ assertEquals("char", ClassName.forCode('C'));
+ assertEquals("double", ClassName.forCode('D'));
+ assertEquals("float", ClassName.forCode('F'));
+ assertEquals("int", ClassName.forCode('I'));
+ assertEquals("long", ClassName.forCode('J'));
+ assertEquals("short", ClassName.forCode('S'));
+ assertEquals("boolean", ClassName.forCode('Z'));
+ assertEquals("void", ClassName.forCode('V'));
+
+ assertNull(ClassName.forCode('X'));
+
+ assertEquals("byte", ClassName.forCode((int) 'B'));
+ assertEquals("char", ClassName.forCode((int) 'C'));
+ assertEquals("double", ClassName.forCode((int) 'D'));
+ assertEquals("float", ClassName.forCode((int) 'F'));
+ assertEquals("int", ClassName.forCode((int) 'I'));
+ assertEquals("long", ClassName.forCode((int) 'J'));
+ assertEquals("short", ClassName.forCode((int) 'S'));
+ assertEquals("boolean", ClassName.forCode((int) 'Z'));
+ assertEquals("void", ClassName.forCode((int) 'V'));
+
+ assertNull(ClassName.forCode((int) 'X'));
+ }
+
+ public void testGetCodeForClassName() {
+ assertEquals('I', ClassName.getCodeForClassName(int.class.getName()));
+ assertEquals('I', ClassName.getCodeForClassName("int"));
+ assertEquals('B', ClassName.getCodeForClassName(byte.class.getName()));
+ assertEquals('B', ClassName.getCodeForClassName("byte"));
+
+ assertEquals((char) 0, ClassName.getCodeForClassName(java.lang.Object.class.getName()));
+ }
+
+ public void testConstructor() {
+ boolean exCaught = false;
+ try {
+ Object at = ReflectionTools.newInstance(ClassName.class);
+ fail("bogus: " + at); //$NON-NLS-1$
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof InvocationTargetException) {
+ if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
+ exCaught = true;
+ }
+ }
+ }
+ assertTrue(exCaught);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java
deleted file mode 100644
index 80e9ba38f4..0000000000
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java
+++ /dev/null
@@ -1,676 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.utility.tests.internal;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-import java.util.Map.Entry;
-import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-@SuppressWarnings("nls")
-public class ClassToolsTests extends TestCase {
-
- private static String testStaticField;
-
- public ClassToolsTests(String name) {
- super(name);
- }
-
- /**
- * Return the compiler-generated class name. The Eclipse compiler generates
- * "local" classes with names in the form "com.foo.Outer$1$Local"; while the
- * JDK compiler generates "com.foo.Outer$1Local". There might be other
- * differences.... ~bjv
- */
- public static String compilerDependentClassNameFor(String className) {
- int index = className.indexOf("$1$");
- if (index == -1) {
- return className;
- }
- try {
- Class.forName(className);
- } catch (ClassNotFoundException ex) {
- return className.substring(0, index + 2) + className.substring(index + 3);
- }
- return className;
- }
-
- private static String munge(String className) {
- return compilerDependentClassNameFor(className);
- }
-
- public void testAllFields() {
- int fieldCount = 0;
- fieldCount += java.util.Vector.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractList.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractCollection.class.getDeclaredFields().length;
- fieldCount += java.lang.Object.class.getDeclaredFields().length;
- Field[] fields = ClassTools.allFields(java.util.Vector.class);
- assertEquals(fieldCount, fields.length);
- assertTrue(CollectionTools.contains(this.names(fields), "modCount"));
- assertTrue(CollectionTools.contains(this.names(fields), "serialVersionUID"));
- assertTrue(CollectionTools.contains(this.names(fields), "capacityIncrement"));
- assertTrue(CollectionTools.contains(this.names(fields), "elementCount"));
- assertTrue(CollectionTools.contains(this.names(fields), "elementData"));
- assertTrue(fields[0].isAccessible());
- }
-
- public void testAllMethods() {
- int methodCount = 0;
- methodCount += java.util.Vector.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractList.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractCollection.class.getDeclaredMethods().length;
- methodCount += java.lang.Object.class.getDeclaredMethods().length;
- Method[] methods = ClassTools.allMethods(java.util.Vector.class);
- assertEquals(methodCount, methods.length);
- assertTrue(CollectionTools.contains(this.names(methods), "wait"));
- assertTrue(CollectionTools.contains(this.names(methods), "addElement"));
- assertTrue(methods[0].isAccessible());
- }
-
- public void testNewInstanceClass() {
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class);
- assertNotNull(v);
- assertEquals(0, v.size());
- }
-
- public void testNewInstanceClassClassObject() {
- int initialCapacity = 200;
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class, int.class, new Integer(initialCapacity));
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
- }
-
- public void testNewInstanceClassClassArrayObjectArray() {
- int initialCapacity = 200;
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = int.class;
- Object[] parms = new Object[1];
- parms[0] = new Integer(initialCapacity);
- Vector<?> v = ClassTools.newInstance(java.util.Vector.class, parmTypes, parms);
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- parms[0] = new Integer(-1);
- boolean exCaught = false;
- try {
- v = ClassTools.newInstance(java.util.Vector.class, parmTypes, parms);
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue("RuntimeException not thrown", exCaught);
-
- parmTypes[0] = java.lang.String.class;
- parms[0] = "foo";
- exCaught = false;
- try {
- v = ClassTools.attemptNewInstance(java.util.Vector.class, parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown", exCaught);
- }
-
- public void testFieldValue() {
- int initialCapacity = 200;
- Vector<?> v = new Vector<Object>(initialCapacity);
- Object[] elementData = (Object[]) ClassTools.fieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- // test inherited field
- Integer modCountInteger = (Integer) ClassTools.fieldValue(v, "modCount");
- int modCount = modCountInteger.intValue();
- assertEquals(0, modCount);
-
- boolean exCaught = false;
- Object bogusFieldValue = null;
- try {
- bogusFieldValue = ClassTools.attemptToGetFieldValue(v, "bogusField");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown: " + bogusFieldValue, exCaught);
- }
-
- public void testExecuteMethodObjectString() {
- Vector<String> v = new Vector<String>();
- int size = ((Integer) ClassTools.executeMethod(v, "size")).intValue();
- assertEquals(0, size);
-
- v.addElement("foo");
- size = ((Integer) ClassTools.executeMethod(v, "size")).intValue();
- assertEquals(1, size);
- }
-
- public void testExecuteMethodObjectStringClassObject() {
- Vector<String> v = new Vector<String>();
- boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", Object.class, "foo")).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
- Object voidResult = ClassTools.executeMethod(v, "addElement", Object.class, "bar");
- assertNull(voidResult);
- }
-
- public void testExecuteMethodObjectStringClassArrayObjectArray() {
- Vector<String> v = new Vector<String>();
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = java.lang.Object.class;
- Object[] parms = new Object[1];
- parms[0] = "foo";
- boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", parmTypes, parms)).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- Object bogusMethodReturnValue = null;
- try {
- bogusMethodReturnValue = ClassTools.attemptToExecuteMethod(v, "bogusMethod", parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusMethodReturnValue, exCaught);
- }
-
- public void testExecuteStaticMethodClassString() {
- Double randomObject = (Double) ClassTools.executeStaticMethod(java.lang.Math.class, "random");
- assertNotNull(randomObject);
- double random = randomObject.doubleValue();
- assertTrue(random >= 0);
- assertTrue(random < 1);
- }
-
- public void testExecuteStaticMethodClassStringClassObject() {
- String s = (String) ClassTools.executeStaticMethod(java.lang.String.class, "valueOf", boolean.class, Boolean.TRUE);
- assertNotNull(s);
- assertEquals("true", s);
- }
-
- public void testExecuteStaticMethodClassStringClassArrayObjectArray() {
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = boolean.class;
- Object[] parms = new Object[1];
- parms[0] = Boolean.TRUE;
- String s = (String) ClassTools.executeStaticMethod(java.lang.String.class, "valueOf", parmTypes, parms);
- assertNotNull(s);
- assertEquals("true", s);
-
- boolean exCaught = false;
- Object bogusStaticMethodReturnValue = null;
- try {
- bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "bogusStaticMethod", parmTypes, parms);
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
-
- // test non-static method
- exCaught = false;
- try {
- bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "toString");
- } catch (NoSuchMethodException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
- }
-
- public void testSetFieldValue() {
- Vector<String> v = new Vector<String>();
- Object[] newElementData = new Object[5];
- newElementData[0] = "foo";
- ClassTools.setFieldValue(v, "elementData", newElementData);
- ClassTools.setFieldValue(v, "elementCount", new Integer(1));
- // test inherited field
- ClassTools.setFieldValue(v, "modCount", new Integer(1));
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- try {
- ClassTools.attemptToSetFieldValue(v, "bogusField", "foo");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testSetStaticFieldValue() {
- ClassTools.setStaticFieldValue(this.getClass(), "testStaticField", "new value");
- assertEquals(testStaticField, "new value");
-
- boolean exCaught = false;
- try {
- ClassTools.attemptToSetStaticFieldValue(this.getClass(), "bogusStaticField", "new value");
- } catch (NoSuchFieldException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testShortName() {
- assertEquals("Vector", ClassTools.shortClassNameForObject(new java.util.Vector<Object>()));
- assertEquals("Vector", ClassTools.shortNameFor(java.util.Vector.class));
- }
-
- public void testNestedName() {
- Map<String, String> map = new HashMap<String, String>();
- map.put("foo", "bar");
- Entry<String, String> entry = map.entrySet().iterator().next();
- assertEquals("Entry", ClassTools.nestedClassNameForObject(entry));
- assertEquals("Entry", ClassTools.nestedNameFor(java.util.Map.Entry.class));
- }
-
- public void testPackageName() {
- assertEquals("java.util", ClassTools.packageNameFor(java.util.Vector.class));
- assertEquals("java.util", ClassTools.packageNameFor(java.util.Map.Entry.class));
- }
-
- public void testArrayDepthFor() {
- assertEquals(0, ClassTools.arrayDepthFor(java.util.Vector.class));
- assertEquals(0, ClassTools.arrayDepthFor(int.class));
- assertEquals(0, ClassTools.arrayDepthFor(void.class));
- assertEquals(1, ClassTools.arrayDepthFor(java.util.Vector[].class));
- assertEquals(1, ClassTools.arrayDepthFor(int[].class));
- assertEquals(3, ClassTools.arrayDepthFor(java.util.Vector[][][].class));
- assertEquals(3, ClassTools.arrayDepthFor(int[][][].class));
- }
-
- public void testArrayDepthForObject() {
- assertEquals(0, ClassTools.arrayDepthForObject(new java.util.Vector<Object>()));
- assertEquals(1, ClassTools.arrayDepthForObject(new java.util.Vector[0]));
- assertEquals(1, ClassTools.arrayDepthForObject(new int[0]));
- assertEquals(3, ClassTools.arrayDepthForObject(new java.util.Vector[0][0][0]));
- assertEquals(3, ClassTools.arrayDepthForObject(new int[0][0][0]));
- }
-
- public void testArrayDepthForClassNamed() {
- assertEquals(0, ClassTools.arrayDepthForClassNamed(java.util.Vector.class.getName()));
- assertEquals(0, ClassTools.arrayDepthForClassNamed(int.class.getName()));
- assertEquals(0, ClassTools.arrayDepthForClassNamed(void.class.getName()));
- assertEquals(1, ClassTools.arrayDepthForClassNamed(java.util.Vector[].class.getName()));
- assertEquals(1, ClassTools.arrayDepthForClassNamed(int[].class.getName()));
- assertEquals(3, ClassTools.arrayDepthForClassNamed(java.util.Vector[][][].class.getName()));
- assertEquals(3, ClassTools.arrayDepthForClassNamed(int[][][].class.getName()));
- }
-
- public void testElementTypeFor() {
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector.class));
- assertEquals(int.class, ClassTools.elementTypeFor(int.class));
- assertEquals(void.class, ClassTools.elementTypeFor(void.class));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[].class));
- assertEquals(int.class, ClassTools.elementTypeFor(int[].class));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[][][].class));
- assertEquals(int.class, ClassTools.elementTypeFor(int[][][].class));
- }
-
- public void testElementTypeForObject() {
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector<Object>()));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0]));
- assertEquals(int.class, ClassTools.elementTypeForObject(new int[0]));
- assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0][0][0]));
- assertEquals(int.class, ClassTools.elementTypeForObject(new int[0][0][0]));
- }
-
- public void testElementTypeNameFor() {
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector.class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int.class));
- assertEquals(void.class.getName(), ClassTools.elementTypeNameFor(void.class));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[].class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[].class));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[][][].class));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[][][].class));
- }
-
- public void testElementTypeNameForClassNamed() {
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector.class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int.class.getName()));
- assertEquals(void.class.getName(), ClassTools.elementTypeNameForClassNamed(void.class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[].class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[].class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[][][].class.getName()));
- assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[][][].class.getName()));
- }
-
- public void testClassCodes() {
- assertEquals("byte", ClassTools.classNameForCode('B'));
- assertEquals("char", ClassTools.classNameForCode('C'));
- assertEquals("double", ClassTools.classNameForCode('D'));
- assertEquals("float", ClassTools.classNameForCode('F'));
- assertEquals("int", ClassTools.classNameForCode('I'));
- assertEquals("long", ClassTools.classNameForCode('J'));
- assertEquals("short", ClassTools.classNameForCode('S'));
- assertEquals("boolean", ClassTools.classNameForCode('Z'));
- assertEquals("void", ClassTools.classNameForCode('V'));
-
- boolean exCaught = false;
- try {
- ClassTools.classNameForCode('X');
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
- }
-
- public void testClassNamedIsTopLevel() throws Exception {
- assertTrue(ClassTools.classNamedIsTopLevel(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsTopLevel(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsTopLevel(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsTopLevel(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
- }
-
- public void testClassNamedIsMember() throws Exception {
- assertFalse(ClassTools.classNamedIsMember(java.util.Map.class.getName())); // top-level
- assertTrue(ClassTools.classNamedIsMember(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsMember(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsMember(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsMember(array.getClass().getName()));
-
- // test a few edge cases
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1"));
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a1$aaa"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a"));
- assertTrue(ClassTools.classNamedIsMember("java.util.Map$a12345$b12345"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$12345a"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map$333"));
- assertFalse(ClassTools.classNamedIsMember("java.util.Map3$333"));
- }
-
- public void testClassNamedIsLocal() throws Exception {
- class LocalClass {
- void foo() {
- System.getProperty("foo");
- }
- }
- new LocalClass().foo();
- assertFalse(ClassTools.classNamedIsLocal(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsLocal(java.util.Map.Entry.class.getName())); // member
- assertTrue(ClassTools.classNamedIsLocal(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertFalse(ClassTools.classNamedIsLocal(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1$aaa$bbb"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$11$aaa"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1$a")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc1")); // eclipse naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1a")); // jdk naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc")); // jdk naming convention
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc1")); // jdk naming convention
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a12345$b12345"));
- assertTrue(ClassTools.classNamedIsLocal("java.util.Map$12345$a1234"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map$333"));
- assertFalse(ClassTools.classNamedIsLocal("java.util.Map3$333"));
- }
-
- public void testClassNamedIsAnonymous() throws Exception {
- assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.class.getName())); // top-level
- assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassTools.classNamedIsAnonymous(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local
- assertTrue(ClassTools.classNamedIsAnonymous(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- Class<?> localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a1$aaa"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1$a"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a12345$b12345"));
- assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$12345$a1234"));
- assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map$333"));
- assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map3$333"));
- }
-
- public void testCodeForClass() {
- assertEquals('I', ClassTools.codeForClass(int.class));
- assertEquals('B', ClassTools.codeForClass(byte.class));
- }
-
- public void testCodeForClassNamed() {
- assertEquals('I', ClassTools.codeForClassNamed(int.class.getName()));
- assertEquals('I', ClassTools.codeForClassNamed("int"));
- assertEquals('B', ClassTools.codeForClassNamed(byte.class.getName()));
- assertEquals('B', ClassTools.codeForClassNamed("byte"));
- }
-
- public void testClassIsPrimitiveWrapperClass() {
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Void.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Boolean.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Integer.class));
- assertTrue(ClassTools.classIsPrimitiveWrapperClass(java.lang.Float.class));
-
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(java.lang.String.class));
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(void.class));
- assertFalse(ClassTools.classIsPrimitiveWrapperClass(int.class));
- }
-
- public void testClassIsVariablePrimitiveWrapperClass() {
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Void.class));
-
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Boolean.class));
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Integer.class));
- assertTrue(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.Float.class));
-
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(java.lang.String.class));
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(void.class));
- assertFalse(ClassTools.classIsVariablePrimitiveWrapperClass(int.class));
- }
-
- public void testClassNamedIsPrimitive() {
- assertTrue(void.class.isPrimitive());
-
- assertTrue(ClassTools.classNamedIsPrimitive(void.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(int.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(float.class.getName()));
- assertTrue(ClassTools.classNamedIsPrimitive(boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Boolean.class.getName()));
- assertFalse(ClassTools.classNamedIsPrimitive(java.lang.Integer.class.getName()));
- }
-
- public void testClassNamedIsVariablePrimitive() {
- assertFalse(ClassTools.classNamedIsVariablePrimitive(void.class.getName()));
-
- assertTrue(ClassTools.classNamedIsVariablePrimitive(int.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitive(float.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitive(boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitive(java.lang.Boolean.class.getName()));
- }
-
- public void testWrapperClassName() {
- assertEquals(java.lang.Void.class.getName(), ClassTools.wrapperClassName(void.class.getName()));
- assertEquals(java.lang.Integer.class.getName(), ClassTools.wrapperClassName(int.class.getName()));
- assertEquals(java.lang.Float.class.getName(), ClassTools.wrapperClassName(float.class.getName()));
- assertEquals(java.lang.Boolean.class.getName(), ClassTools.wrapperClassName(boolean.class.getName()));
-
- try {
- ClassTools.wrapperClassName(java.lang.String.class.getName());
- fail("should not get here...");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- public void testWrapperClass() {
- assertEquals(java.lang.Void.class, ClassTools.wrapperClass(void.class));
- assertEquals(java.lang.Integer.class, ClassTools.wrapperClass(int.class));
- assertEquals(java.lang.Float.class, ClassTools.wrapperClass(float.class));
- assertEquals(java.lang.Boolean.class, ClassTools.wrapperClass(boolean.class));
-
- try {
- ClassTools.wrapperClass(java.lang.String.class);
- fail("should not get here...");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- public void testClassNamedIsVariablePrimitiveWrapperClass() {
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Void.class.getName()));
-
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Integer.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Float.class.getName()));
- assertTrue(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Boolean.class.getName()));
-
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Number.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.String.class.getName()));
- assertFalse(ClassTools.classNamedIsVariablePrimitiveWrapperClass(java.lang.Object.class.getName()));
- }
-
- public void testClassForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class, ClassTools.classForTypeDeclaration("int", 0));
- assertEquals(int[].class, ClassTools.classForTypeDeclaration("int", 1));
- assertEquals(int[][][].class, ClassTools.classForTypeDeclaration("int", 3));
-
- assertEquals(Object.class, ClassTools.classForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class, ClassTools.classForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class, ClassTools.classForTypeDeclaration("void", 0));
- try {
- ClassTools.classForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (ClassNotFoundException ex) {
- // expected
- }
- }
-
- public void testClassNameForTypeDeclarationString() throws Exception {
- assertEquals("int", ClassTools.classNameForTypeDeclaration("int"));
- assertEquals("[I", ClassTools.classNameForTypeDeclaration("int[]"));
- assertEquals("[[I", ClassTools.classNameForTypeDeclaration("int [ ] [ ]"));
-
- assertEquals("java.lang.Object", ClassTools.classNameForTypeDeclaration("java.lang.Object"));
- assertEquals("[Ljava.lang.Object;", ClassTools.classNameForTypeDeclaration("java.lang.Object\t[]"));
- assertEquals("[[Ljava.lang.Object;", ClassTools.classNameForTypeDeclaration("java.lang.Object\t[]\t[]"));
- }
-
- public void testArrayDepthForTypeDeclarationString() throws Exception {
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object[]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("java.lang.Object[][][]"));
-
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("int"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("int[]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("int[][][]"));
-
- assertEquals(0, ClassTools.arrayDepthForTypeDeclaration("float"));
- assertEquals(1, ClassTools.arrayDepthForTypeDeclaration("float [ ]"));
- assertEquals(3, ClassTools.arrayDepthForTypeDeclaration("float[] [] []"));
- }
-
- public void testElementTypeNameForTypeDeclarationString() throws Exception {
- assertEquals("java.lang.Object", ClassTools.elementTypeNameForTypeDeclaration("java.lang.Object"));
- assertEquals("java.lang.Object", ClassTools.elementTypeNameForTypeDeclaration("java.lang.Object[]"));
- assertEquals("java.lang.Object", ClassTools.elementTypeNameForTypeDeclaration("java.lang.Object[][][]"));
-
- assertEquals("int", ClassTools.elementTypeNameForTypeDeclaration("int"));
- assertEquals("int", ClassTools.elementTypeNameForTypeDeclaration("int[]"));
- assertEquals("int", ClassTools.elementTypeNameForTypeDeclaration("int[][][]"));
-
- assertEquals("float", ClassTools.elementTypeNameForTypeDeclaration("float"));
- assertEquals("float", ClassTools.elementTypeNameForTypeDeclaration("float [ ]"));
- assertEquals("float", ClassTools.elementTypeNameForTypeDeclaration("float[] [] []"));
- }
-
- public void testClassNameForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class.getName(), ClassTools.classNameForTypeDeclaration("int", 0));
- assertEquals(int[].class.getName(), ClassTools.classNameForTypeDeclaration("int", 1));
- assertEquals(int[][][].class.getName(), ClassTools.classNameForTypeDeclaration("int", 3));
-
- assertEquals(Object.class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class.getName(), ClassTools.classNameForTypeDeclaration("void", 0));
- try {
- ClassTools.classNameForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- private Iterator<String> names(Field[] fields) {
- return new TransformationIterator<Field, String>(CollectionTools.iterator(fields)) {
- @Override
- protected String transform(Field field) {
- return field.getName();
- }
- };
- }
-
- private Iterator<String> names(Method[] methods) {
- return new TransformationIterator<Method, String>(CollectionTools.iterator(methods)) {
- @Override
- protected String transform(Method method) {
- return method.getName();
- }
- };
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java
index 0263de0c3c..e219032fe9 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -12,6 +12,9 @@ package org.eclipse.jpt.utility.tests.internal;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -19,7 +22,9 @@ import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.Classpath;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+@SuppressWarnings("nls")
public class ClasspathTests extends TestCase {
private static final String JAVA_HOME = System.getProperty("java.home");
@@ -31,35 +36,35 @@ public class ClasspathTests extends TestCase {
String path = "";
// no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;;C:\\jdk\\jaws.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;;C:\\jdk\\jaws.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
// no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\..\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\..\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
- path = new Classpath(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk1\\jdk2\\jdk3\\..\\..\\..\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().path();
+ path = new Classpath(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk1\\jdk2\\jdk3\\..\\..\\..\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
assertEquals(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
}
@@ -83,107 +88,144 @@ public class ClasspathTests extends TestCase {
assertEquals("java/lang/String.class", fileName);
}
+ public void testConvertToArchiveEntryNameBase() {
+ String fileName = Classpath.convertToArchiveEntryNameBase(java.lang.String.class);
+ assertEquals("java/lang/String", fileName);
+ }
+
public void testConvertToClassFileName() {
char sc = File.separatorChar;
String fileName = Classpath.convertToClassFileName(java.lang.String.class);
assertEquals("java" + sc + "lang" + sc + "String.class", fileName);
}
+ public void testConvertToClassFileString() {
+ char sc = File.separatorChar;
+ File file = Classpath.convertToClassFile(java.lang.String.class.getName());
+ assertEquals("java" + sc + "lang" + sc + "String.class", file.getPath());
+ }
+
+ public void testConvertToClassFileClass() {
+ char sc = File.separatorChar;
+ File file = Classpath.convertToClassFile(java.lang.String.class);
+ assertEquals("java" + sc + "lang" + sc + "String.class", file.getPath());
+ }
+
public void testConvertToJavaFileName() {
char sc = File.separatorChar;
- String fileName = Classpath.convertToJavaFileName(java.lang.String.class.getName());
+ String fileName = Classpath.convertToJavaFileName(java.lang.String.class);
assertEquals("java" + sc + "lang" + sc + "String.java", fileName);
}
+ public void testConvertToJavaFileString() {
+ char sc = File.separatorChar;
+ File file = Classpath.convertToJavaFile(java.lang.String.class.getName());
+ assertEquals("java" + sc + "lang" + sc + "String.java", file.getPath());
+ }
+
+ public void testConvertToJavaFileClass() {
+ char sc = File.separatorChar;
+ File file = Classpath.convertToJavaFile(java.lang.String.class);
+ assertEquals("java" + sc + "lang" + sc + "String.java", file.getPath());
+ }
+
+ public void testConvertToFileNameBase() {
+ char sc = File.separatorChar;
+ String fileName = Classpath.convertToFileNameBase(java.lang.String.class);
+ assertEquals("java" + sc + "lang" + sc + "String", fileName);
+ }
+
public void testConvertToURLs() {
- URL[] entries = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).urls();
- int i = 0;
- assertEquals(this.morphURL("/C:/jdk/rt.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/jdk/i18n.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/jdk/jaws.jar"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/foo/classes"), entries[i++].getPath());
- assertEquals(this.morphURL("/C:/bar/bar.jar"), entries[i++].getPath());
- assertEquals(i, entries.length);
+ Iterator<URL> entries = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getURLs().iterator();
+ assertEquals(this.morphURL("/C:/jdk/rt.jar"), entries.next().getPath());
+ assertEquals(this.morphURL("/C:/jdk/i18n.jar"), entries.next().getPath());
+ assertEquals(this.morphURL("/C:/jdk/jaws.jar"), entries.next().getPath());
+ assertEquals(this.morphURL("/C:/foo/classes"), entries.next().getPath());
+ assertEquals(this.morphURL("/C:/bar/bar.jar"), entries.next().getPath());
+ assertFalse(entries.hasNext());
}
- public void testEntries() {
+ public void testGetEntries() {
Classpath cp = new Classpath(this.morph("C:\\jdk\\rt.jar;;.;C:\\jdk\\i18n.jar;;;C:\\jdk\\jaws.jar;;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\bar\\bar.jar;"));
- Classpath.Entry[] entries = cp.entries();
- int i = 0;
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName());
- assertEquals(this.morph("."), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(i, entries.length);
+ Iterator<Classpath.Entry> entries = cp.getEntries().iterator();
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entries.next().getFileName());
+ assertEquals(this.morph("."), entries.next().getFileName());
+ assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\foo\\classes"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
+ assertFalse(entries.hasNext());
cp = cp.compressed();
- entries = cp.entries();
- i = 0;
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName());
- assertEquals(this.morph("."), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName());
- assertEquals(i, entries.length);
- }
-
- public void testEntryForFileNamed() {
+ entries = cp.getEntries().iterator();
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entries.next().getFileName());
+ assertEquals(this.morph("."), entries.next().getFileName());
+ assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\foo\\classes"), entries.next().getFileName());
+ assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
+ assertFalse(entries.hasNext());
+ }
+
+ public void testGetEntryForFileNamed() {
Classpath.Entry entry = null;
// in the middle - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// in the middle - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;rt.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;rt.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals("rt.jar", entry.getFileName());
// at the beginning - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// at the beginning - unqualified
- entry = new Classpath(this.morph("rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
+ entry = new Classpath(this.morph("rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals("rt.jar", entry.getFileName());
// at the end - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rt.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// at the end - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;rt.jar")).entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;rt.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals("rt.jar", entry.getFileName());
// alone - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("C:\\jdk\\rt.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// alone - unqualified
- entry = new Classpath("rt.jar").entryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.fileName());
+ entry = new Classpath("rt.jar").getEntryForFileNamed("rt.jar");
+ assertEquals("rt.jar", entry.getFileName());
// trick entry at the beginning
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// trick entry in the middle
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// trick entry at the end
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).entryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName());
+ entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).getEntryForFileNamed("rt.jar");
+ assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
// missing
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).entryForFileNamed("rt.jar");
+ entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).getEntryForFileNamed("rt.jar");
assertEquals("path entry should not be found", null, entry);
}
+ public void testGetEntryForClassNamed() {
+ assertNotNull(Classpath.completeClasspath().getEntryForClassNamed(java.lang.String.class.getName()));
+ assertNull(Classpath.completeClasspath().getEntryForClassNamed("foo.bar.Baz"));
+ }
+
public void testLocationForClass() {
Class<?> javaClass = Classpath.class;
File entry = new File(Classpath.locationFor(javaClass));
@@ -206,8 +248,8 @@ public class ClasspathTests extends TestCase {
}
public void testJREClassNames() {
- assertTrue("Vector is missing from JRE class names", ArrayTools.contains(Classpath.bootClasspath().classNames(), java.util.Vector.class.getName()));
- assertTrue("File is missing from JRE class names", ArrayTools.contains(Classpath.bootClasspath().classNames(), java.io.File.class.getName()));
+ assertTrue("Vector is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().getClassNames(), java.util.Vector.class.getName()));
+ assertTrue("File is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().getClassNames(), java.io.File.class.getName()));
}
public void testJavaExtensionDirectoryNames() {
@@ -222,36 +264,32 @@ public class ClasspathTests extends TestCase {
assertTrue("standard extension dir missing: " + stdExtDir.getParent(), ArrayTools.contains(Classpath.javaExtensionDirectories(), stdExtDir));
}
- //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build)
- //TODO Test should be revised to be compatible with IBM JDK
- // public void testJavaExtensionClasspathEntries() {
- // char sep = File.separatorChar;
- // String jdk = System.getProperty("java.version");
- // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) {
- // Collection jarNames = new ArrayList();
- // Classpath.Entry[] entries = Classpath.javaExtensionClasspath().getEntries();
- // for (int i = 0; i < entries.length; i++) {
- // jarNames.add(entries[i].fileName());
- // }
- // String stdExtJarName = JAVA_HOME + sep + "lib" + sep + "ext" + sep + "dnsns.jar";
- // assertTrue("jdk 1.4.x standard extension jar missing: " + stdExtJarName, jarNames.contains(stdExtJarName));
- // } else {
- // fail("we need to update this test for the current jdk");
- // }
- // }
-
- //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build)
- //TODO Test should be revised to be compatible with IBM JDK
- // public void testJavaExtensionClassNames() {
- // String jdk = System.getProperty("java.version");
- // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) {
- // String className = "sun.net.spi.nameservice.dns.DNSNameService";
- // assertTrue("jdk 1.4.x standard extension class missing: " + className,
- // ArrayTools.contains(Classpath.javaExtensionClasspath().classNames(), className));
- // } else {
- // fail("we need to update this test for the current jdk");
- // }
- // }
+ public void testJavaExtensionClasspathEntries() {
+ char sep = File.separatorChar;
+ String jdk = System.getProperty("java.version");
+ if (jdk.startsWith("1.4") || jdk.startsWith("1.5") || jdk.startsWith("1.6")) {
+ Collection<String> jarNames = new ArrayList<String>();
+ Iterable<Classpath.Entry> entries = Classpath.javaExtensionClasspath().getEntries();
+ for (Classpath.Entry entry : entries) {
+ jarNames.add(entry.getFileName());
+ }
+ String stdExtJarName = JAVA_HOME + sep + "lib" + sep + "ext" + sep + "dnsns.jar";
+ assertTrue("jdk 1.4.x standard extension jar missing: " + stdExtJarName, jarNames.contains(stdExtJarName));
+ } else {
+ fail("we need to update this test for the current jdk");
+ }
+ }
+
+ public void testJavaExtensionClassNames() {
+ String jdk = System.getProperty("java.version");
+ if (jdk.startsWith("1.4") || jdk.startsWith("1.5") || jdk.startsWith("1.6")) {
+ String className = "sun.net.spi.nameservice.dns.DNSNameService";
+ assertTrue("jdk 1.4.x standard extension class missing: " + className,
+ CollectionTools.contains(Classpath.javaExtensionClasspath().classNames(), className));
+ } else {
+ fail("we need to update this test for the current jdk");
+ }
+ }
public void testJavaClasspathClassNames() {
String className = this.getClass().getName();
@@ -260,10 +298,70 @@ public class ClasspathTests extends TestCase {
// when the tests are executed as an ANT task, they are run under
// an ANT class loader and the "Java" classpath does not include this class
if (cl.getClass().getName().startsWith("sun.misc")) {
- assertTrue("class missing: " + className, ArrayTools.contains(Classpath.javaClasspath().classNames(), className));
+ assertTrue("class missing: " + className, CollectionTools.contains(Classpath.javaClasspath().getClassNames(), className));
+ }
+ }
+
+ public void testCompleteClasspathClassNames() {
+ String className = this.getClass().getName();
+ ClassLoader cl = this.getClass().getClassLoader();
+ // make sure we are running under the "normal" class loader;
+ // when the tests are executed as an ANT task, they are run under
+ // an ANT class loader and the "Java" classpath does not include this class
+ if (cl.getClass().getName().startsWith("sun.misc")) {
+ assertTrue("class missing: " + className, CollectionTools.contains(Classpath.completeClasspath().getClassNames(), className));
}
}
+ public void testClasspathForClass() {
+ assertNotNull(Classpath.classpathFor(java.lang.String.class));
+ }
+
+ public void testAddClassNamesTo() {
+ Collection<String> classNames = new ArrayList<String>(1000);
+ Classpath.bootClasspath().addClassNamesTo(classNames);
+ assertTrue(classNames.contains(java.util.Vector.class.getName()));
+ }
+
+ public void testToString() {
+ assertNotNull(Classpath.bootClasspath().toString());
+ }
+
+ public void testEntry_getCanonicalFile() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(entry.getCanonicalFile().getPath().endsWith(".jar"));
+ }
+
+ public void testEntry_getCanonicalFileName() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(entry.getCanonicalFileName().endsWith("rt.jar"));
+ }
+
+ public void testEntry_equals() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertFalse(entry.equals("foo"));
+ }
+
+ public void testEntry_containsClass() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(entry.contains(java.lang.String.class));
+ }
+
+ public void testEntry_containsString() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(entry.contains(java.lang.String.class.getName()));
+ }
+
+ public void testEntry_getClassNames() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(CollectionTools.contains(entry.getClassNames(), java.lang.String.class.getName()));
+ }
+
+ public void testEntry_classNames() {
+ Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
+ assertTrue(CollectionTools.contains(entry.classNames(), java.lang.String.class.getName()));
+ }
+
/**
* morph the specified path to a platform-independent path
*/
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java
index 92d0523361..52cec208fe 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.utility.tests.internal;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,6 +30,7 @@ import java.util.Vector;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.Bag;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.HashBag;
import org.eclipse.jpt.utility.internal.Range;
@@ -2213,6 +2215,21 @@ public class CollectionToolsTests extends TestCase {
assertEquals(original.get(2), result.get(2));
}
+ public void testConstructor() {
+ boolean exCaught = false;
+ try {
+ Object at = ReflectionTools.newInstance(CollectionTools.class);
+ fail("bogus: " + at); //$NON-NLS-1$
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof InvocationTargetException) {
+ if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
+ exCaught = true;
+ }
+ }
+ }
+ assertTrue(exCaught);
+ }
+
// ********** test harness **********
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandExecutorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandExecutorTests.java
index 5ad5e1b869..3b0fd9a01e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandExecutorTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandExecutorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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.
@@ -47,6 +47,11 @@ public class CommandExecutorTests extends TestCase {
}
}
+ public void testThreadLocalCommandExecutor_toString() throws Exception {
+ CommandExecutor commandExecutor = new ThreadLocalCommandExecutor();
+ assertNotNull(commandExecutor.toString());
+ }
+
public void testThreadLocalCommandExecutor() throws Exception {
ThreadLocalCommandExecutor threadLocalCommandExecutor = new ThreadLocalCommandExecutor();
TestRunnable testRunnable1 = new TestRunnable(threadLocalCommandExecutor, 1);
@@ -57,14 +62,22 @@ public class CommandExecutorTests extends TestCase {
Thread thread2 = new Thread(testRunnable2);
thread2.run();
+ TestRunnable testRunnable3 = new TestRunnable(threadLocalCommandExecutor, 3, null);
+ Thread thread3 = new Thread(testRunnable3);
+ thread3.run();
+
thread1.join();
thread2.join();
+ thread3.join();
assertEquals(1, testRunnable1.testCommand.count);
assertEquals(1, testRunnable1.testCommandExecutor.count);
assertEquals(2, testRunnable2.testCommand.count);
assertEquals(2, testRunnable2.testCommandExecutor.count);
+
+ assertEquals(3, testRunnable3.testCommand.count);
+ assertNull(testRunnable3.testCommandExecutor);
}
static class TestCommandExecutor implements CommandExecutor {
@@ -79,11 +92,15 @@ public class CommandExecutorTests extends TestCase {
final ThreadLocalCommandExecutor threadLocalCommandExecutor;
final int executionCount;
final TestCommand testCommand = new TestCommand();
- final TestCommandExecutor testCommandExecutor = new TestCommandExecutor();
+ final TestCommandExecutor testCommandExecutor;
TestRunnable(ThreadLocalCommandExecutor threadLocalCommandExecutor, int executionCount) {
+ this(threadLocalCommandExecutor, executionCount, new TestCommandExecutor());
+ }
+ TestRunnable(ThreadLocalCommandExecutor threadLocalCommandExecutor, int executionCount, TestCommandExecutor testCommandExecutor) {
super();
this.threadLocalCommandExecutor = threadLocalCommandExecutor;
this.executionCount = executionCount;
+ this.testCommandExecutor = testCommandExecutor;
}
public void run() {
this.threadLocalCommandExecutor.set(this.testCommandExecutor);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandRunnableTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandRunnableTests.java
new file mode 100644
index 0000000000..717d813f69
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CommandRunnableTests.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.Command;
+import org.eclipse.jpt.utility.internal.CommandRunnable;
+
+@SuppressWarnings("nls")
+public class CommandRunnableTests extends TestCase {
+ boolean commandExecuted = false;
+
+ public CommandRunnableTests(String name) {
+ super(name);
+ }
+
+ public void testNullCommand() {
+ boolean exCaught = false;
+ try {
+ Runnable runnable = new CommandRunnable(null);
+ fail("bogus: " + runnable);
+ } catch (NullPointerException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public void testRun() {
+ Runnable runnable = new CommandRunnable(this.buildCommand());
+ runnable.run();
+ assertTrue(this.commandExecuted);
+ }
+
+ public void testToString() {
+ Runnable runnable = new CommandRunnable(this.buildCommand());
+ assertNotNull(runnable.toString());
+ }
+
+ private Command buildCommand() {
+ return new Command() {
+ public void execute() {
+ CommandRunnableTests.this.commandExecuted = true;
+ }
+ };
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CompositeCommandTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CompositeCommandTests.java
new file mode 100644
index 0000000000..ff81cd152c
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CompositeCommandTests.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.Command;
+import org.eclipse.jpt.utility.internal.CommandRunnable;
+import org.eclipse.jpt.utility.internal.CompositeCommand;
+
+public class CompositeCommandTests extends TestCase {
+ boolean command1Executed = false;
+ boolean command2Executed = false;
+
+ public CompositeCommandTests(String name) {
+ super(name);
+ }
+
+ public void testRun() {
+ Runnable runnable = new CommandRunnable(this.buildCompositeCommand());
+ runnable.run();
+ assertTrue(this.command1Executed);
+ assertTrue(this.command2Executed);
+ }
+
+ public void testToString() {
+ Runnable runnable = new CommandRunnable(this.buildCompositeCommand());
+ assertNotNull(runnable.toString());
+ }
+
+ private Command buildCompositeCommand() {
+ return new CompositeCommand(
+ this.buildCommand1(),
+ this.buildCommand2()
+ );
+ }
+
+ private Command buildCommand1() {
+ return new Command() {
+ public void execute() {
+ CompositeCommandTests.this.command1Executed = true;
+ }
+ };
+ }
+
+ private Command buildCommand2() {
+ return new Command() {
+ public void execute() {
+ CompositeCommandTests.this.command2Executed = true;
+ }
+ };
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java
index 7c297fadaf..cb02a0c888 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -23,11 +23,15 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
+
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.FileTools;
+import org.eclipse.jpt.utility.internal.Tools;
+@SuppressWarnings("nls")
public class FileToolsTests extends TestCase {
private File tempDir;
@@ -210,23 +214,11 @@ public class FileToolsTests extends TestCase {
assertEquals(file2, file3);
}
- private boolean isExecutingOnWindows() {
- return this.isExecutingOn("Windows");
- }
-
- // private boolean isExecutingOnLinux() {
- // return this.isExecutingOn("Linux");
- // }
- //
- private boolean isExecutingOn(String osName) {
- return System.getProperty("os.name").indexOf(osName) != -1;
- }
-
public void testPathFiles() {
File[] expected;
File[] actual;
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
expected = new File[] { new File("C:/"), new File("C:/foo"), new File("C:/foo/bar"), new File("C:/foo/bar/baz.txt") };
actual = this.pathFiles(new File("C:/foo/bar/baz.txt"));
assertTrue(Arrays.equals(expected, actual));
@@ -250,7 +242,7 @@ public class FileToolsTests extends TestCase {
}
private File[] pathFiles(File file) {
- return (File[]) ClassTools.executeStaticMethod(FileTools.class, "pathFiles", File.class, file);
+ return (File[]) ReflectionTools.executeStaticMethod(FileTools.class, "pathFiles", File.class, file);
}
public void testRelativeParentFile() {
@@ -274,16 +266,16 @@ public class FileToolsTests extends TestCase {
}
private File relativeParentFile(int len) {
- return (File) ClassTools.executeStaticMethod(FileTools.class, "relativeParentFile", int.class, new Integer(len));
+ return (File) ReflectionTools.executeStaticMethod(FileTools.class, "relativeParentFile", int.class, new Integer(len));
}
public void testConvertToRelativeFile() {
- String prefix = this.isExecutingOnWindows() ? "C:" : "";
+ String prefix = Tools.osIsWindows() ? "C:" : "";
File file;
File dir;
File relativeFile;
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
// on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
this.verifyUnchangedRelativeFile("/dir1/dir2/file.txt", "C:/dir1/dir2");
// different drives
@@ -347,12 +339,12 @@ public class FileToolsTests extends TestCase {
}
public void testConvertToAbsoluteFile() {
- String prefix = this.isExecutingOnWindows() ? "C:" : "";
+ String prefix = Tools.osIsWindows() ? "C:" : "";
File file;
File dir;
File absoluteFile;
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
// on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
this.verifyUnchangedAbsoluteFile("C:/dir1/dir2/file.txt", "C:/dir1/dir2");
// different drives
@@ -421,7 +413,7 @@ public class FileToolsTests extends TestCase {
}
public void testFileNameIsReserved() {
- boolean expected = this.isExecutingOnWindows();
+ boolean expected = Tools.osIsWindows();
assertEquals(expected, FileTools.fileNameIsReserved("CON"));
assertEquals(expected, FileTools.fileNameIsReserved("con"));
assertEquals(expected, FileTools.fileNameIsReserved("cON"));
@@ -433,7 +425,7 @@ public class FileToolsTests extends TestCase {
}
public void testFileHasAnyReservedComponents() {
- boolean expected = this.isExecutingOnWindows();
+ boolean expected = Tools.osIsWindows();
assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("C:/CON")));
assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("/con/foo")));
assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("c:/temp/cON")));
@@ -445,7 +437,7 @@ public class FileToolsTests extends TestCase {
}
public void testShortenFileNameFile() {
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
this.verifyShortenFileNameFileWin();
} else {
this.verifyShortenFileNameFileNonWin();
@@ -477,7 +469,7 @@ public class FileToolsTests extends TestCase {
}
public void testShortenFileNameFileInt() {
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
this.verifyShortenFileNameFileIntWin();
} else {
this.verifyShortenFileNameFileIntNonWin();
@@ -509,7 +501,7 @@ public class FileToolsTests extends TestCase {
}
public void testShortenFileNameURL() throws Exception {
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
this.verifyShortenFileNameURLWin();
} else {
this.verifyShortenFileNameURLNonWin();
@@ -531,7 +523,7 @@ public class FileToolsTests extends TestCase {
}
public void testShortenFileNameURLInt() throws Exception {
- if (this.isExecutingOnWindows()) {
+ if (Tools.osIsWindows()) {
this.verifyShortenFileNameURLIntWin();
} else {
this.verifyShortenFileNameURLIntNonWin();
@@ -561,7 +553,7 @@ public class FileToolsTests extends TestCase {
private File buildTempDir() throws IOException {
// build a new directory for each test, to prevent any cross-test effects
- File dir = FileTools.newTemporaryDirectory(ClassTools.shortClassNameForObject(this) + "." + this.getName());
+ File dir = FileTools.newTemporaryDirectory(this.getClass().getSimpleName() + "." + this.getName());
File file0a = new File(dir, "file0a");
file0a.createNewFile();
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java
index 645f55b9ca..3b20add7f4 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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,6 +20,7 @@ import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.Bag;
import org.eclipse.jpt.utility.internal.HashBag;
+import org.eclipse.jpt.utility.internal.Tools;
@SuppressWarnings("nls")
public class HashBagTests extends TestCase {
@@ -378,27 +379,34 @@ public class HashBagTests extends TestCase {
assertTrue(exCaught);
}
-//TODO - poor load factor is seen in the Eclipse build environment for some reason
-// public void testHashingDistribution() throws Exception {
-// Bag<String> bigBag = new HashBag<String>();
-// for (int i = 0; i < 10000; i++) {
-// bigBag.add("object" + i);
-// }
-//
-// java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
-// field.setAccessible(true);
-// Object[] table = (Object[]) field.get(bigBag);
-// int bucketCount = table.length;
-// int filledBucketCount = 0;
-// for (Object o : table) {
-// if (o != null) {
-// filledBucketCount++;
-// }
-// }
-// float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor > 0.20);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor < 0.75);
-// }
+ public void testHashingDistribution() throws Exception {
+ Bag<String> bigBag = new HashBag<String>();
+ for (int i = 0; i < 10000; i++) {
+ bigBag.add("object" + i);
+ }
+
+ java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
+ field.setAccessible(true);
+ Object[] table = (Object[]) field.get(bigBag);
+ int bucketCount = table.length;
+ int filledBucketCount = 0;
+ for (Object o : table) {
+ if (o != null) {
+ filledBucketCount++;
+ }
+ }
+ float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
+ if ((loadFactor < 0.20) || (loadFactor > 0.80)) {
+ String msg = "poor load factor: " + loadFactor;
+ if (Tools.jvmIsSun()) {
+ fail(msg);
+ } else {
+ // poor load factor is seen in the Eclipse build environment for some reason...
+ System.out.println(this.getClass().getName() + '.' + this.getName() + " - " + msg);
+ TestTools.printSystemProperties();
+ }
+ }
+ }
public void testRemove() {
assertTrue(this.bag.remove("one"));
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java
index a411df4798..7d69a5890b 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IdentityHashBagTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,6 +20,7 @@ import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.IdentityHashBag;
+import org.eclipse.jpt.utility.internal.Tools;
@SuppressWarnings("nls")
public class IdentityHashBagTests extends TestCase {
@@ -390,29 +391,34 @@ public class IdentityHashBagTests extends TestCase {
assertTrue(exCaught);
}
- // Commenting out this test as it is also failing in the Eclipse build
- // apparenly there are some hashing issues that need to be looked into.
-// public void testHashingDistribution() throws Exception {
-// IdentityHashBag<String> bigBag = new IdentityHashBag<String>();
-// for (int i = 0; i < 10000; i++) {
-// bigBag.add("object" + i);
-// }
-//
-// java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
-// field.setAccessible(true);
-// Object[] table = (Object[]) field.get(bigBag);
-// int bucketCount = table.length;
-// int filledBucketCount = 0;
-// for (int i = 0; i < bucketCount; i++) {
-// if (table[i] != null) {
-// filledBucketCount++;
-// }
-// }
-// float loadFactor = ((float) filledBucketCount)/((float) bucketCount);
-// // System.out.println("load factor: " + loadFactor + " (" + filledBucketCount + "/" + bucketCount + ")");
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor > 0.20);
-// assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor < 0.75);
-// }
+ public void testHashingDistribution() throws Exception {
+ IdentityHashBag<String> bigBag = new IdentityHashBag<String>();
+ for (int i = 0; i < 10000; i++) {
+ bigBag.add("object" + i);
+ }
+
+ java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
+ field.setAccessible(true);
+ Object[] table = (Object[]) field.get(bigBag);
+ int bucketCount = table.length;
+ int filledBucketCount = 0;
+ for (int i = 0; i < bucketCount; i++) {
+ if (table[i] != null) {
+ filledBucketCount++;
+ }
+ }
+ float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
+ if ((loadFactor < 0.20) || (loadFactor > 0.80)) {
+ String msg = "poor load factor: " + loadFactor;
+ if (Tools.jvmIsSun()) {
+ fail(msg);
+ } else {
+ // poor load factor is seen in the Eclipse build environment for some reason...
+ System.out.println(this.getClass().getName() + '.' + this.getName() + " - " + msg);
+ TestTools.printSystemProperties();
+ }
+ }
+ }
public void testRemove() {
assertTrue(this.bag.remove(this.one));
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java
index 07dad198b5..117aba69c4 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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,6 +13,7 @@ import java.sql.Types;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.JDBCType;
+@SuppressWarnings("nls")
public class JDBCTypeTests extends TestCase {
public JDBCTypeTests(String name) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java
index 91a8822499..d602e5f397 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -35,14 +35,21 @@ public class JptUtilityTests {
suite.addTest(JptUtilitySynchronizersTests.suite());
suite.addTestSuite(ArrayToolsTests.class);
+ suite.addTestSuite(AsynchronousCommandExecutorTests.class);
+ suite.addTestSuite(BagTests.class);
+ suite.addTestSuite(BidiFilterTests.class);
+ suite.addTestSuite(BidiStringConverterTests.class);
+ suite.addTestSuite(BidiTransformerTests.class);
suite.addTestSuite(BitToolsTests.class);
suite.addTestSuite(BooleanReferenceTests.class);
suite.addTestSuite(BooleanToolsTests.class);
suite.addTestSuite(ClasspathTests.class);
- suite.addTestSuite(ClassToolsTests.class);
+ suite.addTestSuite(ClassNameTests.class);
suite.addTestSuite(CollectionToolsTests.class);
suite.addTestSuite(CommandExecutorTests.class);
+ suite.addTestSuite(CommandRunnableTests.class);
suite.addTestSuite(CommandTests.class);
+ suite.addTestSuite(CompositeCommandTests.class);
suite.addTestSuite(ExceptionHandlerTests.class);
suite.addTestSuite(FileToolsTests.class);
suite.addTestSuite(FilterTests.class);
@@ -58,6 +65,7 @@ public class JptUtilityTests {
suite.addTestSuite(NotNullFilterTests.class);
suite.addTestSuite(ObjectReferenceTests.class);
suite.addTestSuite(RangeTests.class);
+ suite.addTestSuite(ReflectionToolsTests.class);
suite.addTestSuite(ReverseComparatorTests.class);
suite.addTestSuite(SimpleAssociationTests.class);
suite.addTestSuite(SimpleQueueTests.class);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
index 33ea3129b4..98cbfe6609 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
@@ -1,3 +1,12 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
package org.eclipse.jpt.utility.tests.internal;
import java.io.Serializable;
@@ -7,6 +16,7 @@ import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.ListenerList;
+import org.eclipse.jpt.utility.internal.Tools;
@SuppressWarnings("nls")
public class ListenerListTests extends TestCase {
@@ -138,26 +148,32 @@ public class ListenerListTests extends TestCase {
assertFalse(CollectionTools.contains(listenerList.getListeners(), listener2));
}
-//TODO - This test doesn't pass in the Eclipse build environment (Linux) for some reason
-// public void testSerialization() throws Exception {
-// ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-// Listener listener1 = new LocalListener();
-// Listener listener2 = new LocalListener();
-// listenerList.add(listener1);
-// listenerList.add(listener2);
-//
-// ListenerList<Listener> listenerList2 = TestTools.serialize(listenerList);
-// assertNotSame(listenerList, listenerList2);
-// assertEquals(2, listenerList2.size());
-//
-// Listener listener3 = new NonSerializableListener();
-// listenerList.add(listener3);
-//
-// listenerList2 = TestTools.serialize(listenerList);
-// assertNotSame(listenerList, listenerList2);
-// assertEquals(2, listenerList2.size());
-//
-// }
+ public void testSerialization() throws Exception {
+ // This test doesn't pass in the Eclipse build environment (Linux/IBM VM) for some reason
+ if (Tools.jvmIsSun()) {
+ this.verifySerialization();
+ }
+ }
+
+ private void verifySerialization() throws Exception {
+ ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
+ Listener listener1 = new LocalListener();
+ Listener listener2 = new LocalListener();
+ listenerList.add(listener1);
+ listenerList.add(listener2);
+
+ ListenerList<Listener> listenerList2 = TestTools.serialize(listenerList);
+ assertNotSame(listenerList, listenerList2);
+ assertEquals(2, listenerList2.size());
+
+ Listener listener3 = new NonSerializableListener();
+ listenerList.add(listener3);
+
+ listenerList2 = TestTools.serialize(listenerList);
+ assertNotSame(listenerList, listenerList2);
+ assertEquals(2, listenerList2.size());
+
+ }
interface Listener extends EventListener {
void somethingHappened();
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReflectionToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReflectionToolsTests.java
new file mode 100644
index 0000000000..afdfc679fd
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReflectionToolsTests.java
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.utility.tests.internal;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jpt.utility.internal.ReflectionTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
+
+@SuppressWarnings("nls")
+public class ReflectionToolsTests extends TestCase {
+
+ private static String testStaticField;
+
+ public ReflectionToolsTests(String name) {
+ super(name);
+ }
+
+// this is no longer true - it appears the JLS now defines the generated names...
+// /**
+// * Return the compiler-generated class name. The Eclipse compiler generates
+// * "local" classes with names in the form "com.foo.Outer$1$Local"; while the
+// * JDK compiler generates "com.foo.Outer$1Local". There might be other
+// * differences.... ~bjv
+// */
+// public static String compilerDependentClassNameFor(String className) {
+// int index = className.indexOf("$1$");
+// if (index == -1) {
+// return className;
+// }
+// try {
+// Class.forName(className);
+// } catch (ClassNotFoundException ex) {
+// return className.substring(0, index + 2) + className.substring(index + 3);
+// }
+// return className;
+// }
+//
+// private static String munge(String className) {
+// return compilerDependentClassNameFor(className);
+// }
+
+ public void testAllFields() {
+ int fieldCount = 0;
+ fieldCount += java.util.Vector.class.getDeclaredFields().length;
+ fieldCount += java.util.AbstractList.class.getDeclaredFields().length;
+ fieldCount += java.util.AbstractCollection.class.getDeclaredFields().length;
+ fieldCount += java.lang.Object.class.getDeclaredFields().length;
+ Iterable<Field> fields = ReflectionTools.getAllFields(java.util.Vector.class);
+ assertEquals(fieldCount, CollectionTools.size(fields));
+ assertTrue(CollectionTools.contains(this.fieldNames(fields), "modCount"));
+ assertTrue(CollectionTools.contains(this.fieldNames(fields), "serialVersionUID"));
+ assertTrue(CollectionTools.contains(this.fieldNames(fields), "capacityIncrement"));
+ assertTrue(CollectionTools.contains(this.fieldNames(fields), "elementCount"));
+ assertTrue(CollectionTools.contains(this.fieldNames(fields), "elementData"));
+ assertTrue(fields.iterator().next().isAccessible());
+ }
+
+ public void testAllMethods() {
+ int methodCount = 0;
+ methodCount += java.util.Vector.class.getDeclaredMethods().length;
+ methodCount += java.util.AbstractList.class.getDeclaredMethods().length;
+ methodCount += java.util.AbstractCollection.class.getDeclaredMethods().length;
+ methodCount += java.lang.Object.class.getDeclaredMethods().length;
+ Iterable<Method> methods = ReflectionTools.getAllMethods(java.util.Vector.class);
+ assertEquals(methodCount, CollectionTools.size(methods));
+ assertTrue(CollectionTools.contains(this.methodNames(methods), "wait"));
+ assertTrue(CollectionTools.contains(this.methodNames(methods), "addElement"));
+ assertTrue(methods.iterator().next().isAccessible());
+ }
+
+ public void testNewInstanceClass() {
+ Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class);
+ assertNotNull(v);
+ assertEquals(0, v.size());
+ }
+
+ public void testNewInstanceClassClassObject() {
+ int initialCapacity = 200;
+ Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class, int.class, new Integer(initialCapacity));
+ assertNotNull(v);
+ assertEquals(0, v.size());
+ Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
+ assertEquals(initialCapacity, elementData.length);
+ }
+
+ public void testNewInstanceClassClassArrayObjectArray() {
+ int initialCapacity = 200;
+ Class<?>[] parmTypes = new Class[1];
+ parmTypes[0] = int.class;
+ Object[] parms = new Object[1];
+ parms[0] = new Integer(initialCapacity);
+ Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
+ assertNotNull(v);
+ assertEquals(0, v.size());
+ Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
+ assertEquals(initialCapacity, elementData.length);
+
+ parms[0] = new Integer(-1);
+ boolean exCaught = false;
+ try {
+ v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
+ } catch (RuntimeException ex) {
+ exCaught = true;
+ }
+ assertTrue("RuntimeException not thrown", exCaught);
+
+ parmTypes[0] = java.lang.String.class;
+ parms[0] = "foo";
+ exCaught = false;
+ try {
+ v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchMethodException not thrown", exCaught);
+ }
+
+ public void testFieldValue() {
+ int initialCapacity = 200;
+ Vector<?> v = new Vector<Object>(initialCapacity);
+ Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
+ assertEquals(initialCapacity, elementData.length);
+
+ // test inherited field
+ Integer modCountInteger = (Integer) ReflectionTools.getFieldValue(v, "modCount");
+ int modCount = modCountInteger.intValue();
+ assertEquals(0, modCount);
+
+ boolean exCaught = false;
+ Object bogusFieldValue = null;
+ try {
+ bogusFieldValue = ReflectionTools.getFieldValue(v, "bogusField");
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchFieldException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchFieldException not thrown: " + bogusFieldValue, exCaught);
+ }
+
+ public void testExecuteMethodObjectString() {
+ Vector<String> v = new Vector<String>();
+ int size = ((Integer) ReflectionTools.executeMethod(v, "size")).intValue();
+ assertEquals(0, size);
+
+ v.addElement("foo");
+ size = ((Integer) ReflectionTools.executeMethod(v, "size")).intValue();
+ assertEquals(1, size);
+ }
+
+ public void testExecuteMethodObjectStringClassObject() {
+ Vector<String> v = new Vector<String>();
+ boolean booleanResult = ((Boolean) ReflectionTools.executeMethod(v, "add", Object.class, "foo")).booleanValue();
+ assertTrue(booleanResult);
+ assertTrue(v.contains("foo"));
+ Object voidResult = ReflectionTools.executeMethod(v, "addElement", Object.class, "bar");
+ assertNull(voidResult);
+ }
+
+ public void testExecuteMethodObjectStringClassArrayObjectArray() {
+ Vector<String> v = new Vector<String>();
+ Class<?>[] parmTypes = new Class[1];
+ parmTypes[0] = java.lang.Object.class;
+ Object[] parms = new Object[1];
+ parms[0] = "foo";
+ boolean booleanResult = ((Boolean) ReflectionTools.executeMethod(v, "add", parmTypes, parms)).booleanValue();
+ assertTrue(booleanResult);
+ assertTrue(v.contains("foo"));
+
+ boolean exCaught = false;
+ Object bogusMethodReturnValue = null;
+ try {
+ bogusMethodReturnValue = ReflectionTools.executeMethod(v, "bogusMethod", parmTypes, parms);
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchMethodException not thrown: " + bogusMethodReturnValue, exCaught);
+ }
+
+ public void testExecuteStaticMethodClassString() {
+ Double randomObject = (Double) ReflectionTools.executeStaticMethod(java.lang.Math.class, "random");
+ assertNotNull(randomObject);
+ double random = randomObject.doubleValue();
+ assertTrue(random >= 0);
+ assertTrue(random < 1);
+ }
+
+ public void testExecuteStaticMethodClassStringClassObject() {
+ String s = (String) ReflectionTools.executeStaticMethod(java.lang.String.class, "valueOf", boolean.class, Boolean.TRUE);
+ assertNotNull(s);
+ assertEquals("true", s);
+ }
+
+ public void testExecuteStaticMethodClassStringClassArrayObjectArray() {
+ Class<?>[] parmTypes = new Class[1];
+ parmTypes[0] = boolean.class;
+ Object[] parms = new Object[1];
+ parms[0] = Boolean.TRUE;
+ String s = (String) ReflectionTools.executeStaticMethod(java.lang.String.class, "valueOf", parmTypes, parms);
+ assertNotNull(s);
+ assertEquals("true", s);
+
+ boolean exCaught = false;
+ Object bogusStaticMethodReturnValue = null;
+ try {
+ bogusStaticMethodReturnValue = ReflectionTools.executeStaticMethod(java.lang.String.class, "bogusStaticMethod", parmTypes, parms);
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
+
+ // test non-static method
+ exCaught = false;
+ try {
+ bogusStaticMethodReturnValue = ReflectionTools.executeStaticMethod(java.lang.String.class, "toString");
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
+ }
+
+ public void testSetFieldValue() {
+ Vector<String> v = new Vector<String>();
+ Object[] newElementData = new Object[5];
+ newElementData[0] = "foo";
+ ReflectionTools.setFieldValue(v, "elementData", newElementData);
+ ReflectionTools.setFieldValue(v, "elementCount", new Integer(1));
+ // test inherited field
+ ReflectionTools.setFieldValue(v, "modCount", new Integer(1));
+ assertTrue(v.contains("foo"));
+
+ boolean exCaught = false;
+ try {
+ ReflectionTools.setFieldValue(v, "bogusField", "foo");
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchFieldException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchFieldException not thrown", exCaught);
+ }
+
+ public void testSetStaticFieldValue() {
+ ReflectionTools.setStaticFieldValue(this.getClass(), "testStaticField", "new value");
+ assertEquals(testStaticField, "new value");
+
+ boolean exCaught = false;
+ try {
+ ReflectionTools.setStaticFieldValue(this.getClass(), "bogusStaticField", "new value");
+ } catch (RuntimeException ex) {
+ if (ex.getCause() instanceof NoSuchFieldException) {
+ exCaught = true;
+ }
+ }
+ assertTrue("NoSuchFieldException not thrown", exCaught);
+ }
+
+ public void testSimpleName() {
+ assertEquals("Vector", java.util.Vector.class.getSimpleName());
+ assertEquals("Entry", java.util.Map.Entry.class.getSimpleName());
+ assertEquals("int", int.class.getSimpleName());
+ assertEquals("int[]", int[].class.getSimpleName());
+ assertEquals("int[][]", int[][].class.getSimpleName());
+ assertEquals("void", void.class.getSimpleName());
+ }
+
+ public void testPackageName() {
+ assertEquals("java.util", java.util.Vector.class.getPackage().getName());
+ assertEquals("java.util", java.util.Map.Entry.class.getPackage().getName());
+ }
+
+ public void testArrayDepthFor() {
+ assertEquals(0, ReflectionTools.getArrayDepth(java.util.Vector.class));
+ assertEquals(0, ReflectionTools.getArrayDepth(int.class));
+ assertEquals(0, ReflectionTools.getArrayDepth(void.class));
+ assertEquals(1, ReflectionTools.getArrayDepth(java.util.Vector[].class));
+ assertEquals(1, ReflectionTools.getArrayDepth(int[].class));
+ assertEquals(3, ReflectionTools.getArrayDepth(java.util.Vector[][][].class));
+ assertEquals(3, ReflectionTools.getArrayDepth(int[][][].class));
+ }
+
+ public void testElementTypeFor() {
+ assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector.class));
+ assertEquals(int.class, ReflectionTools.getElementType(int.class));
+ assertEquals(void.class, ReflectionTools.getElementType(void.class));
+ assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector[].class));
+ assertEquals(int.class, ReflectionTools.getElementType(int[].class));
+ assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector[][][].class));
+ assertEquals(int.class, ReflectionTools.getElementType(int[][][].class));
+ }
+
+ public void testClassIsPrimitiveWrapperClass() {
+ assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Void.class));
+ assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Boolean.class));
+ assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Integer.class));
+ assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Float.class));
+
+ assertFalse(ReflectionTools.classIsPrimitiveWrapper(java.lang.String.class));
+ assertFalse(ReflectionTools.classIsPrimitiveWrapper(void.class));
+ assertFalse(ReflectionTools.classIsPrimitiveWrapper(int.class));
+ }
+
+ public void testClassIsVariablePrimitiveWrapperClass() {
+ assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Void.class));
+
+ assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Boolean.class));
+ assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Integer.class));
+ assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Float.class));
+
+ assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.String.class));
+ assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(void.class));
+ assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(int.class));
+ }
+
+ public void testWrapperClass() {
+ assertEquals(java.lang.Void.class, ReflectionTools.getWrapperClass(void.class));
+ assertEquals(java.lang.Integer.class, ReflectionTools.getWrapperClass(int.class));
+ assertEquals(java.lang.Float.class, ReflectionTools.getWrapperClass(float.class));
+ assertEquals(java.lang.Boolean.class, ReflectionTools.getWrapperClass(boolean.class));
+
+ assertNull(ReflectionTools.getWrapperClass(java.lang.String.class));
+ }
+
+ public void testClassForTypeDeclarationStringInt() throws Exception {
+ assertEquals(int.class, ReflectionTools.getClassForTypeDeclaration("int", 0));
+ assertEquals(int[].class, ReflectionTools.getClassForTypeDeclaration("int", 1));
+ assertEquals(int[][][].class, ReflectionTools.getClassForTypeDeclaration("int", 3));
+
+ assertEquals(Object.class, ReflectionTools.getClassForTypeDeclaration("java.lang.Object", 0));
+ assertEquals(Object[][][].class, ReflectionTools.getClassForTypeDeclaration("java.lang.Object", 3));
+
+ assertEquals(void.class, ReflectionTools.getClassForTypeDeclaration("void", 0));
+ try {
+ ReflectionTools.getClassForTypeDeclaration(void.class.getName(), 1);
+ fail("should not get here...");
+ } catch (RuntimeException ex) {
+ // expected
+ }
+ }
+
+ public void testCodeForClass() {
+ assertEquals('I', ReflectionTools.getCodeForClass(int.class));
+ assertEquals('B', ReflectionTools.getCodeForClass(byte.class));
+ }
+
+ public void testClassNameForTypeDeclarationString() throws Exception {
+ assertEquals("int", ReflectionTools.getClassNameForTypeDeclaration("int"));
+ assertEquals("[I", ReflectionTools.getClassNameForTypeDeclaration("int[]"));
+ assertEquals("[[I", ReflectionTools.getClassNameForTypeDeclaration("int [ ] [ ]"));
+
+ assertEquals("java.lang.Object", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object"));
+ assertEquals("[Ljava.lang.Object;", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object\t[]"));
+ assertEquals("[[Ljava.lang.Object;", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object\t[]\t[]"));
+ }
+
+ public void testArrayDepthForTypeDeclarationString() throws Exception {
+ assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object"));
+ assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object[]"));
+ assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object[][][]"));
+
+ assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("int"));
+ assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("int[]"));
+ assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("int[][][]"));
+
+ assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("float"));
+ assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("float [ ]"));
+ assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("float[] [] []"));
+ }
+
+ public void testElementTypeNameForTypeDeclarationString() throws Exception {
+ assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object"));
+ assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object[]"));
+ assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object[][][]"));
+
+ assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int"));
+ assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int[]"));
+ assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int[][][]"));
+
+ assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float"));
+ assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float [ ]"));
+ assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float[] [] []"));
+ }
+
+ public void testClassNameForTypeDeclarationStringInt() throws Exception {
+ assertEquals(int.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 0));
+ assertEquals(int[].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 1));
+ assertEquals(int[][][].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 3));
+
+ assertEquals(Object.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object", 0));
+ assertEquals(Object[][][].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object", 3));
+
+ assertEquals(void.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("void", 0));
+ try {
+ ReflectionTools.getClassNameForTypeDeclaration(void.class.getName(), 1);
+ fail("should not get here...");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ private Iterable<String> fieldNames(Iterable<Field> fields) {
+ return new TransformationIterable<Field, String>(fields) {
+ @Override
+ protected String transform(Field field) {
+ return field.getName();
+ }
+ };
+ }
+
+ private Iterable<String> methodNames(Iterable<Method> methods) {
+ return new TransformationIterable<Method, String>(methods) {
+ @Override
+ protected String transform(Method method) {
+ return method.getName();
+ }
+ };
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java
index 7ae00fdc2e..1661b0ca8f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -16,6 +16,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.ReverseComparator;
+@SuppressWarnings("nls")
public class ReverseComparatorTests extends TestCase {
private Comparator<String> naturalReverseComparator;
private Comparator<String> customComparator;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java
index 5f425f9985..36c706a330 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SimpleAssociationTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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.
@@ -54,6 +54,8 @@ public class SimpleAssociationTests extends TestCase {
}
public void testEquals() {
+ assertFalse(this.assoc.equals("foo"));
+
assertEquals(this.assoc, this.copy(this.assoc));
SimpleAssociation<String, String> assoc2 = new SimpleAssociation<String, String>("foo", "baz");
@@ -61,10 +63,21 @@ public class SimpleAssociationTests extends TestCase {
assoc2 = new SimpleAssociation<String, String>("fop", "bar");
assertFalse(this.assoc.equals(assoc2));
+
+ SimpleAssociation<String, String> assoc3 = new SimpleAssociation<String, String>(null, null);
+ SimpleAssociation<String, String> assoc4 = new SimpleAssociation<String, String>(null, null);
+ assertEquals(assoc3, assoc4);
}
public void testHashCode() {
assertEquals(this.assoc.hashCode(), this.copy(this.assoc).hashCode());
+
+ SimpleAssociation<String, String> assoc2 = new SimpleAssociation<String, String>(null, null);
+ assertEquals(assoc2.hashCode(), this.copy(assoc2).hashCode());
+ }
+
+ public void testToString() {
+ assertNotNull(this.assoc.toString());
}
public void testClone() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java
index 0078dcc58b..8319dc0c11 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -912,6 +912,13 @@ public class StringToolsTests extends TestCase {
assertEquals(expected, writer.toString());
}
+ // ********** #toString() **********
+
+ public void testBuildToStringClassName_anonymous() {
+ Object o = new Object(){/*anonymous subclass of Object*/};
+ assertEquals("Object", StringTools.buildToStringClassName(o.getClass()));
+ }
+
// ********** queries **********
public void testStringIsEmptyString() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java
index c7a4d1c052..7fc143fd90 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -21,6 +21,9 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
import junit.framework.TestCase;
import junit.framework.TestFailure;
import junit.framework.TestResult;
@@ -70,6 +73,33 @@ public final class TestTools {
}
/**
+ * Sort and print out all the current Java System properties on the
+ * console.
+ */
+ public static void printSystemProperties() {
+ synchronized (System.out) {
+ printSystemPropertiesOn(System.out);
+ }
+ }
+
+ /**
+ * Sort and print out all the current Java System properties on the
+ * specified print stream.
+ */
+ public static void printSystemPropertiesOn(PrintStream stream) {
+ SortedSet<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ for (Object key : System.getProperties().keySet()) {
+ sortedKeys.add((String) key);
+ }
+ for (String key : sortedKeys) {
+ stream.print(key);
+ stream.print(" => "); //$NON-NLS-1$
+ stream.print(System.getProperty(key));
+ stream.println();
+ }
+ }
+
+ /**
* execute the specified test and return a text output of its results
*/
public static String execute(TestCase testCase) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java
index 3b104b9b89..eda0e7f432 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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,6 +13,7 @@ import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.FileTools;
import org.eclipse.jpt.utility.internal.XMLStringEncoder;
+@SuppressWarnings("nls")
public class XMLStringEncoderTests extends TestCase {
public XMLStringEncoderTests(String name) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/FilteringIterableTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/FilteringIterableTests.java
index 7d870c0a85..713163e06f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/FilteringIterableTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/FilteringIterableTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -38,7 +38,7 @@ public class FilteringIterableTests extends TestCase {
public void testFilter() {
Filter<String> filter = this.buildFilter();
int i = 0;
- for (String s : new FilteringIterable<String, String>(this.buildNestedIterable(), filter)) {
+ for (String s : new FilteringIterable<String>(this.buildNestedIterable(), filter)) {
assertTrue(s.contains(PREFIX));
i++;
}
@@ -51,7 +51,7 @@ public class FilteringIterableTests extends TestCase {
public void testMissingFilter() {
boolean exCaught = false;
- Iterable<String> iterable = new FilteringIterable<String, String>(this.buildNestedIterable());
+ Iterable<String> iterable = new FilteringIterable<String>(this.buildNestedIterable());
try {
Iterator<String> iterator = iterable.iterator();
fail("bogus iterator: " + iterator);
@@ -66,7 +66,7 @@ public class FilteringIterableTests extends TestCase {
}
private Iterable<String> buildFilteringIterable(Iterable<String> nestedIterable) {
- return new FilteringIterable<String, String>(nestedIterable) {
+ return new FilteringIterable<String>(nestedIterable) {
@Override
protected boolean accept(String s) {
return s.startsWith(PREFIX);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/JptUtilityIterablesTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/JptUtilityIterablesTests.java
index f3f88f4627..9394bd0501 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/JptUtilityIterablesTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/JptUtilityIterablesTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -28,7 +28,7 @@ public class JptUtilityIterablesTests {
suite.addTestSuite(EmptyIterableTests.class);
suite.addTestSuite(EmptyListIterableTests.class);
suite.addTestSuite(FilteringIterableTests.class);
- suite.addTestSuite(GenericIterableWrapperTests.class);
+ suite.addTestSuite(SuperIterableWrapperTests.class);
suite.addTestSuite(GraphIterableTests.class);
suite.addTestSuite(LiveCloneIterableTests.class);
suite.addTestSuite(LiveCloneListIterableTests.class);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/GenericIterableWrapperTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/SuperIterableWrapperTests.java
index c936cf45db..f56b76bbdd 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/GenericIterableWrapperTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterables/SuperIterableWrapperTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2010 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,12 +14,12 @@ import java.util.Collections;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterables.GenericIterableWrapper;
+import org.eclipse.jpt.utility.internal.iterables.SuperIterableWrapper;
@SuppressWarnings("nls")
-public class GenericIterableWrapperTests extends TestCase {
+public class SuperIterableWrapperTests extends TestCase {
- public GenericIterableWrapperTests(String name) {
+ public SuperIterableWrapperTests(String name) {
super(name);
}
@@ -34,7 +34,7 @@ public class GenericIterableWrapperTests extends TestCase {
}
assertEquals("foobarbaz", concat);
- Iterable<Object> iterable = new GenericIterableWrapper<Object>(list);
+ Iterable<Object> iterable = new SuperIterableWrapper<Object>(list);
concat = "";
for (Object s : iterable) {
concat += s;
@@ -43,7 +43,7 @@ public class GenericIterableWrapperTests extends TestCase {
}
public void testToString() {
- Iterable<Object> iterable = new GenericIterableWrapper<Object>(Collections.emptyList());
+ Iterable<Object> iterable = new SuperIterableWrapper<Object>(Collections.emptyList());
assertNotNull(iterable.toString());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java
index 6e7940a584..8e1fe4ce6a 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -12,11 +12,11 @@ package org.eclipse.jpt.utility.tests.internal.iterators;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
import java.util.NoSuchElementException;
+
import junit.framework.TestCase;
+
import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.SimpleFilter;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
@@ -123,39 +123,6 @@ public class FilteringIteratorTests extends TestCase {
}
}
- // test a filtered iterator with a nested iterator of a sub-type (Number vs. Integer)
- public void testGenerics1() {
- List<Integer> integers = new ArrayList<Integer>();
- integers.add(new Integer(0));
- integers.add(new Integer(1));
- integers.add(new Integer(2));
- integers.add(new Integer(3));
- Iterator<Number> stream = new FilteringIterator<Integer, Number>(integers.iterator()) {
- @Override
- protected boolean accept(Integer o) {
- return o.intValue() > 1;
- }
- };
- assertEquals(2, CollectionTools.size(stream));
- }
-
- // test a filtered iterator with a nested iterator of a super-type (Integer vs. Number)
- // i.e. trust that Filter will only return the appropriate sub-type objects
- public void testGenerics2() {
- List<Number> numbers = new ArrayList<Number>();
- numbers.add(new Integer(0));
- numbers.add(new Long(1));
- numbers.add(new Integer(2));
- numbers.add(new Float(3));
- Iterator<Integer> stream = new FilteringIterator<Number, Integer>(numbers.iterator()) {
- @Override
- protected boolean accept(Number o) {
- return o instanceof Integer;
- }
- };
- assertEquals(2, CollectionTools.size(stream));
- }
-
public void testFilterHasNext() {
int i = 0;
for (Iterator<String> stream = this.buildFilterIterator(); stream.hasNext();) {
@@ -172,11 +139,11 @@ public class FilteringIteratorTests extends TestCase {
}
private Iterator<String> buildFilteredIterator(Iterator<String> nestedIterator, Filter<String> filter) {
- return new FilteringIterator<String, String>(nestedIterator, filter);
+ return new FilteringIterator<String>(nestedIterator, filter);
}
private Iterator<String> buildInnerFilteredIterator(Iterator<String> nestedIterator) {
- return new FilteringIterator<String, String>(nestedIterator) {
+ return new FilteringIterator<String>(nestedIterator) {
@Override
protected boolean accept(String s) {
return s.startsWith(PREFIX);
@@ -190,7 +157,7 @@ public class FilteringIteratorTests extends TestCase {
// this inner iterator will call the "outer" object
private Iterator<String> buildInnerFilteredIterator2(Iterator<String> nestedIterator) {
- return new FilteringIterator<String, String>(nestedIterator) {
+ return new FilteringIterator<String>(nestedIterator) {
@Override
protected boolean accept(String s) {
return s.startsWith(FilteringIteratorTests.this.getPrefix());
@@ -287,7 +254,7 @@ public class FilteringIteratorTests extends TestCase {
boolean exCaught = false;
try {
// missing method override
- Iterator<String> iterator = new FilteringIterator<String, String>(this.buildNestedIterator());
+ Iterator<String> iterator = new FilteringIterator<String>(this.buildNestedIterator());
String s = iterator.next();
fail("invalid string: " + s);
} catch (UnsupportedOperationException ex) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
index ef3d0d0982..0cd247c942 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 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.
@@ -31,7 +31,7 @@ public class JptUtilityIteratorsTests {
suite.addTestSuite(EmptyListIteratorTests.class);
suite.addTestSuite(EnumerationIteratorTests.class);
suite.addTestSuite(FilteringIteratorTests.class);
- suite.addTestSuite(GenericIteratorWrapperTests.class);
+ suite.addTestSuite(SuperIteratorWrapperTests.class);
suite.addTestSuite(GraphIteratorTests.class);
suite.addTestSuite(PeekableIteratorTests.class);
suite.addTestSuite(ReadOnlyCompositeListIteratorTests.class);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GenericIteratorWrapperTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SuperIteratorWrapperTests.java
index daafb9ffd4..23c5126148 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GenericIteratorWrapperTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SuperIteratorWrapperTests.java
@@ -14,12 +14,12 @@ import java.util.Iterator;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.iterators.GenericIteratorWrapper;
+import org.eclipse.jpt.utility.internal.iterators.SuperIteratorWrapper;
@SuppressWarnings("nls")
-public class GenericIteratorWrapperTests extends TestCase {
+public class SuperIteratorWrapperTests extends TestCase {
- public GenericIteratorWrapperTests(String name) {
+ public SuperIteratorWrapperTests(String name) {
super(name);
}
@@ -34,7 +34,7 @@ public class GenericIteratorWrapperTests extends TestCase {
}
assertEquals("foobarbaz", concat);
- Iterator<Object> iterator = new GenericIteratorWrapper<Object>(list);
+ Iterator<Object> iterator = new SuperIteratorWrapper<Object>(list);
concat = "";
while (iterator.hasNext()) {
Object next = iterator.next();
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java
index 73a51e224a..b7f430b7e8 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,16 +9,25 @@
******************************************************************************/
package org.eclipse.jpt.utility.tests.internal.model;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.EventListener;
import java.util.HashSet;
import java.util.List;
import junit.framework.TestCase;
+import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.ListenerList;
+import org.eclipse.jpt.utility.internal.Tools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.ChangeSupport;
import org.eclipse.jpt.utility.model.event.CollectionAddEvent;
@@ -44,8 +53,10 @@ import org.eclipse.jpt.utility.model.listener.ChangeAdapter;
import org.eclipse.jpt.utility.model.listener.ChangeListener;
import org.eclipse.jpt.utility.model.listener.CollectionChangeAdapter;
import org.eclipse.jpt.utility.model.listener.ListChangeAdapter;
+import org.eclipse.jpt.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.utility.model.listener.PropertyChangeAdapter;
import org.eclipse.jpt.utility.model.listener.StateChangeAdapter;
+import org.eclipse.jpt.utility.model.listener.StateChangeListener;
import org.eclipse.jpt.utility.model.listener.TreeChangeAdapter;
import org.eclipse.jpt.utility.tests.internal.TestTools;
@@ -4179,82 +4190,105 @@ public class ChangeSupportTests
// ********** serialization test **********
- //TODO - This test doesn't pass in the Eclipse build environment (Linux) for some reason
-// public void testSerialization() throws java.io.IOException, ClassNotFoundException {
-// LocalModel model1 = new LocalModel();
-// Foo foo1 = new Foo();
-// Bar bar1 = new Bar();
-// Joo joo1 = new Joo();
-// Jar jar1 = new Jar();
-// model1.addStateChangeListener(foo1);
-// model1.addStateChangeListener(bar1);
-// model1.addListChangeListener(joo1);
-// model1.addListChangeListener(jar1);
-//
-// ChangeListener[] listeners1 = this.getListeners(model1, StateChangeListener.class);
-// assertEquals(2, listeners1.length);
-// // the order of these could change...
-// assertEquals(Foo.class, listeners1[0].getClass());
-// assertEquals(Bar.class, listeners1[1].getClass());
-//
-// listeners1 = this.getListeners(model1, ListChangeListener.class);
-// assertEquals(2, listeners1.length);
-// // the order of these could change...
-// assertEquals(Joo.class, listeners1[0].getClass());
-// assertEquals(Jar.class, listeners1[1].getClass());
-//
-// LocalModel model2 = TestTools.serialize(model1);
-//
-// ChangeListener[] listeners2 = this.getListeners(model2, StateChangeListener.class);
-// assertEquals(1, listeners2.length);
-// assertEquals(Foo.class, listeners2[0].getClass());
-//
-// listeners2 = this.getListeners(model2, ListChangeListener.class);
-// assertEquals(1, listeners2.length);
-// assertEquals(Joo.class, listeners2[0].getClass());
-// }
-//
-// private ChangeListener[] getListeners(LocalModel model, Class<? extends ChangeListener> listenerClass) {
-// ChangeSupport changeSupport = (ChangeSupport) ClassTools.fieldValue(model, "changeSupport");
-// return (ChangeListener[]) ClassTools.executeMethod(changeSupport, "getListeners", Class.class, listenerClass);
-// }
-//
-// private static class LocalModel extends AbstractModel {
-// LocalModel() {
-// super();
-// }
-// }
-//
-// private static class Foo implements Serializable, StateChangeListener {
-// Foo() {
-// super();
-// }
-// public void stateChanged(StateChangeEvent event) {
-// // do nothing
-// }
-// }
-//
-// private static class Bar implements StateChangeListener {
-// Bar() {
-// super();
-// }
-// public void stateChanged(StateChangeEvent event) {
-// // do nothing
-// }
-// }
-//
-// private static class Joo extends ListChangeAdapter implements Serializable {
-//// private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("changeSupport", ChangeSupport.class)};
-// Joo() {
-// super();
-// }
-// }
-//
-// private static class Jar extends ListChangeAdapter {
-// Jar() {
-// super();
-// }
-// }
+ public void testSerialization() throws java.io.IOException, ClassNotFoundException {
+ if (Tools.jvmIsSun()) {
+ // This test doesn't pass in the Eclipse build environment (Linux/IBM JVM) for some reason
+ this.verifySerialization();
+ }
+ }
+
+ private void verifySerialization() throws java.io.IOException, ClassNotFoundException {
+ LocalModel model1 = new LocalModel();
+ Foo foo1 = new Foo();
+ Bar bar1 = new Bar();
+ Joo joo1 = new Joo();
+ Jar jar1 = new Jar();
+ model1.addStateChangeListener(foo1);
+ model1.addStateChangeListener(bar1);
+ model1.addListChangeListener("foo", joo1);
+ model1.addListChangeListener("foo", jar1);
+
+ Iterable<EventListener> listeners1 = this.getListeners(model1, StateChangeListener.class, null);
+ Object[] listenersArray1 = ArrayTools.array(listeners1);
+ assertEquals(2, listenersArray1.length);
+ // the order of these could change...
+ assertEquals(Foo.class, listenersArray1[0].getClass());
+ assertEquals(Bar.class, listenersArray1[1].getClass());
+
+ listeners1 = this.getListeners(model1, ListChangeListener.class, "foo");
+ listenersArray1 = ArrayTools.array(listeners1);
+ assertEquals(2, listenersArray1.length);
+ // the order of these could change...
+ assertEquals(Joo.class, listenersArray1[0].getClass());
+ assertEquals(Jar.class, listenersArray1[1].getClass());
+
+ LocalModel model2 = TestTools.serialize(model1);
+
+ Iterable<EventListener> listeners2 = this.getListeners(model2, StateChangeListener.class, null);
+ Object[] listenersArray2 = ArrayTools.array(listeners2);
+ assertEquals(1, listenersArray2.length);
+ assertEquals(Foo.class, listenersArray2[0].getClass());
+
+ listeners2 = this.getListeners(model2, ListChangeListener.class, "foo");
+ listenersArray2 = ArrayTools.array(listeners2);
+ assertEquals(1, listenersArray2.length);
+ assertEquals(Joo.class, listenersArray2[0].getClass());
+ }
+
+ private Iterable<EventListener> getListeners(LocalModel model, Class<? extends EventListener> listenerClass, String aspectName) {
+ return this.getListenerList(model, listenerClass, aspectName).getListeners();
+ }
+
+ @SuppressWarnings("unchecked")
+ private ListenerList<EventListener> getListenerList(LocalModel model, Class<? extends EventListener> listenerClass, String aspectName) {
+ ChangeSupport changeSupport = (ChangeSupport) ReflectionTools.getFieldValue(model, "changeSupport");
+ return (ListenerList<EventListener>) ReflectionTools.executeMethod(changeSupport, "getListenerList_", new Class<?>[] {Class.class, String.class}, new Object[] {listenerClass, aspectName});
+ }
+
+ // we have to manually handle 'changeSupport' since AbstractModel is not Serializable
+ private static class LocalModel extends AbstractModel implements Serializable {
+ LocalModel() {
+ super();
+ }
+ private synchronized void writeObject(ObjectOutputStream s) throws IOException {
+ s.defaultWriteObject();
+ s.writeObject(this.changeSupport);
+ }
+ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
+ s.defaultReadObject();
+ this.changeSupport = (ChangeSupport) s.readObject();
+ }
+ }
+
+ private static class Foo implements Serializable, StateChangeListener {
+ Foo() {
+ super();
+ }
+ public void stateChanged(StateChangeEvent event) {
+ // do nothing
+ }
+ }
+
+ private static class Bar implements StateChangeListener {
+ Bar() {
+ super();
+ }
+ public void stateChanged(StateChangeEvent event) {
+ // do nothing
+ }
+ }
+
+ private static class Joo extends ListChangeAdapter implements Serializable {
+ Joo() {
+ super();
+ }
+ }
+
+ private static class Jar extends ListChangeAdapter {
+ Jar() {
+ super();
+ }
+ }
// ********** bug(?) test **********
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
index 76a759d76f..43adcd065e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -17,7 +17,7 @@ import java.util.Iterator;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
@@ -199,7 +199,7 @@ public class ReflectiveCollectionChangeListenerTests extends TestCase {
TestModel testModel = new TestModel();
String string = "foo";
Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- Method method = ClassTools.method(target, "collectionChangedDoubleArgument", new Class[] {CollectionChangeEvent.class, Object.class});
+ Method method = ReflectionTools.getMethod(target, "collectionChangedDoubleArgument", new Class[] {CollectionChangeEvent.class, Object.class});
boolean exCaught = false;
try {
CollectionChangeListener listener = ReflectiveChangeListener.buildCollectionChangeListener(target, method);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
index ad8b76b362..8a3965d1ae 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -17,7 +17,7 @@ import java.util.ListIterator;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
@@ -323,7 +323,7 @@ public class ReflectiveListChangeListenerTests extends TestCase {
TestModel testModel = new TestModel();
String string = "foo";
Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- Method method = ClassTools.method(target, "listChangedDoubleArgument", new Class[] {ListChangeEvent.class, Object.class});
+ Method method = ReflectionTools.getMethod(target, "listChangedDoubleArgument", new Class[] {ListChangeEvent.class, Object.class});
boolean exCaught = false;
try {
ListChangeListener listener = ReflectiveChangeListener.buildListChangeListener(target, method);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
index 59d6e8dbce..8ca4f3a10e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 +11,7 @@ package org.eclipse.jpt.utility.tests.internal.model.listener;
import java.lang.reflect.Method;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -40,7 +40,7 @@ public class ReflectivePropertyChangeListenerTests extends TestCase {
public void testSingleArgument2() throws Exception {
TestModel testModel = new TestModel(7);
Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
+ Method method = ReflectionTools.getMethod(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, method));
testModel.setValue(99);
assertFalse(target.zeroArgumentFlag);
@@ -62,7 +62,7 @@ public class ReflectivePropertyChangeListenerTests extends TestCase {
public void testSingleArgumentNamedProperty2() throws Exception {
TestModel testModel = new TestModel(7);
Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
+ Method method = ReflectionTools.getMethod(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, method));
testModel.setValue(99);
assertFalse(target.zeroArgumentFlag);
@@ -105,7 +105,7 @@ public class ReflectivePropertyChangeListenerTests extends TestCase {
public void testBogusDoubleArgument2() throws Exception {
TestModel testModel = new TestModel(7);
Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ClassTools.method(target, "propertyChangedDoubleArgument", new Class[] {PropertyChangeEvent.class, Object.class});
+ Method method = ReflectionTools.getMethod(target, "propertyChangedDoubleArgument", new Class[] {PropertyChangeEvent.class, Object.class});
boolean exCaught = false;
try {
PropertyChangeListener listener = ReflectiveChangeListener.buildPropertyChangeListener(target, method);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
index 4848960509..28aed8f49f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 +11,7 @@ package org.eclipse.jpt.utility.tests.internal.model.listener;
import java.lang.reflect.Method;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.model.event.StateChangeEvent;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -49,7 +49,7 @@ public class ReflectiveStateChangeListenerTests extends TestCase {
public void testSingleArgument2() throws Exception {
TestModel testModel = new TestModel();
Target target = new Target(testModel);
- Method method = ClassTools.method(target, "stateChangedSingleArgument2", new Class[] {Object.class});
+ Method method = ReflectionTools.getMethod(target, "stateChangedSingleArgument2", new Class[] {Object.class});
testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, method));
testModel.changeState();
assertFalse(target.zeroArgumentFlag);
@@ -92,7 +92,7 @@ public class ReflectiveStateChangeListenerTests extends TestCase {
public void testBogusDoubleArgument2() throws Exception {
TestModel testModel = new TestModel();
Target target = new Target(testModel);
- Method method = ClassTools.method(target, "stateChangedDoubleArgument", new Class[] {StateChangeEvent.class, Object.class});
+ Method method = ReflectionTools.getMethod(target, "stateChangedDoubleArgument", new Class[] {StateChangeEvent.class, Object.class});
boolean exCaught = false;
try {
StateChangeListener listener = ReflectiveChangeListener.buildStateChangeListener(target, method);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java
index 5c1223ae4e..3532f88f2f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeListValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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,6 +20,7 @@ import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class CompositeListValueModelTests extends TestCase {
private SimpleListValueModel<String> lvm0;
private SimpleListValueModel<String> lvm1;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
index dca32f9315..c7d0e9bcaf 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -17,6 +17,7 @@ import org.eclipse.jpt.utility.internal.model.value.StaticCollectionValueModel;
import org.eclipse.jpt.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class StaticCollectionValueModelTests extends TestCase {
private static final Collection<String> COLLECTION = buildCollection();
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java
index 0d7cbc6110..d7a7d24810 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticListValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -17,6 +17,7 @@ import org.eclipse.jpt.utility.internal.model.value.StaticListValueModel;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class StaticListValueModelTests extends TestCase {
private static final List<String> LIST = buildList();
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java
index 380cf17c58..14e3d9a014 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/StaticValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.jpt.utility.internal.model.value.StaticPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class StaticValueModelTests extends TestCase {
private PropertyValueModel<String> objectHolder;
private static final PropertyValueModel<String> OBJECT_HOLDER = new StaticPropertyValueModel<String>("foo");
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
index 49aab95fc0..c8dc777f8e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -15,7 +15,7 @@ import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencePropertyValueModel;
import org.eclipse.jpt.utility.model.Model;
@@ -373,7 +373,7 @@ public class PreferencePropertyValueModelTests extends PreferencesTestCase {
}
private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
+ PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ReflectionTools.getFieldValue(node, "prefListeners");
return prefListeners.length > 0;
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
index c57af46fb6..390429f54c 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -16,7 +16,7 @@ import java.util.prefs.NodeChangeListener;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencesCollectionValueModel;
@@ -305,7 +305,7 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
}
private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
+ PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ReflectionTools.getFieldValue(node, "prefListeners");
return prefListeners.length > 0;
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
index ce4c304a6e..88ca7b93d7 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,13 +14,14 @@ import java.util.List;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.Preferences;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.tests.internal.TestTools;
/**
* set up and tear down a test node for any subclass that
* needs to test preferences-related stuff
*/
+@SuppressWarnings("nls")
public abstract class PreferencesTestCase extends TestCase {
protected Preferences classNode;
public Preferences testNode;
@@ -34,12 +35,12 @@ public abstract class PreferencesTestCase extends TestCase {
protected void setUp() throws Exception {
super.setUp();
Preferences packageNode = Preferences.userNodeForPackage(this.getClass());
- this.classNode = packageNode.node(ClassTools.shortClassNameForObject(this));
+ this.classNode = packageNode.node(this.getClass().getSimpleName());
// clean out any leftover crap...
if ((this.classNode.keys().length > 0) || (this.classNode.childrenNames().length > 0)) {
this.classNode.removeNode();
// ...and re-create the node
- this.classNode = packageNode.node(ClassTools.shortClassNameForObject(this));
+ this.classNode = packageNode.node(this.getClass().getSimpleName());
}
this.testNode = this.classNode.node(TEST_NODE_NAME);
}
@@ -79,7 +80,7 @@ public abstract class PreferencesTestCase extends TestCase {
@SuppressWarnings("unchecked")
private List<EventObject> preferencesEventQueue() {
- return (List<EventObject>) ClassTools.staticFieldValue(AbstractPreferences.class, "eventQueue");
+ return (List<EventObject>) ReflectionTools.getStaticFieldValue(AbstractPreferences.class, "eventQueue");
}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
index 4302458d3d..f29d9118a6 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 +14,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.CheckBoxModelAdapter;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -22,6 +22,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class CheckBoxModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Boolean> booleanHolder;
private ButtonModel buttonModelAdapter;
@@ -111,12 +112,12 @@ public class CheckBoxModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
assertEquals(0, listenerList.getListenerList().length);
}
private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
assertFalse(listenerList.getListenerList().length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
index c3bc373dc7..7dcf11311e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -36,6 +36,7 @@ import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
/**
* Play around with a set of check boxes.
*/
+@SuppressWarnings("nls")
public class CheckBoxModelAdapterUITest {
private TestModel testModel;
@@ -48,14 +49,14 @@ public class CheckBoxModelAdapterUITest {
private ButtonModel notFlag2ButtonModel;
public static void main(String[] args) throws Exception {
- new CheckBoxModelAdapterUITest().exec(args);
+ new CheckBoxModelAdapterUITest().exec();
}
private CheckBoxModelAdapterUITest() {
super();
}
- private void exec(String[] args) throws Exception {
+ private void exec() throws Exception {
this.testModel = new TestModel(true, true);
this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
index e79111a232..0bc9a5793b 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -15,7 +15,7 @@ import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.ListModel;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.ComboBoxModelAdapter;
@@ -27,6 +27,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.model.value.CoordinatedList;
+@SuppressWarnings("nls")
public class ComboBoxModelAdapterTests extends TestCase {
public ComboBoxModelAdapterTests(String name) {
@@ -79,12 +80,12 @@ public class ComboBoxModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
+ boolean hasNoListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
assertTrue(hasNoListeners);
}
private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
+ boolean hasListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
assertTrue(hasListeners);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
index bb6e8f0ce7..afae125606 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -18,6 +18,7 @@ import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.List;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ComboBoxModel;
@@ -28,7 +29,7 @@ import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
-import org.eclipse.jpt.utility.internal.ClassTools;
+
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
@@ -49,6 +50,7 @@ import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
* DefaultLongListBrowserDialogUITest subclasses this class; so be
* careful when making changes.
*/
+@SuppressWarnings("nls")
public class ComboBoxModelAdapterUITest {
protected JFrame window;
@@ -60,14 +62,14 @@ public class ComboBoxModelAdapterUITest {
private int nextColorNumber = 0;
public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest().exec(args);
+ new ComboBoxModelAdapterUITest().exec();
}
protected ComboBoxModelAdapterUITest() {
super();
}
- protected void exec(String[] args) throws Exception {
+ protected void exec() throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); // Metal LAF
// UIManager.setLookAndFeel(com.sun.java.swing.plaf.windows.WindowsLookAndFeel.class.getName());
@@ -119,7 +121,7 @@ public class ComboBoxModelAdapterUITest {
}
private void openWindow() {
- this.window = new JFrame(ClassTools.shortNameFor(this.getClass()));
+ this.window = new JFrame(this.getClass().getSimpleName());
this.window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.window.addWindowListener(this.buildWindowListener());
this.window.getContentPane().add(this.buildMainPanel(), "Center");
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
index e9c5fc4a09..afc1c15a02 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -17,10 +17,11 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
/**
*
*/
+@SuppressWarnings("nls")
public class ComboBoxModelAdapterUITest2 extends ComboBoxModelAdapterUITest {
public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest2().exec(args);
+ new ComboBoxModelAdapterUITest2().exec();
}
public ComboBoxModelAdapterUITest2() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
index cb255e7b12..a24b75b3bf 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -21,6 +21,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class DateSpinnerModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Object> valueHolder;
private SpinnerModel spinnerModelAdapter;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
index d647360a88..e980515201 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 +14,7 @@ import javax.swing.event.DocumentListener;
import javax.swing.event.DocumentEvent.EventType;
import javax.swing.text.Document;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.DocumentAdapter;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -22,6 +22,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class DocumentAdapterTests extends TestCase {
private WritablePropertyValueModel<String> stringHolder;
Document documentAdapter;
@@ -128,14 +129,14 @@ public class DocumentAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object document) throws Exception {
- Object delegate = ClassTools.fieldValue(document, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
+ Object delegate = ReflectionTools.getFieldValue(document, "delegate");
+ Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getDocumentListeners");
assertEquals(0, listeners.length);
}
private void verifyHasListeners(Object document) throws Exception {
- Object delegate = ClassTools.fieldValue(document, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
+ Object delegate = ReflectionTools.getFieldValue(document, "delegate");
+ Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getDocumentListeners");
assertFalse(listeners.length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
index 39b43388cd..c57649b86a 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -38,6 +38,7 @@ import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
/**
* Play around with a set of entry fields.
*/
+@SuppressWarnings("nls")
public class DocumentAdapterUITest {
private TestModel testModel;
@@ -48,14 +49,14 @@ public class DocumentAdapterUITest {
private Document upperCaseNameDocument;
public static void main(String[] args) throws Exception {
- new DocumentAdapterUITest().exec(args);
+ new DocumentAdapterUITest().exec();
}
private DocumentAdapterUITest() {
super();
}
- private void exec(String[] args) throws Exception {
+ private void exec() throws Exception {
this.testModel = new TestModel(DEFAULT_NAME);
this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
this.nameHolder = this.buildNameHolder(this.testModelHolder);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
index 6765325f00..86f3b698e9 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -22,7 +22,7 @@ import javax.swing.ListModel;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.Bag;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.HashBag;
import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
@@ -263,12 +263,12 @@ public class ListModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
+ boolean hasNoListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
assertTrue(hasNoListeners);
}
private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ClassTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
+ boolean hasListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
assertTrue(hasListeners);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
index 0407b59a60..087fefc813 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,6 +20,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class ListSpinnerModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Object> valueHolder;
private SpinnerModel spinnerModelAdapter;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
index bc5df140e8..1debef863e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,6 +20,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class NumberSpinnerModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Number> valueHolder;
private SpinnerModel spinnerModelAdapter;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
index 3a8384c1a7..bbeac0e5fd 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -26,6 +26,7 @@ import org.eclipse.jpt.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class PrimitiveListTreeModelTests extends TestCase {
TestModel testModel;
private TreeModel treeModel;
@@ -137,7 +138,7 @@ public class PrimitiveListTreeModelTests extends TestCase {
// ********** inner classes **********
- private class TestModel extends AbstractModel {
+ class TestModel extends AbstractModel {
private final List<String> names;
static final String NAMES_LIST = "names";
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
index 0c4bbeb9f3..908f4bee86 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 +14,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.RadioButtonModelAdapter;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -22,6 +22,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class RadioButtonModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Object> valueHolder;
@@ -207,12 +208,12 @@ public class RadioButtonModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
assertEquals(0, listenerList.getListenerList().length);
}
private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
assertFalse(listenerList.getListenerList().length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
index c8bb0234ef..3d9ac7344d 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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,7 @@ import javax.swing.SpinnerModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.SpinnerModelAdapter;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
@@ -21,6 +21,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
+@SuppressWarnings("nls")
public class SpinnerModelAdapterTests extends TestCase {
private WritablePropertyValueModel<Object> valueHolder;
SpinnerModel spinnerModelAdapter;
@@ -93,14 +94,14 @@ public class SpinnerModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.fieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
+ Object delegate = ReflectionTools.getFieldValue(adapter, "delegate");
+ Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getChangeListeners");
assertEquals(0, listeners.length);
}
private void verifyHasListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.fieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
+ Object delegate = ReflectionTools.getFieldValue(adapter, "delegate");
+ Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getChangeListeners");
assertFalse(listeners.length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
index c08467d97d..ce51ef0776 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -36,9 +36,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
-/**
- *
- */
+@SuppressWarnings("nls")
public class TableModelAdapterTests extends TestCase {
private Crowd crowd;
TableModelEvent event;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
index 6b70b279ca..78854f61bd 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -47,7 +47,6 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.text.Document;
-import org.eclipse.jpt.utility.internal.ClassTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.model.value.CollectionAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
@@ -214,7 +213,7 @@ public class TableModelAdapterUITest {
}
private void openWindow() {
- JFrame window = new JFrame(ClassTools.shortClassNameForObject(this));
+ JFrame window = new JFrame(this.getClass().getSimpleName());
window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
window.addWindowListener(this.buildWindowListener());
window.getContentPane().add(this.buildMainPanel(), "Center");
@@ -505,7 +504,7 @@ public class TableModelAdapterUITest {
return this.promptUserForName(null);
}
- private String promptUserForName(String originalName) {
+ private String promptUserForName(@SuppressWarnings("unused") String originalName) {
while (true) {
String name = JOptionPane.showInputDialog("Person Name");
if (name == null) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
index b8f40c394f..7339172161 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -49,6 +49,7 @@ import org.eclipse.jpt.utility.tests.internal.model.value.swing.TreeModelAdapter
/**
* an example UI for testing the TreeModelAdapter
*/
+@SuppressWarnings("nls")
public class TreeModelAdapterUITest {
// hold the tree so we can restore its expansion state
@@ -60,14 +61,14 @@ public class TreeModelAdapterUITest {
private TextField nameTextField;
public static void main(String[] args) throws Exception {
- new TreeModelAdapterUITest().exec(args);
+ new TreeModelAdapterUITest().exec();
}
private TreeModelAdapterUITest() {
super();
}
- private void exec(String[] args) throws Exception {
+ private void exec() throws Exception {
this.rootNodeHolder = this.buildRootNodeHolder();
this.sorted = this.rootNodeHolder.getValue() instanceof SortedTestNode;
this.treeModel = this.buildTreeModel();
@@ -132,7 +133,7 @@ public class TreeModelAdapterUITest {
};
}
- void treeSelectionChanged(TreeSelectionEvent e) {
+ void treeSelectionChanged(@SuppressWarnings("unused") TreeSelectionEvent e) {
TestModel selectedTestModel = this.selectedTestModel();
if (selectedTestModel != null) {
this.nameTextField.setText(selectedTestModel.getName());
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
index 7a6a82f517..b835e96de6 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -12,7 +12,7 @@ package org.eclipse.jpt.utility.tests.internal.synchronizers;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.Command;
-import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.CompositeException;
import org.eclipse.jpt.utility.internal.ConsumerThreadCoordinator;
import org.eclipse.jpt.utility.internal.synchronizers.AsynchronousSynchronizer;
@@ -58,8 +58,8 @@ public class AsynchronousSynchronizerTests extends TestCase {
}
protected static void stop(Synchronizer synchronizer) {
- ConsumerThreadCoordinator ctc = (ConsumerThreadCoordinator) ClassTools.fieldValue(synchronizer, "consumerThreadCoordinator");
- if (ClassTools.fieldValue(ctc, "thread") != null) {
+ ConsumerThreadCoordinator ctc = (ConsumerThreadCoordinator) ReflectionTools.getFieldValue(synchronizer, "consumerThreadCoordinator");
+ if (ReflectionTools.getFieldValue(ctc, "thread") != null) {
synchronizer.stop();
}
}
@@ -168,8 +168,8 @@ public class AsynchronousSynchronizerTests extends TestCase {
public void testThreadName() {
Synchronizer s = new AsynchronousSynchronizer(this.command1, "sync");
s.start();
- ConsumerThreadCoordinator ctc = (ConsumerThreadCoordinator) ClassTools.fieldValue(s, "consumerThreadCoordinator");
- Thread t = (Thread) ClassTools.fieldValue(ctc, "thread");
+ ConsumerThreadCoordinator ctc = (ConsumerThreadCoordinator) ReflectionTools.getFieldValue(s, "consumerThreadCoordinator");
+ Thread t = (Thread) ReflectionTools.getFieldValue(ctc, "thread");
assertEquals("sync", t.getName());
s.stop();
}
@@ -309,7 +309,7 @@ public class AsynchronousSynchronizerTests extends TestCase {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.toStringClassNameForObject(this));
+ sb.append(this.getClass().getSimpleName());
sb.append('(');
this.toString(sb);
sb.append(')');
@@ -385,7 +385,7 @@ public class AsynchronousSynchronizerTests extends TestCase {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.toStringClassNameForObject(this));
+ sb.append(this.getClass().getSimpleName());
sb.append('(');
this.toString(sb);
sb.append(')');
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
index 054bf08452..c2391be3d4 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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.
@@ -12,7 +12,6 @@ package org.eclipse.jpt.utility.tests.internal.synchronizers;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.Command;
-import org.eclipse.jpt.utility.internal.ClassTools;
import org.eclipse.jpt.utility.internal.CompositeException;
import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
import org.eclipse.jpt.utility.internal.synchronizers.Synchronizer;
@@ -557,7 +556,7 @@ public class SynchronousSynchronizerTests extends TestCase {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.toStringClassNameForObject(this));
+ sb.append(this.getClass().getSimpleName());
sb.append('(');
this.toString(sb);
sb.append(')');
@@ -633,7 +632,7 @@ public class SynchronousSynchronizerTests extends TestCase {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(ClassTools.toStringClassNameForObject(this));
+ sb.append(this.getClass().getSimpleName());
sb.append('(');
this.toString(sb);
sb.append(')');

Back to the top