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:org.jboss.test.security.test.SecurityDomainTolerateUnitTestCase.java

public void testWeb() throws Exception {
    String baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
    HttpClient httpConn = new HttpClient();
    GetMethod indexGet = new GetMethod(baseURLNoAuth + "sdtolerate/");
    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;/*from   ww w.  jav  a2 s .c om*/
    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 + "sdtolerate/j_security_check");
    formPost.addRequestHeader("Referer", baseURLNoAuth + "sdtolerate/login.jsp");
    formPost.addParameter("j_username", this.username);
    formPost.addParameter("j_password", new String(password));
    responseCode = httpConn.executeMethod(formPost);
    String loginResult = formPost.getResponseBodyAsString();
    if (loginResult.indexOf("Encountered a login error") > 0)
        fail("Login Failed");

    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 index.jsp
    Header location = formPost.getResponseHeader("Location");
    String indexURI = location.getValue();
    GetMethod war1Index = new GetMethod(indexURI);
    responseCode = httpConn.executeMethod(war1Index);
    response = war1Index.getStatusText();
    log.debug("responseCode=" + responseCode + ", response=" + response);
    assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
}

From source file:org.switchyard.quickstarts.demo.policy.security.wss.signencrypt.WorkServiceMain.java

private static int getPort(int defaultPort) {
    return Integer.getInteger(PORT, defaultPort);
}

From source file:org.wisdom.maven.pipeline.Pipeline.java

/**
 * Starts the watching./*from  w w  w  .  j a  v  a2 s.c  om*/
 *
 * @return the current pipeline.
 */
public Pipeline watch() {
    // Delete all error reports before starting the watcher.
    error = new File(baseDir, "target/pipeline");
    FileUtils.deleteQuietly(error);
    mojo.getLog().debug("Creating the target/pipeline directory : " + error.mkdirs());

    // Start the watching process.
    watcher = new FileAlterationMonitor(Integer.getInteger("watch.period", 2) * 1000);
    watcher.setThreadFactory(new DefensiveThreadFactory("wisdom-pipeline-watcher", mojo));
    FileAlterationObserver srcObserver = new FileAlterationObserver(new File(baseDir, "src"),
            TrueFileFilter.INSTANCE);
    PipelineWatcher listener = new PipelineWatcher(this);
    srcObserver.addListener(listener);
    watcher.addObserver(srcObserver);

    if (pomFileMonitoring) {
        FileAlterationObserver pomObserver = new FileAlterationObserver(baseDir, new FileFilter() {
            @Override
            public boolean accept(File file) {
                return file.equals(new File(baseDir, "pom.xml"));
            }
        });
        pomObserver.addListener(listener);
        watcher.addObserver(pomObserver);
    }

    try {
        mojo.getLog().info("Start watching " + baseDir.getAbsolutePath());
        watcher.start();
    } catch (Exception e) {
        mojo.getLog().error("Cannot start the watcher", e);
    }
    return this;
}

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

/**
 * Test Successful programmatic login in a servlet
 *
 *///  w  ww  .ja  v  a 2s  . c om
