Search in sources :

Example 21 with Macro

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}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 22 with Macro

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;"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 23 with Macro

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)"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 24 with Macro

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());
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 25 with Macro

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}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Aggregations

Macro (aQute.bnd.osgi.Macro)32 Processor (aQute.bnd.osgi.Processor)29 Project (aQute.bnd.build.Project)1 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)1 Attrs (aQute.bnd.header.Attrs)1 Analyzer (aQute.bnd.osgi.Analyzer)1 Version (aQute.bnd.version.Version)1 Description (aQute.lib.getopt.Description)1 Replacer (aQute.libg.sed.Replacer)1 Sed (aQute.libg.sed.Sed)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 Field (java.lang.reflect.Field)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 Proxy (java.lang.reflect.Proxy)1 URL (java.net.URL)1