Search in sources :

Example 66 with Processor

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

Example 67 with Processor

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

Example 68 with Processor

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

Example 69 with Processor

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

Example 70 with Processor

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

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