public void testSuccessfulLogin() throws Exception {
    String baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
    String path1 = "war1/TestServlet?operation=login&username=jduke&pass=theduke";
    HttpMethod indexGet = null;
    HttpMethod indexGet2 = null;
    try {
        indexGet = new GetMethod(baseURLNoAuth + path1);
        int responseCode = httpConn.executeMethod(indexGet);
        assertTrue("Get OK(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_OK);
        // assert access to the restricted are of the first application is now allowed.
        SSOBaseCase.checkAccessAllowed(this.httpConn, baseURLNoAuth + "war1/restricted/restricted.html");
        // assert the sso cookie has been created.
        SSOBaseCase.processSSOCookie(this.httpConn.getState(), baseURLNoAuth, baseURLNoAuth);
        // assert access to the second application is allowed.
        SSOBaseCase.checkAccessAllowed(this.httpConn, baseURLNoAuth + "war2/index.html");

        // perform a programmatic logout and assert access is not allowed anymore.
        indexGet2 = new GetMethod(baseURLNoAuth + "war1/TestServlet?operation=logout");
        responseCode = httpConn.executeMethod(indexGet2);
        assertTrue("Get OK(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_OK);
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war1/restricted/restricted.html");
        SSOBaseCase.checkAccessDenied(this.httpConn, baseURLNoAuth + "war2/index.html");
    } finally {
        if (indexGet != null)
            indexGet.releaseConnection();
        if (indexGet2 != null)
            indexGet2.releaseConnection();
    }
}

From source file:org.apache.sling.testing.teleporter.client.DefaultPropertyBasedCustomizer.java

public DefaultPropertyBasedCustomizer() {
    testReadyTimeout = Integer.getInteger(PROPERTY_TESTREADY_TIMEOUT_SECONDS, 12);
    serverUsername = System.getProperty(PROPERTY_SERVER_USERNAME, "admin");
    serverPassword = System.getProperty(PROPERTY_SERVER_PASSWORD, "admin");
    includeDependencyPrefixes = System.getProperty(PROPERTY_INCLUDE_DEPENDENCY_PREFIXES);
    excludeDependencyPrefixes = System.getProperty(PROPERTY_EXCLUDE_DEPENDENCY_PREFIXES);
    embedClasses = System.getProperty(PROPERTY_EMBED_CLASSES);
    baseUrl = System.getProperty(PROPERTY_BASE_URL);
}

From source file:org.apache.cassandra.auth.CassandraRoleManager.java

static int getGensaltLogRounds() {
    int rounds = Integer.getInteger(GENSALT_LOG2_ROUNDS_PROPERTY, 10);
    if (rounds < 4 || rounds > 31)
        throw new ConfigurationException(String.format(
                "Bad value for system property -D%s." + "Please use a value between 4 and 31 inclusively",
                GENSALT_LOG2_ROUNDS_PROPERTY));
    return rounds;
}

From source file:org.apache.jackrabbit.oak.benchmark.AbstractTest.java

protected static int getScale(int def) {
    int scale = Integer.getInteger("scale", 0);
    if (scale == 0) {
        scale = def;//w  ww .  j a va  2s .c  o m
    }
    return scale;
}

From source file:org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor.java

public ApplicationMonitor(Application application)
        throws DependencyBuilderException, TopologyInConsistentException {
    super(application);

    int threadPoolSize = Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE, 100);
    this.executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID,
            threadPoolSize);//from  w  w w.j  a  v  a  2  s . c o m

    //setting the appId for the application
    this.appId = application.getUniqueIdentifier();
}

From source file:org.rifidi.edge.core.sensors.SensorSession.java

/**
 * Get the amount of time to wait on a response before timing out by reading
 * the system property org.rifidi.edge.sessions.timeout. If that property is
 * not available, it returns 5000//ww  w  . j a va 2 s  . c om
 * 
 * @return
 */
public int getTimeout() {
    return Integer.getInteger("org.rifidi.edge.sessions.timeout", 5000);
}

From source file:org.eclipse.scada.utils.osgi.jdbc.pool.PoolConnectionAccessor.java

private static Integer getInteger(final Properties paramProperties, final String name,
        final Integer defaultValue) {
    final Object value = paramProperties.remove(name);
    if (value instanceof Number) {
        logger.debug("Parameter value is numeric - {} -> {}", name, value);
        return ((Number) value).intValue();
    }// w w  w.  java 2 s.c o m

    try {
        if (value != null) {
            logger.debug("Parameter value is string - {} -> {}", name, value);
            return Integer.parseInt(value.toString());
        }
    } catch (final Exception e) {
    }

    final Integer result = Integer.getInteger(name, defaultValue);
    logger.debug("Parameter value via system property - {} -> {}", name, result);
    return result;
}