Example usage for org.apache.commons.lang SystemUtils LINE_SEPARATOR

List of usage examples for org.apache.commons.lang SystemUtils LINE_SEPARATOR

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils LINE_SEPARATOR.

Prototype

String LINE_SEPARATOR

To view the source code for org.apache.commons.lang SystemUtils LINE_SEPARATOR.

Click Source Link

Document

The line.separator System Property.

Usage

From source file:org.marketcetera.orderloader.OrderParserTest.java

static String arrayToLines(String... inLines) {
    StringBuilder builder = new StringBuilder();
    for (String line : inLines) {
        builder.append(line).append(SystemUtils.LINE_SEPARATOR);
    }/*from   ww w  . ja  v  a2s.c  o  m*/
    return builder.toString();
}

From source file:org.marketcetera.ors.security.ORSAdminCLI.java

/**
 * Prints the usage onto the error output stream
 *//*from  www .  j  a va 2  s  .  c  o m*/
private void printUsage() {
    HelpFormatter h = new HelpFormatter();
    final int width = 100;
    final int leftPad = 4;
    final int descPad = 4;
    final String LS = SystemUtils.LINE_SEPARATOR;
    final String l = "-" + OPT_CURRENT_USER + " <" + CLI_ARG_LOGIN_VALUE.getText() + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String p = "-" + OPT_CURRENT_PASSWORD + " <" + CLI_ARG_LOGIN_PASSWORD_VALUE.getText() + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String u = "-" + OPT_OPERATED_USER + " <" + CLI_ARG_USER_NAME_VALUE.getText() + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String up = "-" + OPT_OPERATED_PASSWORD + " <" + CLI_ARG_USER_PASSWORD_VALUE.getText() + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String us = "-" + OPT_OPERATED_SUPERUSER + " " + OPT_YES + '|' + OPT_NO; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String ua = "-" + OPT_OPERATED_ACTIVE + " " + OPT_YES + '|' + OPT_NO; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final String prefix = CMD_NAME + " " + l + p; //$NON-NLS-1$
    final String s = prefix + "--" + CMD_LIST_USERS + " [" + ua + "] " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            LS + prefix + "--" + CMD_ADD_USER + " " + u + " " + up + " [" + us + "] " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            LS + prefix + "--" + CMD_DELETE_USER + " " + u + //$NON-NLS-1$ //$NON-NLS-2$
            LS + prefix + "--" + CMD_RESTORE_USER + " " + u + //$NON-NLS-1$ //$NON-NLS-2$
            LS + prefix + "--" + CMD_CHANGE_PASS + " " + up + " [" + u + "]" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            LS + prefix + "--" + CMD_CHANGE_SUPERUSER + " " + u + " " + us + LS; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final PrintWriter writer = new PrintWriter(err);
    h.printHelp(writer, width, s, CLI_DESC_OPTIONS_HEADER.getText(), options(), leftPad, descPad, "", false); //$NON-NLS-1$
    writer.flush();
}

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

@Test
public void oneContext() throws Exception {
    MyHolder holder1 = new MyHolder(1);
    assertFalse(holder1.isSet());/*ww  w.j  a v  a  2s. co m*/
    MyHolder holder2 = new MyHolder(2, TestMessages.TEST_MESSAGE);
    assertFalse(holder2.isSet());

    MyContext context1 = new MyContext(false, "1");
    MySetter setter11 = new MySetter(holder1);
    context1.add(setter11);
    MySetter setter12 = new MySetter(holder2);
    context1.add(setter12);

    AuthenticationSystem system = new AuthenticationSystem();
    system.add(context1);
    usage(system, "1" + SystemUtils.LINE_SEPARATOR);
    system.setValues();

    assertEquals(1, context1.getCalledCount());
    assertEquals(1, setter11.getCalledCount());
    assertEquals(1, setter12.getCalledCount());

    assertTrue(holder1.isSet());
    assertFalse(holder2.isSet());

    assertEquals(TEST_VALUE, holder1.getValue());

    assertSingleEvent(Level.ERROR, TEST_CATEGORY, TEST_MESSAGE, TEST_LOCATION);
}

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

