You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ad...@apache.org on 2015/11/19 21:16:38 UTC

svn commit: r1715261 - in /commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization: MockSerializedClass.java OurTestClass.java ValidatingObjectInputStreamTest.java

Author: adrianc
Date: Thu Nov 19 20:16:38 2015
New Revision: 1715261

URL: http://svn.apache.org/viewvc?rev=1715261&view=rev
Log:
Fixed broken unit tests. JUnit was trying to execute OurTestClass.java as a test.

Added:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java
Removed:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/OurTestClass.java
Modified:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java

Added: commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java?rev=1715261&view=auto
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java (added)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java Thu Nov 19 20:16:38 2015
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.io.serialization;
+
+import java.io.Serializable;
+
+public class MockSerializedClass implements Serializable {
+    private static final long serialVersionUID = 2139985988735372175L;
+    
+    private final String str;
+    
+    MockSerializedClass(String str) {
+        this.str = str;
+    }
+
+    @Override
+    public int hashCode() {
+        return str.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if(!(obj instanceof MockSerializedClass)) {
+            return false;
+        }
+        return str.equals(((MockSerializedClass)obj).str);
+    }
+}
\ No newline at end of file

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java?rev=1715261&r1=1715260&r2=1715261&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java Thu Nov 19 20:16:38 2015
@@ -36,7 +36,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class ValidatingObjectInputStreamTest extends ClosingBase {
-    private OurTestClass testObject;
+    private MockSerializedClass testObject;
     private InputStream testStream;
 
     static private final ClassNameMatcher ALWAYS_TRUE = new ClassNameMatcher() {
@@ -48,7 +48,7 @@ public class ValidatingObjectInputStream
 
     @Before
     public void setup() throws IOException {
-        testObject = new OurTestClass(UUID.randomUUID().toString());
+        testObject = new MockSerializedClass(UUID.randomUUID().toString());
         final ByteArrayOutputStream bos = willClose(new ByteArrayOutputStream());
         final ObjectOutputStream oos = willClose(new ObjectOutputStream(bos));
         oos.writeObject(testObject);
@@ -56,7 +56,7 @@ public class ValidatingObjectInputStream
     }
 
     private void assertSerialization(ObjectInputStream ois) throws ClassNotFoundException, IOException {
-        final OurTestClass result = (OurTestClass) (ois.readObject());
+        final MockSerializedClass result = (MockSerializedClass) (ois.readObject());
         assertEquals(testObject, result);
     }
 
@@ -73,7 +73,7 @@ public class ValidatingObjectInputStream
                     willClose(new ValidatingObjectInputStream(testStream)));
             fail("Expected an InvalidClassException");
         } catch(InvalidClassException ice) {
-            final String name = OurTestClass.class.getName();
+            final String name = MockSerializedClass.class.getName();
             assertTrue("Expecting message to contain " + name, ice.getMessage().contains(name));
         }
     }
@@ -90,7 +90,7 @@ public class ValidatingObjectInputStream
     public void rejectCustomMatcher() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class)
+                .accept(MockSerializedClass.class)
                 .reject(ALWAYS_TRUE)
         );
     }
@@ -99,7 +99,7 @@ public class ValidatingObjectInputStream
     public void acceptPattern() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(Pattern.compile(".*OurTestClass.*"))
+                .accept(Pattern.compile(".*MockSerializedClass.*"))
         );
     }
 
@@ -107,7 +107,7 @@ public class ValidatingObjectInputStream
     public void rejectPattern() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class)
+                .accept(MockSerializedClass.class)
                 .reject(Pattern.compile("org.*"))
         );
     }
@@ -124,7 +124,7 @@ public class ValidatingObjectInputStream
     public void rejectWildcard() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class)
+                .accept(MockSerializedClass.class)
                 .reject("org.*")
         );
     }
@@ -141,7 +141,7 @@ public class ValidatingObjectInputStream
     public void ourTestClassOnlyAccepted() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class)
+                .accept(MockSerializedClass.class)
         );
     }
 
@@ -149,7 +149,7 @@ public class ValidatingObjectInputStream
     public void ourTestClassAcceptedFirst() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class, Integer.class)
+                .accept(MockSerializedClass.class, Integer.class)
         );
     }
 
@@ -157,7 +157,7 @@ public class ValidatingObjectInputStream
     public void ourTestClassAcceptedSecond() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(Integer.class, OurTestClass.class)
+                .accept(Integer.class, MockSerializedClass.class)
         );
     }
 
@@ -165,7 +165,7 @@ public class ValidatingObjectInputStream
     public void ourTestClassAcceptedFirstWildcard() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept("*OurTestClass","*Integer")
+                .accept("*MockSerializedClass","*Integer")
         );
     }
 
@@ -173,7 +173,7 @@ public class ValidatingObjectInputStream
     public void ourTestClassAcceptedSecondWildcard() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept("*Integer","*OurTestClass")
+                .accept("*Integer","*MockSerializedClass")
         );
     }
 
@@ -182,7 +182,7 @@ public class ValidatingObjectInputStream
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
                 .accept(Long.class)
-                .reject(OurTestClass.class, Integer.class)
+                .reject(MockSerializedClass.class, Integer.class)
         );
     }
     
@@ -190,8 +190,8 @@ public class ValidatingObjectInputStream
     public void rejectPrecedence() throws Exception {
         assertSerialization(
                 willClose(new ValidatingObjectInputStream(testStream))
-                .accept(OurTestClass.class)
-                .reject(OurTestClass.class, Integer.class)
+                .accept(MockSerializedClass.class)
+                .reject(MockSerializedClass.class, Integer.class)
         );
     }