use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testRange.
public static void testRange() throws Exception {
Processor proc = new Processor();
Macro macro = new Macro(proc);
assertEquals("[1.0,1.0]", macro.process("${range;[==,==];1.0.0}"));
assertEquals("[1.0.0,1.0.1]", macro.process("${range;[===,==+];1.0.0}"));
assertEquals("[0.1.0,0.1.2)", macro.process("${range;[=+0,=++);0.0.1}"));
assertEquals("[0.0.9,0.1.2)", macro.process("${range;[==9,=++);0.0.1}"));
assertEquals(0, proc.getErrors().size());
assertEquals(0, proc.getWarnings().size());
proc.setProperty("@", "1.2.3");
assertEquals("[1.0.0,2)", macro.process("${range;[=00,+)}"));
proc.clear();
macro.process("${range;=+0,=++;0.0.1}");
assertEquals(1, proc.getErrors().size());
assertEquals(1, proc.getWarnings().size());
proc.clear();
macro.process("${range;[+,=)}");
assertEquals(1, proc.getErrors().size());
assertEquals(1, proc.getWarnings().size());
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testBasename.
public static void testBasename() {
Processor p = new Processor();
Macro m = new Macro(p);
assertEquals("biz.aQute.bndlib.tests", m.process("${basename;${dir;.project}}"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method assertTemplate.
void assertTemplate(String result, String template, String params) {
Processor top = new Processor();
top.setProperty("template", template);
top.setProperty("macro", "${template;" + params + "}");
String expanded = top.getProperty("macro");
assertEquals(result, expanded);
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testVersion.
public static void testVersion() throws Exception {
Processor proc = new Processor();
Macro macro = new Macro(proc);
assertEquals("1.0.0", macro.process("${version;===;1.0.0}"));
assertEquals("1.0.1", macro.process("${version;==+;1.0.0}"));
assertEquals("1.1.1", macro.process("${version;=++;1.0.0}"));
assertEquals("2.1.1", macro.process("${version;+++;1.0.0}"));
assertEquals("0.1.1", macro.process("${version;-++;1.0.0}"));
assertEquals("0.1.1", macro.process("${version;-++;1.0.0}"));
assertEquals("0.0.0", macro.process("${version;---;1.1.1}"));
assertEquals("0.0", macro.process("${version;--;1.1.1}"));
assertEquals("1", macro.process("${version;=;1.1.1}"));
assertEquals("[1.1,1.2)", macro.process("[${version;==;1.1.1},${version;=+;1.1.1})"));
assertEquals("1.1", macro.process("${version;==;1.1.1}"));
assertEquals("0.1.0", macro.process("${version;=+0;0.0.1}"));
assertEquals("1.0.0", macro.process("${version;+00;0.1.1}"));
// Test implicit version
proc.setProperty("@", "1.2.3");
assertEquals("[1.2,1.3)", macro.process("[${version;==},${version;=+})"));
assertEquals("1.2", macro.process("${version;==}"));
assertEquals("1.3.0", macro.process("${version;=+0}"));
assertEquals("2.0.0", macro.process("${version;+00}"));
assertEquals(0, proc.getErrors().size());
assertEquals(0, proc.getWarnings().size());
//
// Add the S modifier. If qualifier is SNAPSHOT, it will return a
// maven version
//
assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===S;1.2.3.SNAPSHOT}"));
assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===s;1.2.3.SNAPSHOT}"));
assertEquals("1.2.3.SNAPSHOT", macro.process("${version;====;1.2.3.SNAPSHOT}"));
assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===S;1.2.3.BUILD-SNAPSHOT}"));
assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===s;1.2.3.BUILD-SNAPSHOT}"));
assertEquals("1.2.3.BUILD-SNAPSHOT", macro.process("${version;====;1.2.3.BUILD-SNAPSHOT}"));
assertEquals("1.2.3.X", macro.process("${version;===S;1.2.3.X}"));
assertEquals("1.2.3", macro.process("${version;===s;1.2.3.X}"));
assertEquals("1.2.3.X", macro.process("${version;====;1.2.3.X}"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MacroTest method testVersionMaskWithSetExplicitTarget.
public void testVersionMaskWithSetExplicitTarget() throws IOException {
Processor p = new Processor();
p.setProperty("@", "1.2.3");
assertEquals("1.2.3", p.getReplacer().process("${version;===;${@}}"));
assertTrue(p.check());
}
Aggregations