@Test
public void twoContexts() throws Exception {
    MyHolder holder1 = new MyHolder(1);
    assertFalse(holder1.isSet());//from   ww  w  . j  a  v a 2s.  c  o  m
    MyHolder holder2 = new MyHolder(2, TestMessages.TEST_MESSAGE);
    assertFalse(holder2.isSet());

    MyContext context1 = new MyContext(false, "1");
    MySetter setter11 = new MySetter(holder1);
    context1.add(setter11);
    MySetter setter12 = new MySetter(holder2);
    context1.add(setter12);

    MyContext context2 = new MyContext(false, "2");
    MySetter setter21 = new MySetter(holder1);
    context2.add(setter21);
    MySetter setter22 = new MySetter(holder2);
    context2.add(setter22);

    AuthenticationSystem system = new AuthenticationSystem();
    system.add(context1);
    system.add(context2);
    usage(system, "1" + SystemUtils.LINE_SEPARATOR + "2" + SystemUtils.LINE_SEPARATOR);
    system.setValues();

    assertEquals(1, context1.getCalledCount());
    assertEquals(1, setter11.getCalledCount());
    assertEquals(1, setter12.getCalledCount());

    assertEquals(1, context2.getCalledCount());
    assertEquals(0, setter21.getCalledCount());
    assertEquals(1, setter22.getCalledCount());

    assertTrue(holder1.isSet());
    assertTrue(holder2.isSet());

    assertEquals(TEST_VALUE, holder1.getValue());
    assertEquals(TEST_VALUE, holder2.getValue());

    assertNoEvents();
}

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

@Test
public void threeContexts() throws Exception {
    MyHolder holder1 = new MyHolder(1);
    assertFalse(holder1.isSet());/*ww  w  .j  av  a2  s.  c  o m*/
    MyHolder holder2 = new MyHolder(2, TestMessages.TEST_MESSAGE);
    assertFalse(holder2.isSet());

    MyContext context1 = new MyContext(false, "1");
    MySetter setter11 = new MySetter(holder1);
    context1.add(setter11);
    MySetter setter12 = new MySetter(holder2);
    context1.add(setter12);

    MyContext context2 = new MyContext(false, "2");
    MySetter setter21 = new MySetter(holder1);
    context2.add(setter21);
    MySetter setter22 = new MySetter(holder2);
    context2.add(setter22);

    MyContext context3 = new MyContext(false, "3");
    MySetter setter31 = new MySetter(holder1);
    context3.add(setter31);
    MySetter setter32 = new MySetter(holder2);
    context3.add(setter32);

    AuthenticationSystem system = new AuthenticationSystem();
    system.add(context1);
    system.add(context2);
    system.add(context3);
    usage(system, "1" + SystemUtils.LINE_SEPARATOR + "2" + SystemUtils.LINE_SEPARATOR + "3"
            + SystemUtils.LINE_SEPARATOR);
    system.setValues();

    assertEquals(1, context1.getCalledCount());
    assertEquals(1, setter11.getCalledCount());
    assertEquals(1, setter12.getCalledCount());

    assertEquals(1, context2.getCalledCount());
    assertEquals(0, setter21.getCalledCount());
    assertEquals(1, setter22.getCalledCount());

    assertEquals(0, context3.getCalledCount());
    assertEquals(0, setter31.getCalledCount());
    assertEquals(0, setter32.getCalledCount());

    assertTrue(holder1.isSet());
    assertTrue(holder2.isSet());

    assertEquals(TEST_VALUE, holder1.getValue());
    assertEquals(TEST_VALUE, holder2.getValue());

    assertNoEvents();
}

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

