Package net.continuumsecurity.internal.scanner

Source Code of net.continuumsecurity.internal.scanner.PortScannerTest

package net.continuumsecurity.internal.scanner;

import net.continuumsecurity.scanner.PortResult;
import net.continuumsecurity.scanner.PortScanner;
import org.junit.Test;

import java.util.List;
import java.util.concurrent.ExecutionException;

public class PortScannerTest {
    PortScanner scanner;

    @Test
    public void testPortOpen() throws ExecutionException, InterruptedException {
        scanner = new PortScanner("www.google.com",80,80,1,500);
        List<PortResult> results = scanner.scan();
        assert results.size() == 1;
        assert results.get(0).getPort() == 80;
        assert results.get(0).getState() == PortResult.PortState.OPEN;
    }


    @Test
    public void testPortClosed() throws ExecutionException, InterruptedException {
        scanner = new PortScanner("127.0.0.1",65531,65531,1,500);
        List<PortResult> results = scanner.scan();
        assert results.size() == 1;
        assert results.get(0).getPort() == 65531;
        assert results.get(0).getState() == PortResult.PortState.CLOSED;
    }

    @Test
    public void testPortTimedOut() throws ExecutionException, InterruptedException {
        scanner = new PortScanner("www.google.com",83,83,1,500);
        List<PortResult> results = scanner.scan();
        assert results.size() == 1;
        assert results.get(0).getPort() == 83;
        assert results.get(0).getState() == PortResult.PortState.TIMEDOUT;
    }

}
TOP

Related Classes of net.continuumsecurity.internal.scanner.PortScannerTest

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.