DataSerializer { public static String readString(DataInput in) throws IOException { return StaticSerialization.readString(in); } DataSerializer(); static void writeClass(Class<?> c, DataOutput out); static void writeNonPrimitiveClassName(String className, DataOutput out); static Class<?> readClass(DataInput in); static String readNonPrimitiveClassName(DataInput in); static void writeRegion(Region<?, ?> rgn, DataOutput out); static Region<K, V> readRegion(DataInput in); static void writeDate(Date date, DataOutput out); static Date readDate(DataInput in); static void writeFile(File file, DataOutput out); static File readFile(DataInput in); static void writeInetAddress(InetAddress address, DataOutput out); static InetAddress readInetAddress(DataInput in); static void writeString(String value, DataOutput out); static String readString(DataInput in); static void writeBoolean(Boolean value, DataOutput out); static Boolean readBoolean(DataInput in); static void writeCharacter(Character value, DataOutput out); static Character readCharacter(DataInput in); static void writeByte(Byte value, DataOutput out); static Byte readByte(DataInput in); static void writeShort(Short value, DataOutput out); static Short readShort(DataInput in); static void writeInteger(Integer value, DataOutput out); static Integer readInteger(DataInput in); static void writeLong(Long value, DataOutput out); static Long readLong(DataInput in); static void writeFloat(Float value, DataOutput out); static Float readFloat(DataInput in); static void writeDouble(Double value, DataOutput out); static Double readDouble(DataInput in); static void writePrimitiveBoolean(boolean value, DataOutput out); static boolean readPrimitiveBoolean(DataInput in); static void writePrimitiveByte(byte value, DataOutput out); static byte readPrimitiveByte(DataInput in); static void writePrimitiveChar(char value, DataOutput out); static char readPrimitiveChar(DataInput in); static void writePrimitiveShort(short value, DataOutput out); static short readPrimitiveShort(DataInput in); static void writeUnsignedByte(int value, DataOutput out); static int readUnsignedByte(DataInput in); static void writeUnsignedShort(int value, DataOutput out); static int readUnsignedShort(DataInput in); static void writePrimitiveInt(int value, DataOutput out); static int readPrimitiveInt(DataInput in); static void writePrimitiveLong(long value, DataOutput out); static long readPrimitiveLong(DataInput in); static void writePrimitiveFloat(float value, DataOutput out); static float readPrimitiveFloat(DataInput in); static void writePrimitiveDouble(double value, DataOutput out); static double readPrimitiveDouble(DataInput in); static void writeByteArray(byte[] array, DataOutput out); static void writeByteArray(byte[] array, int len, DataOutput out); static void writeObjectAsByteArray(Object obj, DataOutput out); static byte[] readByteArray(DataInput in); static void writeStringArray(String[] array, DataOutput out); static String[] readStringArray(DataInput in); static void writeShortArray(short[] array, DataOutput out); static short[] readShortArray(DataInput in); static void writeCharArray(char[] array, DataOutput out); static char[] readCharArray(DataInput in); static void writeBooleanArray(boolean[] array, DataOutput out); static boolean[] readBooleanArray(DataInput in); static void writeIntArray(int[] array, DataOutput out); static int[] readIntArray(DataInput in); static void writeLongArray(long[] array, DataOutput out); static long[] readLongArray(DataInput in); static void writeFloatArray(float[] array, DataOutput out); static float[] readFloatArray(DataInput in); static void writeDoubleArray(double[] array, DataOutput out); static double[] readDoubleArray(DataInput in); static void writeObjectArray(Object[] array, DataOutput out); static Object[] readObjectArray(DataInput in); static void writeArrayOfByteArrays(byte[][] array, DataOutput out); static byte[][] readArrayOfByteArrays(DataInput in); static void writeArrayList(ArrayList<?> list, DataOutput out); static ArrayList<E> readArrayList(DataInput in); static void writeVector(Vector<?> list, DataOutput out); static Vector<E> readVector(DataInput in); static void writeStack(Stack<?> list, DataOutput out); static Stack<E> readStack(DataInput in); static void writeLinkedList(LinkedList<?> list, DataOutput out); static LinkedList<E> readLinkedList(DataInput in); static void writeHashSet(HashSet<?> set, DataOutput out); static HashSet<E> readHashSet(DataInput in); static void writeLinkedHashSet(LinkedHashSet<?> set, DataOutput out); static LinkedHashSet<E> readLinkedHashSet(DataInput in); static void writeHashMap(Map<?, ?> map, DataOutput out); static HashMap<K, V> readHashMap(DataInput in); static void writeIdentityHashMap(IdentityHashMap<?, ?> map, DataOutput out); static IdentityHashMap<K, V> readIdentityHashMap(DataInput in); static void writeConcurrentHashMap(ConcurrentHashMap<?, ?> map, DataOutput out); static ConcurrentHashMap<K, V> readConcurrentHashMap(DataInput in); static void writeHashtable(Hashtable<?, ?> map, DataOutput out); static Hashtable<K, V> readHashtable(DataInput in); static void writeTreeMap(TreeMap<?, ?> map, DataOutput out); static TreeMap<K, V> readTreeMap(DataInput in); static void writeLinkedHashMap(Map<?, ?> map, DataOutput out); static LinkedHashMap<K, V> readLinkedHashMap(DataInput in); static void writeTreeSet(TreeSet<?> set, DataOutput out); static TreeSet<E> readTreeSet(DataInput in); static void writeProperties(Properties props, DataOutput out); static Properties readProperties(DataInput in); static void writeObject(Object o, DataOutput out, boolean allowJavaSerialization); static void writeObject(Object o, DataOutput out); @SuppressWarnings("unchecked") static T readObject(final DataInput in); @SuppressWarnings("unchecked") static DataSerializer register(Class<?> c); abstract Class<?>[] getSupportedClasses(); abstract boolean toData(Object o, DataOutput out); abstract Object fromData(DataInput in); abstract int getId(); @Override boolean equals(Object o); @Override int hashCode(); void setEventId(Object/* EventID */ eventId); Object getEventId(); void setContext(Object/* ClientProxyMembershipID */ context); Object getContext(); static void writeEnum(Enum e, DataOutput out); static E readEnum(Class<E> clazz, DataInput in);  }
@Test public void readStringShouldReturnCanonicalEmptyString() throws IOException { byte[] serializedEmptyStringBytes = BlobHelper.serializeToBlob(""); ByteArrayDataInput dataInput1 = new ByteArrayDataInput(); dataInput1.initialize(serializedEmptyStringBytes, null); ByteArrayDataInput dataInput2 = new ByteArrayDataInput(); dataInput2.initialize(serializedEmptyStringBytes, null); String firstRead = DataSerializer.readString(dataInput1); String secondRead = DataSerializer.readString(dataInput2); assertThat(secondRead).isSameAs(firstRead); }