Search in sources :

Example 16 with Baseline

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();
            }
        }
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) ReporterAdapter(aQute.libg.reporter.ReporterAdapter) ProjectBuilder(aQute.bnd.build.ProjectBuilder) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info) File(java.io.File)

Example 17 with Baseline

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");
            }
        }
    }
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Version(aQute.bnd.version.Version) ProjectBuilder(aQute.bnd.build.ProjectBuilder) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Example 18 with Baseline

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());
    }
}
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 19 with Baseline

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());
    }
}
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 20 with Baseline

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());
    }
}
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) BundleInfo(aQute.bnd.differ.Baseline.BundleInfo) Info(aQute.bnd.differ.Baseline.Info)

Aggregations

Baseline (aQute.bnd.differ.Baseline)27 Info (aQute.bnd.differ.Baseline.Info)15 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)15 Jar (aQute.bnd.osgi.Jar)15 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)13 Processor (aQute.bnd.osgi.Processor)11 Builder (aQute.bnd.osgi.Builder)9 Diff (aQute.bnd.service.diff.Diff)6 ArrayList (java.util.ArrayList)5 ProjectBuilder (aQute.bnd.build.ProjectBuilder)4 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)2 Tree (aQute.bnd.service.diff.Tree)2 Version (aQute.bnd.version.Version)2 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 WorkspaceReleaseDialog (bndtools.release.ui.WorkspaceReleaseDialog)2 IOException (java.io.IOException)2 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Project (aQute.bnd.build.Project)1