01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.io.serializer.impl;
05:
06: import com.tc.io.serializer.TCObjectInputStream;
07: import com.tc.io.serializer.TCObjectOutputStream;
08: import com.tc.io.serializer.api.StringIndex;
09: import com.tc.objectserver.persistence.impl.NullStringIndexPersistor;
10: import com.tc.objectserver.persistence.impl.StringIndexImpl;
11:
12: import java.io.ByteArrayInputStream;
13: import java.io.ByteArrayOutputStream;
14:
15: import junit.framework.TestCase;
16:
17: public class StringSerializerTest extends TestCase {
18: public void test() throws Exception {
19: StringIndex stringIndex = new StringIndexImpl(
20: new NullStringIndexPersistor());
21: StringSerializer ss = new StringSerializer(stringIndex);
22:
23: ByteArrayOutputStream baout = new ByteArrayOutputStream();
24: for (int i = 0; i < 100; i++) {
25: String test = "This is a nice test string: " + i;
26: TCObjectOutputStream out = new TCObjectOutputStream(baout);
27: ss.serializeTo(test, out);
28: out.flush();
29:
30: ByteArrayInputStream bain = new ByteArrayInputStream(baout
31: .toByteArray());
32: assertEquals(test, ss
33: .deserializeFrom(new TCObjectInputStream(bain)));
34: baout.reset();
35: }
36: }
37: }
|