diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox')
9 files changed, 319 insertions, 235 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportRemoteTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportRemoteTests.java index 048f7e5af..fdb0c5299 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportRemoteTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportRemoteTests.java @@ -78,7 +78,7 @@ public class ImportExportRemoteTests extends ServerBasedTestCase { try (InputStream input = new FileInputStream(testFile)) { List<IUDetail> ius = importexportService.importP2F(input); assertEquals("Exported the number of features is not expected.", 1, ius.size()); - assertTrue("Exported feature is not expected.", iu.equals(ius.get(0).getIU())); + assertEquals("Exported feature is not expected.", iu, ius.get(0).getIU()); assertEquals("Exported the number of referred repositories is not expected.", 1, ius.get(0).getReferencedRepositories().size()); assertEquals("Exported referred repository is not expected.", uri, @@ -128,7 +128,7 @@ public class ImportExportRemoteTests extends ServerBasedTestCase { try (InputStream input = new FileInputStream(testFile)) { List<IUDetail> ius = importexportService.importP2F(input); assertEquals("Exported the number of features is not expected.", 1, ius.size()); - assertTrue("Exported feature is not expected.", iu.equals(ius.get(0).getIU())); + assertEquals("Exported feature is not expected.", iu, ius.get(0).getIU()); assertEquals("Exported the number of referred repositories is not expected.", 1, ius.get(0).getReferencedRepositories().size()); assertEquals("Exported referred repository is not expected.", uri, diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportTests.java index 84353aeea..cbde87226 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/importexport/ImportExportTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.importexport; +import static org.junit.Assert.assertThrows; + import java.io.*; import java.util.ArrayList; import java.util.List; @@ -67,16 +69,16 @@ public class ImportExportTests extends AbstractProvisioningTest { try (InputStream input = new FileInputStream(p2fFile)) { List<IUDetail> iuDetails = importexportService.importP2F(input); - assertTrue("Should load two features from the p2f file.", iuDetails.size() == 2); + assertEquals("Should load two features from the p2f file.", 2, iuDetails.size()); int counter = 0; for (IUDetail iu : iuDetails) { if ("org.polarion.eclipse.team.svn.connector.feature.group".equals(iu.getIU().getId())) { counter++; - assertTrue("Should have two referred repository.", iu.getReferencedRepositories().size() == 2); + assertEquals("Should have two referred repository.", 2, iu.getReferencedRepositories().size()); } else if ("org.polarion.eclipse.team.svn.connector.svnkit16.feature.group" .equals(iu.getIU().getId())) { counter++; - assertTrue("Should have one referred repository", iu.getReferencedRepositories().size() == 1); + assertEquals("Should have one referred repository", 1, iu.getReferencedRepositories().size()); } } assertEquals("Load unexpected content.", 2, counter); @@ -96,10 +98,8 @@ public class ImportExportTests extends AbstractProvisioningTest { File p2fFile = getTestData("Error load test file.", "testData/importexport/incompatible.p2f"); try (InputStream input = new FileInputStream(p2fFile)) { - importexportService.importP2F(input); - assertTrue("Didn't complain the given file is not supported by current version.", false); - } catch (VersionIncompatibleException e) { - // expected + assertThrows("Didn't complain the given file is not supported by current version.", + VersionIncompatibleException.class, () -> importexportService.importP2F(input)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java index 319338c91..a4cfbd144 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java @@ -14,6 +14,8 @@ package org.eclipse.equinox.p2.tests.ui.actions; +import static org.junit.Assert.assertNotEquals; + import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -35,7 +37,7 @@ public class ElementUtilsTest extends ProfileModificationActionTest { } public void testInvalid() { - assertTrue(ElementUtils.elementsToIUs(getInvalidSelection()).size() == 0); + assertTrue(ElementUtils.elementsToIUs(getInvalidSelection()).isEmpty()); } public void testIUs() { @@ -47,7 +49,7 @@ public class ElementUtilsTest extends ProfileModificationActionTest { } public void testMixedIUsAndNonIUs() { - assertTrue(getMixedIUsAndNonIUs().length != ElementUtils.elementsToIUs(getMixedIUsAndNonIUs()).size()); + assertNotEquals(getMixedIUsAndNonIUs().length, ElementUtils.elementsToIUs(getMixedIUsAndNonIUs()).size()); } public void testMixedIUsAndElements() { @@ -56,15 +58,15 @@ public class ElementUtilsTest extends ProfileModificationActionTest { public void testUpdateUsingElements() throws URISyntaxException { // Two visible repos, one is added, the other is not - URI known1 = new URI("http://example.com/known1"); - URI known2 = new URI("http://example.com/known2"); + URI known1 = new URI("https://example.com/known1"); + URI known2 = new URI("https://example.com/known2"); IMetadataRepositoryManager manager = getMetadataRepositoryManager(); manager.addRepository(known1); // Add system repos that should not be known or affected by ElementUtils // One is an enabled system repo, one is disabled system repo - URI uri = new URI("http://example.com/1"); - URI uri2 = new URI("http://example.com/2"); + URI uri = new URI("https://example.com/1"); + URI uri2 = new URI("https://example.com/2"); manager.addRepository(uri); manager.setRepositoryProperty(uri, IRepository.PROP_SYSTEM, Boolean.toString(true)); manager.addRepository(uri2); @@ -80,10 +82,10 @@ public class ElementUtilsTest extends ProfileModificationActionTest { MetadataRepositoryElement[] elements = children.toArray(new MetadataRepositoryElement[children.size()]); // Add a visible repo not known by the elements - URI uri3 = new URI("http://example.com/3"); + URI uri3 = new URI("https://example.com/3"); manager.addRepository(uri3); - // Now update the repo using the elements. + // Now update the repo using the elements. // We expect known2 to get added because it was in the elements // We expect uri3 to get removed (as if it had been removed from a pref page) // System repos shouldn't be touched diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWithRemediationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWithRemediationTest.java index acf2fe1d4..bedcda8ae 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWithRemediationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWithRemediationTest.java @@ -35,9 +35,9 @@ import org.eclipse.swt.widgets.TreeItem; */ public class InstallWithRemediationTest extends WizardTest { - // private static final String SELECTION_PAGE = "IUSelectionPage"; + // private static final String SELECTION_PAGE = "IUSelectionPage"; private static final String AVAILABLE_SOFTWARE_PAGE = "AvailableSoftwarePage"; - // private static final String MAIN_IU = "MainIU"; + // private static final String MAIN_IU = "MainIU"; IInstallableUnit toInstall; @@ -54,154 +54,175 @@ public class InstallWithRemediationTest extends WizardTest { iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, "true"); iu.setVersion(Version.createOSGi(2, 0, 0)); iu.setSingleton(true); - iu.setLicenses(new ILicense[] {new License(null, "There is a license to accept!", null)}); - iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, TOPLEVELIU, iu.getVersion())}); + iu.setLicenses(new ILicense[] { new License(null, "There is a license to accept!", null) }); + iu.setCapabilities(new IProvidedCapability[] { MetadataFactory + .createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, TOPLEVELIU, iu.getVersion()) }); toInstall = MetadataFactory.createInstallableUnit(iu); - createTestMetdataRepository(new IInstallableUnit[] {toInstall, anotherIUToInstall}); + createTestMetdataRepository(new IInstallableUnit[] { toInstall, anotherIUToInstall }); } // - // public void testInstallWizardResolved() { - // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); - // iusInvolved.add(toInstall); - // InstallOperation op = new InstallOperation(getSession(), iusInvolved); - // op.setProfileId(TESTPROFILE); - // PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); - // ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); - // dialog.setBlockOnOpen(false); - // dialog.open(); - // ProfileModificationJob longOp = null; + // public void testInstallWizardResolved() { + // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + // iusInvolved.add(toInstall); + // InstallOperation op = new InstallOperation(getSession(), iusInvolved); + // op.setProfileId(TESTPROFILE); + // PreselectedIUInstallWizard wizard = new + // PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + // ProvisioningWizardDialog dialog = new + // ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + // dialog.setBlockOnOpen(false); + // dialog.open(); + // ProfileModificationJob longOp = null; // - // try { - // SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); - // // should already have a plan - // assertTrue("1.0", page1.isPageComplete()); - // // simulate the next button by getting next page and showing - // IWizardPage page = page1.getNextPage(); - // dialog.showPage(page); - // // we should be ok - // assertTrue("1.1", page.isPageComplete()); + // try { + // SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // // should already have a plan + // assertTrue("1.0", page1.isPageComplete()); + // // simulate the next button by getting next page and showing + // IWizardPage page = page1.getNextPage(); + // dialog.showPage(page); + // // we should be ok + // assertTrue("1.1", page.isPageComplete()); // - // // if another operation is scheduled for this profile, we should not be allowed to proceed - // longOp = getLongTestOperation(); - // getProvisioningUI().schedule(longOp, StatusManager.LOG); - // // causes recalculation of plan and status - // wizard.recomputePlan(dialog); - // // can't move to next page while op is running - // assertFalse("1.2", page.isPageComplete()); - // longOp.cancel(); + // // if another operation is scheduled for this profile, we should not be + // allowed to proceed + // longOp = getLongTestOperation(); + // getProvisioningUI().schedule(longOp, StatusManager.LOG); + // // causes recalculation of plan and status + // wizard.recomputePlan(dialog); + // // can't move to next page while op is running + // assertFalse("1.2", page.isPageComplete()); + // longOp.cancel(); // - // // op is no longer running, recompute plan - // wizard.recomputePlan(dialog); + // // op is no longer running, recompute plan + // wizard.recomputePlan(dialog); // - // // license needs approval - // assertFalse("1.4", wizard.canFinish()); - // // finish button should be disabled - // dialog.updateButtons(); - // Button finishButton = dialog.testGetButton(IDialogConstants.FINISH_ID); - // assertFalse("1.5", finishButton.isEnabled()); - // } finally { - // dialog.getShell().close(); - // if (longOp != null) - // longOp.cancel(); - // } - // } + // // license needs approval + // assertFalse("1.4", wizard.canFinish()); + // // finish button should be disabled + // dialog.updateButtons(); + // Button finishButton = dialog.testGetButton(IDialogConstants.FINISH_ID); + // assertFalse("1.5", finishButton.isEnabled()); + // } finally { + // dialog.getShell().close(); + // if (longOp != null) + // longOp.cancel(); + // } + // } // - // public void testInstallWizard() throws Exception { - // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); - // iusInvolved.add(toInstall); - // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); - // op.setProfileId(TESTPROFILE); - // PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); - // ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); - // dialog.setBlockOnOpen(false); - // dialog.open(); - // ProfileModificationJob longOp = null; + // public void testInstallWizard() throws Exception { + // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + // iusInvolved.add(toInstall); + // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); + // op.setProfileId(TESTPROFILE); + // PreselectedIUInstallWizard wizard = new + // PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + // ProvisioningWizardDialog dialog = new + // ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + // dialog.setBlockOnOpen(false); + // dialog.open(); + // ProfileModificationJob longOp = null; // - // try { - // SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); - // // should already have a plan - // assertTrue("1.0", page1.isPageComplete()); - // // simulate the next button by getting next page and showing - // InstallWizardPage page = (InstallWizardPage) page1.getNextPage(); + // try { + // SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // // should already have a plan + // assertTrue("1.0", page1.isPageComplete()); + // // simulate the next button by getting next page and showing + // InstallWizardPage page = (InstallWizardPage) page1.getNextPage(); // - // // get the operation - // Field opField = ResolutionResultsWizardPage.class.getDeclaredField("resolvedOperation"); - // opField.setAccessible(true); - // assertTrue("Expected instance of MyNewInstallOperation", opField.get(page) instanceof MyNewInstallOperation); - // } finally { - // dialog.getShell().close(); - // if (longOp != null) - // longOp.cancel(); - // } - // } + // // get the operation + // Field opField = + // ResolutionResultsWizardPage.class.getDeclaredField("resolvedOperation"); + // opField.setAccessible(true); + // assertTrue("Expected instance of MyNewInstallOperation", opField.get(page) + // instanceof MyNewInstallOperation); + // } finally { + // dialog.getShell().close(); + // if (longOp != null) + // longOp.cancel(); + // } + // } // - // public void testInstallWizardWithoutLicenceBypass() throws Exception { - // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); - // iusInvolved.add(toInstall); - // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); - // op.setProfileId(TESTPROFILE); - // PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); - // wizard.setBypassLicencePage(false); - // ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); - // dialog.setBlockOnOpen(false); - // dialog.open(); - // ProfileModificationJob longOp = null; + // public void testInstallWizardWithoutLicenceBypass() throws Exception { + // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + // iusInvolved.add(toInstall); + // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); + // op.setProfileId(TESTPROFILE); + // PreselectedIUInstallWizard wizard = new + // PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + // wizard.setBypassLicencePage(false); + // ProvisioningWizardDialog dialog = new + // ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + // dialog.setBlockOnOpen(false); + // dialog.open(); + // ProfileModificationJob longOp = null; // - // try { - // SelectableIUsPage selectableIUsPage = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); - // // should already have a plan - // assertTrue("1.0", selectableIUsPage.isPageComplete()); - // // simulate the next button by getting next page and showing - // InstallWizardPage installWizardPage = (InstallWizardPage) selectableIUsPage.getNextPage(); + // try { + // SelectableIUsPage selectableIUsPage = (SelectableIUsPage) + // wizard.getPage(SELECTION_PAGE); + // // should already have a plan + // assertTrue("1.0", selectableIUsPage.isPageComplete()); + // // simulate the next button by getting next page and showing + // InstallWizardPage installWizardPage = (InstallWizardPage) + // selectableIUsPage.getNextPage(); // - // assertFalse("Licence page bypass flag must be false", wizard.isBypassLicencePage()); - // IWizardPage licensePage = installWizardPage.getNextPage(); - // assertTrue("Expected instance of AcceptLicensesWizardPage", licensePage instanceof AcceptLicensesWizardPage); + // assertFalse("Licence page bypass flag must be false", + // wizard.isBypassLicencePage()); + // IWizardPage licensePage = installWizardPage.getNextPage(); + // assertTrue("Expected instance of AcceptLicensesWizardPage", licensePage + // instanceof AcceptLicensesWizardPage); // - // } finally { - // dialog.getShell().close(); - // if (longOp != null) - // longOp.cancel(); - // } - // } + // } finally { + // dialog.getShell().close(); + // if (longOp != null) + // longOp.cancel(); + // } + // } // - // public void testInstallWizardWithLicenceBypass() throws Exception { - // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); - // iusInvolved.add(toInstall); - // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); - // op.setProfileId(TESTPROFILE); - // PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); - // wizard.setBypassLicencePage(true); - // ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); - // dialog.setBlockOnOpen(false); - // dialog.open(); - // ProfileModificationJob longOp = null; + // public void testInstallWizardWithLicenceBypass() throws Exception { + // ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + // iusInvolved.add(toInstall); + // InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); + // op.setProfileId(TESTPROFILE); + // PreselectedIUInstallWizard wizard = new + // PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + // wizard.setBypassLicencePage(true); + // ProvisioningWizardDialog dialog = new + // ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + // dialog.setBlockOnOpen(false); + // dialog.open(); + // ProfileModificationJob longOp = null; // - // try { - // SelectableIUsPage selectableIUsPage = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); - // // should already have a plan - // assertTrue("1.0", selectableIUsPage.isPageComplete()); - // // simulate the next button by getting next page and showing - // InstallWizardPage installWizardPage = (InstallWizardPage) selectableIUsPage.getNextPage(); + // try { + // SelectableIUsPage selectableIUsPage = (SelectableIUsPage) + // wizard.getPage(SELECTION_PAGE); + // // should already have a plan + // assertTrue("1.0", selectableIUsPage.isPageComplete()); + // // simulate the next button by getting next page and showing + // InstallWizardPage installWizardPage = (InstallWizardPage) + // selectableIUsPage.getNextPage(); // - // assertTrue("Licence page bypass flag must be true", wizard.isBypassLicencePage()); - // IWizardPage licensePage = installWizardPage.getNextPage(); - // assertNull("Expected instance of AcceptLicensesWizardPage must be null", licensePage); + // assertTrue("Licence page bypass flag must be true", + // wizard.isBypassLicencePage()); + // IWizardPage licensePage = installWizardPage.getNextPage(); + // assertNull("Expected instance of AcceptLicensesWizardPage must be null", + // licensePage); // - // } finally { - // dialog.getShell().close(); - // if (longOp != null) - // longOp.cancel(); - // } - // } + // } finally { + // dialog.getShell().close(); + // if (longOp != null) + // longOp.cancel(); + // } + // } // - // private static class MyNewInstallOperation extends InstallOperation { - // public MyNewInstallOperation(ProvisioningSession session, Collection<IInstallableUnit> toInstall) { - // super(session, toInstall); - // } - // } + // private static class MyNewInstallOperation extends InstallOperation { + // public MyNewInstallOperation(ProvisioningSession session, + // Collection<IInstallableUnit> toInstall) { + // super(session, toInstall); + // } + // } /** * Tests the wizard @@ -223,15 +244,17 @@ public class InstallWithRemediationTest extends WizardTest { AvailableIUsPage page1 = (AvailableIUsPage) wizard.getPage(AVAILABLE_SOFTWARE_PAGE); // test initial wizard state - assertTrue("1.0", page1.getSelectedIUs().size() == 0); + assertTrue("1.0", page1.getSelectedIUs().isEmpty()); assertFalse("1.1", page1.isPageComplete()); // Start reaching in... AvailableIUGroup group = page1.testGetAvailableIUGroup(); group.setRepositoryFilter(AvailableIUGroup.AVAILABLE_ALL, null); - // Now manipulate the tree itself. we are reaching way in. - // We are trying to select everything in the repo apart from the IU we know is broken - DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer().getContentProvider(); + // Now manipulate the tree itself. we are reaching way in. + // We are trying to select everything in the repo apart from the IU we know is + // broken + DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer() + .getContentProvider(); provider.setSynchronous(true); group.getCheckboxTreeViewer().refresh(); group.getCheckboxTreeViewer().expandAll(); @@ -268,11 +291,12 @@ public class InstallWithRemediationTest extends WizardTest { remediationPage = wizard.getNextPage(page1); dialog.showPage(remediationPage); - // // this doesn't test much, it's just calling group API to flesh out NPE's, etc. - // group.getCheckedLeafIUs(); - // group.getDefaultFocusControl(); - // group.getSelectedIUElements(); - // group.getSelectedIUs(); + // // this doesn't test much, it's just calling group API to flesh out NPE's, + // etc. + // group.getCheckedLeafIUs(); + // group.getDefaultFocusControl(); + // group.getSelectedIUElements(); + // group.getSelectedIUs(); } finally { dialog.close(); diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java index f1ca13870..125fdd7b4 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java @@ -52,10 +52,11 @@ public class InstallWizardTest extends WizardTest { iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, "true"); iu.setVersion(Version.createOSGi(1, 0, 0)); iu.setSingleton(true); - iu.setLicenses(new ILicense[] {new License(null, "There is a license to accept!", null)}); - iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())}); + iu.setLicenses(new ILicense[] { new License(null, "There is a license to accept!", null) }); + iu.setCapabilities(new IProvidedCapability[] { + MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion()) }); toInstall = MetadataFactory.createInstallableUnit(iu); - createTestMetdataRepository(new IInstallableUnit[] {toInstall}); + createTestMetdataRepository(new IInstallableUnit[] { toInstall }); } public void testInstallWizardResolved() { @@ -79,7 +80,8 @@ public class InstallWizardTest extends WizardTest { // we should be ok assertTrue("1.1", page.isPageComplete()); - // if another operation is scheduled for this profile, we should not be allowed to proceed + // if another operation is scheduled for this profile, we should not be allowed + // to proceed longOp = getLongTestOperation(); getProvisioningUI().schedule(longOp, StatusManager.LOG); // causes recalculation of plan and status @@ -125,7 +127,8 @@ public class InstallWizardTest extends WizardTest { // get the operation Field opField = ResolutionResultsWizardPage.class.getDeclaredField("resolvedOperation"); opField.setAccessible(true); - assertTrue("Expected instance of MyNewInstallOperation", opField.get(page) instanceof MyNewInstallOperation); + assertTrue("Expected instance of MyNewInstallOperation", + opField.get(page) instanceof MyNewInstallOperation); } finally { dialog.getShell().close(); if (longOp != null) @@ -154,7 +157,8 @@ public class InstallWizardTest extends WizardTest { assertFalse("License page bypass flag must be false", wizard.isBypassLicensePage()); IWizardPage licensePage = installWizardPage.getNextPage(); - assertTrue("Expected instance of AcceptLicensesWizardPage", licensePage instanceof AcceptLicensesWizardPage); + assertTrue("Expected instance of AcceptLicensesWizardPage", + licensePage instanceof AcceptLicensesWizardPage); } finally { dialog.getShell().close(); @@ -219,15 +223,17 @@ public class InstallWizardTest extends WizardTest { AvailableIUsPage page1 = (AvailableIUsPage) wizard.getPage(AVAILABLE_SOFTWARE_PAGE); // test initial wizard state - assertTrue("1.0", page1.getSelectedIUs().size() == 0); + assertTrue("1.0", page1.getSelectedIUs().isEmpty()); assertFalse("1.1", page1.isPageComplete()); // Start reaching in... AvailableIUGroup group = page1.testGetAvailableIUGroup(); group.setRepositoryFilter(AvailableIUGroup.AVAILABLE_ALL, null); - // Now manipulate the tree itself. we are reaching way in. - // We are trying to select everything in the repo apart from the IU we know is broken - DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer().getContentProvider(); + // Now manipulate the tree itself. we are reaching way in. + // We are trying to select everything in the repo apart from the IU we know is + // broken + DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer() + .getContentProvider(); provider.setSynchronous(true); group.getCheckboxTreeViewer().refresh(); group.getCheckboxTreeViewer().expandAll(); @@ -252,7 +258,8 @@ public class InstallWizardTest extends WizardTest { dialog.showPage(page); assertTrue("3.0", page.isPageComplete()); - // if another operation is scheduled for this profile, we should not be allowed to proceed + // if another operation is scheduled for this profile, we should not be allowed + // to proceed longOp = getLongTestOperation(); getProvisioningUI().schedule(longOp, StatusManager.LOG); // causes recalculation of plan and status diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java index fc71e623c..47676b6ee 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java @@ -36,17 +36,19 @@ import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest; public class InstallOperationTests extends AbstractProvisioningUITest { public void testInstallerPlan() throws ProvisionException { URI uri = getTestData("InstallHandler", "testData/installPlan").toURI(); - Set<IInstallableUnit> ius = getMetadataRepositoryManager().loadRepository(uri, getMonitor()).query(QueryUtil.createIUQuery("A"), getMonitor()).toSet(); - assertTrue("One IU", ius.size() == 1); + Set<IInstallableUnit> ius = getMetadataRepositoryManager().loadRepository(uri, getMonitor()) + .query(QueryUtil.createIUQuery("A"), getMonitor()).toSet(); + assertEquals("One IU", 1, ius.size()); InstallOperation op = new InstallOperation(getSession(), ius); op.setProfileId(TESTPROFILE); ProvisioningContext pc = new ProvisioningContext(getAgent()); - pc.setArtifactRepositories(new URI[] {uri}); - pc.setMetadataRepositories(new URI[] {uri}); + pc.setArtifactRepositories(new URI[] { uri }); + pc.setMetadataRepositories(new URI[] { uri }); op.setProvisioningContext(pc); assertTrue("Should resolve", op.resolveModal(getMonitor()).isOK()); assertTrue("Should install", op.getProvisioningJob(null).runModal(getMonitor()).isOK()); - assertFalse("Action1 should have been installed", getProfile(TESTPROFILE).query(QueryUtil.createIUQuery("Action1"), getMonitor()).isEmpty()); + assertFalse("Action1 should have been installed", + getProfile(TESTPROFILE).query(QueryUtil.createIUQuery("Action1"), getMonitor()).isEmpty()); } public void testDetectMissingRequirement() throws ProvisionException, OperationCanceledException { @@ -59,35 +61,43 @@ public class InstallOperationTests extends AbstractProvisioningUITest { repoA = getMetadataRepositoryManager().loadRepository(uriA, getMonitor()); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=305565 - repoA.addReferences(Collections.singletonList(new RepositoryReference(uriA, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); + repoA.addReferences(Collections + .singletonList(new RepositoryReference(uriA, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); // now create a second set of repos and refer from the first repoB = getMetadataRepositoryManager().loadRepository(uriB, getMonitor()); - repoB.addReferences(Collections.singletonList(new RepositoryReference(uriB, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); - repoA.addReferences(Collections.singletonList(new RepositoryReference(repoB.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED))); + repoB.addReferences(Collections + .singletonList(new RepositoryReference(uriB, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); + repoA.addReferences(Collections.singletonList( + new RepositoryReference(repoB.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED))); // this repo is referred by the previous one repoC = getMetadataRepositoryManager().loadRepository(uriC, getMonitor()); - repoC.addReferences(Collections.singletonList(new RepositoryReference(uriC, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); - repoB.addReferences(Collections.singletonList(new RepositoryReference(repoC.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED))); + repoC.addReferences(Collections + .singletonList(new RepositoryReference(uriC, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED))); + repoB.addReferences(Collections.singletonList( + new RepositoryReference(repoC.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED))); String id = "TestProfileIDForMissingRequirement"; createProfile(id); ProvisioningContext context = new ProvisioningContext(getAgent()); - context.setMetadataRepositories(new URI[] {repoA.getLocation()}); + context.setMetadataRepositories(new URI[] { repoA.getLocation() }); context.setArtifactRepositories(new URI[0]); - IInstallableUnit[] units = repoA.query(QueryUtil.createIUQuery("A"), getMonitor()).toArray(IInstallableUnit.class); + IInstallableUnit[] units = repoA.query(QueryUtil.createIUQuery("A"), getMonitor()) + .toArray(IInstallableUnit.class); assertTrue("should find A in main repo", units.length > 0); // NOW WE CAN TEST! - assertNull("ProvisioningContext does not follow by default", context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES)); + assertNull("ProvisioningContext does not follow by default", + context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES)); InstallOperation op = new InstallOperation(getSession(), Collections.singleton(units[0])); op.setProvisioningContext(context); op.setProfileId(id); assertTrue("Should resolve", op.resolveModal(getMonitor()).isOK()); - assertNotNull("Context was reset to follow", context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES)); + assertNotNull("Context was reset to follow", + context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES)); getArtifactRepositoryManager().removeRepository(uriA); getArtifactRepositoryManager().removeRepository(uriB); @@ -99,7 +109,7 @@ public class InstallOperationTests extends AbstractProvisioningUITest { } public void testUpdateWithNamespaceChange() { - //Create the IU that will be detected as an update + // Create the IU that will be detected as an update InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription(); iud.setId("NewB"); iud.setVersion(Version.create("1.0.0")); @@ -110,14 +120,15 @@ public class InstallOperationTests extends AbstractProvisioningUITest { Collection<IMatchExpression<IInstallableUnit>> updateExpression = new ArrayList<>(); updateExpression.add(matchExpression); - iud.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(updateExpression, IUpdateDescriptor.HIGH, (String) null, (URI) null)); + iud.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(updateExpression, IUpdateDescriptor.HIGH, + (String) null, (URI) null)); IInstallableUnit newIUB = MetadataFactory.createInstallableUnit(iud); - //create the IU being updated + // create the IU being updated IInstallableUnit installed = createIU("B"); - //Setup the profile - installAsRoots(profile, new IInstallableUnit[] {installed}, true, createPlanner(), createEngine()); + // Setup the profile + installAsRoots(profile, new IInstallableUnit[] { installed }, true, createPlanner(), createEngine()); List<IInstallableUnit> ius = new ArrayList<>(); ius.add(newIUB); @@ -126,6 +137,7 @@ public class InstallOperationTests extends AbstractProvisioningUITest { IStatus resolutionStatus = op.resolveModal(getMonitor()); assertEquals(IStatusCodes.PROFILE_CHANGE_ALTERED, ((MultiStatus) resolutionStatus).getChildren()[0].getCode()); - assertEquals(IStatusCodes.ALTERED_IMPLIED_UPDATE, ((MultiStatus) (((MultiStatus) resolutionStatus).getChildren()[0])).getChildren()[0].getCode()); + assertEquals(IStatusCodes.ALTERED_IMPLIED_UPDATE, + ((MultiStatus) (((MultiStatus) resolutionStatus).getChildren()[0])).getChildren()[0].getCode()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java index cb0c9aa5c..0b84b4e63 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java @@ -33,43 +33,73 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { protected void setUp() throws Exception { super.setUp(); a1 = createIU("A", Version.create("1.0.0")); - IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 1.0.0]"), 0, "update description"); - a120WithDifferentId = createIU("UpdateA", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); - a130 = createIU("A", Version.createOSGi(1, 3, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); - a140WithDifferentId = createIU("UpdateForA", Version.createOSGi(1, 4, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); - IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - IRequirement lifeCycle = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); - firstPatchForA1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); - secondPatchForA1 = createIUPatch("P", Version.create("2.0.0"), true, new IRequirementChange[] {change}, new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); - thirdPatchForA1 = createIUPatch("P2", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); + IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 1.0.0]"), 0, + "update description"); + a120WithDifferentId = createIU("UpdateA", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, + NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + a130 = createIU("A", Version.createOSGi(1, 3, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, + NO_TP_DATA, false, update, NO_REQUIRES); + a140WithDifferentId = createIU("UpdateForA", Version.createOSGi(1, 4, 0), null, NO_REQUIRES, NO_PROVIDES, + NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + IRequirementChange change = MetadataFactory.createRequirementChange( + MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, + false, false, false), + MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", + new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); + IRequirement lifeCycle = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + new VersionRange("[1.0.0, 1.0.0]"), null, false, false); + firstPatchForA1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] { change }, + new IRequirement[][] { { MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + VersionRange.emptyRange, null, false, false) } }, + lifeCycle); + secondPatchForA1 = createIUPatch("P", Version.create("2.0.0"), true, new IRequirementChange[] { change }, + new IRequirement[][] { { MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + VersionRange.emptyRange, null, false, false) } }, + lifeCycle); + thirdPatchForA1 = createIUPatch("P2", Version.create("1.0.0"), true, new IRequirementChange[] { change }, + new IRequirement[][] { { MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + VersionRange.emptyRange, null, false, false) } }, + lifeCycle); - IRequirementChange change2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - IRequirement lifeCycle2 = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.2.0]"), null, false, false); - patchFora2 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change2}, new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle2); + IRequirementChange change2 = MetadataFactory.createRequirementChange( + MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, + false, false, false), + MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", + new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); + IRequirement lifeCycle2 = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + new VersionRange("[2.0.0, 3.2.0]"), null, false, false); + patchFora2 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] { change2 }, + new IRequirement[][] { { MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", + VersionRange.emptyRange, null, false, false) } }, + lifeCycle2); b1 = createIU("B", Version.create("1.0.0")); - update = MetadataFactory.createUpdateDescriptor("B", new VersionRange("[1.0.0, 1.0.0]"), 0, "update description"); - b12 = createIU("B", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + update = MetadataFactory.createUpdateDescriptor("B", new VersionRange("[1.0.0, 1.0.0]"), 0, + "update description"); + b12 = createIU("B", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, + NO_TP_DATA, false, update, NO_REQUIRES); // Ensure that all versions, not just the latest, are considered by the UI getPolicy().setShowLatestVersionsOnly(false); } public void testChooseUpdateOverPatch() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2}); + createTestMetdataRepository( + new IInstallableUnit[] { a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); UpdateOperation op = getProvisioningUI().getUpdateOperation(iusInvolved, null); op.resolveModal(getMonitor()); IProfileChangeRequest request = op.getProfileChangeRequest(); - assertTrue("1.0", request.getAdditions().size() == 1); - assertTrue("1.1", request.getAdditions().iterator().next().equals(a130)); - assertTrue("1.2", request.getRemovals().size() == 1); - assertTrue("1.3", request.getRemovals().iterator().next().equals(a1)); + assertEquals("1.0", 1, request.getAdditions().size()); + assertEquals("1.1", a130, request.getAdditions().iterator().next()); + assertEquals("1.2", 1, request.getRemovals().size()); + assertEquals("1.3", a1, request.getRemovals().iterator().next()); } public void testForcePatchOverUpdate() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2}); + createTestMetdataRepository( + new IInstallableUnit[] { a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); @@ -84,16 +114,17 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { } } assertNotNull(".99", firstPatch); - op.setSelectedUpdates(new Update[] {firstPatch}); + op.setSelectedUpdates(new Update[] { firstPatch }); op.resolveModal(getMonitor()); IProfileChangeRequest request = op.getProfileChangeRequest(); - assertTrue("1.0", request.getAdditions().size() == 1); - assertTrue("1.1", request.getAdditions().iterator().next().equals(firstPatchForA1)); - assertTrue("1.2", request.getRemovals().size() == 0); + assertEquals("1.0", 1, request.getAdditions().size()); + assertEquals("1.1", firstPatchForA1, request.getAdditions().iterator().next()); + assertTrue("1.2", request.getRemovals().isEmpty()); } public void testRecognizePatchIsInstalled() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2}); + createTestMetdataRepository( + new IInstallableUnit[] { a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2 }); install(a1, true, false); install(firstPatchForA1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); @@ -102,15 +133,17 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { op.resolveModal(getMonitor()); IProfileChangeRequest request = op.getProfileChangeRequest(); // update was favored, that would happen even if patch was not installed - assertTrue("1.0", request.getAdditions().size() == 1); - assertTrue("1.1", request.getAdditions().iterator().next().equals(a130)); - // the patch is not being shown to the user because we figured out it was already installed + assertEquals("1.0", 1, request.getAdditions().size()); + assertEquals("1.1", a130, request.getAdditions().iterator().next()); + // the patch is not being shown to the user because we figured out it was + // already installed // The elements showing are a130 and a120WithDifferentId assertEquals("1.2", 2, op.getPossibleUpdates().length); } public void testChooseNotTheNewest() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2}); + createTestMetdataRepository( + new IInstallableUnit[] { a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); @@ -125,18 +158,18 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { } } assertNotNull(".99", notNewest); - op.setSelectedUpdates(new Update[] {notNewest}); + op.setSelectedUpdates(new Update[] { notNewest }); op.resolveModal(getMonitor()); IProfileChangeRequest request = op.getProfileChangeRequest(); // selected was favored - assertTrue("1.0", request.getAdditions().size() == 1); - assertTrue("1.1", request.getAdditions().iterator().next().equals(a120WithDifferentId)); + assertEquals("1.0", 1, request.getAdditions().size()); + assertEquals("1.1", a120WithDifferentId, request.getAdditions().iterator().next()); // The two updates and the patch were recognized assertEquals("1.2", 3, op.getPossibleUpdates().length); } public void testChooseLatestPatches() { - createTestMetdataRepository(new IInstallableUnit[] {a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1}); + createTestMetdataRepository(new IInstallableUnit[] { a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); @@ -145,7 +178,7 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { IProfileChangeRequest request = op.getProfileChangeRequest(); // the latest two patches were selected HashSet<IInstallableUnit> chosen = new HashSet<>(); - assertTrue("1.0", request.getAdditions().size() == 2); + assertEquals("1.0", 2, request.getAdditions().size()); chosen.addAll(request.getAdditions()); assertTrue("1.1", chosen.contains(secondPatchForA1)); assertTrue("1.2", chosen.contains(thirdPatchForA1)); @@ -154,7 +187,8 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { } public void testLatestHasDifferentId() { - createTestMetdataRepository(new IInstallableUnit[] {a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1, a120WithDifferentId, a130, a140WithDifferentId}); + createTestMetdataRepository(new IInstallableUnit[] { a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1, + a120WithDifferentId, a130, a140WithDifferentId }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); @@ -162,15 +196,15 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { op.resolveModal(getMonitor()); IProfileChangeRequest request = op.getProfileChangeRequest(); // update 140 was recognized as the latest even though it had a different id - assertTrue("1.0", request.getAdditions().size() == 1); - assertTrue("1.1", request.getAdditions().iterator().next().equals(a140WithDifferentId)); + assertEquals("1.0", 1, request.getAdditions().size()); + assertEquals("1.1", a140WithDifferentId, request.getAdditions().iterator().next()); // All three patches and all three updates can be chosen assertEquals("1.2", 6, op.getPossibleUpdates().length); } // bug 300445 public void testRemoveSelectionAfterResolve() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a130, b1, b12}); + createTestMetdataRepository(new IInstallableUnit[] { a1, a130, b1, b12 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); @@ -180,14 +214,14 @@ public class UpdateOperationTests extends AbstractProvisioningUITest { Update[] updates = op.getSelectedUpdates(); assertEquals("1.0", 2, updates.length); // choose just one - op.setSelectedUpdates(new Update[] {updates[0]}); + op.setSelectedUpdates(new Update[] { updates[0] }); op.resolveModal(getMonitor()); assertEquals("1.1", 1, op.getSelectedUpdates().length); } // bug 290858 public void testSearchForUpdatesInJob() { - createTestMetdataRepository(new IInstallableUnit[] {a1, a130, b1, b12}); + createTestMetdataRepository(new IInstallableUnit[] { a1, a130, b1, b12 }); install(a1, true, false); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a1); diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java index 6214b5448..9d279de2c 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java @@ -40,12 +40,16 @@ public class QueryProviderTests extends AbstractProvisioningUITest { categoryProperties.put("org.eclipse.equinox.p2.type.category", "true"); HashMap<String, String> groupProperties = new HashMap<>(); groupProperties.put("org.eclipse.equinox.p2.type.group", "true"); - category = createIU(CAT, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, NESTED), categoryProperties, true); - nestedCategory = createIU(NESTED, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, A), categoryProperties, true); - a = createIU(A, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, B), groupProperties, true); - b = createIU(B, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, C), groupProperties, true); + category = createIU(CAT, Version.create("1.0.0"), + createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, NESTED), categoryProperties, true); + nestedCategory = createIU(NESTED, Version.create("1.0.0"), + createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, A), categoryProperties, true); + a = createIU(A, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, B), + groupProperties, true); + b = createIU(B, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, C), + groupProperties, true); c = createIU(C, Version.create("1.0.0"), NO_REQUIRES, NO_PROPERTIES, true); - testRepo = createTestMetdataRepository(new IInstallableUnit[] {category, nestedCategory, a, b, c}); + testRepo = createTestMetdataRepository(new IInstallableUnit[] { category, nestedCategory, a, b, c }); } public void testNestedCategories() { @@ -69,8 +73,9 @@ public class QueryProviderTests extends AbstractProvisioningUITest { public void testInstallDrilldown() { IUElementListRoot root = new IUElementListRoot(); - AvailableIUElement element = new AvailableIUElement(root, a, TESTPROFILE, getPolicy().getShowDrilldownRequirements()); - root.setChildren(new Object[] {element}); + AvailableIUElement element = new AvailableIUElement(root, a, TESTPROFILE, + getPolicy().getShowDrilldownRequirements()); + root.setChildren(new Object[] { element }); ArrayList<IInstallableUnit> iusInvolved = new ArrayList<>(); iusInvolved.add(a); InstallOperation op = new InstallOperation(getSession(), iusInvolved); @@ -79,7 +84,7 @@ public class QueryProviderTests extends AbstractProvisioningUITest { IQueryable<IInstallableUnit> queryable = op.getProvisioningPlan().getAdditions(); element.setQueryable(queryable); Object[] children = element.getChildren(element); - assertTrue("1.1", children.length == 1); + assertEquals("1.1", 1, children.length); } } diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java index 181b9bbab..6630186f2 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java @@ -50,7 +50,7 @@ public class QueryableArtifactRepositoryManagerTest extends AbstractQueryTest { QueryableArtifactRepositoryManager manager = getQueryableManager(); IQueryResult<URI> result = manager.locationsQueriable().query(new RepositoryLocationQuery(), getMonitor()); - assertTrue(queryResultSize(result) == repoCount); + assertEquals(repoCount, queryResultSize(result)); } private QueryableArtifactRepositoryManager getQueryableManager() { |