Here are the examples of the java api class java.io.ObjectInputStream taken from open source projects.
1. Filter#unpickle()
Project: bboss
File: Filter.java
File: Filter.java
/** * Reconstitute a serialized object. * @param data The pickled object. * @return The reconstituted object. * @exception IOException If the input stream complains. * @exception ClassNotFoundException If the serialized object class cannot * be located. */ public static Object unpickle(byte[] data) throws IOException, ClassNotFoundException { ByteArrayInputStream bis; ObjectInputStream ois; Object ret; bis = new ByteArrayInputStream(data); ois = new ObjectInputStream(bis); ret = ois.readObject(); ois.close(); return (ret); }
2. CmsDataTypeUtil#dataDeserialize()
Project: opencms-core
File: CmsDataTypeUtil.java
File: CmsDataTypeUtil.java
/** * Returns the deserialized (if needed) object.<p> * * @param data the data to deserialize * @param type the data type * * @return the deserialized object * * @throws IOException if the inputstream fails * @throws ClassNotFoundException if the serialized object fails */ public static Object dataDeserialize(byte[] data, String type) throws IOException, ClassNotFoundException { // check the type of the stored data Class<?> clazz = Class.forName(type); if (isParseable(clazz)) { // this is parseable data return parse(new String(data), clazz); } // this is a serialized object ByteArrayInputStream bin = new ByteArrayInputStream(data); ObjectInputStream oin = new ObjectInputStream(bin); return oin.readObject(); }
3. EmbeddedChannelIdTest#testSerialization()
Project: netty
File: EmbeddedChannelIdTest.java
File: EmbeddedChannelIdTest.java
@Test public void testSerialization() throws IOException, ClassNotFoundException { // test that a deserialized instance works the same as a normal instance (issue #2869) ChannelId normalInstance = EmbeddedChannelId.INSTANCE; ByteBufOutputStream buffer = new ByteBufOutputStream(Unpooled.buffer()); ObjectOutputStream outStream = new ObjectOutputStream(buffer); outStream.writeObject(normalInstance); outStream.close(); ObjectInputStream inStream = new ObjectInputStream(new ByteBufInputStream(buffer.buffer())); ChannelId deserializedInstance = (ChannelId) inStream.readObject(); inStream.close(); Assert.assertEquals(normalInstance, deserializedInstance); Assert.assertEquals(normalInstance.hashCode(), deserializedInstance.hashCode()); Assert.assertEquals(0, normalInstance.compareTo(deserializedInstance)); }
4. ObjectDecoder#decode()
Project: netty
File: ObjectDecoder.java
File: ObjectDecoder.java
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } ObjectInputStream is = new CompactObjectInputStream(new ByteBufInputStream(frame), classResolver); Object result = is.readObject(); is.close(); return result; }
5. AutomaticLazyLoadingTest#disableLazyLoaders()
Project: mybatis-3
File: AutomaticLazyLoadingTest.java
File: AutomaticLazyLoadingTest.java
/** * Disable lazy loaders by serializing / deserializing the element */ private Element disableLazyLoaders(Element anElement) throws Exception { ByteArrayOutputStream myBuffer = new ByteArrayOutputStream(); ObjectOutputStream myObjectOutputStream = new ObjectOutputStream(myBuffer); myObjectOutputStream.writeObject(anElement); myObjectOutputStream.close(); myBuffer.close(); ObjectInputStream myObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(myBuffer.toByteArray())); Element myResult = (Element) myObjectInputStream.readObject(); myObjectInputStream.close(); return myResult; }
6. AutomaticLazyLoadingTest#disableLazyLoaders()
Project: mybatis
File: AutomaticLazyLoadingTest.java
File: AutomaticLazyLoadingTest.java
/** * Disable lazy loaders by serializing / deserializing the element */ private Element disableLazyLoaders(Element anElement) throws Exception { ByteArrayOutputStream myBuffer = new ByteArrayOutputStream(); ObjectOutputStream myObjectOutputStream = new ObjectOutputStream(myBuffer); myObjectOutputStream.writeObject(anElement); myObjectOutputStream.close(); myBuffer.close(); ObjectInputStream myObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(myBuffer.toByteArray())); Element myResult = (Element) myObjectInputStream.readObject(); myObjectInputStream.close(); return myResult; }
7. SerializableRefTest#copy()
Project: metamodel
File: SerializableRefTest.java
File: SerializableRefTest.java
@SuppressWarnings("unchecked") private <E> SerializableRef<E> copy(SerializableRef<E> ref) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(baos); os.writeObject(ref); os.flush(); os.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream is = new ObjectInputStream(bais); Object obj = is.readObject(); is.close(); return (SerializableRef<E>) obj; }
8. SerializationTestHelper#serializeClone()
Project: logging-log4j2
File: SerializationTestHelper.java
File: SerializationTestHelper.java
/** * Creates a clone by serializing object and * deserializing byte stream. * * @param obj object to serialize and deserialize. * @return clone * @throws IOException on IO error. * @throws ClassNotFoundException if class not found. */ public static Object serializeClone(final Object obj) throws IOException, ClassNotFoundException { final ByteArrayOutputStream memOut = new ByteArrayOutputStream(); try (final ObjectOutputStream objOut = new ObjectOutputStream(memOut)) { objOut.writeObject(obj); } final ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray()); final ObjectInputStream objIs = new ObjectInputStream(src); return objIs.readObject(); }
9. SerializationTestHelper#serializeClone()
Project: log4j-extras
File: SerializationTestHelper.java
File: SerializationTestHelper.java
/** * Creates a clone by serializing object and * deserializing byte stream. * @param obj object to serialize and deserialize. * @return clone * @throws IOException on IO error. * @throws ClassNotFoundException if class not found. */ public static Object serializeClone(final Object obj) throws IOException, ClassNotFoundException { ByteArrayOutputStream memOut = new ByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(memOut); objOut.writeObject(obj); objOut.close(); ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray()); ObjectInputStream objIs = new ObjectInputStream(src); return objIs.readObject(); }
10. SerializationTestHelper#serializeClone()
Project: log4j
File: SerializationTestHelper.java
File: SerializationTestHelper.java
/** * Creates a clone by serializing object and * deserializing byte stream. * @param obj object to serialize and deserialize. * @return clone * @throws IOException on IO error. * @throws ClassNotFoundException if class not found. */ public static Object serializeClone(final Object obj) throws IOException, ClassNotFoundException { ByteArrayOutputStream memOut = new ByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(memOut); objOut.writeObject(obj); objOut.close(); ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray()); ObjectInputStream objIs = new ObjectInputStream(src); return objIs.readObject(); }
11. ResultTest#assertResultSerializable()
Project: junit4
File: ResultTest.java
File: ResultTest.java
private void assertResultSerializable(Result result) throws IOException, ClassNotFoundException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(result); objectOutputStream.flush(); byte[] bytes = byteArrayOutputStream.toByteArray(); ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Result fromStream = (Result) objectInputStream.readObject(); assertSerializedCorrectly(result, fromStream); InputStream resource = getClass().getResourceAsStream(getName()); assertNotNull("Could not read resource " + getName(), resource); objectInputStream = new ObjectInputStream(resource); fromStream = (Result) objectInputStream.readObject(); assertSerializedCorrectly(new ResultWithFixedRunTime(result), fromStream); }
12. ISOMsg2Test#testSerializeDeserializeThenCompare()
Project: jPOS
File: ISOMsg2Test.java
File: ISOMsg2Test.java
@Test public void testSerializeDeserializeThenCompare() throws Exception { ISOMsg msg = new ISOMsg(); msg.setMTI("0800"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(buffer); out.writeObject(msg); out.close(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); ISOMsg dest = (ISOMsg) in.readObject(); in.close(); assertEquals("obj != deserialize(serialize(obj))", msg.getMTI(), dest.getMTI()); }
13. ISOAmountTest#testReadWriteExternal()
Project: jPOS
File: ISOAmountTest.java
File: ISOAmountTest.java
@Test public void testReadWriteExternal() throws IOException, ClassNotFoundException, ISOException { // given ByteArrayOutputStream data = new ByteArrayOutputStream(); ObjectOutputStream ostr = new ObjectOutputStream(data); // when iSOAmount.writeExternal(ostr); ostr.close(); ObjectInputStream istr = new ObjectInputStream(new ByteArrayInputStream(data.toByteArray())); // then ISOAmount pickled = new ISOAmount(); pickled.readExternal(istr); istr.close(); assertThat(pickled.getAmountAsString(), is(iSOAmount.getAmountAsString())); }
14. TestDateTimeZone#testSerialization2()
Project: joda-time-android
File: TestDateTimeZone.java
File: TestDateTimeZone.java
//----------------------------------------------------------------------- public void testSerialization2() throws Exception { DateTimeZone zone = DateTimeZone.forID("+01:00"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(zone); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeZone result = (DateTimeZone) ois.readObject(); ois.close(); assertEquals(zone, result); }
15. TestDateTimeZone#testSerialization1()
Project: joda-time-android
File: TestDateTimeZone.java
File: TestDateTimeZone.java
//----------------------------------------------------------------------- public void testSerialization1() throws Exception { DateTimeZone zone = DateTimeZone.forID("Europe/Paris"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(zone); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeZone result = (DateTimeZone) ois.readObject(); ois.close(); assertSame(zone, result); }
16. TestCachedDateTimeZone#testSerialization()
Project: joda-time
File: TestCachedDateTimeZone.java
File: TestCachedDateTimeZone.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { CachedDateTimeZone test = CachedDateTimeZone.forZone(DateTimeZone.forID("Europe/Paris")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); CachedDateTimeZone result = (CachedDateTimeZone) ois.readObject(); ois.close(); assertEquals(test, result); }
17. TestYears#testSerialization()
Project: joda-time
File: TestYears.java
File: TestYears.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Years test = Years.THREE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Years result = (Years) ois.readObject(); ois.close(); assertSame(test, result); }
18. TestYearMonth_Basics#testSerialization()
Project: joda-time
File: TestYearMonth_Basics.java
File: TestYearMonth_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { YearMonth test = new YearMonth(1972, 6, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); YearMonth result = (YearMonth) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
19. TestYearMonthDay_Basics#testSerialization()
Project: joda-time
File: TestYearMonthDay_Basics.java
File: TestYearMonthDay_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { YearMonthDay test = new YearMonthDay(1972, 6, 9, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); YearMonthDay result = (YearMonthDay) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
20. TestWeeks#testSerialization()
Project: joda-time
File: TestWeeks.java
File: TestWeeks.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Weeks test = Weeks.THREE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Weeks result = (Weeks) ois.readObject(); ois.close(); assertSame(test, result); }
21. TestTimeOfDay_Basics#testSerialization()
Project: joda-time
File: TestTimeOfDay_Basics.java
File: TestTimeOfDay_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { TimeOfDay test = new TimeOfDay(10, 20, 30, 40, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); TimeOfDay result = (TimeOfDay) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
22. TestSerialization#inlineCompare()
Project: joda-time
File: TestSerialization.java
File: TestSerialization.java
public void inlineCompare(Serializable test, boolean same) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); ois.close(); if (same) { assertSame(test, obj); } else { assertEquals(test, obj); } }
23. TestSerialization#loadAndCompare()
Project: joda-time
File: TestSerialization.java
File: TestSerialization.java
private void loadAndCompare(Serializable test, String filename, boolean same) throws Exception { FileInputStream fis = new FileInputStream("src/test/resources/" + filename + ".dat"); ObjectInputStream ois = new ObjectInputStream(fis); Object obj = ois.readObject(); ois.close(); if (same) { assertSame(test, obj); } else { assertEquals(test, obj); } // try { // fis = new FileInputStream("src/test/resources/" + filename + "2.dat"); // ois = new ObjectInputStream(fis); // obj = ois.readObject(); // ois.close(); // if (same) { // assertSame(test, obj); // } else { // assertEquals(test, obj); // } // } catch (FileNotFoundException ex) { // // ignore // } }
24. TestSeconds#testSerialization()
Project: joda-time
File: TestSeconds.java
File: TestSeconds.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Seconds test = Seconds.THREE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Seconds result = (Seconds) ois.readObject(); ois.close(); assertSame(test, result); }
25. TestPeriod_Basics#testSerialization()
Project: joda-time
File: TestPeriod_Basics.java
File: TestPeriod_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Period test = new Period(123L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Period result = (Period) ois.readObject(); ois.close(); assertEquals(test, result); }
26. TestPeriodType#assertSameAfterSerialization()
Project: joda-time
File: TestPeriodType.java
File: TestPeriodType.java
private void assertSameAfterSerialization(PeriodType type) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(type); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); PeriodType result = (PeriodType) ois.readObject(); ois.close(); assertEquals(type, result); }
27. TestPeriodType#assertEqualsAfterSerialization()
Project: joda-time
File: TestPeriodType.java
File: TestPeriodType.java
//----------------------------------------------------------------------- private void assertEqualsAfterSerialization(PeriodType type) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(type); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); PeriodType result = (PeriodType) ois.readObject(); ois.close(); assertEquals(type, result); }
28. TestPartial_Basics#testSerialization()
Project: joda-time
File: TestPartial_Basics.java
File: TestPartial_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Partial test = createHourMinPartial(COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Partial result = (Partial) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
29. TestMutablePeriod_Basics#testSerialization()
Project: joda-time
File: TestMutablePeriod_Basics.java
File: TestMutablePeriod_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { MutablePeriod test = new MutablePeriod(123L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); MutablePeriod result = (MutablePeriod) ois.readObject(); ois.close(); assertEquals(test, result); }
30. TestMutableInterval_Basics#testSerialization()
Project: joda-time
File: TestMutableInterval_Basics.java
File: TestMutableInterval_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { MutableInterval test = new MutableInterval(TEST_TIME1, TEST_TIME2); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); MutableInterval result = (MutableInterval) ois.readObject(); ois.close(); assertEquals(test, result); }
31. TestMutableDateTime_Basics#testSerialization()
Project: joda-time
File: TestMutableDateTime_Basics.java
File: TestMutableDateTime_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { MutableDateTime test = new MutableDateTime(TEST_TIME_NOW); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); MutableDateTime result = (MutableDateTime) ois.readObject(); ois.close(); assertEquals(test, result); }
32. TestMonths#testSerialization()
Project: joda-time
File: TestMonths.java
File: TestMonths.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Months test = Months.THREE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Months result = (Months) ois.readObject(); ois.close(); assertSame(test, result); }
33. TestMonthDay_Basics#testSerialization()
Project: joda-time
File: TestMonthDay_Basics.java
File: TestMonthDay_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { MonthDay test = new MonthDay(5, 6, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); MonthDay result = (MonthDay) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
34. TestMinutes#testSerialization()
Project: joda-time
File: TestMinutes.java
File: TestMinutes.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Minutes test = Minutes.THREE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Minutes result = (Minutes) ois.readObject(); ois.close(); assertSame(test, result); }
35. TestLocalTime_Basics#testSerialization()
Project: joda-time
File: TestLocalTime_Basics.java
File: TestLocalTime_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { LocalTime test = new LocalTime(10, 20, 30, 40, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); LocalTime result = (LocalTime) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
36. TestLocalDate_Basics#testSerialization()
Project: joda-time
File: TestLocalDate_Basics.java
File: TestLocalDate_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { LocalDate test = new LocalDate(1972, 6, 9, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); LocalDate result = (LocalDate) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); }
37. TestLocalDateTime_Basics#testSerialization()
Project: joda-time
File: TestLocalDateTime_Basics.java
File: TestLocalDateTime_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { LocalDateTime test = new LocalDateTime(1972, 6, 9, 10, 20, 30, 40, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); LocalDateTime result = (LocalDateTime) ois.readObject(); ois.close(); assertEquals(test, result); assertTrue(Arrays.equals(test.getValues(), result.getValues())); assertTrue(Arrays.equals(test.getFields(), result.getFields())); assertEquals(test.getChronology(), result.getChronology()); // check deserialization assertTrue(result.isSupported(DateTimeFieldType.dayOfMonth())); }
38. TestInterval_Basics#testSerialization()
Project: joda-time
File: TestInterval_Basics.java
File: TestInterval_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Interval test = new Interval(TEST_TIME1, TEST_TIME2, COPTIC_PARIS); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Interval result = (Interval) ois.readObject(); ois.close(); assertEquals(test, result); }
39. TestInstant_Basics#testSerialization()
Project: joda-time
File: TestInstant_Basics.java
File: TestInstant_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Instant test = new Instant(TEST_TIME_NOW); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Instant result = (Instant) ois.readObject(); ois.close(); assertEquals(test, result); }
40. TestHours#testSerialization()
Project: joda-time
File: TestHours.java
File: TestHours.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Hours test = Hours.SEVEN; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Hours result = (Hours) ois.readObject(); ois.close(); assertSame(test, result); }
41. TestDuration_Basics#testSerialization()
Project: joda-time
File: TestDuration_Basics.java
File: TestDuration_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Duration test = new Duration(123L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Duration result = (Duration) ois.readObject(); ois.close(); assertEquals(test, result); }
42. TestDurationFieldType#doSerialization()
Project: joda-time
File: TestDurationFieldType.java
File: TestDurationFieldType.java
private DurationFieldType doSerialization(DurationFieldType type) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(type); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DurationFieldType result = (DurationFieldType) ois.readObject(); ois.close(); return result; }
43. TestDays#testSerialization()
Project: joda-time
File: TestDays.java
File: TestDays.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { Days test = Days.SEVEN; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Days result = (Days) ois.readObject(); ois.close(); assertSame(test, result); }
44. TestDateTime_Basics#testSerialization()
Project: joda-time
File: TestDateTime_Basics.java
File: TestDateTime_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { DateTime test = new DateTime(TEST_TIME_NOW); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTime result = (DateTime) ois.readObject(); ois.close(); assertEquals(test, result); }
45. TestDateTimeZone#testSerialization2()
Project: joda-time
File: TestDateTimeZone.java
File: TestDateTimeZone.java
//----------------------------------------------------------------------- public void testSerialization2() throws Exception { DateTimeZone zone = DateTimeZone.forID("+01:00"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(zone); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeZone result = (DateTimeZone) ois.readObject(); ois.close(); assertEquals(zone, result); }
46. TestDateTimeZone#testSerialization1()
Project: joda-time
File: TestDateTimeZone.java
File: TestDateTimeZone.java
//----------------------------------------------------------------------- public void testSerialization1() throws Exception { DateTimeZone zone = DateTimeZone.forID("Europe/Paris"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(zone); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeZone result = (DateTimeZone) ois.readObject(); ois.close(); assertSame(zone, result); }
47. TestDateTimeFieldType#doSerialization()
Project: joda-time
File: TestDateTimeFieldType.java
File: TestDateTimeFieldType.java
private DateTimeFieldType doSerialization(DateTimeFieldType type) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(type); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeFieldType result = (DateTimeFieldType) ois.readObject(); ois.close(); return result; }
48. TestDateTimeComparator#testSerialization2()
Project: joda-time
File: TestDateTimeComparator.java
File: TestDateTimeComparator.java
//----------------------------------------------------------------------- public void testSerialization2() throws Exception { DateTimeComparator c = DateTimeComparator.getInstance(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(c); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeComparator result = (DateTimeComparator) ois.readObject(); ois.close(); assertSame(c, result); }
49. TestDateTimeComparator#testSerialization1()
Project: joda-time
File: TestDateTimeComparator.java
File: TestDateTimeComparator.java
//----------------------------------------------------------------------- public void testSerialization1() throws Exception { DateTimeField f = ISO.dayOfYear(); f.toString(); DateTimeComparator c = DateTimeComparator.getInstance(DateTimeFieldType.hourOfDay(), DateTimeFieldType.dayOfYear()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(c); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateTimeComparator result = (DateTimeComparator) ois.readObject(); ois.close(); assertEquals(c, result); }
50. TestDateMidnight_Basics#testSerialization()
Project: joda-time
File: TestDateMidnight_Basics.java
File: TestDateMidnight_Basics.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { DateMidnight test = new DateMidnight(TEST_TIME_NOW_UTC); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DateMidnight result = (DateMidnight) ois.readObject(); ois.close(); assertEquals(test, result); }
51. TestScaledDurationField#testSerialization()
Project: joda-time
File: TestScaledDurationField.java
File: TestScaledDurationField.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { DurationField test = iField; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DurationField result = (DurationField) ois.readObject(); ois.close(); assertEquals(test, result); }
52. TestPreciseDurationField#testSerialization()
Project: joda-time
File: TestPreciseDurationField.java
File: TestPreciseDurationField.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { DurationField test = iField; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DurationField result = (DurationField) ois.readObject(); ois.close(); assertEquals(test, result); }
53. TestMillisDurationField#testSerialization()
Project: joda-time
File: TestMillisDurationField.java
File: TestMillisDurationField.java
//----------------------------------------------------------------------- public void testSerialization() throws Exception { DurationField test = MillisDurationField.INSTANCE; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(test); oos.close(); byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DurationField result = (DurationField) ois.readObject(); ois.close(); assertSame(test, result); }
54. SocketFactoryTest#serializeAndClone()
Project: jdk7u-jdk
File: SocketFactoryTest.java
File: SocketFactoryTest.java
public static Object serializeAndClone(Object o) throws Exception { System.out.println("Serializing object: " + o); final ByteArrayOutputStream obytes = new ByteArrayOutputStream(); final ObjectOutputStream ostr = new ObjectOutputStream(obytes); ostr.writeObject(o); ostr.flush(); System.out.println("Deserializing object"); final ByteArrayInputStream ibytes = new ByteArrayInputStream(obytes.toByteArray()); final ObjectInputStream istr = new ObjectInputStream(ibytes); return istr.readObject(); }
55. SimpleSerialization#main()
Project: jdk7u-jdk
File: SimpleSerialization.java
File: SimpleSerialization.java
public static void main(final String[] args) throws Exception { final Vector<String> v1 = new Vector<>(); v1.add("entry1"); v1.add("entry2"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v1); oos.close(); final byte[] data = baos.toByteArray(); final ByteArrayInputStream bais = new ByteArrayInputStream(data); final ObjectInputStream ois = new ObjectInputStream(bais); final Object deserializedObject = ois.readObject(); ois.close(); if (false == v1.equals(deserializedObject)) { throw new RuntimeException(getFailureText(v1, deserializedObject)); } }
56. SimpleSerialization#main()
Project: jdk7u-jdk
File: SimpleSerialization.java
File: SimpleSerialization.java
public static void main(final String[] args) throws Exception { Hashtable<String, String> h1 = new Hashtable<>(); h1.put("key", "value"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(h1); oos.close(); final byte[] data = baos.toByteArray(); final ByteArrayInputStream bais = new ByteArrayInputStream(data); final ObjectInputStream ois = new ObjectInputStream(bais); final Object deserializedObject = ois.readObject(); ois.close(); if (false == h1.equals(deserializedObject)) { throw new RuntimeException(getFailureText(h1, deserializedObject)); } }
57. SimpleSerialization#main()
Project: jdk7u-jdk
File: SimpleSerialization.java
File: SimpleSerialization.java
public static void main(final String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); enumMap.put(TestEnum.e01, TestEnum.e01.name()); enumMap.put(TestEnum.e04, TestEnum.e04.name()); enumMap.put(TestEnum.e05, TestEnum.e05.name()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(enumMap); oos.close(); final byte[] data = baos.toByteArray(); final ByteArrayInputStream bais = new ByteArrayInputStream(data); final ObjectInputStream ois = new ObjectInputStream(bais); final Object deserializedObject = ois.readObject(); ois.close(); if (false == enumMap.equals(deserializedObject)) { throw new RuntimeException(getFailureText(enumMap, deserializedObject)); } }
58. JavaSerializeDeserializeTestCase#deserialize()
Project: tuscany-sdo
File: JavaSerializeDeserializeTestCase.java
File: JavaSerializeDeserializeTestCase.java
/** * deserializeDataObject is a private method to be called by the other * methods in the ScrenarioLibrary * * @param fileName * @return * @throws IOException * @throws ClassNotFoundException */ public DataObject deserialize(ByteArrayOutputStream baos, HelperContext hc) throws IOException, ClassNotFoundException { //FileInputStream fis = new FileInputStream("temp"); ObjectInputStream input = null; ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(baos.toByteArray()); input = SDOUtil.createObjectInputStream(byteArrayInput, hc); Object object = input.readObject(); input.close(); if (object instanceof DataGraph) return ((DataGraph) object).getRootObject(); else return (DataObject) object; }
59. Utils#decodeJavaObject()
Project: TomP2P
File: Utils.java
File: Utils.java
public static synchronized Object decodeJavaObject(List<ByteBuffer> buffers) throws ClassNotFoundException, IOException { int count = buffers.size(); Vector<InputStream> is = new Vector<InputStream>(count); for (ByteBuffer byteBuffer : buffers) { is.add(createInputStream(byteBuffer)); } SequenceInputStream sis = new SequenceInputStream(is.elements()); ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(sis)); Object obj = ois.readObject(); ois.close(); return obj; }
60. ValidationTrackerImplTest#cloneBySerialiation()
Project: tapestry5
File: ValidationTrackerImplTest.java
File: ValidationTrackerImplTest.java
@SuppressWarnings("unchecked") protected final <T> T cloneBySerialiation(T input) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(input); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); T result = (T) ois.readObject(); ois.close(); return result; }
61. ValidationTrackerImplTest#cloneBySerialiation()
Project: tapestry-5
File: ValidationTrackerImplTest.java
File: ValidationTrackerImplTest.java
@SuppressWarnings("unchecked") protected final <T> T cloneBySerialiation(T input) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(input); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); T result = (T) ois.readObject(); ois.close(); return result; }
62. EhCacheBasedAclCacheTests#testDiskSerializationOfMutableAclObjectInstance()
Project: spring-security
File: EhCacheBasedAclCacheTests.java
File: EhCacheBasedAclCacheTests.java
// SEC-527 @Test public void testDiskSerializationOfMutableAclObjectInstance() throws Exception { // Serialization test File file = File.createTempFile("SEC_TEST", ".object"); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(acl); oos.close(); FileInputStream fis = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(fis); MutableAcl retrieved = (MutableAcl) ois.readObject(); ois.close(); assertThat(retrieved).isEqualTo(acl); Object retrieved1 = FieldUtils.getProtectedFieldValue("aclAuthorizationStrategy", retrieved); assertThat(retrieved1).isEqualTo(null); Object retrieved2 = FieldUtils.getProtectedFieldValue("permissionGrantingStrategy", retrieved); assertThat(retrieved2).isEqualTo(null); }
63. TestUtils#serializeAndDeserialize()
Project: settlers-remake
File: TestUtils.java
File: TestUtils.java
public static <T> T serializeAndDeserialize(T object) throws IOException, ClassNotFoundException { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(byteOutStream); oos.writeObject(object); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteOutStream.toByteArray())); @SuppressWarnings("unchecked") T readList = (T) ois.readObject(); ois.close(); return readList; }
64. AppletServer#lookupName()
Project: scouter
File: AppletServer.java
File: AppletServer.java
private void lookupName(String cmd, InputStream ins, OutputStream outs) throws IOException { ObjectInputStream in = new ObjectInputStream(ins); String name = DataInputStream.readUTF(in); ExportedObject found = (ExportedObject) exportedNames.get(name); outs.write(okHeader); ObjectOutputStream out = new ObjectOutputStream(outs); if (found == null) { logging2(name + "not found."); // error code out.writeInt(-1); out.writeUTF("error"); } else { logging2(name); out.writeInt(found.identifier); out.writeUTF(found.object.getClass().getName()); } out.flush(); out.close(); in.close(); }
65. SerializeUtils#copyObject()
Project: samoa
File: SerializeUtils.java
File: SerializeUtils.java
public static Object copyObject(Serializable obj) throws Exception { ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(baoStream)); out.writeObject(obj); out.flush(); out.close(); byte[] byteArray = baoStream.toByteArray(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new ByteArrayInputStream(byteArray))); Object copy = in.readObject(); in.close(); return copy; }
66. FeedOpsTest#testSyndFeedSerialization()
Project: rome
File: FeedOpsTest.java
File: FeedOpsTest.java
// 1.9 public void testSyndFeedSerialization() throws Exception { final SyndFeed feed1 = getCachedSyndFeed(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(feed1); oos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); final SyndFeed feed2 = (SyndFeed) ois.readObject(); ois.close(); assertTrue(feed1.equals(feed2)); }
67. FeedOpsTest#testWireFeedSerialization()
Project: rome
File: FeedOpsTest.java
File: FeedOpsTest.java
// 1.4 public void testWireFeedSerialization() throws Exception { final WireFeed feed1 = getCachedWireFeed(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(feed1); oos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); final WireFeed feed2 = (WireFeed) ois.readObject(); ois.close(); assertTrue(feed1.equals(feed2)); }
68. FeedOpsTest#testSyndFeedSerialization()
Project: rome
File: FeedOpsTest.java
File: FeedOpsTest.java
// 1.9 public void testSyndFeedSerialization() throws Exception { final SyndFeed feed1 = this.getCachedSyndFeed(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(feed1); oos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); final SyndFeed feed2 = (SyndFeed) ois.readObject(); ois.close(); assertTrue(feed1.equals(feed2)); }
69. FeedOpsTest#testWireFeedSerialization()
Project: rome
File: FeedOpsTest.java
File: FeedOpsTest.java
// 1.4 public void testWireFeedSerialization() throws Exception { final WireFeed feed1 = getCachedWireFeed(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(feed1); oos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); final WireFeed feed2 = (WireFeed) ois.readObject(); ois.close(); assertTrue(feed1.equals(feed2)); }
70. ConnectionURLTest#testSerialization()
Project: qpid-java
File: ConnectionURLTest.java
File: ConnectionURLTest.java
public void testSerialization() throws Exception { String url = "amqp://ritchiem:bob@/test?brokerlist='tcp://localhost:5672'"; ConnectionURL connectionurl = new AMQConnectionURL(url); assertTrue(connectionurl instanceof Serializable); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(connectionurl); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); Object deserializedObject = ois.readObject(); ois.close(); ConnectionURL deserialisedConnectionUrl = (AMQConnectionURL) deserializedObject; assertEquals(connectionurl, deserialisedConnectionUrl); assertEquals(connectionurl.hashCode(), deserialisedConnectionUrl.hashCode()); }
71. AMQDestinationTest#serialiseDeserialiseDestination()
Project: qpid-java
File: AMQDestinationTest.java
File: AMQDestinationTest.java
private Destination serialiseDeserialiseDestination(final Destination dest) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(dest); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); Object deserializedObject = ois.readObject(); ois.close(); return (Destination) deserializedObject; }
72. AMQConnectionFactoryTest#testSerialization()
Project: qpid-java
File: AMQConnectionFactoryTest.java
File: AMQConnectionFactoryTest.java
public void testSerialization() throws Exception { AMQConnectionFactory factory = new AMQConnectionFactory(); assertTrue(factory instanceof Serializable); factory.setConnectionURLString("amqp://guest:guest@clientID/test?brokerlist='tcp://localhost:5672'"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(factory); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); Object deserializedObject = ois.readObject(); ois.close(); AMQConnectionFactory deserialisedFactory = (AMQConnectionFactory) deserializedObject; assertEquals(factory, deserialisedFactory); assertEquals(factory.hashCode(), deserialisedFactory.hashCode()); }
73. SerializationTest#prefixMap()
Project: patricia-trie
File: SerializationTest.java
File: SerializationTest.java
@Test public void prefixMap() throws IOException, ClassNotFoundException { Trie<String, String> trie1 = new PatriciaTrie<String, String>(StringKeyAnalyzer.CHAR); trie1.put("Hello", "World"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(trie1); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); @SuppressWarnings("unchecked") Trie<String, String> trie2 = (Trie<String, String>) ois.readObject(); ois.close(); TestCase.assertEquals(1, trie1.prefixMap("Hello").size()); TestCase.assertEquals(1, trie2.prefixMap("Hello").size()); }
74. SerializationTest#serialize()
Project: patricia-trie
File: SerializationTest.java
File: SerializationTest.java
@Test public void serialize() throws IOException, ClassNotFoundException { Trie<String, String> trie1 = new PatriciaTrie<String, String>(StringKeyAnalyzer.CHAR); trie1.put("Hello", "World"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(trie1); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); @SuppressWarnings("unchecked") Trie<String, String> trie2 = (Trie<String, String>) ois.readObject(); ois.close(); TestCase.assertEquals(trie1.size(), trie2.size()); TestCase.assertEquals("World", trie2.get("Hello")); }
75. TestConfiguration#testSerialization()
Project: PalDB
File: TestConfiguration.java
File: TestConfiguration.java
@Test public void testSerialization() throws Throwable { Configuration c = new Configuration(); c.set("foo", "bar"); c.registerSerializer(new PointSerializer()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); out.writeObject(c); out.close(); bos.close(); byte[] bytes = bos.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bis); Configuration sc = (Configuration) in.readObject(); in.close(); bis.close(); Assert.assertEquals(sc, c); }
76. OChannelBinaryAsynchClient#throwSerializedException()
Project: orientdb
File: OChannelBinaryAsynchClient.java
File: OChannelBinaryAsynchClient.java
private void throwSerializedException(final byte[] serializedException) throws IOException { final OMemoryInputStream inputStream = new OMemoryInputStream(serializedException); final ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); Object throwable = null; try { throwable = objectInputStream.readObject(); } catch (ClassNotFoundException e) { OLogManager.instance().error(this, "Error during exception deserialization", e); throw new OException("Error during exception deserialization: " + e.toString()); } objectInputStream.close(); if (throwable instanceof OException) throw (OException) throwable; else if (throwable instanceof Throwable) // WRAP IT throw new OResponseProcessingException("Exception during response processing.", (Throwable) throwable); else OLogManager.instance().error(this, "Error during exception serialization, serialized exception is not Throwable, exception type is " + (throwable != null ? throwable.getClass().getName() : "null")); }
77. SubjectNullTests#deserializeBuffer()
Project: openjdk
File: SubjectNullTests.java
File: SubjectNullTests.java
/** * Deserialize an object from a byte array. * * @param type The {@code Class} that the serialized file is supposed * to contain. * @param serBuffer The byte array containing the serialized object data * * @return An object of the type specified in the {@code type} parameter */ private static <T> T deserializeBuffer(Class<T> type, byte[] serBuffer) throws IOException, ClassNotFoundException { ByteArrayInputStream bis = new ByteArrayInputStream(serBuffer); ObjectInputStream ois = new ObjectInputStream(bis); T newObj = type.cast(ois.readObject()); ois.close(); bis.close(); return newObj; }
78. SocketFactoryTest#serializeAndClone()
Project: openjdk
File: SocketFactoryTest.java
File: SocketFactoryTest.java
public static Object serializeAndClone(Object o) throws Exception { System.out.println("Serializing object: " + o); final ByteArrayOutputStream obytes = new ByteArrayOutputStream(); final ObjectOutputStream ostr = new ObjectOutputStream(obytes); ostr.writeObject(o); ostr.flush(); System.out.println("Deserializing object"); final ByteArrayInputStream ibytes = new ByteArrayInputStream(obytes.toByteArray()); final ObjectInputStream istr = new ObjectInputStream(ibytes); return istr.readObject(); }
79. SimpleSerialization#main()
Project: openjdk
File: SimpleSerialization.java
File: SimpleSerialization.java
public static void main(final String[] args) throws Exception { final Vector<String> v1 = new Vector<>(); v1.add("entry1"); v1.add("entry2"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v1); oos.close(); final byte[] data = baos.toByteArray(); final ByteArrayInputStream bais = new ByteArrayInputStream(data); final ObjectInputStream ois = new ObjectInputStream(bais); final Object deserializedObject = ois.readObject(); ois.close(); if (false == v1.equals(deserializedObject)) { throw new RuntimeException(getFailureText(v1, deserializedObject)); } }
80. Serialization#serDeser()
Project: openjdk
File: Serialization.java
File: Serialization.java
private static HashSet<Integer> serDeser(HashSet<Integer> hashSet) throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(hashSet); oos.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); HashSet<Integer> result = (HashSet<Integer>) ois.readObject(); oos.close(); ois.close(); return result; }
81. SimpleSerialization#main()
Project: openjdk
File: SimpleSerialization.java
File: SimpleSerialization.java
public static void main(final String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); enumMap.put(TestEnum.e01, TestEnum.e01.name()); enumMap.put(TestEnum.e04, TestEnum.e04.name()); enumMap.put(TestEnum.e05, TestEnum.e05.name()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(enumMap); oos.close(); final byte[] data = baos.toByteArray(); final ByteArrayInputStream bais = new ByteArrayInputStream(data); final ObjectInputStream ois = new ObjectInputStream(bais); final Object deserializedObject = ois.readObject(); ois.close(); if (false == enumMap.equals(deserializedObject)) { throw new RuntimeException(getFailureText(enumMap, deserializedObject)); } }
82. SerializationTest#testArraySerialization()
Project: j2objc
File: SerializationTest.java
File: SerializationTest.java
public void testArraySerialization() throws Exception { String[] names = new String[] { "tom", "dick", "harry" }; assertTrue("array is not Serializable", names instanceof Serializable); assertTrue("array is not instance of Serializable", Serializable.class.isInstance(names)); assertTrue("array cannot be assigned to Serializable", Serializable.class.isAssignableFrom(names.getClass())); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(names); oos.close(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ObjectInputStream ois = new ObjectInputStream(in); String[] result = (String[]) ois.readObject(); ois.close(); assertTrue("arrays not equal", Arrays.equals(names, result)); }
83. SerializationTest#testSerialization()
Project: j2objc
File: SerializationTest.java
File: SerializationTest.java
public void testSerialization() throws IOException, ClassNotFoundException { Greeting greeting = new Greeting("hello", "world", 42); assertEquals("hello, world!", greeting.toString()); assertEquals(42, greeting.n); // Save the greeting to a file. ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TEST_FILE_NAME)); out.writeObject(greeting); out.close(); File binFile = new File(TEST_FILE_NAME); assertTrue(binFile.exists()); // Read back the greeting. ObjectInputStream in = new ObjectInputStream(new FileInputStream(TEST_FILE_NAME)); Greeting greeting2 = (Greeting) in.readObject(); in.close(); assertEquals("hello, world!", greeting.toString()); // 0 because n is transient. assertEquals(0, greeting2.n); }
84. SerializationTester#getDeserilizedObject()
Project: j2objc
File: SerializationTester.java
File: SerializationTester.java
/* * ------------------------------------------------------------------- * Methods * ------------------------------------------------------------------- */ /** * Serialize an object and then deserialize it. * * @param inputObject * the input object * @return the deserialized object */ public static Object getDeserilizedObject(Object inputObject) throws IOException, ClassNotFoundException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(inputObject); oos.close(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); Object outputObject = ois.readObject(); lastOutput = outputObject; ois.close(); return outputObject; }
85. SerializeUtils#copyObject()
Project: incubator-samoa
File: SerializeUtils.java
File: SerializeUtils.java
public static Object copyObject(Serializable obj) throws Exception { ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(baoStream)); out.writeObject(obj); out.flush(); out.close(); byte[] byteArray = baoStream.toByteArray(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new ByteArrayInputStream(byteArray))); Object copy = in.readObject(); in.close(); return copy; }
86. TableSplit#readFields()
Project: incubator-carbondata
File: TableSplit.java
File: TableSplit.java
@Override public void readFields(DataInput in) throws IOException { int sizeLoc = in.readInt(); for (int i = 0; i < sizeLoc; i++) { byte[] b = new byte[in.readInt()]; in.readFully(b); locations.add(new String(b, Charset.defaultCharset())); } byte[] buf = new byte[in.readInt()]; in.readFully(buf); ByteArrayInputStream bis = new ByteArrayInputStream(buf); ObjectInputStream ois = new ObjectInputStream(bis); try { partition = (Partition) ois.readObject(); } catch (ClassNotFoundException e) { LOGGER.error(e, e.getMessage()); } ois.close(); }
87. IgniteUtilsSelfTest#testJavaSerialization()
Project: ignite
File: IgniteUtilsSelfTest.java
File: IgniteUtilsSelfTest.java
/** * @throws Exception If failed. */ public void testJavaSerialization() throws Exception { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(byteOut); objOut.writeObject(new byte[] { 1, 2, 3, 4, 5, 5 }); objOut.flush(); byte[] sBytes = byteOut.toByteArray(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(sBytes)); in.readObject(); }
88. UserRequest#deserialize()
Project: hudson-2.x
File: UserRequest.java
File: UserRequest.java
/*package*/ static Object deserialize(final Channel channel, byte[] data, ClassLoader defaultClassLoader) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois; if (channel.remoteCapability.supportsMultiClassLoaderRPC()) { // this code is coupled with the ObjectOutputStream subtype above ois = new MultiClassLoaderSerializer.Input(channel, in); } else { ois = new ObjectInputStreamEx(in, defaultClassLoader); } return ois.readObject(); }
89. BindingSpeedTest#runSerialUnshared()
Project: h-store
File: BindingSpeedTest.java
File: BindingSpeedTest.java
int runSerialUnshared() throws Exception { fo.reset(); ObjectOutputStream oos = new ObjectOutputStream(fo); oos.writeObject(new Data()); byte[] bytes = fo.toByteArray(); FastInputStream fi = new FastInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(fi); ois.readObject(); return bytes.length; }
90. ModificationTest#shouldSerializeAndUnserializeAllAttributes()
Project: gocd
File: ModificationTest.java
File: ModificationTest.java
@Test public void shouldSerializeAndUnserializeAllAttributes() throws IOException, ClassNotFoundException { HashMap<String, String> additionalData = new HashMap<String, String>(); additionalData.put("foo", "bar"); Modification modification = new Modification("user", "comment", "[email protected]", new Date(), "pipe/1/stage/2", JsonHelper.toJsonString(additionalData)); modification.setPipelineLabel("label-1"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(modification); ObjectInputStream inputStream1 = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); Modification unserializedModification = (Modification) inputStream1.readObject(); assertThat(unserializedModification, is(modification)); assertThat(unserializedModification.getAdditionalData(), is(JsonHelper.toJsonString(additionalData))); modification = new Modification("user", null, "[email protected]", new Date(), "pipe/1/stage/2", JsonHelper.toJsonString(additionalData)); byteArrayOutputStream = new ByteArrayOutputStream(); objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(modification); inputStream1 = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); unserializedModification = (Modification) inputStream1.readObject(); assertThat(unserializedModification.getComment(), is(nullValue())); assertThat(unserializedModification.getAdditionalData(), is(JsonHelper.toJsonString(additionalData))); assertThat(unserializedModification, is(modification)); }
91. SerializeRoundTrip#roundTrip()
Project: encog-java-core
File: SerializeRoundTrip.java
File: SerializeRoundTrip.java
public static Object roundTrip(Object obj) throws IOException, ClassNotFoundException { // first serialize to memory ByteArrayOutputStream memory = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(memory); out.writeObject(obj); out.close(); memory.close(); // now reload ByteArrayInputStream memory2 = new ByteArrayInputStream(memory.toByteArray()); ObjectInputStream in = new ObjectInputStream(memory2); Object result = in.readObject(); in.close(); memory2.close(); // return the result; return result; }
92. SerializationTestSupport#deserialize()
Project: drools
File: SerializationTestSupport.java
File: SerializationTestSupport.java
/** * Deserialize the target object from disk. */ protected Object deserialize(String version, Class clazz) throws Exception { InputStream is = getClass().getResourceAsStream(getSerializedFileName(version, clazz)); ObjectInputStream ois = new ObjectInputStream(is); Object obj = (Object) ois.readObject(); ois.close(); is.close(); return obj; }
93. UnicodeTest#testLargeString()
Project: directory-shared
File: UnicodeTest.java
File: UnicodeTest.java
/** * * Test write/read of a large string (> 64Kb) * * @throws Exception */ @Test public void testLargeString() throws Exception { ObjectOutputStream dos = new ObjectOutputStream(fos); ObjectInputStream dis = new ObjectInputStream(fis); // 65535 * 3 + 17 char[] fill = new char[196622]; // German &ü Arrays.fill(fill, 'ü'); String testString = new String(fill); Unicode.writeUTF(dos, testString); dos.flush(); dos.close(); assertEquals(testString, Unicode.readUTF(dis)); dis.close(); }
94. UnicodeTest#testEmptyString()
Project: directory-shared
File: UnicodeTest.java
File: UnicodeTest.java
/** * * Test write/read of an empty string * * @throws Exception */ @Test public void testEmptyString() throws Exception { ObjectOutputStream dos = new ObjectOutputStream(fos); ObjectInputStream dis = new ObjectInputStream(fis); String testString = ""; Unicode.writeUTF(dos, testString); dos.flush(); dos.close(); assertEquals(testString, Unicode.readUTF(dis)); dis.close(); }
95. UnicodeTest#testNullString()
Project: directory-shared
File: UnicodeTest.java
File: UnicodeTest.java
/** * * Test write/read of a null string * * @throws Exception */ @Test public void testNullString() throws Exception { ObjectOutputStream dos = new ObjectOutputStream(fos); ObjectInputStream dis = new ObjectInputStream(fis); String testString = null; Unicode.writeUTF(dos, testString); dos.flush(); dos.close(); assertEquals(testString, Unicode.readUTF(dis)); dis.close(); }
96. RdnTest#testSimpleRdnThreeValuesUnorderedSerialization()
Project: directory-shared
File: RdnTest.java
File: RdnTest.java
/** * Test serialization of a simple Rdn with three unordered values */ @Test public void testSimpleRdnThreeValuesUnorderedSerialization() throws LdapException, IOException, ClassNotFoundException { Rdn rdn = new Rdn(" B = b + A = a + C = c "); rdn.normalize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(rdn); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Rdn rdn2 = (Rdn) in.readObject(); assertEquals(rdn, rdn2); }
97. RdnTest#testSimpleRdnThreeValuesSerialization()
Project: directory-shared
File: RdnTest.java
File: RdnTest.java
/** * Test serialization of a simple Rdn with three values */ @Test public void testSimpleRdnThreeValuesSerialization() throws LdapException, IOException, ClassNotFoundException { Rdn rdn = new Rdn(" A = a + B = b + C = c "); rdn.normalize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(rdn); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Rdn rdn2 = (Rdn) in.readObject(); assertEquals(rdn, rdn2); }
98. RdnTest#testSimpleRdnOneValueSerialization()
Project: directory-shared
File: RdnTest.java
File: RdnTest.java
/** * Test serialization of a simple Rdn with one value */ @Test public void testSimpleRdnOneValueSerialization() throws LdapException, IOException, ClassNotFoundException { Rdn rdn = new Rdn(" ABC = def "); rdn.normalize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(rdn); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Rdn rdn2 = (Rdn) in.readObject(); assertEquals(rdn, rdn2); }
99. RdnTest#testSimpleRdnNoValueSerialization()
Project: directory-shared
File: RdnTest.java
File: RdnTest.java
/** * Test serialization of a simple Rdn with no value */ @Test public void testSimpleRdnNoValueSerialization() throws LdapException, IOException, ClassNotFoundException { Rdn rdn = new Rdn(" ABC ="); rdn.normalize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(rdn); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Rdn rdn2 = (Rdn) in.readObject(); assertEquals(rdn, rdn2); }
100. RdnTest#testSimpleRdn2Serialization()
Project: directory-shared
File: RdnTest.java
File: RdnTest.java
/** * Test serialization of a simple Rdn */ @Test public void testSimpleRdn2Serialization() throws LdapException, IOException, ClassNotFoundException { Rdn rdn = new Rdn(" ABC = DEF "); rdn.normalize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(rdn); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Rdn rdn2 = (Rdn) in.readObject(); assertEquals(rdn, rdn2); }