Search in sources :

Example 21 with Diff

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

the class ComponentOrderingTest method testOrdering.

public static void testOrdering() throws Exception {
    Builder builder = new Builder();
    builder.addClasspath(new File("bin"));
    builder.setProperty("Service-Component", "OSGI-INF/a.xml,OSGI-INF/b.xml,OSGI-INF/c.xml,OSGI-INF/d.xml");
    Jar a = builder.build();
    String exa = (String) a.getManifest().getMainAttributes().getValue(Constants.EXPORT_PACKAGE);
    builder = new Builder();
    builder.addClasspath(new File("bin"));
    builder.setProperty("Service-Component", "OSGI-INF/d.xml,OSGI-INF/b.xml,OSGI-INF/a.xml,OSGI-INF/c.xml");
    Jar b = builder.build();
    String exb = (String) b.getManifest().getMainAttributes().getValue("Service-Component");
    Tree newer = differ.tree(b);
    Tree older = differ.tree(a);
    Diff diff = newer.diff(older);
    assertEquals(Delta.UNCHANGED, diff.getDelta());
}
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)

Example 22 with Diff

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

the class DiffTest method testInheritance.

public static void testInheritance() throws Exception {
    Builder b = new Builder();
    b.addClasspath(IO.getFile("bin"));
    b.setProperty(Constants.EXPORT_PACKAGE, "test.diff");
    b.build();
    Tree newer = differ.tree(b);
    Tree older = differ.tree(b);
    System.out.println(newer);
    System.out.println(older);
    Diff diff = newer.diff(older);
    Diff p = diff.get("<api>").get("test.diff");
    assertTrue(p.getDelta() == Delta.UNCHANGED);
    show(p, 0);
    Diff c = p.get("test.diff.DiffTest$I");
    assertNotNull(c.get("hashCode()"));
    assertNotNull(c.get("finalize()"));
    assertNotNull(c.get("foo()"));
    Diff cc = p.get("test.diff.DiffTest$Final");
    assertNotNull(cc.get("foo()"));
    b.close();
}
Also used : Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Tree(aQute.bnd.service.diff.Tree)

Example 23 with Diff

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

the class DiffTest method testGuavaDiff.

/**
	 * The diff command reports changes on (at least) the guava bundles when
	 * they have not changed, even when I feed it the same file at both ends.
	 * Even stranger is the fact that, though always about the same class, the
	 * actual diff is not consistent. Tested with several versions of bnd
	 * (including master HEAD) as well as several versions of the guava bundles
	 * from maven central. Reproduced by @bnd .
	 * 
	 * <pre>
	 *  $ java -jar
	 * biz.aQute.bnd.jar diff guava-14.0.1.jar guava-14.0.1.jar MINOR PACKAGE
	 * com.google.common.collect MINOR CLASS
	 * com.google.common.collect.ContiguousSet MINOR METHOD
	 * tailSet(java.lang.Object,boolean) ADDED RETURN
	 * com.google.common.collect.ImmutableCollection ADDED RETURN
	 * com.google.common.collect.ImmutableSet ADDED RETURN
	 * com.google.common.collect.ImmutableSortedSet ADDED RETURN
	 * com.google.common.collect.ImmutableSortedSetFauxverideShim ADDED RETURN
	 * com.google.common.collect.SortedIterable ADDED RETURN
	 * java.io.Serializable ADDED RETURN java.lang.Iterable ADDED RETURN
	 * java.lang.Iterable ADDED RETURN java.lang.Iterable ADDED RETURN
	 * java.util.Collection ADDED RETURN java.util.Collection ADDED RETURN
	 * java.util.Set
	 * </pre>
	 * 
	 * @throws Exception
	 */
public void testGuavaDiff() throws Exception {
    File guava = IO.getFile("testresources/guava-14.0.1.jar");
    Tree one = differ.tree(guava);
    System.out.println(one.get("<api>"));
    Tree two = differ.tree(guava);
    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 24 with Diff

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

the class DiffTest method testBaselineDiffs.

public void testBaselineDiffs() throws Exception {
    Tree newerTree = make(IO.getFile("testresources/baseline/test1.jar"));
    Tree olderTree = make(IO.getFile("testresources/baseline/test2.jar"));
    Diff diff = newerTree.diff(olderTree);
    show(diff, 2);
    assertEquals(Delta.UNCHANGED, diff.getDelta());
    assertEquals(Delta.UNCHANGED, diff.get("<init>()").getDelta());
    assertEquals(Delta.UNCHANGED, diff.get("putAll(java.util.List)").getDelta());
}
Also used : Diff(aQute.bnd.service.diff.Diff) Tree(aQute.bnd.service.diff.Tree)

Example 25 with Diff

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

the class UsesOrderingTest method testOrdering.

public static void testOrdering() throws Exception {
    Builder builder = new Builder();
    builder.addClasspath(new File("bin"));
    builder.setProperty(Constants.EXPORT_PACKAGE, "test.diff;uses:=\"d,c,a,b\"");
    Jar a = builder.build();
    String exa = (String) a.getManifest().getMainAttributes().getValue(Constants.EXPORT_PACKAGE);
    builder = new Builder();
    builder.addClasspath(new File("bin"));
    builder.setProperty(Constants.EXPORT_PACKAGE, "test.diff;uses:=\"d,b,a,c\"");
    Jar b = builder.build();
    String exb = (String) b.getManifest().getMainAttributes().getValue(Constants.EXPORT_PACKAGE);
    Tree newer = differ.tree(b);
    Tree older = differ.tree(a);
    Diff diff = newer.diff(older);
    show(diff, 0);
    assertEquals(Delta.UNCHANGED, diff.getDelta());
}
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