Java Code Examples for org.jboss.arquillian.core.spi.Validate#notNullOrEmpty()

The following examples show how to use org.jboss.arquillian.core.spi.Validate#notNullOrEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EAPAppServerProvider.java    From keycloak with Apache License 2.0 6 votes vote down vote up
public EAPAppServerProvider() {
    containerName = System.getProperty("app.server");
    appServerHome = System.getProperty("app.server.home");
    appServerJavaHome = System.getProperty("app.server.java.home");
    appServerPortOffset = System.getProperty("app.server.port.offset");
    managementProtocol = System.getProperty("app.server.management.protocol");
    managementPort = System.getProperty("app.server.management.port");
    startupTimeoutInSeconds = System.getProperty("app.server.startup.timeout");

    Validate.notNullOrEmpty(containerName, "app.server is not set.");
    Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
    Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set.");
    Validate.notNullOrEmpty(appServerPortOffset, "app.server.port.offset is not set.");
    Validate.notNullOrEmpty(managementProtocol, "app.server.management.protocol is not set.");
    Validate.notNullOrEmpty(managementPort, "app.server.management.port is not set.");
    Validate.notNullOrEmpty(startupTimeoutInSeconds, "app.server.startup.timeout is not set.");
}
 
Example 2
Source File: Configuration.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
/**
 * Gets value of {@code name} property. In case a value for such name does not exist or is a null object or an empty string,
 * {@code defaultValue} is returned.
 *
 * @param name         name of a property you want to get the value of
 * @param defaultValue value returned in case {@code name} is a null string or it is empty
 * @return value of a {@code name} property of {@code defaultValue} when {@code name} is null or empty string
 * @throws IllegalArgumentException if {@code name} is a null object or an empty string or if {@code defaultValue} is a null
 *                                  object
 */
public String getProperty(String name, String defaultValue) throws IllegalStateException {
    Validate.notNullOrEmpty(name, "Unable to get the configuration value of null or empty configuration key");
    Validate.notNull(defaultValue, "Unable to set configuration value of " + name + " to null object.");

    final String found = getConfiguration().get(name);

    if (found == null || found.isEmpty()) {
        return defaultValue;
    } else {
        return found;
    }
}
 
Example 3
Source File: EAPAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private String getCrossDCProperties(int number, String portOffset) {
    if (System.getProperty("cache.server") == null || System.getProperty("cache.server").equals("undefined")) {
        return "";
    }
    String cacheHotrodPortString = System.getProperty("cache.server." + number + ".port.offset");
    Validate.notNullOrEmpty(cacheHotrodPortString, "cache.server." + number + ".port.offset is not set.");

    int tcppingPort = 7600 + Integer.parseInt(portOffset);
    int cacheHotrodPort = 11222 + Integer.parseInt(cacheHotrodPortString);
    
    //properties used in servers/app-server/jboss/common/cli/configure-crossdc-config.cli
    return "-Dtcpping.port=" + tcppingPort + " -Dcache.hotrod.port=" + cacheHotrodPort + " ";
}
 
Example 4
Source File: EAPAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addHaNodeContainer(Node group, int number) {
        String portOffset = System.getProperty("app.server." + number + ".port.offset");
        String managementPort = System.getProperty("app.server." + number + ".management.port");

        Validate.notNullOrEmpty(portOffset, "app.server." + number + ".port.offset is not set.");
        Validate.notNullOrEmpty(managementPort, "app.server." + number + ".management.port is not set.");

        Node container = group.createChild("container");
        container.attribute("mode", "manual");
        container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);

        configuration = container.createChild("configuration");
        createChild("enabled", "true");
        createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
        createChild("jbossHome", appServerHome);
        createChild("javaHome", appServerJavaHome);
        //cleanServerBaseDir cannot be used until WFARQ-44 is fixed
