Package org.lightfish.business.appmonitoring.boundary

Source Code of org.lightfish.business.appmonitoring.boundary.ApplicationsSocketIT

/*
*
*/
package org.lightfish.business.appmonitoring.boundary;

import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.ContainerProvider;
import javax.websocket.DeploymentException;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.lightfish.business.MessageEndpoint;

/**
*
* @author adam-bien.com
*/
public class ApplicationsSocketIT {

    private MessageEndpoint endpoint;
    private CountDownLatch latch;

    @Before
    public void init() throws DeploymentException, IOException {
        this.latch = new CountDownLatch(1);
        this.endpoint = new MessageEndpoint(this.latch);
        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        ClientEndpointConfig config = ClientEndpointConfig.Builder.create().build();
        String uri = "ws://localhost:8080/lightfish/applications/lightfish";
        System.out.println("Connecting to " + uri);
        Session session = container.connectToServer(this.endpoint, config, URI.create(uri));
    }

    /**
     * Setup updates to 2 seconds before performing this test
     */
    @Test
    public void statisticsArrived() throws InterruptedException {
        assertTrue(this.latch.await(5, TimeUnit.SECONDS));
        String message = endpoint.getMessage();
        assertNotNull(message);
        System.out.println("Message: " + message);
    }

}
TOP

Related Classes of org.lightfish.business.appmonitoring.boundary.ApplicationsSocketIT

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.