Example usage for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.

Prototype

String[] EMPTY_STRING_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.

Click Source Link

Document

An empty immutable String array.

Usage

From source file:org.jboss.as.test.integration.domain.rbac.JmxRBACProviderHostScopedRolesTestCase.java

private void doOperation(boolean successExpected, String objectName, String operationName,
        JmxManagementInterface jmx) throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName(objectName);
    try {/*w  w  w. j  a v a2s  .  c  o m*/
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}

From source file:org.jboss.as.test.integration.mgmt.access.AbstractJmxNonCoreMBeansSensitivityTestCase.java

private void doOperation(boolean successExpected, String operationName, JmxManagementInterface jmx)
        throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("jboss.test:service=testdeployments");
    try {//from   w  ww . j  av a  2s. c  o m
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}

From source file:org.mangelp.fakeSmtpWeb.httpServer.mvc.Dispatcher.java

/**
 * @param session/*from  www . j a va2  s. co m*/
 * @return
 * @throws ActionHandlerException
 *             If no action handler is found for the detected action
 */
private ActionResult dispathAction(HttpGetRequest request) throws ActionHandlerException {

    String parts[] = StringUtils.strip(request.getRequestUri(), "/").split("/");
    String actionHandlerName = "default";
    String actionName = "default";

    if (parts.length > 1) {
        actionHandlerName = parts[0];
    }

    if (parts.length >= 2) {
        actionName = parts[1];
    }

    String[] subPath = ArrayUtils.EMPTY_STRING_ARRAY;

    if (parts.length > 2) {
        subPath = (String[]) ArrayUtils.subarray(parts, 2, parts.length);
    }

    String logPrefix = String.format("Handle %s$%s:%s", actionHandlerName, actionName,
            StringUtils.join(subPath, "/"));

    Dispatcher.logger.debug(logPrefix);

    AbstractActionHandler actionHandler = this.findActionHandler(actionHandlerName);

    if (actionHandler == null) {
        throw new ActionHandlerException("No action handler found for " + actionHandlerName);
    }

    Actions action = this.findAction(actionName, actionHandler);

    if (action == null) {
        throw new ActionHandlerException("No action found within the action handler for " + actionName);
    }

    ActionResult result = null;

    try {
        ActionInput input = this.createActionInput(request, actionHandler, subPath);
        result = actionHandler.execute(action, input);
    } catch (Throwable t) {
        throw new ActionHandlerException("Failed to execute " + logPrefix, t);
    }

    return result;
}

From source file:org.marketcetera.util.auth.SetterContextCliTest.java

@Test
public void contextBasics() throws Exception {
    Holder<String> holder = new Holder<String>();
    CliSetter<Holder<String>> setter = new TestSetter<Holder<String>>(holder, TestMessages.TEST_USAGE,
            TEST_SHORT_FORM, TEST_LONG_FORM, TestMessages.TEST_DESCRIPTION);

    simpleContextWithName(new CliContext(true, ArrayUtils.EMPTY_STRING_ARRAY), setter, true, true,
            Messages.CLI_NAME, TEST_CLI);
    simpleContextWithName(new CliContext(false, ArrayUtils.EMPTY_STRING_ARRAY), setter, false, true,
            Messages.CLI_NAME, TEST_CLI);
    simpleContextWithName(new CliContext(TestMessages.TEST_CONTEXT, true, ArrayUtils.EMPTY_STRING_ARRAY),
            setter, true, true, TestMessages.TEST_CONTEXT, TEST_CONTEXT);
    simpleContextWithName(new CliContext(TestMessages.TEST_CONTEXT, false, ArrayUtils.EMPTY_STRING_ARRAY),
            setter, false, true, TestMessages.TEST_CONTEXT, TEST_CONTEXT);

    holder.setValue("x");
    simpleContextWithName(new CliContext(true, ArrayUtils.EMPTY_STRING_ARRAY), setter, true, true,
            Messages.CLI_NAME, TEST_CLI);
    simpleContextWithName(new CliContext(false, ArrayUtils.EMPTY_STRING_ARRAY), setter, false, false,
            Messages.CLI_NAME, TEST_CLI);
    simpleContextWithName(new CliContext(TestMessages.TEST_CONTEXT, true, ArrayUtils.EMPTY_STRING_ARRAY),
            setter, true, true, TestMessages.TEST_CONTEXT, TEST_CONTEXT);
    simpleContextWithName(new CliContext(TestMessages.TEST_CONTEXT, false, ArrayUtils.EMPTY_STRING_ARRAY),
            setter, false, false, TestMessages.TEST_CONTEXT, TEST_CONTEXT);

    CliContext context = new CliContext(true, TEST_ARGS);
    assertArrayEquals(TEST_ARGS, context.getArgs());
}

From source file:org.marketcetera.util.auth.SetterContextCliTest.java

