diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal')
-rw-r--r-- | jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java | 9 |
1 files changed, 7 insertions, 2 deletions
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 1eed587df1..04a3d84786 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 @@ -12,6 +12,7 @@ package org.eclipse.jpt.utility.tests.internal; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; @@ -34,7 +35,6 @@ public final class TestTools { * specified object to a byte array; then de-serializing the byte array and * returning the resultant object */ - @SuppressWarnings("unchecked") public static <T> T serialize(T o) throws IOException, ClassNotFoundException { ByteArrayOutputStream baOutStream = new ByteArrayOutputStream(2000); ObjectOutputStream outStream = new ObjectOutputStream(baOutStream); @@ -43,12 +43,17 @@ public final class TestTools { ByteArrayInputStream baInStream = new ByteArrayInputStream(baOutStream.toByteArray()); ObjectInputStream inStream = new ObjectInputStream(baInStream); - T o2 = (T) inStream.readObject(); + T o2 = readObject(inStream); inStream.close(); return o2; } + @SuppressWarnings("unchecked") + private static <T> T readObject(ObjectInput objectInput) throws IOException, ClassNotFoundException { + return (T) objectInput.readObject(); + } + /** * some tests require access to the Web (e.g. any tests that parse an XML * document that specifies a DTD or Schema that is loaded from the Web); use |