public void testSplit() { ValueHolder<String> value = new Constant<String>("buckminster.tigris.org:/cvs"); // $NON-NLS-1$ String fmtString = "First \"{0}\", second \"{1}\", third \"{2}\", and fourth \"{3}\""; //$NON-NLS-1$ Format fmt = new Format(fmtString); Split split = new Split("\\.|:", 0); // $NON-NLS-1$ split.addValueHolder(value); fmt.addValueHolder(split); String expected = new MessageFormat(fmtString) .format( new String[] { "buckminster", //$NON-NLS-1$ "tigris", "org", "/cvs" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IProperties<String> props = BMProperties.getSystemProperties(); String result = fmt.getValue(props); log(result); assertEquals(expected, result); }
public void testExpressions() { ValueHolder<String> cvsRoot = new Constant<String>(":pserver:${user.name}@buckminster.tigris.org:/cvs"); // $NON-NLS-1$ String fmtString = "First \"{0}\", second \"{1}\", third \"{2}\", and fourth \"{3}\""; //$NON-NLS-1$ Format fmt = new Format(fmtString); Split split = new Split(":|@", 0); // $NON-NLS-1$ Replace rpl = new Replace(); rpl.addMatch(new Replace.Match("^:(.*)$", "$1", false)); // $NON-NLS-1$ //$NON-NLS-2$ rpl.addValueHolder(cvsRoot); split.addValueHolder(rpl); fmt.addValueHolder(split); String expected = new MessageFormat(fmtString) .format( new String[] { "pserver", //$NON-NLS-1$ System.getProperty("user.name"), "buckminster.tigris.org", "/cvs" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IProperties<String> props = BMProperties.getSystemProperties(); String result = fmt.getValue(props); log(result); assertEquals(expected, result); }