### Question:
AdminCacheUtils { public DataProvider getProvider(final Class clazz) { DataProvider result = providers.get(clazz); if (result == null) { for (DataProvider provider : allProviders) { if (provider.accept(clazz)) { providers.put(clazz, provider); return provider; } } return null; } else { return result; } } private  AdminCacheUtils(); DataProvider getProvider(final Class clazz); final boolean validateKey(final String key); static AdminCache getCache(); static AdminCacheUtils getInstance();  }### Answer:
@Test public void testSimpleGetProvider() throws IOException { DataProvider provider; byte[] data; Object o = "The Man Who Sold The World"; assertNotNull(provider = acu.getProvider(o.getClass())); ByteArrayOutputStream baos = new ByteArrayOutputStream(); provider.writeToStream(o, baos); assertNotNull(data = baos.toByteArray()); assertTrue(o.equals(provider.toInstance(new ByteArrayInputStream(data), o.getClass()))); o = "The Man Who Sold The World".getBytes(); assertNotNull(provider = acu.getProvider(o.getClass())); baos = new ByteArrayOutputStream(); provider.writeToStream(o, baos); assertNotNull(data = baos.toByteArray()); assertArrayEquals((byte[]) o, data); assertArrayEquals((byte[]) o, (byte[]) provider.toInstance( new ByteArrayInputStream(data), byte[].class)); }
@Test public void testGetProvider4CommandModel() throws Exception { DataProvider provider; byte[] data; assertNotNull(provider = acu.getProvider(CommandModel.class)); CachedCommandModel beatles1 = CachedCommandModelTest.createBeateles(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); provider.writeToStream(beatles1, baos); assertNotNull(data = baos.toByteArray()); System.out.println("BTW: " + new String(data, "UTF-8")); CachedCommandModel beatles2 = (CachedCommandModel) provider.toInstance( new ByteArrayInputStream(data), CachedCommandModel.class); beatles2.setETag(null); assertEquals(beatles1.getETag(), CachedCommandModel.computeETag(beatles2)); }