//        createChild("cleanServerBaseDir", appServerHome + "/standalone-ha-node-" + number);
        createChild("serverConfig", "standalone-ha.xml");
        createChild("jbossArguments", 
                "-Djboss.server.base.dir=" + appServerHome + "/standalone-ha-node-" + number + " " +
                "-Djboss.socket.binding.port-offset=" + portOffset + " " +
                "-Djboss.node.name=ha-node-" + number + " " +
                getCrossDCProperties(number, portOffset) +
                System.getProperty("adapter.test.props", " ") +
                System.getProperty("kie.maven.settings", " ")
        );
        createChild("javaVmArguments", 
                "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=790" + number + " " +
                System.getProperty("app.server.memory.settings", "") + " " +
                "-Djava.net.preferIPv4Stack=true" + " " +
                System.getProperty("app.server.jvm.args.extra")
        );
        createChild("managementProtocol", managementProtocol);
        createChild("managementPort", managementPort);
        createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
    }
 
Example 5
Source File: WildflyDeprecatedAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private String getCrossDCProperties(int number, String portOffset) {
    if (System.getProperty("cache.server") == null || System.getProperty("cache.server").equals("undefined")) {
        return "";
    }
    String cacheHotrodPortString = System.getProperty("cache.server." + number + ".port.offset");
    Validate.notNullOrEmpty(cacheHotrodPortString, "cache.server." + number + ".port.offset is not set.");

    int tcppingPort = 7600 + Integer.parseInt(portOffset);
    int cacheHotrodPort = 11222 + Integer.parseInt(cacheHotrodPortString);
    
    //properties used in servers/app-server/jboss/common/cli/configure-crossdc-config.cli
    return "-Dtcpping.port=" + tcppingPort + " -Dcache.hotrod.port=" + cacheHotrodPort + " ";
}
 
Example 6
Source File: WildflyDeprecatedAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addHaNodeContainer(Node group, int number) {
        String portOffset = System.getProperty("app.server." + number + ".port.offset");
        String managementPort = System.getProperty("app.server." + number + ".management.port");

        Validate.notNullOrEmpty(portOffset, "app.server." + number + ".port.offset is not set.");
        Validate.notNullOrEmpty(managementPort, "app.server." + number + ".management.port is not set.");

        Node container = group.createChild("container");
        container.attribute("mode", "manual");
        container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);

        configuration = container.createChild("configuration");
        createChild("enabled", "true");
        createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
        createChild("jbossHome", appServerHome);
        createChild("javaHome", appServerJavaHome);
        //cleanServerBaseDir cannot be used until WFARQ-44 is fixed
//        createChild("cleanServerBaseDir", appServerHome + "/standalone-ha-node-" + number);
        createChild("serverConfig", "standalone-ha.xml");
        createChild("jbossArguments", 
                "-Djboss.server.base.dir=" + appServerHome + "/standalone-ha-node-" + number + " " +
                "-Djboss.socket.binding.port-offset=" + portOffset + " " +
                "-Djboss.node.name=ha-node-" + number + " " +
                getCrossDCProperties(number, portOffset) +
                System.getProperty("adapter.test.props", " ") +
                System.getProperty("kie.maven.settings", " ")
        );
        createChild("javaVmArguments", 
                "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=790" + number + " " +
                System.getProperty("app.server.memory.settings", "") + " " +
                "-Djava.net.preferIPv4Stack=true"
        );
        createChild("managementProtocol", managementProtocol);
        createChild("managementPort", managementPort);
        createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
    }
 
Example 7
Source File: WildflyAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private String getCrossDCProperties(int number, String portOffset) {
    if (System.getProperty("cache.server") == null || System.getProperty("cache.server").equals("undefined")) {
        return "";
    }
    String cacheHotrodPortString = System.getProperty("cache.server." + number + ".port.offset");
    Validate.notNullOrEmpty(cacheHotrodPortString, "cache.server." + number + ".port.offset is not set.");

    int tcppingPort = 7600 + Integer.parseInt(portOffset);
    int cacheHotrodPort = 11222 + Integer.parseInt(cacheHotrodPortString);
    
    //properties used in servers/app-server/jboss/common/cli/configure-crossdc-config.cli
    return "-Dtcpping.port=" + tcppingPort + " -Dcache.hotrod.port=" + cacheHotrodPort + " ";
}
 
