use of aQute.bnd.service.diff.Tree in project bnd by bndtools.
the class DiffTest method testSimple.
public static void testSimple() throws Exception {
DiffPluginImpl differ = new DiffPluginImpl();
differ.setIgnore("Bundle-Copyright,Bundle-Description,Bundle-License,Bundle-Name,bundle-manifestversion,Export-Package,Import-Package,Bundle-Vendor,Bundle-Version");
Tree newer = differ.tree(new Jar(IO.getFile("jar/osgi.core-4.3.0.jar")));
// 4.2
Tree older = differ.tree(new Jar(IO.getFile("jar/osgi.core.jar")));
Diff diff = newer.get("<manifest>").diff(older.get("<manifest>"));
show(diff, 0);
assertEquals(Delta.UNCHANGED, diff.getDelta());
}
use of aQute.bnd.service.diff.Tree in project bnd by bndtools.
the class DiffTest method testNestedExportedAnnotations2.
/**
* Test the scenario where nested annotations can generate false positive in
* diffs
* <p>
* The trigger is a class-level annotations of the form
*
* <pre>
* {@literal @}Properties(value = { {@literal @}Property(name = "some.key",
* value = "some.value") })
* </pre>
*
* @throws Exception
*/
public void testNestedExportedAnnotations2() throws Exception {
File input = IO.getFile("testresources/exported-annotations.jar");
Tree one = differ.tree(input);
Tree two = differ.tree(input);
Diff diff = one.diff(two);
assertTrue(diff.getDelta() == Delta.UNCHANGED);
}
use of aQute.bnd.service.diff.Tree in project bnd by bndtools.
the class DiffTest method testAPI.
/**
* Test API differences. We have a package in the /demo workspace project
* and we have the same package in our test.api package.
*/
public void testAPI() throws Exception {
Jar older = new Jar(IO.getFile("../demo/generated/demo.jar"));
Builder b = new Builder();
b.addClasspath(IO.getFile("bin"));
b.setExportPackage("test.api");
b.build();
assertTrue(b.check());
Jar newer = b.getJar();
Tree newerTree = differ.tree(newer).get("<api>").get("test.api");
Tree olderTree = differ.tree(older).get("<api>").get("test.api");
Diff treeDiff = newerTree.diff(olderTree);
show(treeDiff, 2);
assertEquals(Delta.MAJOR, treeDiff.getDelta());
Diff diff = treeDiff.get("test.api.Interf");
assertEquals(Delta.MAJOR, diff.getDelta());
assertEquals(Delta.UNCHANGED, diff.get("abstract").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo()").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo()").get("abstract").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo()").get("java.util.Collection").getDelta());
assertEquals(Delta.MAJOR, diff.get("foo(java.lang.Object)").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo(java.lang.Object)").get("abstract").getDelta());
assertEquals(Delta.REMOVED, diff.get("foo(java.lang.Object)").get("java.lang.Object").getDelta());
assertEquals(Delta.ADDED, diff.get("foo(java.lang.Object)").get("java.util.List").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("fooInt()").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("fooInt()").get("int").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("fooString()").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("fooString()").get("java.lang.String").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo(java.util.List)").getDelta());
assertEquals(Delta.UNCHANGED, diff.get("foo(java.util.List)").get("void").getDelta());
diff = treeDiff.get("test.api.A");
assertEquals(Delta.MINOR, diff.getDelta());
assertEquals(Delta.ADDED, diff.get("n").getDelta());
assertEquals(Delta.ADDED, diff.get("n").get("static").getDelta());
assertEquals(Delta.ADDED, diff.get("n").get("int").getDelta());
diff = treeDiff.get("test.api.C");
assertEquals(Delta.MAJOR, diff.getDelta());
assertEquals(Delta.MAJOR, diff.get("s").getDelta());
assertEquals(Delta.ADDED, diff.get("s").get("int").getDelta());
assertEquals(Delta.REMOVED, diff.get("s").get("java.lang.String").getDelta());
b.close();
}
use of aQute.bnd.service.diff.Tree in project bnd by bndtools.
the class DiffTest method testNestedExportedAnnotations.
/**
* Test the scenario where nested annotations can generate false positive in
* diffs
* <p>
* The trigger is a class-level annotations of the form
*
* <pre>
* {@literal @}Properties(value = { {@literal @}Property(name = "some.key",
* value = "some.value") })
* </pre>
*
* @throws Exception
*/
public void testNestedExportedAnnotations() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("bin/"));
b.setExportPackage("test.annotations.diff.payload");
Jar build = b.build();
Tree one = differ.tree(build);
System.out.println(one);
Tree two = differ.tree(build);
Diff diff = one.diff(two);
assertTrue(diff.getDelta() == Delta.UNCHANGED);
b.close();
}
use of aQute.bnd.service.diff.Tree in project bnd by bndtools.
the class Baseline method baseline.
/**
* This method compares a jar to a baseline jar and returns version
* suggestions if the baseline does not agree with the newer jar. The
* returned set contains all the exported packages.
*
* @param newer
* @param older
* @return null if ok, otherwise a set of suggested versions for all
* packages (also the ones that were ok).
* @throws Exception
*/
public Set<Info> baseline(Jar newer, Jar older, Instructions packageFilters) throws Exception {
Tree n = differ.tree(newer);
Parameters nExports = getExports(newer);
Tree o = differ.tree(older);
Parameters oExports = getExports(older);
if (packageFilters == null)
packageFilters = new Instructions();
return baseline(n, nExports, o, oExports, packageFilters);
}
Aggregations