@Test public void test() throws AgentAlreadyRegisteredException, EncodingFailedException, L2pSecurityException, SerializationException, InterruptedException, AgentException, AgentNotKnownException { System.out.println("start: " + new Date()); LocalNode testee = LocalNode.launchNode(); try { testee.registerReceiver(eve); fail("L2pSecurityException expected"); } catch (L2pSecurityException e) { } eve.unlockPrivateKey("evespass"); adam.unlockPrivateKey("adamspass"); testee.registerReceiver(eve); testee.registerReceiver(adam); assertFalse(eve.isLocked()); assertFalse(adam.isLocked()); System.out.println("check1: " + new Date()); testVariable = false; MessageResultListener listener = new MessageResultListener(10000) { public void notifySuccess() { LocalNodeTest.testVariable = true; } }; PingPongContent c = new PingPongContent(); Message m = new Message(adam, eve, c); testee.sendMessage(m, listener); listener.waitForAllAnswers(); assertFalse(listener.isTimedOut()); assertFalse(listener.hasException()); assertTrue(listener.isSuccess()); assertTrue(listener.isFinished()); Message answer = listener.getResults()[0]; answer.open(adam, testee); assertTrue(c.getTimestamp() < ((PingPongContent) answer.getContent()).getTimestamp()); assertTrue(testVariable); }
@Test public void testRegisteringAgents() throws L2pSecurityException, MalformedXMLException, IOException, AgentAlreadyRegisteredException, AgentNotKnownException, AgentException { adam.unlockPrivateKey("adamspass"); // abel.unlockPrivateKey ( "abelspass"); LocalNode testee = LocalNode.launchAgent(adam); // testee.storeAgent(abel); try { testee.storeAgent(abel); fail("L2sSecurityAxception expected"); } catch (L2pSecurityException e) { } try { testee.storeAgent(adam); fail("AgentAlreadyRegistered exception expected"); } catch (AgentAlreadyRegisteredException e) { } abel.unlockPrivateKey("abelspass"); testee.storeAgent(abel); LocalNode testee2 = LocalNode.launchNode(); UserAgent retrieve = (UserAgent) testee2.getAgent(abel.getId()); assertTrue(retrieve.isLocked()); try { testee2.updateAgent(retrieve); fail("SecurtityException expected"); } catch (L2pSecurityException e) { } retrieve.unlockPrivateKey("abelspass"); testee2.updateAgent(retrieve); }