@Test
public void setValues() throws Exception {
    Holder<String> userHolder = new Holder<String>(Messages.NO_USER);
    HolderCharArray passwordHolder = new HolderCharArray(Messages.NO_PASSWORD);

    CliSetterString userSetter = new CliSetterString(userHolder,
            new I18NBoundMessage2P(Messages.USER_CLI_USAGE, "u", "username"), "u", "username",
            Messages.USER_DESCRIPTION);//from  w  ww  . j a v  a2 s.c  om
    CliSetterCharArray passwordSetter = new CliSetterCharArray(passwordHolder,
            new I18NBoundMessage2P(Messages.PASSWORD_CLI_USAGE, "p", "password"), "p", "password",
            Messages.PASSWORD_DESCRIPTION);

    CliContext context = new CliContext(false, ArrayUtils.EMPTY_STRING_ARRAY);
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, context.getCommandLine().getArgs());
    assertNull(userHolder.getValue());
    assertNull(passwordHolder.getValueAsString());

    context = new CliContext(false, new String[] { "-p", "firstp" });
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, context.getCommandLine().getArgs());
    assertNull(userHolder.getValue());
    assertEquals("firstp", passwordHolder.getValueAsString());

    context = new CliContext(false, new String[] { "-u", "firstu", "-p", "secondp" });
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, context.getCommandLine().getArgs());
    assertEquals("firstu", userHolder.getValue());
    assertEquals("firstp", passwordHolder.getValueAsString());

    context = new CliContext(false, new String[] { "-u", "secondu" });
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, context.getCommandLine().getArgs());
    assertEquals("firstu", userHolder.getValue());
    assertEquals("firstp", passwordHolder.getValueAsString());

    context = new CliContext(true, new String[] { "-u", StringUtils.EMPTY, "-p", StringUtils.EMPTY });
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, context.getCommandLine().getArgs());
    assertEquals("firstu", userHolder.getValue());
    assertEquals("firstp", passwordHolder.getValueAsString());

    context = new CliContext(TestMessages.TEST_CONTEXT, true,
            new String[] { "-u", "thirdu", "-p", "thirdp", "extra" });
    context.add(userSetter);
    context.add(passwordSetter);
    context.setValues();
    assertArrayEquals(new String[] { "extra" }, context.getCommandLine().getArgs());
    assertEquals("thirdu", userHolder.getValue());
    assertEquals("thirdp", passwordHolder.getValueAsString());
}

From source file:org.marketcetera.util.auth.StandardAuthenticationTest.java

@Test
public void all() {
    authenticate(TEST_ROOT + "auth_user.xml", ArrayUtils.EMPTY_STRING_ARRAY, false, "tu1", null);
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "--p", "tp1" }, true, "tu1", "tp1");
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "-p", "tp1" }, true, "tu1", "tp1");
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "-u", StringUtils.EMPTY, "-p", "tp1" }, true,
            "tu1", "tp1");
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "--password", "tp1" }, true, "tu1", "tp1");
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "-password", "tp1" }, true, "tu1", "tp1");
    authenticate(TEST_ROOT + "auth_user.xml", new String[] { "-u", "tux", "-p", "tpx" }, true, "tux", "tpx");

    authenticate(TEST_ROOT + "auth_pwd.xml", ArrayUtils.EMPTY_STRING_ARRAY, false, null, "tp2");
    authenticate(TEST_ROOT + "auth_pwd.xml", new String[] { "-u", "tu2" }, true, "tu2", "tp2");
    authenticate(TEST_ROOT + "auth_pwd.xml", new String[] { "-u", "tu2", "-p", StringUtils.EMPTY }, true, "tu2",
            "tp2");
    authenticate(TEST_ROOT + "auth_pwd.xml", new String[] { "-u", "tux", "-p", "tpx" }, true, "tux", "tpx");

    authenticate(TEST_ROOT + "auth_both.xml", ArrayUtils.EMPTY_STRING_ARRAY, true, "tu3", "tp3");
    authenticate(TEST_ROOT + "auth_both.xml", new String[] { "-u", "tux", "-p", "tpx" }, true, "tux", "tpx");

    authenticate(TEST_ROOT + "auth_none.xml", ArrayUtils.EMPTY_STRING_ARRAY, false, null, null);
    authenticate(TEST_ROOT + "auth_none.xml", new String[] { "-u", "tux" }, false, "tux", null);
    authenticate(TEST_ROOT + "auth_none.xml", new String[] { "-p", "tpx" }, false, null, "tpx");
    authenticate(TEST_ROOT + "auth_none.xml", new String[] { "-u", "tu3", "-p", "tp3" }, true, "tu3", "tp3");

    authenticate(TEST_ROOT + "auth_blank.xml", ArrayUtils.EMPTY_STRING_ARRAY, false, null, null);
    authenticate(TEST_ROOT + "auth_blank.xml", new String[] { "-u", "tux" }, false, "tux", null);
    authenticate(TEST_ROOT + "auth_blank.xml", new String[] { "-p", "tpx" }, false, null, "tpx");
    authenticate(TEST_ROOT + "auth_blank.xml", new String[] { "-u", "tu3", "-p", "tp3" }, true, "tu3", "tp3");
}

From source file:org.marketcetera.util.auth.StandardAuthenticationTest.java

