Search in sources :

Example 1 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testCompilerEnumDifference.

/**
	 * Test 2 jars compiled with different compilers
	 */
public void testCompilerEnumDifference() throws Exception {
    DiffPluginImpl diff = new DiffPluginImpl();
    try (Jar ecj = new Jar(IO.getFile("jar/baseline/com.example.baseline.ecj.jar"));
        Jar javac = new Jar(IO.getFile("jar/baseline/com.example.baseline.javac.jar"))) {
        Tree tecj = diff.tree(ecj);
        Tree tjavac = diff.tree(javac);
        Diff d = tecj.diff(tjavac);
        assertEquals(Delta.UNCHANGED, d.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 2 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testBundleVersionBumpDifferentSymbolicNames.

// Adding a method to a ProviderType produces a MINOR bump (1.0.0 -> 1.1.0)
public void testBundleVersionBumpDifferentSymbolicNames() 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-providerbump.jar"))) {
        newer.getManifest().getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, "a.different.name");
        baseline.baseline(newer, older, null);
        BundleInfo bundleInfo = baseline.getBundleInfo();
        assertFalse(bundleInfo.mismatch);
        assertEquals(newer.getVersion(), bundleInfo.suggestedVersion.toString());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline)

Example 3 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testMinorAndRemovedChange.

// Adding a method to an exported class and unexporting a package produces a MINOR bump (1.0.0 -> 1.1.0)
public void testMinorAndRemovedChange() 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-and-removed-change-1.0.1.jar"))) {
        baseline.baseline(newer, older, null);
        BundleInfo bundleInfo = baseline.getBundleInfo();
        assertTrue(bundleInfo.mismatch);
        assertEquals("2.0.0", bundleInfo.suggestedVersion.toString());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline)

Example 4 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testProviderTypeBump.

// Adding a method to a ProviderType produces a MINOR bump (1.0.0 -> 1.1.0)
public void testProviderTypeBump() 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-providerbump.jar"))) {
        Set<Info> infoSet = baseline.baseline(newer, older, null);
        System.out.println(differ.tree(newer).get("<api>"));
        assertEquals(1, infoSet.size());
        Info info = infoSet.iterator().next();
        assertTrue(info.mismatch);
        assertEquals("dummy.api", info.packageName);
        assertEquals("1.1.0", info.suggestedVersion.toString());
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Example 5 with DiffPluginImpl

use of aQute.bnd.differ.DiffPluginImpl in project bnd by bndtools.

the class BaselineTest method testClassesDiffWithoutSource.

public void testClassesDiffWithoutSource() throws Exception {
    DiffPluginImpl diff = new DiffPluginImpl();
    try (Jar jar = new Jar(IO.getFile("jar/osgi.jar"));
        Jar out = new Jar(".")) {
        for (String path : jar.getResources().keySet()) {
            if (!path.startsWith("OSGI-OPT/src/"))
                out.putResource(path, jar.getResource(path));
        }
        Tree tree = diff.tree(out);
        assertNull(tree.get("<resources>").get("OSGI-OPT/src/org/osgi/application/ApplicationContext.java"));
        assertNotNull(tree.get("<resources>").get("org/osgi/application/ApplicationContext.class"));
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Tree(aQute.bnd.service.diff.Tree) Jar(aQute.bnd.osgi.Jar) Matchers.anyString(org.mockito.Matchers.anyString)

Aggregations

DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)21 Jar (aQute.bnd.osgi.Jar)20 Baseline (aQute.bnd.differ.Baseline)15 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)12 Processor (aQute.bnd.osgi.Processor)11 Info (aQute.bnd.differ.Baseline.Info)9 ProjectBuilder (aQute.bnd.build.ProjectBuilder)5 Builder (aQute.bnd.osgi.Builder)5 Tree (aQute.bnd.service.diff.Tree)5 Diff (aQute.bnd.service.diff.Diff)4 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 File (java.io.File)2 Project (aQute.bnd.build.Project)1 Instructions (aQute.bnd.osgi.Instructions)1 Differ (aQute.bnd.service.diff.Differ)1 Version (aQute.bnd.version.Version)1 Reporter (aQute.service.reporter.Reporter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1