Search in sources :

Example 11 with Diff

use of aQute.bnd.service.diff.Diff 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());
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Diff(aQute.bnd.service.diff.Diff) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar)

Example 12 with Diff

use of aQute.bnd.service.diff.Diff in project bnd by bndtools.

the class DiffTest method testAPIStaticSuperClassChange.

public void testAPIStaticSuperClassChange() 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();
    Processor processor = new Processor();
    DiffPluginImpl differ = new DiffPluginImpl();
    Baseline baseline = new Baseline(processor, differ);
    Info info = baseline.baseline(newer, older, null).iterator().next();
    Diff field = info.packageDiff.get("test.api.B");
    show(field, 2);
    assertEquals(Delta.UNCHANGED, field.getDelta());
    b.close();
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info)

Example 13 with Diff

use of aQute.bnd.service.diff.Diff 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);
}
Also used : Diff(aQute.bnd.service.diff.Diff) Tree(aQute.bnd.service.diff.Tree) File(java.io.File)

Example 14 with Diff

use of aQute.bnd.service.diff.Diff 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();
}
Also used : Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar)

Example 15 with Diff

use of aQute.bnd.service.diff.Diff 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();
}
Also used : Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar) File(java.io.File)

Aggregations

Diff (aQute.bnd.service.diff.Diff)28 Tree (aQute.bnd.service.diff.Tree)17 Jar (aQute.bnd.osgi.Jar)9 File (java.io.File)7 Baseline (aQute.bnd.differ.Baseline)6 Builder (aQute.bnd.osgi.Builder)6 Info (aQute.bnd.differ.Baseline.Info)4 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)4 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)3 Delta (aQute.bnd.service.diff.Delta)3 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)2 DiffImpl (aQute.bnd.differ.DiffImpl)2 Parameters (aQute.bnd.header.Parameters)2 Instructions (aQute.bnd.osgi.Instructions)2 Processor (aQute.bnd.osgi.Processor)2 Version (aQute.bnd.version.Version)2 Tag (aQute.lib.tag.Tag)2 PrintWriter (java.io.PrintWriter)2 ArrayList (java.util.ArrayList)2 Attrs (aQute.bnd.header.Attrs)1