com.almende.test.dht.TestAgent.java Source code

Java tutorial

Introduction

Here is the source code for com.almende.test.dht.TestAgent.java

Source

/*
 * Copyright: Almende B.V. (2014), Rotterdam, The Netherlands
 * License: The Apache Software License, Version 2.0
 */
package com.almende.test.dht;

import java.io.IOException;
import java.net.URISyntaxException;

import junit.framework.TestCase;

import org.junit.Test;

import com.almende.eve.agent.AgentConfig;
import com.almende.eve.transport.http.DebugServlet;
import com.almende.eve.transport.http.HttpTransportConfig;
import com.almende.util.jackson.JOM;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * The Class TestAgent.
 */
public class TestAgent extends TestCase {

    /**
     * Test agents.
     * 
     * @throws IOException
     *             Signals that an I/O exception has occurred.
     * @throws URISyntaxException
     *             the URI syntax exception
     * @throws InterruptedException
     *             the interrupted exception
     */
    @Test
    public void testAgent() throws IOException, URISyntaxException, InterruptedException {

        final HttpTransportConfig transportConfig = new HttpTransportConfig();
        transportConfig.setServletUrl("http://localhost:8080/agents/");
        transportConfig.setServletClass(DebugServlet.class.getName());

        transportConfig.setServletLauncher("JettyLauncher");
        final ObjectNode jettyParms = JOM.createObjectNode();
        jettyParms.put("port", 8080);
        transportConfig.set("jetty", jettyParms);

        final AgentConfig config = new AgentConfig("example");
        config.addTransport(transportConfig);

        DHTAgent agent = new DHTAgent();
        agent.setConfig(config);

        Thread.sleep(1000000);
    }
}