use of aQute.bnd.differ.Baseline 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();
}
}
}
}
use of aQute.bnd.differ.Baseline in project bnd by bndtools.
the class BaselineTest method testJava8DefaultMethods.
public void testJava8DefaultMethods() throws Exception {
try (Builder older = new Builder();
Builder newer = new Builder()) {
older.addClasspath(IO.getFile("java8/older/bin"));
older.setExportPackage("*");
newer.addClasspath(IO.getFile("java8/newer/bin"));
newer.setExportPackage("*");
try (Jar o = older.build();
Jar n = newer.build()) {
assertTrue(older.check());
assertTrue(newer.check());
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(older, differ);
Set<Info> infoSet = baseline.baseline(n, o, null);
assertEquals(1, infoSet.size());
for (Info info : infoSet) {
assertTrue(info.mismatch);
assertEquals(new Version(0, 1, 0), info.suggestedVersion);
assertEquals(info.packageName, "api_default_methods");
}
}
}
}
use of aQute.bnd.differ.Baseline in project bnd by bndtools.
the class BaselineTest method testConsumerTypeBump.
// Adding a method to a ConsumerType produces a MINOR bump (1.0.0 -> 2.0.0)
public static void testConsumerTypeBump() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("testresources/api-orig.jar"));
Jar newer = new Jar(IO.getFile("testresources/api-consumerbump.jar"))) {
Set<Info> infoSet = baseline.baseline(newer, older, null);
assertEquals(1, infoSet.size());
Info info = infoSet.iterator().next();
assertTrue(info.mismatch);
assertEquals("dummy.api", info.packageName);
assertEquals("2.0.0", info.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline in project bnd by bndtools.
the class BaselineTest method testMinorChange.
// Adding a method to an exported class produces a MINOR bump (1.0.0 -> 1.1.0)
public void testMinorChange() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("testresources/minor-and-removed-change-1.0.0.jar"));
Jar newer = new Jar(IO.getFile("testresources/minor-change-1.0.1.jar"))) {
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertTrue(bundleInfo.mismatch);
assertEquals("1.1.0", bundleInfo.suggestedVersion.toString());
}
}
use of aQute.bnd.differ.Baseline in project bnd by bndtools.
the class BaselineTest method testProviderProtectedFieldRemovedChange.
// Deleting a protected field on a ProviderType API class produces a MINOR
// bump (1.0.0 -> 1.1.0)
public void testProviderProtectedFieldRemovedChange() throws Exception {
Processor processor = new Processor();
DiffPluginImpl differ = new DiffPluginImpl();
Baseline baseline = new Baseline(processor, differ);
try (Jar older = new Jar(IO.getFile("jar/baseline/provider-deletion-1.0.0.jar"));
Jar newer = new Jar(IO.getFile("jar/baseline/provider-deletion-1.1.0.jar"))) {
baseline.baseline(newer, older, null);
BundleInfo bundleInfo = baseline.getBundleInfo();
assertFalse(bundleInfo.mismatch);
assertEquals("1.1.0", bundleInfo.suggestedVersion.toString());
Set<Info> packageInfos = baseline.getPackageInfos();
assertEquals(1, packageInfos.size());
Info change = packageInfos.iterator().next();
assertTrue(change.mismatch);
assertEquals("bnd.baseline.test", change.packageName);
assertEquals("1.1.0", change.suggestedVersion.toString());
}
}
Aggregations