Search in sources :

Example 11 with ReporterAdapter

use of aQute.libg.reporter.ReporterAdapter in project bnd by bndtools.

the class UTF8PropertiesTest method testProperty0.

private void testProperty0(String content, String key, String value, String check) throws IOException {
    UTF8Properties p = new UTF8Properties();
    ReporterAdapter ra = new ReporterAdapter();
    p.load(content, null, ra);
    if (check == null)
        assertTrue(ra.check());
    else
        assertTrue(ra.check(check));
    assertEquals(value, p.get(key));
    assertEquals(1, p.size());
    Properties pp = new Properties();
    pp.load(new StringReader(content));
    assertEquals(value, pp.get(key));
    assertEquals(1, pp.size());
    assertEquals(pp, p);
}
Also used : ReporterAdapter(aQute.libg.reporter.ReporterAdapter) StringReader(java.io.StringReader) Properties(java.util.Properties)

Example 12 with ReporterAdapter

use of aQute.libg.reporter.ReporterAdapter in project bnd by bndtools.

the class UTF8PropertiesTest method testPackageinfoWithCrLf.

public void testPackageinfoWithCrLf() throws IOException {
    UTF8Properties p = new UTF8Properties();
    ReporterAdapter ra = new ReporterAdapter();
    p.load("version 1.0.1\r\n", null, ra);
    assertEquals("1.0.1", p.get("version"));
    assertEquals(1, p.size());
}
Also used : ReporterAdapter(aQute.libg.reporter.ReporterAdapter)

Example 13 with ReporterAdapter

use of aQute.libg.reporter.ReporterAdapter in project bnd by bndtools.

the class UTF8PropertiesTest method assertError.

private void assertError(String string, String key, int line, String... check) throws IOException {
    ReporterAdapter ra = new ReporterAdapter();
    UTF8Properties up = new UTF8Properties();
    up.load(string, IO.getFile("foo"), ra);
    assertNotNull("No '" + key + "' property found", up.getProperty(key));
    if (check.length == 0)
        assertEquals(0, ra.getErrors().size());
    else {
        assertTrue(ra.getErrors().size() > 0);
        Location location = ra.getLocation(ra.getErrors().get(0));
        assertEquals("Faulty line number", line, location.line);
    }
    assertTrue(ra.check(check));
}
Also used : ReporterAdapter(aQute.libg.reporter.ReporterAdapter) Location(aQute.service.reporter.Report.Location)

Example 14 with ReporterAdapter

use of aQute.libg.reporter.ReporterAdapter in project bnd by bndtools.

the class UTF8PropertiesTest method testEscapedNewlinEmpty.

public void testEscapedNewlinEmpty() throws IOException {
    UTF8Properties p = new UTF8Properties();
    ReporterAdapter ra = new ReporterAdapter();
    p.load("a=x\\\n\n", null, ra);
    assertEquals("x", p.get("a"));
    assertEquals(1, p.size());
}
Also used : ReporterAdapter(aQute.libg.reporter.ReporterAdapter)

Example 15 with ReporterAdapter

use of aQute.libg.reporter.ReporterAdapter in project bnd by bndtools.

the class BaselineTest method testPrematureJar.

/**
	 * When a JAR is build the manifest is not set in the resources but in a
	 * instance var.
	 *
	 * @throws Exception
	 */
public void testPrematureJar() throws Exception {
    File file = IO.getFile(new File(""), "jar/osgi.jar");
    try (Builder b1 = new Builder();
        Builder b2 = new Builder()) {
        b1.addClasspath(file);
        b1.setProperty(Constants.BUNDLE_VERSION, "1.0.0.${tstamp}");
        b1.setExportPackage("org.osgi.service.event");
        try (Jar j1 = b1.build()) {
            assertTrue(b1.check());
            File tmp = new File("tmp.jar");
            j1.write(tmp);
            try (Jar j11 = new Jar(tmp)) {
                Thread.sleep(2000);
                b2.addClasspath(file);
                b2.setProperty(Constants.BUNDLE_VERSION, "1.0.0.${tstamp}");
                b2.setExportPackage("org.osgi.service.event");
                try (Jar j2 = b2.build()) {
                    assertTrue(b2.check());
                    DiffPluginImpl differ = new DiffPluginImpl();
                    ReporterAdapter ra = new ReporterAdapter();
                    Baseline baseline = new Baseline(ra, differ);
                    ra.setTrace(true);
                    ra.setPedantic(true);
                    Set<Info> infos = baseline.baseline(j2, j11, null);
                    print(baseline.getDiff(), " ");
                    assertEquals(Delta.UNCHANGED, baseline.getDiff().getDelta());
                }
            } finally {
                tmp.delete();
            }
        }
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) ReporterAdapter(aQute.libg.reporter.ReporterAdapter) ProjectBuilder(aQute.bnd.build.ProjectBuilder) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info) File(java.io.File)

Aggregations

ReporterAdapter (aQute.libg.reporter.ReporterAdapter)15 File (java.io.File)4 Reporter (aQute.service.reporter.Reporter)3 Baseline (aQute.bnd.differ.Baseline)2 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)2 CommandLine (aQute.lib.getopt.CommandLine)2 Sed (aQute.libg.sed.Sed)2 Method (java.lang.reflect.Method)2 ProjectBuilder (aQute.bnd.build.ProjectBuilder)1 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)1 Info (aQute.bnd.differ.Baseline.Info)1 Builder (aQute.bnd.osgi.Builder)1 Jar (aQute.bnd.osgi.Jar)1 JVM (aQute.jpm.lib.JVM)1 JustAnotherPackageManager (aQute.jpm.lib.JustAnotherPackageManager)1 Description (aQute.lib.getopt.Description)1 PersistentMap (aQute.lib.persistentmap.PersistentMap)1 Location (aQute.service.reporter.Report.Location)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1