private static <T extends Setter<?>> void setContext(Context<T> context, T setter, boolean override,
        boolean shouldProcess, String name) {
    String usage = name;//from  w  w  w.j  av  a 2 s  .  c o m
    if (override) {
        usage += " " + TEST_OVERRIDES;
    }
    usage += SystemUtils.LINE_SEPARATOR;

    assertArrayEquals(new Object[0], IterableUtils.toArray(context.getSetters()));

    ByteArrayOutputStream outputStream;
    CloseableRegistry r = new CloseableRegistry();
    try {
        outputStream = new ByteArrayOutputStream();
        r.register(outputStream);
        PrintStream printStream = new PrintStream(outputStream);
        r.register(printStream);
        context.printUsage(printStream);
    } finally {
        r.close();
    }
    assertEquals(usage, new String(outputStream.toByteArray()));

    context.add(setter);
    assertArrayEquals(new Object[] { setter }, IterableUtils.toArray(context.getSetters()));

    r = new CloseableRegistry();
    try {
        outputStream = new ByteArrayOutputStream();
        r.register(outputStream);
        PrintStream printStream = new PrintStream(outputStream);
        r.register(printStream);
        context.printUsage(printStream);
    } finally {
        r.close();
    }
    usage += " " + TEST_USAGE + SystemUtils.LINE_SEPARATOR;
    assertEquals(usage, new String(outputStream.toByteArray()));

    assertEquals(override, context.getOverride());
    assertEquals(shouldProcess, context.shouldProcess(setter));
}

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 {/* w  ww . java  2 s  .c  om*/
        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.l10n.MessageComparator.java

/**
 * Returns a textual form of the differences between source and
 * destination.//from  w ww  . ja  v  a  2 s . c  o m
 *
 * @return The differences. This is the empty string if there are
 * no differences.
 */

public String getDifferences() {
    StringBuilder builder = new StringBuilder();
    for (MessageInfoPair mismatch : getMismatches()) {
        if (builder.length() > 0) {
            builder.append(SystemUtils.LINE_SEPARATOR);
        }
        builder.append(Messages.PARAM_COUNT_MISMATCH.getText(mismatch.getSrcInfo().getKey(),
                mismatch.getSrcInfo().getParamCount(), mismatch.getDstInfo().getParamCount()));
    }
    for (MessageInfo info : getExtraSrcInfo()) {
        if (builder.length() > 0) {
            builder.append(SystemUtils.LINE_SEPARATOR);
        }
        builder.append(Messages.EXTRA_SRC_MESSAGE.getText(info.getKey()));
    }
    for (MessageInfo info : getExtraDstInfo()) {
        if (builder.length() > 0) {
            builder.append(SystemUtils.LINE_SEPARATOR);
        }
        builder.append(Messages.EXTRA_DST_MESSAGE.getText(info.getKey()));
    }
    return builder.toString();
}

From source file:org.marketcetera.util.l10n.MessageComparatorTest.java

@Test
public void mismatch() throws Exception {
    MessageComparator comparator = new MessageComparator(MismatchMessages.class);
    assertFalse(comparator.isMatch());/*ww w .  jav a  2s  .  co  m*/

    assertArrayPermutation(new MessageInfoPair[] {
            new MessageInfoPair(new I18NMessageInfo("b1.ttl", 1, MismatchMessages.B1_TTL),
                    new PropertyMessageInfo("b1.ttl", 0, "B Text")) },
            comparator.getMismatches());
    assertArrayPermutation(new MessageInfo[] { new I18NMessageInfo("b3.ttl", -1, MismatchMessages.B3_TTL) },
            comparator.getExtraSrcInfo());
    assertArrayPermutation(new MessageInfo[] { new PropertyMessageInfo("b2.ttl", 1, "B Text {0,date,full}") },
            comparator.getExtraDstInfo());

    assertEquals(
            "Parameter count mismatch: message key 'b1.ttl'; " + "source count is 1; destination count is 0"
                    + SystemUtils.LINE_SEPARATOR + "Extra message in source: key 'b3.ttl'"
                    + SystemUtils.LINE_SEPARATOR + "Extra message in destination: key 'b2.ttl'",
            comparator.getDifferences());
}

From source file:org.marketcetera.util.quickfix.AnalyzedMessageTest.java

@Test
public void empty() throws Exception {
    NewOrderSingle msg = new NewOrderSingle();
    msg.toString();//  ww  w.j  a va  2s. co m
    AnalyzedMessage msgA = new AnalyzedMessage(TEST_DICTIONARY, msg);
    assertNoEvents();
    assertEquals(3, msgA.getHeader().size());
    assertEquals(0, msgA.getBody().size());
    assertEquals(1, msgA.getTrailer().size());
    assertEquals(TEST_HEADER + "5" + SystemUtils.LINE_SEPARATOR + " MsgType [35R] = NewOrderSingle [D]"
            + TEST_FOOTER + "181", msgA.toString());
}