summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-04-29 20:46:39 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-29 20:46:39 -0700
commit7195b3b965df5c3288435d94e8d13bd256e33890 (patch)
tree25f0dc75cf1398f549b6bf6d63039a25bcbe1f8a /support
parent347b2a604114602da9bc4ae040278f74d11c2f51 (diff)
parent91922d920e0020bde20ef5ae21b66cab847dd58b (diff)
downloadlibcore-7195b3b965df5c3288435d94e8d13bd256e33890.zip
libcore-7195b3b965df5c3288435d94e8d13bd256e33890.tar.gz
libcore-7195b3b965df5c3288435d94e8d13bd256e33890.tar.bz2
Merge "Fix X509CertImpl.verify(PublicKey, String) to respect provider argument"
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java85
-rw-r--r--support/src/test/java/tests/support/resource/Support_Resources.java18
2 files changed, 31 insertions, 72 deletions
diff --git a/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
index 68ec773..f20f9de 100644
--- a/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
+++ b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
@@ -40,7 +40,6 @@ import java.util.Collections;
import java.util.HashSet;
import junit.framework.Assert;
import junit.framework.TestCase;
-import libcore.util.Objects;
/**
* Framework for serialization testing. Subclasses only need to override
@@ -64,22 +63,6 @@ import libcore.util.Objects;
public abstract class SerializationTest extends TestCase {
/**
- * Property name for the testing mode.
- */
- public static final String MODE_KEY = "test.mode";
-
-
- /**
- * Testing mode.
- */
- public static String mode = System.getProperty(MODE_KEY);
-
- /**
- * Reference files generation mode switch.
- */
- public static final String SERIAL_REFERENCE_MODE = "serial.reference";
-
- /**
* Key to a system property defining root location of golden files.
*/
public static final String GOLDEN_PATH = "RESOURCE_DIR";
@@ -88,33 +71,6 @@ public abstract class SerializationTest extends TestCase {
"src/test/resources/serialization");
/**
- * Parameterized c-tor inherited from superclass.
- */
- public SerializationTest(String name) {
- super(name);
- }
-
- /**
- * Default c-tor inherited from superclass.
- */
- public SerializationTest() {
- super();
- }
-
- /**
- * Depending on testing mode, produces golden files or performs testing.
- */
- @Override
- public void runBare() throws Throwable {
-
- if (Objects.equal(mode, SERIAL_REFERENCE_MODE)) {
- produceGoldenFiles();
- } else {
- super.runBare();
- }
- }
-
- /**
* This is the main working method of this framework. Subclasses must
* override it to provide actual objects for testing.
*
@@ -193,7 +149,7 @@ public abstract class SerializationTest extends TestCase {
* Serializes specified object to an output stream.
*/
public static void putObjectToStream(Object obj, OutputStream os)
- throws IOException {
+ throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(obj);
oos.flush();
@@ -203,8 +159,8 @@ public abstract class SerializationTest extends TestCase {
/**
* Deserializes single object from an input stream.
*/
- public static Serializable getObjectFromStream(InputStream is) throws IOException,
- ClassNotFoundException {
+ public static Serializable getObjectFromStream(InputStream is)
+ throws IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(is);
Object result = ois.readObject();
ois.close();
@@ -322,8 +278,8 @@ public abstract class SerializationTest extends TestCase {
* object to be compared
* @return object's comparator
*/
- public static SerializableAssert defineComparator(TestCase test,
- Object object) throws Exception {
+ public static SerializableAssert defineComparator(TestCase test, Object object)
+ throws Exception {
if (test instanceof SerializableAssert) {
return (SerializableAssert) test;
@@ -360,9 +316,7 @@ public abstract class SerializationTest extends TestCase {
* @param object -
* to be compared
*/
- public static void verifyGolden(TestCase test, Object object)
- throws Exception {
-
+ public static void verifyGolden(TestCase test, Object object) throws Exception {
verifyGolden(test, object, defineComparator(test, object));
}
@@ -381,8 +335,8 @@ public abstract class SerializationTest extends TestCase {
* @param comparator -
* for comparing (de)serialized objects
*/
- public static void verifyGolden(TestCase test, Object object,
- SerializableAssert comparator) throws Exception {
+ public static void verifyGolden(TestCase test, Object object, SerializableAssert comparator)
+ throws Exception {
Assert.assertNotNull("Null comparator", comparator);
@@ -403,8 +357,7 @@ public abstract class SerializationTest extends TestCase {
* @param objects -
* array of objects to be compared
*/
- public static void verifyGolden(TestCase test, Object[] objects)
- throws Exception {
+ public static void verifyGolden(TestCase test, Object[] objects) throws Exception {
Assert.assertFalse("Empty array", objects.length == 0);
verifyGolden(test, objects, defineComparator(test, objects[0]));
@@ -428,8 +381,8 @@ public abstract class SerializationTest extends TestCase {
* @param comparator -
* for comparing (de)serialized objects
*/
- public static void verifyGolden(TestCase test, Object[] objects,
- SerializableAssert comparator) throws Exception {
+ public static void verifyGolden(TestCase test, Object[] objects, SerializableAssert comparator)
+ throws Exception {
Assert.assertFalse("Empty array", objects.length == 0);
for (int i = 0; i < objects.length; i++) {
@@ -448,8 +401,7 @@ public abstract class SerializationTest extends TestCase {
* @param object -
* to be serialized/deserialized
*/
- public static void verifySelf(Object object)
- throws Exception {
+ public static void verifySelf(Object object) throws Exception {
verifySelf(object, defineComparator(null, object));
}
@@ -466,8 +418,7 @@ public abstract class SerializationTest extends TestCase {
* for comparing serialized/deserialized object with initial
* object
*/
- public static void verifySelf(Object object, SerializableAssert comparator)
- throws Exception {
+ public static void verifySelf(Object object, SerializableAssert comparator) throws Exception {
Serializable initial = (Serializable) object;
@@ -484,8 +435,7 @@ public abstract class SerializationTest extends TestCase {
* @param objects -
* array of objects to be serialized/deserialized
*/
- public static void verifySelf(Object[] objects)
- throws Exception {
+ public static void verifySelf(Object[] objects) throws Exception {
Assert.assertFalse("Empty array", objects.length == 0);
verifySelf(objects, defineComparator(null, objects[0]));
@@ -513,8 +463,7 @@ public abstract class SerializationTest extends TestCase {
}
}
- private static Serializable getObject(TestCase test, String toAppend)
- throws Exception {
+ private static Serializable getObject(TestCase test, String toAppend) throws Exception {
StringBuilder path = new StringBuilder("/serialization");
@@ -546,8 +495,8 @@ public abstract class SerializationTest extends TestCase {
* @throws IOException -
* if I/O error
*/
- public static void createGoldenFile(String root, TestCase test,
- Object object) throws IOException {
+ public static void createGoldenFile(String root, TestCase test, Object object)
+ throws IOException {
String goldenPath = test.getClass().getName().replace('.',
File.separatorChar)
diff --git a/support/src/test/java/tests/support/resource/Support_Resources.java b/support/src/test/java/tests/support/resource/Support_Resources.java
index c1594d4..80a53fb 100644
--- a/support/src/test/java/tests/support/resource/Support_Resources.java
+++ b/support/src/test/java/tests/support/resource/Support_Resources.java
@@ -17,16 +17,15 @@
package tests.support.resource;
-import libcore.io.Streams;
-import tests.support.Support_Configuration;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import tests.support.Support_Configuration;
public class Support_Resources {
@@ -118,13 +117,24 @@ public class Support_Resources {
public static void copyLocalFileto(File dest, InputStream in) throws IOException {
if (!dest.exists()) {
FileOutputStream out = new FileOutputStream(dest);
- Streams.copy(in, out);
+ copy(in, out);
out.close();
dest.deleteOnExit();
}
in.close();
}
+ private static int copy(InputStream in, OutputStream out) throws IOException {
+ int total = 0;
+ byte[] buffer = new byte[8192];
+ int c;
+ while ((c = in.read(buffer)) != -1) {
+ total += c;
+ out.write(buffer, 0, c);
+ }
+ return total;
+ }
+
public static File getExternalLocalFile(String url) throws IOException {
File resources = createTempFolder();
InputStream in = new URL(url).openStream();