### Question:
IOUtils { public static <T> T deserialise(byte[] bytes, boolean compressed) throws IOException, ClassNotFoundException { return deserialise(bytes, compressed, null); } private  IOUtils(); static String getFileContent(String path); static String getFileContent(String path, String encoding); static String getFileContentFromClassPath(Class classInSameModule, String path); static String getFileContentFromClassPath(Class classInSameModule, String path, String encoding); static String readStream(InputStream is); static String readStream(InputStream is, String encoding); static void writeToFile(String fileName, String content); static void closeIfNotNull(Closeable closeable); static void closeIfNotNull(Closeable... o); static long copyStream(InputStream in, OutputStream out); static T deserialise(byte[] bytes, boolean compressed); static T deserialise(byte[] bytes, boolean compressed, ClassLoader classLoader);  }### Answer:
@Test public void testDeserializeValid() throws Exception { final Map validCollection = new HashMap(); validCollection.put("key1", "value1"); OrderedSet value2 = new OrderedSet(); value2.add("A"); value2.add("B"); value2.add("C"); value2.add("D"); validCollection.put("key2", value2); Set<String> value3 = new HashSet<>(); value3.add("value3.1"); value3.add("value3.2"); value3.add("value3.3"); validCollection.put("key3", value3); List<String> value4 = new ArrayList<>(); value4.add("value4.1"); value4.add("value4.2"); value4.add("value4.3"); value4.add("value4.4"); validCollection.put("key4", value4); Map value5 = new HashMap(); value5.put("value2", value2); value5.put("value3", value3); value5.put("value4", value4); validCollection.put("key5", value5); validCollection.put("key6", Collections.emptyMap()); validCollection.put("key7", new Integer(7)); validCollection.put("key8", new Boolean(true)); validCollection.put("key9", new String[]{"1", "2"}); validCollection.put("key10", new Integer[]{1, 2}); validCollection.put("key11", new byte[]{0, 1}); validCollection.put("key12", new char[]{0, 1}); validCollection.put("key13", new short[]{0, 1}); validCollection.put("key14", new int[]{0, 1}); validCollection.put("key15", new long[]{0, 1}); validCollection.put("key16", new float[]{0.0f, 1.0f}); validCollection.put("key17", new double[]{0.0f, 1.0f}); validCollection.put("key18", new boolean[]{true, false}); validCollection.put("key19", new int[][]{{1, 1}, {2, 2}}); final byte[] bytes = getObjectStreamBytes(validCollection, true); Assert.assertNotNull(IOUtils.deserialise(bytes, true)); }
@Test(expectedExceptions = IOException.class) public void testDeserializeInvalid() throws Exception { final Map inValidObject = new HashMap(); inValidObject.put("key1", new File("/tmp/tmpfile.txt")); final byte[] bytes = getObjectStreamBytes(inValidObject, false); IOUtils.deserialise(bytes, false); }