Example usage for java.lang Integer getInteger

List of usage examples for java.lang Integer getInteger

Introduction

In this page you can find the example usage for java.lang Integer getInteger.

Prototype

public static Integer getInteger(String nm, Integer val) 

Source Link

Document

Returns the integer value of the system property with the specified name.

Usage

From source file:de.ingrid.interfaces.csw.admin.JettyStarter.java

private static void init() throws Exception {
    WebAppContext webAppContext = new WebAppContext(System.getProperty("jetty.webapp", DEFAULT_WEBAPP_DIR),
            "/");

    Server server = new Server(Integer.getInteger("jetty.port",
            ApplicationProperties.getInteger(ConfigurationKeys.SERVER_PORT, DEFAULT_JETTY_PORT)));
    // fix slow startup time on virtual machine env.
    HashSessionIdManager hsim = new HashSessionIdManager();
    hsim.setRandom(new Random());
    server.setSessionIdManager(hsim);/*ww w .  j a v a2  s . com*/

    Handler[] handlers = new Handler[2];
    handlers[0] = basicSecurityHandler();
    handlers[1] = webAppContext;
    server.setHandlers(handlers);
    server.start();

    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(
            webAppContext.getServletContext(),
            "org.springframework.web.servlet.FrameworkServlet.CONTEXT.springapp");
    CSWServlet cswServlet = (CSWServlet) wac.getBean("CSWServlet");
    CSWTServlet cswtServlet = (CSWTServlet) wac.getBean("CSWTServlet");

    webAppContext.addServlet(new ServletHolder(cswServlet), "/csw");
    webAppContext.addServlet(new ServletHolder(cswtServlet), "/csw-t");
    server.join();

}

From source file:org.jboss.ejb3.test.clusteredservice.unit.HttpUtils.java

public static String getBaseURL(String username, String password) {
    String url = "http://" + username + ":" + password + "@" + System.getProperty("jboss.bind.address") + ":"
            + Integer.getInteger("web.port", 8080) + "/";
    return url;//from  w w w . j  a  v a  2 s  .  co m
}

From source file:org.jboss.test.web.test.ssl.ClientCertJaspiWebUnitTestCase.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    baseHttpsNoAuth = "https://" + getServerHost() + ":" + Integer.getInteger("secureweb.port", 8443) + "/";
}

From source file:org.jboss.test.util.web.HttpUtils.java

public static String getBaseURL(String username, String password) {
    String url = "http://" + username + ":" + password + "@"
            + System.getProperty("jbosstest.server.host", "localhost") + ":"
            + Integer.getInteger("web.port", 8080) + "/";
    return url;/*from  w w w.j  av a  2  s .c  o  m*/
}

From source file:RolloverFileOutputStream.java

public RolloverFileOutputStream(String filename) throws IOException {
    this(filename, true, Integer.getInteger("ROLLOVERFILE_RETAIN_DAYS", 31).intValue());
}

From source file:org.jboss.test.web.test.StatusServletTestCase.java

public void testStatusServlet() throws Exception {
    HttpClient httpConn = new HttpClient();
    String url = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/status?full=true";
    GetMethod getMethod = new GetMethod(url);
    int responseCode = httpConn.executeMethod(getMethod);
    assertEquals("GET " + url + " OK", HttpURLConnection.HTTP_OK, responseCode);
}

From source file:org.jboss.test.web.test.WebProgrammaticLoginTestCase.java

/**
 * Test unsuccessful login/*from  w  w  w .java2s . c o m*/
 * @throws Exception
 */
