Search in sources :

Example 1 with WebConnector

use of i5.las2peer.connectors.webConnector.WebConnector in project Distributed-Noracle-Backend by Distributed-Noracle.

the class NoracleServiceTest method beforeTest.

/**
 * Called before a test starts.
 *
 * Sets up the node, initializes connector and adds user agent that can be used throughout the test.
 *
 * @throws Exception
 */
@Before
public void beforeTest() {
    try {
        nodes = TestSuite.launchNetwork(networkSize);
        connector = new WebConnector(null);
        connector.start(nodes.get(0));
        // don't follow redirects, some tests want to test for correct redirect
        // responses
        webClient = ClientBuilder.newBuilder().register(MultiPartFeature.class).property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE).build();
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleService", NoracleService.API_VERSION);
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleAgentService", NoracleService.API_VERSION);
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleSpaceService", NoracleService.API_VERSION);
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleQuestionService", NoracleService.API_VERSION);
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleQuestionRelationService", NoracleService.API_VERSION);
        startService(nodes.get(0), "i5.las2peer.services.noracleService.NoracleVoteSe" + "rvice", NoracleService.API_VERSION);
        testAgent = MockAgentFactory.getAdam();
        testAgent.unlock("adamspass");
        PastryNodeImpl activeNode = nodes.get(0);
        activeNode.storeAgent(testAgent);
        basicAuthHeader = "basic " + Base64.getEncoder().encodeToString((testAgent.getLoginName() + ":" + "adamspass").getBytes(StandardCharsets.UTF_8));
        testAgent2 = MockAgentFactory.getEve();
        testAgent2.unlock("evespass");
        activeNode.storeAgent(testAgent2);
        basicAuthHeader2 = "basic " + Base64.getEncoder().encodeToString((testAgent2.getLoginName() + ":" + "evespass").getBytes(StandardCharsets.UTF_8));
        baseUrl = connector.getHttpEndpoint() + "/" + NoracleService.RESOURCE_NAME + "/v" + NoracleService.API_VERSION;
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.toString());
    }
}
Also used : MultiPartFeature(org.glassfish.jersey.media.multipart.MultiPartFeature) WebConnector(i5.las2peer.connectors.webConnector.WebConnector) PastryNodeImpl(i5.las2peer.p2p.PastryNodeImpl) Before(org.junit.Before)

Aggregations

WebConnector (i5.las2peer.connectors.webConnector.WebConnector)1 PastryNodeImpl (i5.las2peer.p2p.PastryNodeImpl)1 MultiPartFeature (org.glassfish.jersey.media.multipart.MultiPartFeature)1 Before (org.junit.Before)1