@Test
public void usage() {
    StandardAuthentication sa = new StandardAuthentication(TEST_ROOT + "auth_none.xml",
            ArrayUtils.EMPTY_STRING_ARRAY);
    ByteArrayOutputStream outputStream;
    CloseableRegistry r = new CloseableRegistry();
    try {//from   ww  w. j  a v a2 s .  c o m
        outputStream = new ByteArrayOutputStream();
        r.register(outputStream);
        PrintStream printStream = new PrintStream(outputStream);
        r.register(printStream);
        sa.printUsage(printStream);
    } finally {
        r.close();
    }
    assertEquals("Spring framework (overriding context)" + SystemUtils.LINE_SEPARATOR
            + " Set 'metc.amq.user' to username in properties file" + SystemUtils.LINE_SEPARATOR
            + " Set 'metc.amq.password' to password in properties file" + SystemUtils.LINE_SEPARATOR
            + SystemUtils.LINE_SEPARATOR + "Command-line options (overriding context)"
            + SystemUtils.LINE_SEPARATOR + " -u or -user followed by username" + SystemUtils.LINE_SEPARATOR
            + " -p or -password followed by password" + SystemUtils.LINE_SEPARATOR + SystemUtils.LINE_SEPARATOR
            + "Console terminal" + SystemUtils.LINE_SEPARATOR + " Type username when prompted"
            + SystemUtils.LINE_SEPARATOR + " Type password when prompted (password won't echo)"
            + SystemUtils.LINE_SEPARATOR + SystemUtils.LINE_SEPARATOR, new String(outputStream.toByteArray()));
}

From source file:org.marketcetera.util.file.SmartLinksDirectoryWalkerTest.java

@Test
public void singleFile() throws Exception {
    ListWalker walker = new ListWalker(false);
    walker.apply(TEST_ROOT + TEST_FILE);
    assertArrayPermutation(new String[] { TEST_FILE }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertEquals(0, walker.getMaxDepth());

    Vector<String> results = new Vector<String>();
    walker = new ListWalker(false);
    walker.apply(TEST_ROOT + TEST_FILE, results);
    assertArrayPermutation(new String[] { TEST_FILE }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertArrayPermutation(new String[] { TEST_FILE }, results.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    assertEquals(0, walker.getMaxDepth());

    walker = new ListWalker(true);
    walker.apply(TEST_ROOT + TEST_FILE);
    assertArrayPermutation(new String[] { TEST_FILE }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertEquals(0, walker.getMaxDepth());

    results = new Vector<String>();
    walker = new ListWalker(true);
    walker.apply(TEST_ROOT + TEST_FILE, results);
    assertArrayPermutation(new String[] { TEST_FILE }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertArrayPermutation(new String[] { TEST_FILE }, results.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    assertEquals(0, walker.getMaxDepth());
}

From source file:org.marketcetera.util.file.SmartLinksDirectoryWalkerTest.java

@Test
public void singleLink() throws Exception {
    assumeTrue(OperatingSystem.LOCAL.isUnix());

    ListWalker walker = new ListWalker(false);
    walker.apply(TEST_ROOT_UNIX + TEST_LINK_PATH);
    assertArrayPermutation(new String[] { TEST_LINK_NAME }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertEquals(0, walker.getMaxDepth());

    Vector<String> results = new Vector<String>();
    walker = new ListWalker(false);
    walker.apply(TEST_ROOT_UNIX + TEST_LINK_PATH, results);
    assertArrayPermutation(new String[] { TEST_LINK_NAME }, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertArrayPermutation(new String[] { TEST_LINK_NAME }, results.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    assertEquals(0, walker.getMaxDepth());

    walker = new ListWalker(true);
    walker.apply(TEST_ROOT_UNIX + TEST_LINK_PATH);
    assertArrayPermutation(new String[] { TEST_LINK_CONTENTS }, walker.getFiles());
    assertArrayPermutation(new String[] { TEST_LINK_NAME }, walker.getDirectories());
    assertEquals(1, walker.getMaxDepth());

    results = new Vector<String>();
    walker = new ListWalker(true);
    walker.apply(TEST_ROOT_UNIX + TEST_LINK_PATH, results);
    assertArrayPermutation(new String[] { TEST_LINK_CONTENTS }, walker.getFiles());
    assertArrayPermutation(new String[] { TEST_LINK_NAME }, walker.getDirectories());
    assertArrayPermutation(new String[] { TEST_LINK_NAME, TEST_LINK_CONTENTS },
            results.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    assertEquals(1, walker.getMaxDepth());
}

From source file:org.marketcetera.util.file.SmartLinksDirectoryWalkerTest.java

@Test
public void nonexistentFiles() throws Exception {
    ListWalker walker = new ListWalker(false);
    walker.apply(TEST_NONEXISTENT_FILE);
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertEquals(-1, walker.getMaxDepth());

    Vector<String> results = new Vector<String>();
    walker = new ListWalker(true);
    walker.apply(TEST_NONEXISTENT_FILE, results);
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getFiles());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, walker.getDirectories());
    assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, results.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    assertEquals(-1, walker.getMaxDepth());
}