aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-10-04 13:20:43 (EDT)
committerbveliev2011-10-04 13:20:43 (EDT)
commitaa799beba58d159140ddb3b0ffc65f845d0ec480 (patch)
tree71d894708d8a8a5b9c6dd112aa5a30c6decbfc80
parent2435bc3e22198acb3171fac376751a4e0c552489 (diff)
downloadorg.eclipse.rtp-aa799beba58d159140ddb3b0ffc65f845d0ec480.zip
org.eclipse.rtp-aa799beba58d159140ddb3b0ffc65f845d0ec480.tar.gz
org.eclipse.rtp-aa799beba58d159140ddb3b0ffc65f845d0ec480.tar.bz2
* install command without version parameter implemented
-rw-r--r--core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java19
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java20
2 files changed, 38 insertions, 1 deletions
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 0089afc..085f55e 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
@@ -73,6 +73,25 @@ public class ConfiguratorServiceTest {
}
@Test
+ public void testInstallNoVersion()
+ throws CoreException, FeatureInstallException, URISyntaxException
+ {
+ featureManager = mock( FeatureManager.class );
+ repositoryManager = mock( RepositoryManager.class );
+ when( p2UtilMock.getFeatureManager() ).thenReturn( featureManager );
+ when( p2UtilMock.getRepositoryManager() ).thenReturn( repositoryManager );
+ List<SourceVersion> versions = sourceProvider.getSources().get( 0 ).getVersions();
+ Collections.sort( versions, getSourceVersionComparator() );
+ SourceVersion latestSourceVersion = versions.get( 0 );
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "rap" );
+ IStatus status = configuratorService.install( parameters );
+ verify( featureManager, atLeastOnce() ).installFeature( latestSourceVersion );
+ verify( repositoryManager, atLeastOnce() ).addRepository( new URI( "http://foo.bar2" ) );
+ assertTrue( status.isOK() );
+ }
+
+ @Test
public void testNothingToInstall()
throws CoreException, FeatureInstallException, URISyntaxException
{
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 4bda33c..a5a2a6f 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
@@ -72,10 +72,17 @@ public class DefaultConfiguratorService implements IConfiguratorService {
List<String> sourceName = new ArrayList<String>();
sourceName.add( parameter.get( 0 ) );
List<Source> searchSources = searchSources( sourceName, sources );
- SourceVersion sourceVersion = searchSourceVerions( parameter.get( 1 ), searchSources );
+ SourceVersion sourceVersion = searchSourceVerions( getVersionParameter( parameter ),
+ searchSources );
return sourceVersion;
}
+ private String getVersionParameter( List<String> parameters ) {
+ return parameters.size() > 1
+ ? parameters.get( 1 )
+ : "";
+ }
+
private void install( SourceVersion sourceVersion ) throws FeatureInstallException {
FeatureManager featureManager = p2Util.getFeatureManager();
featureManager.installFeature( sourceVersion );
@@ -90,6 +97,17 @@ public class DefaultConfiguratorService implements IConfiguratorService {
SourceVersion result = null;
for( Source source : sources ) {
List<SourceVersion> versions = source.getVersions();
+ result = getVersion( sourceVersion, versions );
+ }
+ return result;
+ }
+
+ private SourceVersion getVersion( String sourceVersion, List<SourceVersion> versions ) {
+ SourceVersion result = null;
+ Collections.sort( versions, getSourceVersionComparator() );
+ if( sourceVersion == null || sourceVersion.length() == 0 ) {
+ result = versions.get( 0 );
+ } else {
for( SourceVersion version : versions ) {
if( version.getVersion().equals( sourceVersion ) ) {
result = version;