Example 8
Source File: AbstractTomcatAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public AbstractTomcatAppServerProvider() {
    catalinaHome = System.getProperty("app.server.home");
    bindHttpPort = determineHttpPort();
    jmxPort = System.getProperty("app.server.management.port");
    startupTimeoutInSeconds = System.getProperty("app.server.startup.timeout");

    Validate.notNullOrEmpty(catalinaHome, "app.server.home is not set.");
    Validate.notNullOrEmpty(bindHttpPort, "app.server.http.port is not set.");
    Validate.notNullOrEmpty(jmxPort, "app.server.management.port is not set.");
    Validate.notNullOrEmpty(startupTimeoutInSeconds, "app.server.startup.timeout is not set.");
}
 
Example 9
Source File: Fuse7xAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public Fuse7xAppServerProvider() {
    appServerHome = System.getProperty("app.server.home");
    appServerJavaHome = System.getProperty("app.server.java.home");
    managementUser = System.getProperty("app.server.management.user");
    managementPassword = System.getProperty("app.server.management.password");

    Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
    Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set.");
    Validate.notNullOrEmpty(managementUser, "app.server.management.user is not set.");
    Validate.notNullOrEmpty(managementPassword, "app.server.management.password is not set.");
}
 
Example 10
Source File: WildflyAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public WildflyAppServerProvider() {
    appServerHome = System.getProperty("app.server.home");
    appServerJavaHome = System.getProperty("app.server.java.home");
    appServerPortOffset = System.getProperty("app.server.port.offset");
    managementProtocol = System.getProperty("app.server.management.protocol");
    managementPort = System.getProperty("app.server.management.port");
    startupTimeoutInSeconds = System.getProperty("app.server.startup.timeout");

    Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
    Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set.");
    Validate.notNullOrEmpty(appServerPortOffset, "app.server.port.offset is not set.");
    Validate.notNullOrEmpty(managementProtocol, "app.server.management.protocol is not set.");
    Validate.notNullOrEmpty(managementPort, "app.server.management.port is not set.");
    Validate.notNullOrEmpty(startupTimeoutInSeconds, "app.server.startup.timeout is not set.");
}
 
Example 11
Source File: EAP6AppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addHaNodeContainer(Node group, int number) {
        String portOffset = System.getProperty("app.server." + number + ".port.offset");
        String managementPort = System.getProperty("app.server." + number + ".management.port");

        Validate.notNullOrEmpty(portOffset, "app.server." + number + ".port.offset is not set.");
        Validate.notNullOrEmpty(managementPort, "app.server." + number + ".management.port is not set.");

        Node container = group.createChild("container");
        container.attribute("mode", "manual");
        container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);

        configuration = container.createChild("configuration");
        createChild("enabled", "true");
        createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
        createChild("jbossHome", appServerHome);
        createChild("javaHome", appServerJavaHome);
        //cleanServerBaseDir cannot be used until WFARQ-44 is fixed
//        createChild("cleanServerBaseDir", appServerHome + "/standalone-ha-node-" + number);
        createChild("serverConfig", "standalone-ha.xml");
        createChild("jbossArguments", 
                "-Djboss.server.base.dir=" + appServerHome + "/standalone-ha-node-" + number + " " +
                "-Djboss.socket.binding.port-offset=" + portOffset + " " +
                "-Djboss.node.name=ha-node-" + number + " " +
                System.getProperty("adapter.test.props", " ") +
                System.getProperty("kie.maven.settings", " ")
        );
        createChild("javaVmArguments", 
                "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=790" + number + " " +
                System.getProperty("app.server.memory.settings", "") + " " +
                "-Djava.net.preferIPv4Stack=true"
        );
        createChild("managementProtocol", managementProtocol);
        createChild("managementPort", managementPort);
        createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
    }
 
