use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testIsfile.
public static void testIsfile() {
Processor p = new Processor();
Macro m = new Macro(p);
assertEquals("true", m.process("${isfile;.project}"));
assertEquals("false", m.process("${isfile;thisfiledoesnotexist}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testSystemFail.
public static void testSystemFail() throws Exception {
Processor p = new Processor();
Macro macro = new Macro(p);
String cmd = "${system;mostidioticcommandthatwillsurelyfail}";
assertTrue(macro.process(cmd).startsWith("${system;"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testNestedReplace.
public static void testNestedReplace() {
Processor p = new Processor();
Macro m = new Macro(p);
String value = m.process("xx$(replace;1.2.3-SNAPSHOT;(\\d(\\.\\d)+).*;$1)xx");
System.err.println(p.getWarnings());
assertEquals("xx1.2.3xx", value);
assertEquals("xx1.222.3xx", m.process("xx$(replace;1.222.3-SNAPSHOT;(\\d+(\\.\\d+)+).*;$1)xx"));
p.setProperty("a", "aaaa");
assertEquals("[cac]", m.process("$[replace;acaca;a(.*)a;[$1]]"));
assertEquals("xxx", m.process("$(replace;yxxxy;[^x]*(x+)[^x]*;$1)"));
assertEquals("xxx", m.process("$(replace;yxxxy;([^x]*(x+)[^x]*);$2)"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testProcessNullValue.
public void testProcessNullValue() throws Exception {
try (Processor b = new Processor()) {
Macro m = b.getReplacer();
String tst = m.process(null);
assertEquals("", tst);
assertTrue(b.check());
}
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testPriority.
/**
* Check that variables override macros.
*/
public static void testPriority() {
Processor p = new Processor();
p.setProperty("now", "not set");
Macro macro = new Macro(p);
assertEquals("not set", macro.process("${now}"));
}
Aggregations