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);
}
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());
}
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));
}
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());
}
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();
}
}
}
}
Aggregations