Example 12
Source File: WildflyAppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addHaNodeContainer(Node group, int number) {
        String portOffset = System.getProperty("app.server." + number + ".port.offset");
        String managementPort = System.getProperty("app.server." + number + ".management.port");

        Validate.notNullOrEmpty(portOffset, "app.server." + number + ".port.offset is not set.");
        Validate.notNullOrEmpty(managementPort, "app.server." + number + ".management.port is not set.");

        Node container = group.createChild("container");
        container.attribute("mode", "manual");
        container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);

        configuration = container.createChild("configuration");
        createChild("enabled", "true");
        createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
        createChild("jbossHome", appServerHome);
        createChild("javaHome", appServerJavaHome);
        //cleanServerBaseDir cannot be used until WFARQ-44 is fixed
//        createChild("cleanServerBaseDir", appServerHome + "/standalone-ha-node-" + number);
        createChild("serverConfig", "standalone-ha.xml");
        createChild("jbossArguments", 
                "-Djboss.server.base.dir=" + appServerHome + "/standalone-ha-node-" + number + " " +
                "-Djboss.socket.binding.port-offset=" + portOffset + " " +
                "-Djboss.node.name=ha-node-" + number + " " +
                getCrossDCProperties(number, portOffset) +
                System.getProperty("adapter.test.props", " ") +
                System.getProperty("kie.maven.settings", " ")
        );
        createChild("javaVmArguments", 
                "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=790" + number + " " +
                System.getProperty("app.server.memory.settings", "") + " " +
                "-Djava.net.preferIPv4Stack=true" + " " +
                System.getProperty("app.server.jvm.args.extra")
        );
        createChild("managementProtocol", managementProtocol);
        createChild("managementPort", managementPort);
        createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
    }
 
Example 13
Source File: EAP6AppServerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public EAP6AppServerProvider() {
    appServerHome = System.getProperty("app.server.home");
    appServerJavaHome = System.getProperty("app.server.java.home");
    appServerPortOffset = System.getProperty("app.server.port.offset");
    managementProtocol = System.getProperty("app.server.management.protocol");
    managementPort = System.getProperty("app.server.management.port");
    startupTimeoutInSeconds = System.getProperty("app.server.startup.timeout");

    Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
    Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set.");
    Validate.notNullOrEmpty(appServerPortOffset, "app.server.port.offset is not set.");
    Validate.notNullOrEmpty(managementProtocol, "app.server.management.protocol is not set.");
    Validate.notNullOrEmpty(managementPort, "app.server.management.port is not set.");
    Validate.notNullOrEmpty(startupTimeoutInSeconds, "app.server.startup.timeout is not set.");
}
 
Example 14
Source File: Configuration.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
/**
 * Gets value of {@code name} property. In case a value for such name does not exist or is a null object or an empty string,
 * {@code defaultValue} is returned.
 *
 * @param name name of a property you want to get the value of
 * @param defaultValue value returned in case {@code name} is a null string or it is empty
 * @return value of a {@code name} property of {@code defaultValue} when {@code name} is null or empty string
 * @throws IllegalArgumentException if {@code name} is a null object or an empty string or if {@code defaultValue} is a null
 *         object
 */
public String getProperty(String name, String defaultValue) throws IllegalStateException {
    Validate.notNullOrEmpty(name, "Unable to get the configuration value of null or empty configuration key");
    Validate.notNull(defaultValue, "Unable to set configuration value of " + name + " to null object.");

    String found = getConfiguration().get(name);
    if (found == null || found.isEmpty()) {
        return defaultValue;
    } else {
        return found;
    }
}
 
