use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testFindPath.
public static void testFindPath() throws IOException {
try (Analyzer analyzer = new Analyzer()) {
analyzer.setJar(IO.getFile("jar/asm.jar"));
Macro m = new Macro(analyzer);
assertTrue(m.process("${findname;(.*)\\.class;$1.xyz}").indexOf("FieldVisitor.xyz,") >= 0);
assertTrue(m.process("${findname;(.*)\\.class;$1.xyz}").indexOf("MethodVisitor.xyz,") >= 0);
assertTrue(m.process("${findpath;(.*)\\.class}").indexOf("org/objectweb/asm/AnnotationVisitor.class,") >= 0);
assertTrue(m.process("${findpath;(.*)\\.class}").indexOf("org/objectweb/asm/ByteVector.class, org/objectweb/asm/ClassAdapter.class,") >= 0);
assertEquals("META-INF/MANIFEST.MF", m.process("${findpath;META-INF/MANIFEST.MF}"));
assertEquals("Label.class", m.process("${findname;Label\\..*}"));
assertEquals("Adapter, Visitor, Writer", m.process("${findname;Method(.*)\\.class;$1}"));
}
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testDef.
/**
* Check if we can check for the defintion of a variable
*/
public static void testDef() {
Processor p = new Processor();
p.setProperty("set.1", "1");
p.setProperty("set.2", "2");
Macro m = new Macro(p);
assertEquals("NO", m.process("${if;${def;set.3};YES;NO}"));
assertEquals("YES", m.process("${if;${def;set.1};YES;NO}"));
assertEquals("YES", m.process("${if;${def;set.2};YES;NO}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testParentheses.
public static void testParentheses() {
Processor p = new Processor();
Macro m = new Macro(p);
String value = m.process("$(replace;();(\\(\\));$1)");
assertEquals("()", value);
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testReplace.
/**
* NEW
*/
public static void testReplace() {
Processor p = new Processor();
p.setProperty("specs", "a,b, c, d");
Macro m = new Macro(p);
assertEquals("xay, xby, xcy, xdy", m.process("${replace;${specs};([^\\s]+);x$1y}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testSort.
public static void testSort() {
Processor p = new Processor();
p.setProperty("a", "aaaa");
Macro m = new Macro(p);
assertEquals("aa,bb,cc,dd,ee,ff", m.process("${sort;aa,bb,cc,dd,ee,ff}"));
assertEquals("aa,bb,cc,dd,ee,ff", m.process("${sort;ff,ee,cc,bb,dd,aa}"));
assertEquals("aaaa,bb,cc,dd,ee,ff", m.process("${sort;ff,ee,cc,bb,dd,$<a>}"));
}
Aggregations