Search in sources :

Example 71 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testGlobToRegExp.

public void testGlobToRegExp() {
    Processor p = new Processor();
    Macro m = p.getReplacer();
    assertEquals(".*x", m.process("${glob;*x}"));
    assertEquals("(?!.*x)", m.process("${glob;!*x}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 72 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testVersionMaskWithoutTarget.

public void testVersionMaskWithoutTarget() throws IOException {
    Processor p = new Processor();
    assertEquals("${version;===}", p.getReplacer().process("${version;===}"));
    assertTrue(p.check());
}
Also used : Processor(aQute.bnd.osgi.Processor)

Example 73 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testWarning.

public static void testWarning() {
    Processor p = new Processor();
    p.setProperty("three", "333");
    p.setProperty("empty", "");
    p.setProperty("real", "true");
    Macro m = new Macro(p);
    m.process("    ${warning;xw;1;2;3 ${three}}");
    m.process("    ${error;xe;1;2;3 ${three}}");
    m.process("    ${if;1;$<a>}");
    assertTrue("xw", p.getWarnings().get(0).endsWith("xw"));
    assertTrue("1", p.getWarnings().get(1).endsWith("1"));
    assertTrue("2", p.getWarnings().get(2).endsWith("2"));
    assertTrue("3 333", p.getWarnings().get(3).endsWith("3 333"));
    assertTrue("xw", p.getErrors().get(0).endsWith("xe"));
    assertTrue("1", p.getErrors().get(1).endsWith("1"));
    assertTrue("2", p.getErrors().get(2).endsWith("2"));
    assertTrue("3 333", p.getErrors().get(3).endsWith("3 333"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 74 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testJoin.

public static void testJoin() {
    Processor p = new Processor();
    p.setProperty("a", "aaaa");
    Macro m = new Macro(p);
    assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa,bb,cc,dd,ee,ff}"));
    assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa,bb,cc;dd,ee,ff}"));
    assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa;bb;cc;dd;ee,ff}"));
    assertEquals("aaXbbXccXddXeeXff", m.process("${sjoin;X;aa,bb,cc,dd,ee,ff}"));
    assertEquals("aa\nbb\ncc\ndd\nee\nff", m.process("${sjoin;\n;aa,bb,cc;dd,ee,ff}"));
    assertEquals("aa\nbb\ncc\ndd\nee\nff", m.process("${unescape;${sjoin;\\n;aa,bb,cc;dd,ee,ff}}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 75 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testCurrentWorkingDirectory.

/**
	 * Test replacement of ./ with cwd
	 */
public static void testCurrentWorkingDirectory() {
    Processor top = new Processor();
    // empty
    top.setProperty("cwd.1", "./");
    // empty
    top.setProperty("cwd.2", " ./");
    // empty
    top.setProperty("cwd.3", "./ ");
    // empty
    top.setProperty("cwd.4", " ./ ");
    // empty
    top.setProperty("cwd.5", "|./|");
    // empty
    top.setProperty("cwd.6", "/.//");
    // empty
    top.setProperty("cwd.7", ".");
    // empty
    top.setProperty("cwd.8", " . ");
    // empty
    top.setProperty("cwd.9", " . /");
    // empty
    top.setProperty("cwd.10", " .");
    // empty
    top.setProperty("cwd.11", "| ./|");
    // empty
    top.setProperty("cwd.12", "|\t./|");
    // empty
    top.setProperty("cwd.13", "|\r./|");
    // empty
    top.setProperty("cwd.14", "|\n./|");
    String cwd = top.getBase().getAbsolutePath() + "/";
    assertEquals(" . ", top.getProperty("cwd.8"));
    assertEquals(cwd, top.getProperty("cwd.1"));
    assertEquals(" " + cwd, top.getProperty("cwd.2"));
    assertEquals(cwd + " ", top.getProperty("cwd.3"));
    assertEquals(" " + cwd + " ", top.getProperty("cwd.4"));
    assertEquals("|./|", top.getProperty("cwd.5"));
    assertEquals("/.//", top.getProperty("cwd.6"));
    assertEquals(".", top.getProperty("cwd.7"));
    assertEquals(" . /", top.getProperty("cwd.9"));
    assertEquals(" .", top.getProperty("cwd.10"));
    assertEquals("| " + cwd + "|", top.getProperty("cwd.11"));
    assertEquals("|\t" + cwd + "|", top.getProperty("cwd.12"));
    assertEquals("|\r" + cwd + "|", top.getProperty("cwd.13"));
    assertEquals("|\n" + cwd + "|", top.getProperty("cwd.14"));
}
Also used : Processor(aQute.bnd.osgi.Processor)

Aggregations

Processor (aQute.bnd.osgi.Processor)185 HashMap (java.util.HashMap)43 File (java.io.File)37 Macro (aQute.bnd.osgi.Macro)29 Workspace (aQute.bnd.build.Workspace)27 Jar (aQute.bnd.osgi.Jar)17 HttpClient (aQute.bnd.http.HttpClient)14 Baseline (aQute.bnd.differ.Baseline)12 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)12 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)10 IOException (java.io.IOException)10 Resource (org.osgi.resource.Resource)10 Info (aQute.bnd.differ.Baseline.Info)8 Version (aQute.bnd.version.Version)8 ArrayList (java.util.ArrayList)8 List (java.util.List)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Collection (java.util.Collection)6 Properties (java.util.Properties)6 Parameters (aQute.bnd.header.Parameters)5