Examples of PortScout


Examples of org.rhq.test.PortScout

            //copy the other file from the bundle, too, into the correct location
            FileUtil.copyFile(getFileFromTestClasses("ant-properties/deployed.file"),
                new File(tempDir, "deployed.file"));

            //fire up minimal server
            PortScout portScout = new PortScout();
            int port = 0;
            try {
                port = portScout.getNextFreePort();
            } finally {
                portScout.close();
            }

            undertow = Undertow.builder().addHttpListener(port, "localhost").setHandler(new HttpHandler() {
                @Override
                public void handleRequest(HttpServerExchange httpServerExchange) throws Exception {
View Full Code Here

Examples of org.rhq.test.PortScout

    private UrlReaderTestServer httpServer;
    private String rootUrl;

    @BeforeClass
    public void startWebServer() throws IOException, URISyntaxException {
        PortScout portScout = new PortScout();
        int httpPort = portScout.getNextFreePort();

        Map<String, Object> params = new HashMap<String, Object>();
        params.put(Serve.ARG_PORT, httpPort);
        params.put(Serve.ARG_NOHUP, "nohup");

        httpServer = new UrlReaderTestServer(params, System.err);

        Serve.PathTreeDictionary aliases = new Serve.PathTreeDictionary();
        File root = getRoot();
        aliases.put("/", root);
        aliases.put("/*", root);

        httpServer.setMappingTable(aliases);
        httpServer.addDefaultServlets(null);

        httpServer.addServlet("/auth", new AuthServlet());

        UrlReaderTestServer.AuthRealm authRealm = new UrlReaderTestServer.AuthRealm("auth");
        authRealm.put(TEST_USER, TEST_PASSWORD);

        Serve.PathTreeDictionary realms = new Serve.PathTreeDictionary();
        realms.put("/auth", authRealm);

        httpServer.setRealms(realms);
        portScout.close();

        httpServer.runInBackground();

        rootUrl = InetAddress.getLocalHost().getHostAddress() + ":" + httpPort;
    }
View Full Code Here

Examples of org.rhq.test.PortScout

        }
    }

    public static void addDefaultVariables(Map<String, String> variables, String prefix) {
        InetAddress localhost = determineLocalhost();
        PortScout portScout = new PortScout();
        try {
            checkOrAddDefault(variables, "localhost", localhost.getHostName());
            checkOrAddDefault(variables, "localhost.ip", localhost.getHostAddress());
            checkOrAddDefault(variables, "unresolvable.host", "unreachable.host.com");

            checkOrAddDefault(variables, "port1", getRandomFreePort(portScout));
            checkOrAddDefault(variables, "port2", getRandomFreePort(portScout));
            checkOrAddDefault(variables, "port3", getRandomFreePort(portScout));
            checkOrAddDefault(variables, "port4", getRandomFreePort(portScout));

            if (prefix != null && !prefix.trim().isEmpty()) {
                prefix += ".";
            } else {
                prefix = "";
            }

            checkOrAddDefault(variables, prefix + "snmp.port", getRandomFreePort(portScout));

            checkOrAddDefault(variables, prefix + "listen1", "${port1}");
            checkOrAddDefault(variables, prefix + "listen2", "${port2}");
            checkOrAddDefault(variables, prefix + "listen3", "${port3}");
            checkOrAddDefault(variables, prefix + "listen4", "${port4}");

            checkOrAddDefault(variables, prefix + "vhost1.servername", "${localhost}:${port1}");
            checkOrAddDefault(variables, prefix + "vhost1.urls", "${" + prefix + "vhost1.servername}");
            checkOrAddDefault(variables, prefix + "vhost1.servername.directive", "ServerName ${" + prefix
                + "vhost1.servername}");

            checkOrAddDefault(variables, prefix + "vhost2.servername", "${localhost}:${port2}");
            checkOrAddDefault(variables, prefix + "vhost2.urls", "${" + prefix + "vhost2.servername}");
            checkOrAddDefault(variables, prefix + "vhost2.servername.directive", "ServerName ${" + prefix
                + "vhost2.servername}");

            checkOrAddDefault(variables, prefix + "vhost3.servername", "${localhost}:${port3}");
            checkOrAddDefault(variables, prefix + "vhost3.urls", "${" + prefix + "vhost3.servername}");
            checkOrAddDefault(variables, prefix + "vhost3.servername.directive", "ServerName ${" + prefix
                + "vhost3.servername}");

            checkOrAddDefault(variables, prefix + "vhost4.servername", "${localhost}:${port4}");
            checkOrAddDefault(variables, prefix + "vhost4.urls", "${" + prefix + "vhost4.servername}");
            checkOrAddDefault(variables, prefix + "vhost4.servername.directive", "ServerName ${" + prefix
                + "vhost4.servername}");
        } finally {
            try {
                portScout.close();
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    }
View Full Code Here
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.