Example 15
Source File: FuseUtils.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private static void setUpFuse6() throws IOException {
    log.debug("Going to set up fuse server");

    assertCommand(managementUser, managementPassword,
        "config:edit org.ops4j.pax.url.mvn; " +
        "config:propset org.ops4j.pax.url.mvn.localRepository " + mvnRepoLocal + "; " +
        "config:propset org.ops4j.pax.url.mvn.settings " + mvnLocalSettings + "; " +
        "config:propappend org.ops4j.pax.url.mvn.repositories  " + additionalFuseRepos + "; " +
        "config:update",
    Result.EMPTY);

    assertCommand(managementUser, managementPassword,
        "config:edit jmx.acl.org.apache.karaf.security.jmx; " +
        "config:propappend list* viewer; " +
        "config:propappend set* jmxAdmin; " +
        "config:propappend * jmxAdmin,admin; " +
        "config:update",
    Result.EMPTY);

    assertCommand(managementUser, managementPassword,
        "config:edit org.apache.karaf.management; " +
        "config:propset jmxRealm keycloak;" +
        "config:update",
    Result.EMPTY);

    assertCommand(managementUser, managementPassword,
        "features:addurl mvn:org.keycloak/keycloak-osgi-features/" + projectVersion + "/xml/features; " +
        "features:addurl mvn:org.keycloak.testsuite/fuse-example-keycloak-features/" + projectVersion + "/xml/features; " +
        "features:install keycloak-fuse-6.3-example",
    Result.OK);

    String appServerHome = System.getProperty("app.server.home");
    Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
    assertCommand(managementUser, managementPassword,
        "system-property -p hawtio.roles admin,user; " +
        "system-property -p hawtio.keycloakEnabled true; " +
        "system-property -p hawtio.realm keycloak; " +
        "system-property -p hawtio.keycloakClientConfig file://" + appServerHome + "/etc/keycloak-hawtio-client.json; " +
        "system-property -p hawtio.rolePrincipalClasses org.keycloak.adapters.jaas.RolePrincipal,org.apache.karaf.jaas.boot.principal.RolePrincipal; ",
    Result.EMPTY);

    String output = getCommandOutput(managementUser, managementPassword, "osgi:list | grep hawtio | grep web;");
    Assert.assertThat(output, containsString("hawtio"));
    String id = output.substring(output.indexOf("[") + 1, output.indexOf("]")).trim();
    log.debug("osgi hawtio-web id: " + id);
    assertCommand(managementUser, managementPassword,
        "osgi:restart " + id,
    Result.EMPTY);

    assertCommand(managementUser, managementPassword,
        "config:edit org.apache.karaf.shell; " +
        "config:propset sshRealm keycloak; " +
        "config:update",
    Result.EMPTY);

    log.debug("Fuse server should be ready");
}
 
Example 16
Source File: DesktopVideoRecorder.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
@Override
public void startRecording(String fileName) {
    Validate.notNullOrEmpty(fileName, "File name is a null object or an empty string!");
    startRecording(new File(fileName));
}
 
Example 17
Source File: GovernorConfiguration.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
public void setIgnoreOnly(String ignoreOnly) {
    Validate.notNullOrEmpty(ignoreOnly, "ignoreOnly property can not be a null object nor an empty String.");
    setProperty("ignoreOnly", ignoreOnly);
}
 
Example 18
Source File: RedmineGovernorClient.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
private void initializeRedmineManager(String uri, String apiKey) {
    Validate.notNullOrEmpty(uri, "Redmine uri must be specified.");
    Validate.notNullOrEmpty(apiKey, "User apikey must be provided.");

    redmineManager = RedmineManagerFactory.createWithApiKey(uri, apiKey);
}
 
Example 19
Source File: Configuration.java    From arquillian-recorder with Apache License 2.0 3 votes vote down vote up
/**
 * Sets some property.
 *
 * @param name acts as a key
 * @param value value assigned to the {@code name} key
 * @throws IllegalArgumentException if {@code name} is null or empty or {@code value} is null
 */
public void setProperty(String name, String value) {
    Validate.notNullOrEmpty(name, "Name of property can not be a null object nor an empty string!");
    Validate.notNull(value, "Value of property can not be a null object!");

    configuration.put(name, value);
}
 
Example 20
Source File: Configuration.java    From arquillian-governor with Apache License 2.0 3 votes vote down vote up
/**
 * Sets some property.
 *
 * @param name  acts as a key
 * @param value
 * @throws IllegalArgumentException if {@code name} is null or empty or {@code value} is null
 */
public void setProperty(String name, String value) {
    Validate.notNullOrEmpty(name, "Name of property can not be a null object nor an empty string!");
    Validate.notNull(value, "Value of property can not be a null object!");

    configuration.put(name, value);
}