public void testUnsuccessfulLogin() throws Exception {
    String baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
    String path = "war1/TestServlet";
    // try to perform programmatic auth without supplying login information.
    HttpMethod indexGet = null;
    try {
        indexGet = new GetMethod(baseURLNoAuth + path + "?operation=login");
        int responseCode = httpConn.executeMethod(indexGet);
        assertTrue("Get Error(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR);
        // assert access to the restricted area of the first application is denied.
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war1/restricted/restricted.html");
        // assert access to the second application is not granted, as no successful login
        // was performed (and therefore no ssoid has been set).
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war2/index.html");
    } finally {
        if (indexGet != null)
            indexGet.releaseConnection();
    }
    // try to perform programmatic auth with no valid username/password.
    path = path + "?operation=login&username=dummy&pass=dummy";
    try {
        indexGet = new GetMethod(baseURLNoAuth + path);
        int responseCode = httpConn.executeMethod(indexGet);
        assertTrue("Get Error(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR);
        // assert access to the restricted applications remains denied.
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war1/restricted/restricted.html");
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war2/index.html");
    } finally {
        if (indexGet != null)
            indexGet.releaseConnection();
    }
}

From source file:org.apache.jackrabbit.webdav.simple.LitmusTest.java

public void testLitmus() throws Exception {
    File dir = new File("target", "litmus");
    String litmus = System.getProperty("litmus", "litmus");

    if (Boolean.getBoolean("jackrabbit.test.integration") && isLitmusAvailable(litmus)) {
        final Repository repository = JcrUtils
                .getRepository("jcr-jackrabbit://" + Text.escapePath(dir.getCanonicalPath()));
        Session session = repository.login(); // for the TransientRepository
        try {/*from   w ww .ja  v  a  2 s.  c  o  m*/
            SocketConnector connector = new SocketConnector();
            connector.setHost("localhost");
            connector.setPort(Integer.getInteger("litmus.port", 0));

            Server server = new Server();
            server.addConnector(connector);

            ServletHolder holder = new ServletHolder(new SimpleWebdavServlet() {
                @Override
                public Repository getRepository() {
                    return repository;
                }
            });
            holder.setInitParameter("resource-config", "/config.xml");

            Context context = new Context(server, "/");
            context.setResourceBase("src/test/resources");
            context.addServlet(holder, "/*");
            server.addHandler(context);

            server.start();
            try {
                int port = connector.getLocalPort();
                String url = "http://localhost:" + port + "/default";

                ProcessBuilder builder = new ProcessBuilder(litmus, url, "admin", "admin");
                builder.directory(dir);
                builder.redirectErrorStream();

                assertLitmus(builder, "basic", 0);

                assertLitmus(builder, "http", 0);

                assertLitmus(builder, "props", 0);

                // FIXME: JCR-2637: WebDAV shallow copy test failure
                assertLitmus(builder, "copymove", 1);

                // FIXME: JCR-2638: Litmus locks test failures
                assertLitmus(builder, "locks", 1);
            } finally {
                server.stop();
            }
        } finally {
            session.logout();
        }
    }
}

From source file:org.jboss.test.security.test.WebJASPIFormUnitTestCase.java

protected void setUp() throws Exception {
    super.setUp();
    baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
}

From source file:org.jboss.test.security.test.mapping.RoleMappingWebTestCase.java

/**
 * Test a FORM auth simple webapp. A role of "testRole" will
 * be mapped to Authorized User via the role mapping logic
 *//*w w w  .j  a  v a 2s  . c o m*/
public void testWebAccess() throws Exception {
    baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
    GetMethod indexGet = new GetMethod(baseURLNoAuth + "web-role-map/Secured.jsp");
    int responseCode = httpConn.executeMethod(indexGet);
    String body = indexGet.getResponseBodyAsString();
    assertTrue("Get OK(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_OK);
    assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0);

    HttpState state = httpConn.getState();
    Cookie[] cookies = state.getCookies();
    String sessionID = null;
    for (int c = 0; c < cookies.length; c++) {
        Cookie k = cookies[c];
        if (k.getName().equalsIgnoreCase("JSESSIONID"))
            sessionID = k.getValue();
    }
    getLog().debug("Saw JSESSIONID=" + sessionID);

    // Submit the login form
    PostMethod formPost = new PostMethod(baseURLNoAuth + "web-role-map/j_security_check");
    formPost.addRequestHeader("Referer", baseURLNoAuth + "web-role-map/login.html");
    formPost.addParameter("j_username", "user");
    formPost.addParameter("j_password", "pass");
    responseCode = httpConn.executeMethod(formPost.getHostConfiguration(), formPost, state);
    String response = formPost.getStatusText();
    log.debug("responseCode=" + responseCode + ", response=" + response);
    assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

    //  Follow the redirect to the SecureServlet
    Header location = formPost.getResponseHeader("Location");
    String indexURI = location.getValue();
    GetMethod war1Index = new GetMethod(indexURI);
    responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(), war1Index, state);
    response = war1Index.getStatusText();
    log.debug("responseCode=" + responseCode + ", response=" + response);
    assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
    body = war1Index.getResponseBodyAsString();
    if (body.indexOf("j_security_check") > 0)
        fail("get of " + indexURI + " redirected to login page");
}