XORBinaryManager extends LocalBinaryManager { @Override public void initialize(BinaryManagerDescriptor binaryManagerDescriptor) throws IOException { super.initialize(binaryManagerDescriptor); String key = binaryManagerDescriptor.key; if (key == null || key.length() == 0) { key = "U"; } try { pattern = key.getBytes("UTF-8"); } catch (Exception e) { pattern = new byte[] { 'U' }; } }  @Override void initialize(BinaryManagerDescriptor binaryManagerDescriptor);  }
@Test public void testXORBinaryManagerWithInputStream() throws Exception { XORBinaryManager binaryManager = new XORBinaryManager(); binaryManager.initialize(new BinaryManagerDescriptor()); assertEquals(0, countFiles(binaryManager.getStorageDir())); Binary binary = binaryManager.getBinary(CONTENT_MD5); assertNull(binary); byte[] bytes = CONTENT.getBytes("UTF-8"); binary = binaryManager.getBinary(new ByteArrayInputStream(bytes)); assertNotNull(binary); assertEquals(1, countFiles(binaryManager.getStorageDir())); binary = binaryManager.getBinary(CONTENT_MD5); assertNull(binary); binary = binaryManager.getBinary(XOR_MD5); assertNotNull(binary); assertEquals(bytes.length, binary.getLength()); assertEquals(CONTENT, IOUtils.toString(binary.getStream(), "UTF-8")); }