### Question:
EncryptionStrategy implements BlobStrategy { public byte[] perform(byte[] blob) throws TokenStrategyFailedException { Reject.ifTrue(blob == null); try { byte[] encryptedBlob = AccessController.doPrivileged(new EncryptAction(blob)); if (debug.messageEnabled()) { debug.message(CoreTokenConstants.DEBUG_HEADER + "Encrypted Token"); } return encryptedBlob; } catch (PrivilegedActionException e) { throw new TokenStrategyFailedException("Failed to encrypt JSON Blob", e); } } @Inject  EncryptionStrategy(@Named(CoreTokenConstants.CTS_DEBUG) Debug debug); byte[] perform(byte[] blob); byte[] reverse(byte[] blob);  }### Answer:
@Test (expectedExceptions = IllegalArgumentException.class) public void shouldPreventNullBlobOnPerform() throws TokenStrategyFailedException { strategy.perform(null); }
@Test public void shouldBeThreadSafe() throws InterruptedException, TokenStrategyFailedException { final EncryptionStrategy encryptionStrategy = new EncryptionStrategy(mock(Debug.class)); final String tokenID1 = "cc402b5b-d532-4b70-8ea8-90ca668c6f8d"; final byte[] data1 = ("{\"expireTime\":[\"1441282506944\"],\"tokenName\":[\"access_token\"]," + "\"scope\":[\"openid\"," + "\"profile\"],\"grant_type\":[\"authorization_code\"],\"clientID\":[\"myOAuth2Client\"]," + "\"parent\":[\"453d68bb-6799-49e9-93be-5796698f0f21\"]," + "\"refreshToken\":[\"0377c0df-e5ee-418d-ad0c-b0a69115949e\"]," + "\"id\":[\"" + tokenID1 + "\"],\"tokenType\":[\"Bearer\"],\"realm\":[\"/\"]," + "\"redirectURI\":[\"http: "\"userName\":[\"amadmin\"]}").getBytes(); final byte[] data1Encrypted = encryptionStrategy.perform(data1); final String tokenID2 = "b487f234-dac4-41a8-9782-f1f4bb30f02b"; final byte[] data2 = ("{\"expireTime\":[\"1441282506944\"],\"tokenName\":[\"access_token\"]," + "\"scope\":[\"openid\"," + "\"profile\"],\"grant_type\":[\"authorization_code\"],\"clientID\":[\"myOAuth2Client\"]," + "\"parent\":[\"453d68bb-6799-49e9-93be-5796698f0f21\"]," + "\"refreshToken\":[\"0377c0df-e5ee-418d-ad0c-b0a69115949e\"]," + "\"id\":[\"" + tokenID2 + "\"],\"tokenType\":[\"Bearer\"],\"realm\":[\"/\"]," + "\"redirectURI\":[\"http: "\"userName\":[\"amadmin\"]}").getBytes(); final byte[] data2Encrypted = encryptionStrategy.perform(data2); assertNotEquals(data1Encrypted, data2Encrypted, "Data 1 and Data2 encryption are equal"); final IssueDetected issueDetected = new IssueDetected(); Thread thread1 = new Thread(new CheckEncryptionStrategy(encryptionStrategy, issueDetected, data1Encrypted, data1)); Thread thread2 = new Thread(new CheckEncryptionStrategy(encryptionStrategy, issueDetected, data2Encrypted, data2)); thread1.setName("Data 1 Thread"); thread2.setName("Data 2 Thread"); thread1.start(); thread2.start(); thread1.join(); thread2.join(); if (issueDetected.error) { fail(issueDetected.message); } }