Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 126196 Details for
Bug 262964
Unable to remove/disable repository
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated Repository Action tests
RepositoryActionTests.patch (text/plain), 10.98 KB, created by
Matthew Piggott
on 2009-02-19 13:51:48 EST
(
hide
)
Description:
Updated Repository Action tests
Filename:
MIME Type:
Creator:
Matthew Piggott
Created:
2009-02-19 13:51:48 EST
Size:
10.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java,v >retrieving revision 1.1 >diff -u -r1.1 RemoveRepositoryActionTest.java >--- src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java 6 Nov 2008 22:00:40 -0000 1.1 >+++ src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java 19 Feb 2009 18:50:12 -0000 >@@ -10,13 +10,21 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.tests.touchpoint.eclipse; > >+import java.lang.reflect.Field; > import java.net.URI; > import java.util.HashMap; > import java.util.Map; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.preferences.IPreferencesService; >+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; > import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveRepositoryAction; > import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; >+import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; >+import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; > import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; >+import org.eclipse.equinox.p2.tests.TestActivator; >+import org.osgi.service.prefs.BackingStoreException; > > /** > * Tests for {@link org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveRepositoryAction}. >@@ -43,10 +51,48 @@ > locationURI = new URI(TEST_LOCATION); > action = new RemoveRepositoryAction(); > getArtifactRepositoryManager().addRepository(locationURI); >+ >+ IProfile profile = getProfile(IProfileRegistry.SELF); >+ if (profile != null) >+ return; >+ >+ if (System.getProperty("eclipse.p2.profile") == null) { >+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); >+ try { >+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ >+ selfField.setAccessible(true); >+ Object self = selfField.get(profileRegistry); >+ if (self == null) >+ selfField.set(profileRegistry, "agent"); >+ } catch (Throwable t) { >+ fail(); >+ } >+ } >+ profile = createProfile(IProfileRegistry.SELF); > } > > @Override > protected void tearDown() throws Exception { >+ //Remove Self preference node >+ try { >+ IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); >+ prefService.getRootNode().node("/profile/_SELF_").removeNode(); >+ } catch (BackingStoreException e) { >+ // Exception can be ignored as we're simply attempting to cleanup for other tests >+ } >+ >+ if (System.getProperty("eclipse.p2.profile") == null) { >+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); >+ try { >+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ >+ selfField.setAccessible(true); >+ Object self = selfField.get(profileRegistry); >+ if (self.equals("agent")) >+ selfField.set(profileRegistry, null); >+ } catch (Throwable t) { >+ // ignore as we still want to continue tidying up >+ } >+ } > super.tearDown(); > getArtifactRepositoryManager().removeRepository(locationURI); > } >Index: src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java,v >retrieving revision 1.11 >diff -u -r1.11 AddRepositoryActionTest.java >--- src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java 12 Feb 2009 22:33:02 -0000 1.11 >+++ src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java 19 Feb 2009 18:50:12 -0000 >@@ -10,26 +10,33 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.tests.touchpoint.eclipse; > >-import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction; >- >+import java.lang.reflect.Field; > import java.net.URI; >+import java.net.URISyntaxException; > import java.util.HashMap; > import java.util.Map; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.preferences.IPreferencesService; >+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; >+import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction; > import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddRepositoryAction; > import org.eclipse.equinox.internal.provisional.p2.core.Version; > import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; > import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; >-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; >-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; >+import org.eclipse.equinox.internal.provisional.p2.engine.*; > import org.eclipse.equinox.internal.provisional.p2.metadata.*; > import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; >+import org.eclipse.equinox.p2.tests.TestActivator; >+import org.osgi.service.prefs.BackingStoreException; >+import org.osgi.service.prefs.Preferences; > > /** > * Tests for {@link org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddRepositoryAction}. > */ > public class AddRepositoryActionTest extends AbstractProvisioningTest { > private static final String TEST_LOCATION = "http://eclipse.org/eclipse/updates/AddRepositoryActionTest"; >+ private static final String KEY_URI = "uri"; > AddRepositoryAction action; > private URI locationURI; > >@@ -50,10 +57,48 @@ > action = new AddRepositoryAction(); > locationURI = new URI(TEST_LOCATION); > getArtifactRepositoryManager().removeRepository(locationURI); >+ >+ IProfile profile = getProfile(IProfileRegistry.SELF); >+ if (profile != null) >+ return; >+ >+ if (System.getProperty("eclipse.p2.profile") == null) { >+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); >+ try { >+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ >+ selfField.setAccessible(true); >+ Object self = selfField.get(profileRegistry); >+ if (self == null) >+ selfField.set(profileRegistry, "agent"); >+ } catch (Throwable t) { >+ fail(); >+ } >+ } >+ profile = createProfile(IProfileRegistry.SELF); > } > > @Override > protected void tearDown() throws Exception { >+ //Remove Self preference node >+ try { >+ IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); >+ prefService.getRootNode().node("/profile/_SELF_").removeNode(); >+ } catch (BackingStoreException e) { >+ // Exception can be ignored as we're simply attempting to cleanup for other tests >+ } >+ >+ if (System.getProperty("eclipse.p2.profile") == null) { >+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); >+ try { >+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ >+ selfField.setAccessible(true); >+ Object self = selfField.get(profileRegistry); >+ if (self.equals("agent")) >+ selfField.set(profileRegistry, null); >+ } catch (Throwable t) { >+ // ignore as we still want to continue tidying up >+ } >+ } > super.tearDown(); > getArtifactRepositoryManager().removeRepository(locationURI); > } >@@ -110,6 +155,38 @@ > assertTrue("1.1", result.isOK()); > } > >+ public void testMultipleActionAdd() { >+ Map args = getValidArguments(); >+ IStatus result = action.execute(args); >+ assertTrue("1.0", result.isOK()); >+ >+ result = action.execute(args); >+ assertTrue("1.1", result.isOK()); >+ >+ result = action.undo(args); >+ assertTrue("1.2", result.isOK()); >+ >+ assertTrue("2.0", locationExists(null, TEST_LOCATION)); >+ } >+ >+ public void testUserWins() { >+ try { >+ getArtifactRepositoryManager().addRepository(new URI(TEST_LOCATION)); >+ assertTrue("0.1", locationExists(null, TEST_LOCATION)); >+ } catch (URISyntaxException e) { >+ // Should not occur >+ } >+ >+ Map args = getValidArguments(); >+ IStatus result = action.execute(args); >+ assertTrue("1.0", result.isOK()); >+ >+ result = action.undo(args); >+ assertTrue("1.1", result.isOK()); >+ >+ assertTrue("2.0", locationExists(null, TEST_LOCATION)); >+ } >+ > /** > * Tests for install of an IU that adds a repository. > */ >@@ -131,9 +208,34 @@ > > //check that profile property is set > profile = getProfile(id); >- String value = profile.getProperty(IProfile.PROP_METADATA_REPOSITORIES); >- assertNull("2.0", value); >- value = profile.getProperty(IProfile.PROP_ARTIFACT_REPOSITORIES); >- assertEquals("2.1", TEST_LOCATION, value); >+ // Get Preference node associated with the profile >+ IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); >+ Preferences pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); //$NON-NLS-1$ //$NON-NLS-2$ >+ String value = pref.get(KEY_URI, null); >+ >+ assertEquals("2.0", value, TEST_LOCATION); >+ } >+ >+ /* >+ * Modified from AbstractRepositoryManager >+ */ >+ private String getKey(String location) { >+ String key = location.replace('/', '_'); >+ //remove trailing slash >+ if (key.endsWith("_")) //$NON-NLS-1$ >+ key = key.substring(0, key.length() - 1); >+ return key; >+ } >+ >+ private boolean locationExists(IProfile profile, String location) { >+ IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); >+ Preferences pref; >+ if (profile != null) >+ pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifactRepositories/repositories/" + getKey(location)); >+ else >+ pref = prefService.getRootNode().node("/profile/_SELF_/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(location)); >+ if (location.equals(pref.get(KEY_URI, null))) >+ return true; >+ return false; > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262964
:
126052
|
126054
|
126195
|
126196
|
126198
|
126565