@Test public void testServiceDiscovery() throws CryptoException, InternalSecurityException, AgentAlreadyRegisteredException, AgentException, MalformedXMLException, IOException, EncodingFailedException, SerializationException, InterruptedException, TimeoutException, AgentAccessDeniedException { LocalNode node = new LocalNodeManager().launchNode(); node.startService(ServiceNameVersion.fromString("i5.las2peer.api.TestService@1.0"), "a pass"); node.startService(ServiceNameVersion.fromString("i5.las2peer.api.TestService@1.1"), "a pass"); node.startService(ServiceNameVersion.fromString("i5.las2peer.api.TestService@2.0"), "a pass"); node.startService(ServiceNameVersion.fromString("i5.las2peer.api.TestService2@1.0"), "a pass"); PassphraseAgentImpl userAgent = MockAgentFactory.getAdam(); userAgent.unlock("adamspass"); node.registerReceiver(userAgent); Message request = new Message(userAgent, ServiceAgentImpl.serviceNameToTopicId("i5.las2peer.api.TestService"), new ServiceDiscoveryContent(ServiceNameVersion.fromString("i5.las2peer.api.TestService@1"), false), 30000); Message[] answers = node.sendMessageAndCollectAnswers(request, 4); assertEquals(2, answers.length); boolean found10 = false, found11 = false; for (Message m : answers) { m.open(userAgent, node); ServiceDiscoveryContent c = (ServiceDiscoveryContent) m.getContent(); if (c.getService().getVersion().toString().equals("1.0")) { found10 = true; } else if (c.getService().getVersion().toString().equals("1.1")) { found11 = true; } } assertTrue(found10); assertTrue(found11); request = new Message(userAgent, ServiceAgentImpl.serviceNameToTopicId("i5.las2peer.api.TestService"), new ServiceDiscoveryContent(ServiceNameVersion.fromString("i5.las2peer.api.TestService@1.1"), true), 30000); answers = node.sendMessageAndCollectAnswers(request, 4); assertEquals(1, answers.length); answers[0].open(userAgent, node); ServiceDiscoveryContent c = (ServiceDiscoveryContent) answers[0].getContent(); assertTrue(c.getService().getVersion().toString().equals("1.1")); }
public static long serviceNameToTopicId(String service) { return SimpleTools.longHash(service); }
ServiceAgentImpl extends PassphraseAgentImpl implements ServiceAgent { public static long serviceNameToTopicId(String service) { return SimpleTools.longHash(service); } }
ServiceAgentImpl extends PassphraseAgentImpl implements ServiceAgent { public static long serviceNameToTopicId(String service) { return SimpleTools.longHash(service); } protected  ServiceAgentImpl(ServiceNameVersion service, KeyPair pair, String passphrase, byte[] salt); protected  ServiceAgentImpl(ServiceNameVersion service, PublicKey pubKey, byte[] encodedPrivate, byte[] salt); }
ServiceAgentImpl extends PassphraseAgentImpl implements ServiceAgent { public static long serviceNameToTopicId(String service) { return SimpleTools.longHash(service); } protected  ServiceAgentImpl(ServiceNameVersion service, KeyPair pair, String passphrase, byte[] salt); protected  ServiceAgentImpl(ServiceNameVersion service, PublicKey pubKey, byte[] encodedPrivate, byte[] salt); @Override ServiceNameVersion getServiceNameVersion(); @Override String toXmlString(); @Override void receiveMessage(Message m, AgentContext c); @Override void notifyUnregister(); @Deprecated static ServiceAgentImpl generateNewAgent(String forService, String passPhrase); static ServiceAgentImpl createServiceAgent(ServiceNameVersion service, String passphrase); @Deprecated static ServiceAgentImpl createServiceAgent(String serviceName, String passphrase); static ServiceAgentImpl createFromXml(String xml); static ServiceAgentImpl createFromXml(Element rootElement); @Override void notifyRegistrationTo(Node node); static long serviceNameToTopicId(String service); boolean isRunning(); Object invoke(String method, Object[] parameters); Serializable handle(RMITask task, AgentContext agentContext); Service getServiceInstance(); }
ServiceAgentImpl extends PassphraseAgentImpl implements ServiceAgent { public static long serviceNameToTopicId(String service) { return SimpleTools.longHash(service); } protected  ServiceAgentImpl(ServiceNameVersion service, KeyPair pair, String passphrase, byte[] salt); protected  ServiceAgentImpl(ServiceNameVersion service, PublicKey pubKey, byte[] encodedPrivate, byte[] salt); @Override ServiceNameVersion getServiceNameVersion(); @Override String toXmlString(); @Override void receiveMessage(Message m, AgentContext c); @Override void notifyUnregister(); @Deprecated static ServiceAgentImpl generateNewAgent(String forService, String passPhrase); static ServiceAgentImpl createServiceAgent(ServiceNameVersion service, String passphrase); @Deprecated static ServiceAgentImpl createServiceAgent(String serviceName, String passphrase); static ServiceAgentImpl createFromXml(String xml); static ServiceAgentImpl createFromXml(Element rootElement); @Override void notifyRegistrationTo(Node node); static long serviceNameToTopicId(String service); boolean isRunning(); Object invoke(String method, Object[] parameters); Serializable handle(RMITask task, AgentContext agentContext); Service getServiceInstance();  }