@Test public void testCollisionWithoutCollisionManager() { try { PastryNodeImpl node1 = nodes.get(0); UserAgentImpl smith = MockAgentFactory.getAdam(); smith.unlock("adamspass"); EnvelopeVersion envelope1 = node1.createUnencryptedEnvelope("test", smith.getPublicKey(), "Hello World 1!"); EnvelopeVersion envelope2 = node1.createUnencryptedEnvelope("test", smith.getPublicKey(), "Hello World 2!"); node1.storeEnvelopeAsync(envelope1, smith, new StorageStoreResultHandler() { @Override public void onResult(Serializable serializable, int successfulOperations) { System.out.println("Successfully stored artifact " + successfulOperations + " times"); node1.storeEnvelopeAsync(envelope2, smith, new StorageStoreResultHandler() { @Override public void onResult(Serializable serializable, int successfulOperations) { Assert.fail("Exception expected!"); } }, null, new StorageExceptionHandler() { private boolean testComplete = false; @Override public void onException(Exception e) { synchronized (this) { if (e instanceof EnvelopeAlreadyExistsException) { System.out.println("Expected exception '" + e.toString() + "' received."); testComplete = true; asyncTestState = true; } else if (!testComplete) { storageExceptionHandler.onException(e); } } } }); } }, null, storageExceptionHandler); System.out.println("Waiting ..."); for (int n = 1; n <= 100; n++) { if (asyncTestState) { return; } Thread.sleep(100); } Assert.fail("No collision occurred!"); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.toString()); } }
@Override public String toString() { return identifier + "#" + version; }
EnvelopeVersion implements Serializable, XmlAble { @Override public String toString() { return identifier + "#" + version; } }
EnvelopeVersion implements Serializable, XmlAble { @Override public String toString() { return identifier + "#" + version; } private  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey,
			HashMap<PublicKey, byte[]> readerKeys, HashSet<String> readerGroupIds, byte[] rawContent); protected  EnvelopeVersion(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers); protected  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey, Serializable content,
			Collection<?> readers, Set<String> readerGroups); }
EnvelopeVersion implements Serializable, XmlAble { @Override public String toString() { return identifier + "#" + version; } private  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey,
			HashMap<PublicKey, byte[]> readerKeys, HashSet<String> readerGroupIds, byte[] rawContent); protected  EnvelopeVersion(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers); protected  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey, Serializable content,
			Collection<?> readers, Set<String> readerGroups); static String getAgentIdentifier(String agentId); String getIdentifier(); long getVersion(); PublicKey getAuthorPublicKey(); @Override String toString(); boolean isEncrypted(); HashMap<PublicKey, byte[]> getReaderKeys(); Set<String> getReaderGroupIds(); Serializable getContent(); Serializable getContent(AgentContext context); @Override String toXmlString(); static EnvelopeVersion createFromXml(Element rootElement); static EnvelopeVersion createFromXml(String xml); }
EnvelopeVersion implements Serializable, XmlAble { @Override public String toString() { return identifier + "#" + version; } private  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey,
			HashMap<PublicKey, byte[]> readerKeys, HashSet<String> readerGroupIds, byte[] rawContent); protected  EnvelopeVersion(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content); protected  EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers); protected  EnvelopeVersion(String identifier, long version, PublicKey authorPubKey, Serializable content,
			Collection<?> readers, Set<String> readerGroups); static String getAgentIdentifier(String agentId); String getIdentifier(); long getVersion(); PublicKey getAuthorPublicKey(); @Override String toString(); boolean isEncrypted(); HashMap<PublicKey, byte[]> getReaderKeys(); Set<String> getReaderGroupIds(); Serializable getContent(); Serializable getContent(AgentContext context); @Override String toXmlString(); static EnvelopeVersion createFromXml(Element rootElement); static EnvelopeVersion createFromXml(String xml); static final long LATEST_VERSION; static final long NULL_VERSION; static final long START_VERSION; static final long MAX_UPDATE_CYCLES; }