/** * Called before the tests start. * * <p>Sets up the node and initializes connector and users that can be used throughout the tests. * * @throws Exception */ @BeforeClass public static void startServer() throws Exception { // start node node = LocalNode.newNode(); node.storeAgent(MockAgentFactory.getAdam()); node.launch(); ServiceAgent testService = ServiceAgent.generateNewAgent(testTemplateService, "a pass"); testService.unlockPrivateKey("a pass"); node.registerReceiver(testService); // start connector logStream = new ByteArrayOutputStream(); connector = new WebConnector(true, HTTP_PORT, false, 1000); connector.setLogStream(new PrintStream(logStream)); connector.start(node); Thread.sleep(1000); // wait a second for the connector to become ready testAgent = MockAgentFactory.getAdam(); connector.updateServiceList(); // avoid timing errors: wait for the repository manager to get all services before continuing try { System.out.println("waiting.."); Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } }
@Before public void setUp() throws NoSuchAlgorithmException, L2pSecurityException, CryptoException, MalformedXMLException, IOException { LocalNode.reset(); eve = MockAgentFactory.getEve(); adam = MockAgentFactory.getAdam(); abel = MockAgentFactory.getAbel(); counter = 0; testVariable = false; }
@Before public void startServer() throws Exception { // start Node node = LocalNode.newNode(); adam = MockAgentFactory.getAdam(); adam.unlockPrivateKey(adamsPass); node.storeAgent(adam); node.launch(); ServiceAgent testService = ServiceAgent.createServiceAgent(testServiceClass, "a pass"); testService.unlockPrivateKey("a pass"); node.registerReceiver(testService); // start connector logStream = new ByteArrayOutputStream(); connector = new HttpConnector(); connector.setSocketTimeout(10000); connector.setLogStream(new PrintStream(logStream)); connector.start(node); }