Skip to content

Commit a9159ab

Browse files
committed
Fixed broken unit tests. JUnit was trying to execute OurTestClass.java as a test.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1715261 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3444035 commit a9159ab

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/test/java/org/apache/commons/io/serialization/OurTestClass.java renamed to src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
import java.io.Serializable;
2222

23-
public class OurTestClass implements Serializable {
23+
public class MockSerializedClass implements Serializable {
2424
private static final long serialVersionUID = 2139985988735372175L;
2525

2626
private final String str;
2727

28-
OurTestClass(String str) {
28+
MockSerializedClass(String str) {
2929
this.str = str;
3030
}
3131

@@ -36,9 +36,9 @@ public int hashCode() {
3636

3737
@Override
3838
public boolean equals(Object obj) {
39-
if(!(obj instanceof OurTestClass)) {
39+
if(!(obj instanceof MockSerializedClass)) {
4040
return false;
4141
}
42-
return str.equals(((OurTestClass)obj).str);
42+
return str.equals(((MockSerializedClass)obj).str);
4343
}
4444
}

src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.junit.Test;
3737

3838
public class ValidatingObjectInputStreamTest extends ClosingBase {
39-
private OurTestClass testObject;
39+
private MockSerializedClass testObject;
4040
private InputStream testStream;
4141

4242
static private final ClassNameMatcher ALWAYS_TRUE = new ClassNameMatcher() {
@@ -48,15 +48,15 @@ public boolean matches(String className) {
4848

4949
@Before
5050
public void setup() throws IOException {
51-
testObject = new OurTestClass(UUID.randomUUID().toString());
51+
testObject = new MockSerializedClass(UUID.randomUUID().toString());
5252
final ByteArrayOutputStream bos = willClose(new ByteArrayOutputStream());
5353
final ObjectOutputStream oos = willClose(new ObjectOutputStream(bos));
5454
oos.writeObject(testObject);
5555
testStream = willClose(new ByteArrayInputStream(bos.toByteArray()));
5656
}
5757

5858
private void assertSerialization(ObjectInputStream ois) throws ClassNotFoundException, IOException {
59-
final OurTestClass result = (OurTestClass) (ois.readObject());
59+
final MockSerializedClass result = (MockSerializedClass) (ois.readObject());
6060
assertEquals(testObject, result);
6161
}
6262

@@ -73,7 +73,7 @@ public void exceptionIncludesClassName() throws Exception {
7373
willClose(new ValidatingObjectInputStream(testStream)));
7474
fail("Expected an InvalidClassException");
7575
} catch(InvalidClassException ice) {
76-
final String name = OurTestClass.class.getName();
76+
final String name = MockSerializedClass.class.getName();
7777
assertTrue("Expecting message to contain " + name, ice.getMessage().contains(name));
7878
}
7979
}
@@ -90,7 +90,7 @@ public void acceptCustomMatcher() throws Exception {
9090
public void rejectCustomMatcher() throws Exception {
9191
assertSerialization(
9292
willClose(new ValidatingObjectInputStream(testStream))
93-
.accept(OurTestClass.class)
93+
.accept(MockSerializedClass.class)
9494
.reject(ALWAYS_TRUE)
9595
);
9696
}
@@ -99,15 +99,15 @@ public void rejectCustomMatcher() throws Exception {
9999
public void acceptPattern() throws Exception {
100100
assertSerialization(
101101
willClose(new ValidatingObjectInputStream(testStream))
102-
.accept(Pattern.compile(".*OurTestClass.*"))
102+
.accept(Pattern.compile(".*MockSerializedClass.*"))
103103
);
104104
}
105105

106106
@Test(expected = InvalidClassException.class)
107107
public void rejectPattern() throws Exception {
108108
assertSerialization(
109109
willClose(new ValidatingObjectInputStream(testStream))
110-
.accept(OurTestClass.class)
110+
.accept(MockSerializedClass.class)
111111
.reject(Pattern.compile("org.*"))
112112
);
113113
}
@@ -124,7 +124,7 @@ public void acceptWildcard() throws Exception {
124124
public void rejectWildcard() throws Exception {
125125
assertSerialization(
126126
willClose(new ValidatingObjectInputStream(testStream))
127-
.accept(OurTestClass.class)
127+
.accept(MockSerializedClass.class)
128128
.reject("org.*")
129129
);
130130
}
@@ -141,39 +141,39 @@ public void ourTestClassNotAccepted() throws Exception {
141141
public void ourTestClassOnlyAccepted() throws Exception {
142142
assertSerialization(
143143
willClose(new ValidatingObjectInputStream(testStream))
144-
.accept(OurTestClass.class)
144+
.accept(MockSerializedClass.class)
145145
);
146146
}
147147

148148
@Test
149149
public void ourTestClassAcceptedFirst() throws Exception {
150150
assertSerialization(
151151
willClose(new ValidatingObjectInputStream(testStream))
152-
.accept(OurTestClass.class, Integer.class)
152+
.accept(MockSerializedClass.class, Integer.class)
153153
);
154154
}
155155

156156
@Test
157157
public void ourTestClassAcceptedSecond() throws Exception {
158158
assertSerialization(
159159
willClose(new ValidatingObjectInputStream(testStream))
160-
.accept(Integer.class, OurTestClass.class)
160+
.accept(Integer.class, MockSerializedClass.class)
161161
);
162162
}
163163

164164
@Test
165165
public void ourTestClassAcceptedFirstWildcard() throws Exception {
166166
assertSerialization(
167167
willClose(new ValidatingObjectInputStream(testStream))
168-
.accept("*OurTestClass","*Integer")
168+
.accept("*MockSerializedClass","*Integer")
169169
);
170170
}
171171

172172
@Test
173173
public void ourTestClassAcceptedSecondWildcard() throws Exception {
174174
assertSerialization(
175175
willClose(new ValidatingObjectInputStream(testStream))
176-
.accept("*Integer","*OurTestClass")
176+
.accept("*Integer","*MockSerializedClass")
177177
);
178178
}
179179

@@ -182,16 +182,16 @@ public void reject() throws Exception {
182182
assertSerialization(
183183
willClose(new ValidatingObjectInputStream(testStream))
184184
.accept(Long.class)
185-
.reject(OurTestClass.class, Integer.class)
185+
.reject(MockSerializedClass.class, Integer.class)
186186
);
187187
}
188188

189189
@Test(expected = InvalidClassException.class)
190190
public void rejectPrecedence() throws Exception {
191191
assertSerialization(
192192
willClose(new ValidatingObjectInputStream(testStream))
193-
.accept(OurTestClass.class)
194-
.reject(OurTestClass.class, Integer.class)
193+
.accept(MockSerializedClass.class)
194+
.reject(MockSerializedClass.class, Integer.class)
195195
);
196196
}
197197

0 commit comments

Comments
 (0)