use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testJSINit.
/**
* Check if we can initialize
*/
public void testJSINit() {
Processor processor = new Processor();
processor.setProperty("javascript", "function top() { return 13; }");
assertEquals("16", processor.getReplacer().process("${js;1+2+top()}"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testVersionMask.
public void testVersionMask() throws IOException {
Processor p = new Processor();
assertEquals("1.2.3", p.getReplacer().process("${version;===;1.2.3}"));
assertTrue(p.check());
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testFileNameMacros.
/**
* File name tests
*
* @throws Exception
*/
public void testFileNameMacros() throws Exception {
Processor processor = new Processor();
File a = IO.getFile("testresources/testfilenamemacros.properties");
processor.setProperties(a);
File b = IO.getFile(processor._thisfile(new String[0]));
assertEquals(a, b);
assertEquals("properties", processor.getReplacer()._extension(new String[] { "", "testresources/testfilenamemacros.properties" }));
assertEquals("testfilenamemacros.properties", processor.getReplacer().process("${basename;testfilenamemacros.properties}"));
assertEquals("testfilenamemacros", processor.getReplacer().process("${stem;testfilenamemacros.properties}"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testIf.
public static void testIf() {
Processor p = new Processor();
p.setProperty("a", "aaaa");
Macro m = new Macro(p);
assertEquals("aaaa", m.process("${if;1;$<a>}"));
assertEquals("", m.process("${if;;$<a>}"));
assertEquals("yes", m.process("${if;;$<a>;yes}"));
assertEquals("yes", m.process("${if;false;$<a>;yes}"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testToClassName.
public static void testToClassName() {
Processor p = new Processor();
Macro m = new Macro(p);
assertEquals("com.acme.test.Test", m.process("${toclassname;com/acme/test/Test.class}"));
assertEquals("Test", m.process("$<toclassname;Test.class>"));
assertEquals("Test,com.acme.test.Test", m.process("${toclassname;Test.class, com/acme/test/Test.class}"));
assertEquals("", m.process("$(toclassname;Test)"));
assertEquals("com/acme/test/Test.class", m.process("$[toclasspath;com.acme.test.Test]"));
assertEquals("Test.class", m.process("${toclasspath;Test}"));
assertEquals("Test.class,com/acme/test/Test.class", m.process("${toclasspath;Test,com.acme.test.Test}"));
}
Aggregations