3636import org .junit .Test ;
3737
3838public 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