aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-10-03 05:12:46 (EDT)
committerbveliev2011-10-03 05:12:46 (EDT)
commite98fde17402d6e64391073006e071dddf506f48d (patch)
treef289778619f4ab99c598365c96a91c4ac5f1954f
parent588e8ba655686cc2c5b8f7d5ef4759a3930500df (diff)
downloadorg.eclipse.rtp-e98fde17402d6e64391073006e071dddf506f48d.zip
org.eclipse.rtp-e98fde17402d6e64391073006e071dddf506f48d.tar.gz
org.eclipse.rtp-e98fde17402d6e64391073006e071dddf506f48d.tar.bz2
* Configurator model changed.
- Code adapted to the changes - Test cases adapted to the changes
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/.classpath14
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF3
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/FeatureTest.java22
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java79
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java6
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/example-sources.json (renamed from configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json)6
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Feature.java26
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java34
-rw-r--r--core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java144
-rw-r--r--core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManagerTest.java12
-rw-r--r--core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java12
-rw-r--r--core/org.eclipse.rtp.core.service.provider/data/example-sources.json33
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java16
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java36
14 files changed, 255 insertions, 188 deletions
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/.classpath b/configurator.test/org.eclipse.rtp.configurator.model.test/.classpath
index ad32c83..8a8f166 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/.classpath
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/.classpath
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF b/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
index dc1488d..92d72e7 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
@@ -6,5 +6,4 @@ Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.eclipse.rtp.configurator.model;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="[4.8.2,4.9.0)",
- org.mockito;bundle-version="[1.8.0,1.9.0)",
- org.eclipse.core.runtime;bundle-version="3.7.0"
+ org.mockito;bundle-version="[1.8.0,1.9.0)"
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/FeatureTest.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/FeatureTest.java
new file mode 100644
index 0000000..630c23d
--- /dev/null
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/FeatureTest.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.rtp.configurator.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class FeatureTest {
+
+ @Test
+ public void testGetValues() {
+ Feature feature = new Feature( "org.eclipse.rap.feature", "1.5.0" );
+ assertEquals( "org.eclipse.rap.feature", feature.getId() );
+ assertEquals( "1.5.0", feature.getVersion() );
+ }
+}
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java
index 5e6edd1..6181247 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java
@@ -1,43 +1,34 @@
-/*******************************************************************************
-* Copyright (c) 2011 EclipseSource and others. All rights reserved. This
-* program and the accompanying materials are made available under the terms of
-* the Eclipse Public License v1.0 which accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.model;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
+import java.util.List;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.rtp.configurator.model.internal.SourceUnMarshallerImpl;
import org.junit.Test;
-import org.osgi.framework.Bundle;
-
public class SourceUnMarshallerTest {
-
+
@Test
- public void first() throws IOException {
+ public void testUnmarshal() throws IOException {
InputStream stream = readExampleSources();
SourceUnMarshaller marshaller = new SourceUnMarshallerImpl();
-
SourceProvider provider = marshaller.marshal( stream );
assertEquals( 2, provider.getSources().size() );
checkFirstSource( provider.getSources().get( 0 ) );
checkSecondSource( provider.getSources().get( 1 ) );
}
-
+
private void checkFirstSource( Source source ) {
assertEquals( "rap", source.getName() );
assertEquals( "Some text", source.getDescription() );
@@ -48,17 +39,28 @@ public class SourceUnMarshallerTest {
}
private void checkFirstRapVersion( Source source ) {
- SourceVersion source1 = source.getVersions().get( 0 );
- assertEquals( "org.eclipse.rap.feature.group", source1.getId() );
- assertEquals( "1.4", source1.getVersion() );
- assertEquals( "http://foo.bar", source1.getRepositoryUrl() );
+ SourceVersion version = source.getVersions().get( 0 );
+ assertEquals( "1.4", version.getVersion() );
+ assertEquals( "http://foo.bar", version.getRepositoryUrl() );
+ List<Feature> features = version.getFeatures();
+ assertTrue( 2 == features.size() );
+ checkFeature( "org.eclipse.rap.feature.group", "2.5.0", features.get( 0 ) );
+ checkFeature( "org.eclipse.rap.feature.group.ext", "1.5.0", features.get( 1 ) );
}
private void checkSecondRapVersion( Source source ) {
- SourceVersion source2 = source.getVersions().get( 1 );
- assertEquals( "org.eclipse.rap.feature.group", source2.getId() );
- assertEquals( "1.5", source2.getVersion() );
- assertEquals( "http://foo.bar2", source2.getRepositoryUrl() );
+ SourceVersion version = source.getVersions().get( 1 );
+ assertEquals( "1.5", version.getVersion() );
+ assertEquals( "http://foo.bar2", version.getRepositoryUrl() );
+ List<Feature> features = version.getFeatures();
+ assertTrue( 2 == features.size() );
+ checkFeature( "org.eclipse.rap.feature.group", "2.5.0", features.get( 0 ) );
+ checkFeature( "org.eclipse.rap.feature.group.ext", "1.5.0", features.get( 1 ) );
+ }
+
+ private void checkFeature( String id, String version, Feature feature ) {
+ assertEquals( id, feature.getId() );
+ assertEquals( version, feature.getVersion() );
}
private void checkSecondSource( Source source ) {
@@ -70,18 +72,17 @@ public class SourceUnMarshallerTest {
}
private void checkEquinoxVersion( Source source ) {
- SourceVersion source1 = source.getVersions().get( 0 );
- assertEquals( "org.eclipse.equinox.feature.group", source1.getId() );
- assertEquals( "3.8.1", source1.getVersion() );
- assertEquals( "http://foo.bar3", source1.getRepositoryUrl() );
+ SourceVersion version = source.getVersions().get( 0 );
+ // assertEquals( "org.eclipse.equinox.feature.group", source1.getId() );
+ assertEquals( "3.8.1", version.getVersion() );
+ assertEquals( "http://foo.bar3", version.getRepositoryUrl() );
+ List<Feature> features = version.getFeatures();
+ assertTrue( 2 == features.size() );
+ checkFeature( "org.eclipse.rap.feature.group", "2.5.0", features.get( 0 ) );
+ checkFeature( "org.eclipse.rap.feature.group.ext", "1.5.0", features.get( 1 ) );
}
private InputStream readExampleSources() throws IOException {
- Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.model.test" );
- URL unResolvedUrl = FileLocator.find( bundle, new Path("data/example-sources.json"), null );
- URL testDataUrl = FileLocator.resolve( unResolvedUrl );
- File testDataFile = new Path( testDataUrl.getFile() ).toFile();
- return new FileInputStream( testDataFile );
+ return this.getClass().getResourceAsStream( "example-sources.json" );
}
-
}
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
index 8272b78..a751baa 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
@@ -10,6 +10,7 @@
package org.eclipse.rtp.configurator.model;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import org.junit.Test;
@@ -18,14 +19,13 @@ public class SourceVersionTest {
@Test
public void testGetValues() {
- SourceVersion version = new SourceVersion( "org.eclipse.rap.feature.group",
- "1.4",
+ SourceVersion version = new SourceVersion( "1.4",
"http://foo.bar",
"description",
"http://info.bar" );
- assertEquals( "org.eclipse.rap.feature.group", version.getId() );
assertEquals( "1.4", version.getVersion() );
assertEquals( "http://foo.bar", version.getRepositoryUrl() );
+ assertNull( version.getFeatures() );
}
}
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/example-sources.json
index a761680..ff65b7e 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/example-sources.json
@@ -6,12 +6,12 @@
"infoUrl": "http://foo.bar/info",
"versions": [
{
- "id": "org.eclipse.rap.feature.group",
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
"version": "1.4",
"repositoryUrl": "http://foo.bar"
},
{
- "id": "org.eclipse.rap.feature.group",
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
"version": "1.5",
"repositoryUrl": "http://foo.bar2"
}
@@ -23,7 +23,7 @@
"infoUrl": "http://foo.bar/info3",
"versions": [
{
- "id": "org.eclipse.equinox.feature.group",
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
"version": "3.8.1",
"repositoryUrl": "http://foo.bar3"
}
diff --git a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Feature.java b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Feature.java
new file mode 100644
index 0000000..a24ae96
--- /dev/null
+++ b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Feature.java
@@ -0,0 +1,26 @@
+package org.eclipse.rtp.configurator.model;
+
+
+public class Feature {
+
+ private String id;
+ private String version;
+
+
+ public Feature() {
+ // Only for Gson
+ }
+
+ public Feature(String id, String version) {
+ this.id = id;
+ this.version = version;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+}
diff --git a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
index b22e37f..d260d28 100644
--- a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
+++ b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
-* Copyright (c) 2011 EclipseSource and others. All rights reserved. This
-* program and the accompanying materials are made available under the terms of
-* the Eclipse Public License v1.0 which accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.model;
+import java.util.Collections;
+import java.util.List;
public class SourceVersion {
private String version;
private String repositoryUrl;
- private String id;
+ private List<Feature> features;
SourceVersion() {
// only for Gson
}
-
- public SourceVersion( String id, String version, String repositoryUrl, String description, String infoUrl ) {
- this.id = id;
+
+ public SourceVersion( String version, String repositoryUrl, String description, String infoUrl ) {
this.version = version;
this.repositoryUrl = repositoryUrl;
+ this.features = Collections.emptyList();
}
public String getVersion() {
@@ -33,11 +33,11 @@ public class SourceVersion {
public String getRepositoryUrl() {
return repositoryUrl;
}
-
- public String getId(){
- return id;
+
+ public List<Feature> getFeatures() {
+ return features;
}
-
+
@Override
public String toString() {
StringBuilder result = new StringBuilder();
diff --git a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
index 60b2f8f..6139148 100644
--- a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
+++ b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
@@ -1,16 +1,14 @@
-/*******************************************************************************
-* Copyright (c) 2011 EclipseSource and others. All rights reserved. This
-* program and the accompanying materials are made available under the terms of
-* the Eclipse Public License v1.0 which accompanies this distribution, and is
-* available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html Contributors: EclipseSource - initial API and
+ * implementation
+ *******************************************************************************/
package org.eclipse.rtp.configurator.service.provider.internal;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -38,74 +36,70 @@ import org.junit.Test;
public class ConfiguratorServiceTest {
- private DefaultConfiguratorService configuratorService;
- private P2Util p2UtilMock;
+ private DefaultConfiguratorService configuratorService;
+ private P2Util p2UtilMock;
private SourceProvider sourceProvider;
private FeatureManager featureManager;
private RepositoryManager repositoryManager;
- @Before
- public void setUp() throws IOException {
- configuratorService = new DefaultConfiguratorService();
- p2UtilMock = mock(P2Util.class);
- configuratorService.setP2Util(p2UtilMock);
- InputStream inputStream = Fixture.readExampleSources();
- sourceProvider = Fixture.getSourceProvider( inputStream );
- ConfiguratorModelUtil.setSourceProvider( sourceProvider );
- }
+ @Before
+ public void setUp() throws IOException {
+ configuratorService = new DefaultConfiguratorService();
+ p2UtilMock = mock( P2Util.class );
+ configuratorService.setP2Util( p2UtilMock );
+ InputStream inputStream = Fixture.readExampleSources();
+ sourceProvider = Fixture.getSourceProvider( inputStream );
+ ConfiguratorModelUtil.setSourceProvider( sourceProvider );
+ }
+
+ @Test
+ public void testInstall() throws CoreException, FeatureInstallException, URISyntaxException {
+ featureManager = mock( FeatureManager.class );
+ repositoryManager = mock( RepositoryManager.class );
+ when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
+ when( p2UtilMock.getRepositoryManager() ).thenReturn( repositoryManager );
+ SourceVersion sourceVersion = sourceProvider.getSources().get( 0 ).getVersions().get( 0 );
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "rap" );
+ parameters.add( "1.4" );
+ IStatus status = configuratorService.install( parameters );
+ verify( featureManager, atLeastOnce() ).installFeature( sourceVersion );
+ verify( repositoryManager, atLeastOnce() ).addRepository( new URI( "http://foo.bar" ) );
+ assertTrue( status.isOK() );
+ }
+
+ @Test
+ public void testNothingToInstall()
+ throws CoreException, FeatureInstallException, URISyntaxException
+ {
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "rap" );
+ parameters.add( "1.6" );
+ IStatus status = configuratorService.install( parameters );
+ assertFalse( status.isOK() );
+ }
+
+ @Test
+ public void testRemove() throws CoreException, FeatureInstallException, URISyntaxException {
+ SourceVersion sourceVersion = sourceProvider.getSources().get( 0 ).getVersions().get( 0 );
+ featureManager = mock( FeatureManager.class );
+ when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "rap" );
+ IStatus status = configuratorService.remove( parameters );
+ verify( featureManager, atLeastOnce() ).uninstallFeature( sourceVersion );
+ assertTrue( status.isOK() );
+ }
-
- @Test
- public void testInstall() throws CoreException, FeatureInstallException, URISyntaxException {
- featureManager = mock( FeatureManager.class );
- repositoryManager = mock( RepositoryManager.class );
- when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
- when( p2UtilMock.getRepositoryManager() ).thenReturn( repositoryManager );
- SourceVersion sourceVersion = sourceProvider.getSources().get( 0 ).getVersions().get( 0 );
- List<String> parameters = new ArrayList<String>();
- parameters.add( "rap" );
- parameters.add( "1.4" );
- IStatus status = configuratorService.install( parameters );
-
- verify( featureManager, atLeastOnce() ).installFeature( sourceVersion );
- verify( repositoryManager, atLeastOnce() ).addRepository( new URI("http://foo.bar") );
- assertTrue( status.isOK() );
- }
-
- @Test
- public void testNothingToInstall() throws CoreException, FeatureInstallException, URISyntaxException {
- List<String> parameters = new ArrayList<String>();
- parameters.add( "rap" );
- parameters.add( "1.6" );
- IStatus status = configuratorService.install( parameters );
-
- assertFalse( status.isOK() );
- }
-
- @Test
- public void testRemove() throws CoreException, FeatureInstallException, URISyntaxException {
- SourceVersion sourceVersion = sourceProvider.getSources().get( 0 ).getVersions().get( 0 );
- featureManager = mock( FeatureManager.class );
- when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
- when(featureManager.isInstalled( "org.eclipse.rap.feature.group", "1.4" )).thenReturn( true );
-
- List<String> parameters = new ArrayList<String>();
- parameters.add( "rap" );
- IStatus status = configuratorService.remove( parameters );
-
- verify( featureManager, atLeastOnce() ).uninstallFeature( sourceVersion );
- assertTrue( status.isOK() );
- }
-
- @Test
- public void testNothingToRemove() throws CoreException, FeatureInstallException, URISyntaxException {
- featureManager = mock( FeatureManager.class );
- when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
-
- List<String> parameters = new ArrayList<String>();
- parameters.add( "rap" );
- IStatus status = configuratorService.remove( parameters );
-
- assertTrue( status.isOK() );
- }
+ @Test
+ public void testNothingToRemove()
+ throws CoreException, FeatureInstallException, URISyntaxException
+ {
+ featureManager = mock( FeatureManager.class );
+ when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "rap" );
+ IStatus status = configuratorService.remove( parameters );
+ assertTrue( status.isOK() );
+ }
}
diff --git a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManagerTest.java b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManagerTest.java
index c017640..125bb27 100644
--- a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManagerTest.java
+++ b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManagerTest.java
@@ -77,11 +77,7 @@ public class FeatureManagerTest {
any( ProvisioningContext.class ),
any( SubMonitor.class ) ) ).thenReturn( provisioningPlan );
try {
- this.objectUnderTest.installFeature( new SourceVersion( FEATURE_NAME,
- FEATURE_VERSION,
- "",
- "",
- "" ) );
+ this.objectUnderTest.installFeature( new SourceVersion( FEATURE_VERSION, "", "", "" ) );
fail();
} catch( FeatureInstallException e ) {
assertEquals( "Cannot complete the request. See the error log for details.\n",
@@ -99,11 +95,7 @@ public class FeatureManagerTest {
any( ProvisioningContext.class ),
any( SubMonitor.class ) ) ).thenReturn( provisioningPlan );
try {
- this.objectUnderTest.uninstallFeature( new SourceVersion( FEATURE_NAME,
- FEATURE_VERSION,
- "",
- "",
- "" ) );
+ this.objectUnderTest.uninstallFeature( new SourceVersion( FEATURE_VERSION, "", "", "" ) );
fail();
} catch( FeatureInstallException e ) {
assertEquals( "Cannot complete the request. See the error log for details.\n",
diff --git a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
index 558a87c..79072e3 100644
--- a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
+++ b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
@@ -13,20 +13,18 @@ import org.eclipse.rtp.configurator.model.SourceProvider;
import org.eclipse.rtp.configurator.model.SourceUnMarshaller;
import org.osgi.framework.Bundle;
-
public class Fixture {
-
+
public static InputStream readExampleSources() throws IOException {
- Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.model.test" );
- URL unResolvedUrl = FileLocator.find( bundle, new Path("data/example-sources.json"), null );
+ Bundle bundle = Platform.getBundle( "org.eclipse.rtp.core.service.provider" );
+ URL unResolvedUrl = FileLocator.find( bundle, new Path( "data/example-sources.json" ), null );
URL testDataUrl = FileLocator.resolve( unResolvedUrl );
File testDataFile = new Path( testDataUrl.getFile() ).toFile();
return new FileInputStream( testDataFile );
}
-
- public static SourceProvider getSourceProvider(InputStream inputStream){
+
+ public static SourceProvider getSourceProvider( InputStream inputStream ) {
SourceUnMarshaller marshaller = ConfiguratorModelUtil.getSourceUnMarshaller();
return marshaller.marshal( inputStream );
}
-
}
diff --git a/core/org.eclipse.rtp.core.service.provider/data/example-sources.json b/core/org.eclipse.rtp.core.service.provider/data/example-sources.json
new file mode 100644
index 0000000..ff65b7e
--- /dev/null
+++ b/core/org.eclipse.rtp.core.service.provider/data/example-sources.json
@@ -0,0 +1,33 @@
+{
+ "sources": [
+ {
+ "name": "rap",
+ "description": "Some text",
+ "infoUrl": "http://foo.bar/info",
+ "versions": [
+ {
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
+ "version": "1.4",
+ "repositoryUrl": "http://foo.bar"
+ },
+ {
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
+ "version": "1.5",
+ "repositoryUrl": "http://foo.bar2"
+ }
+ ]
+ },
+ {
+ "name": "equinox",
+ "description": "Some text3",
+ "infoUrl": "http://foo.bar/info3",
+ "versions": [
+ {
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
+ "version": "3.8.1",
+ "repositoryUrl": "http://foo.bar3"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
index ff2254e..7e3c925 100644
--- a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
+++ b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
@@ -19,7 +19,6 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rtp.configurator.core.IConfiguratorService;
import org.eclipse.rtp.configurator.model.Source;
-import org.eclipse.rtp.configurator.model.SourceProvider;
import org.eclipse.rtp.configurator.model.SourceVersion;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureInstallException;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureManager;
@@ -48,12 +47,12 @@ public class DefaultConfiguratorService implements IConfiguratorService {
IStatus result = null;
try {
SourceVersion sourceVersion = getSourceVersions( parameter );
- if(sourceVersion != null){
+ if( sourceVersion != null ) {
loadRepository( sourceVersion );
install( sourceVersion );
result = Status.OK_STATUS;
- }else{
- System.out.println("No source found to install");
+ } else {
+ System.out.println( "No source found to install" );
result = Status.CANCEL_STATUS;
}
} catch( Exception e ) {
@@ -126,18 +125,13 @@ public class DefaultConfiguratorService implements IConfiguratorService {
List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
List<Source> sourceToUinstall = searchSources( anyListOf, sources );
for( Source source : sourceToUinstall ) {
- List<SourceVersion> versions = source.getVersions();
- for( SourceVersion sourceVersion : versions ) {
- if( featureManager.isInstalled( sourceVersion.getId(), sourceVersion.getVersion() ) ) {
- result.add( sourceVersion );
- }
- }
+ result.addAll( source.getVersions() );
}
return result;
}
private List<IStatus> uninstall( FeatureManager featureManager,
- List<SourceVersion> sourceVersionsToUnisntall )
+ List<SourceVersion> sourceVersionsToUnisntall )
{
List<IStatus> errorStatus = new ArrayList<IStatus>();
for( SourceVersion sourceVersion : sourceVersionsToUnisntall ) {
diff --git a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
index 0ab3ade..aa335de 100644
--- a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
+++ b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
@@ -26,7 +26,9 @@ import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
import org.eclipse.equinox.p2.operations.ProvisioningJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.operations.UninstallOperation;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.rtp.configurator.model.Feature;
import org.eclipse.rtp.configurator.model.SourceVersion;
@SuppressWarnings( "restriction" )
@@ -70,10 +72,16 @@ public class FeatureManager {
{
ProvisioningSession session = new ProvisioningSession( provisioningAgent );
ProvisioningContext context = createProvisioningContext();
- Collection<IInstallableUnit> units = getInstallableUnits( context,
- sourceVersion.getId(),
- sourceVersion.getVersion() );
- ProfileChangeOperation operation = getOperation( session, units, action );
+ List<Feature> features = sourceVersion.getFeatures();
+ List<IInstallableUnit> unitsToInstall = new ArrayList<IInstallableUnit>();
+ for( Feature feature : features ) {
+ Collection<IInstallableUnit> units = getInstallableUnits( context,
+ feature.getId(),
+ feature.getVersion(),
+ action );
+ unitsToInstall.addAll( units );
+ }
+ ProfileChangeOperation operation = getOperation( session, unitsToInstall, action );
operation.setProvisioningContext( context );
resolveOperation( operation );
return operation;
@@ -139,21 +147,21 @@ public class FeatureManager {
protected Collection<IInstallableUnit> getInstallableUnits( ProvisioningContext context,
String id,
- String version )
+ String version,
+ Action action )
{
- Collection<IInstallableUnit> toInstall = context.getMetadata( null )
- .query( QueryUtil.createIUQuery( id, Version.create( version ) ), null )
+ IQueryable<IInstallableUnit> queryable = action == Action.INSTALL
+ ? context.getMetadata( null )
+ : getProfile();
+ Collection<IInstallableUnit> toInstall = queryable.query( QueryUtil.createIUQuery( id,
+ Version.create( version ) ),
+ null )
.toUnmodifiableSet();
return toInstall;
}
- public boolean isInstalled( String id, String version ) {
+ public IProfile getProfile() {
IProfileRegistry profileRegistry = ( IProfileRegistry )provisioningAgent.getService( IProfileRegistry.SERVICE_NAME );
- IProfile profile = profileRegistry.getProfile( IProfileRegistry.SELF );
- Collection<IInstallableUnit> toInstall = profile.query( QueryUtil.createIUQuery( id,
- Version.create( version ) ),
- null )
- .toUnmodifiableSet();
- return !toInstall.isEmpty();
+ return profileRegistry.getProfile( IProfileRegistry.SELF );
}
}