aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-11-05 06:48:18 (EDT)
committerbveliev2011-11-05 06:48:18 (EDT)
commit89e9296adf270482042d3e7a69546d64c2655a28 (patch)
treec540b52fdf82e5249761acd9d99e1734fb3e8f42
parent2f008f18547c4d8870bcc94061f083f3300d7d1e (diff)
downloadorg.eclipse.rtp-89e9296adf270482042d3e7a69546d64c2655a28.zip
org.eclipse.rtp-89e9296adf270482042d3e7a69546d64c2655a28.tar.gz
org.eclipse.rtp-89e9296adf270482042d3e7a69546d64c2655a28.tar.bz2
NEW - bug 362942: [Core] "rt list" throws NPE when run from the IDE
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362942
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java6
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java12
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java49
3 files changed, 37 insertions, 30 deletions
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
index f2f9911..16c8e73 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
@@ -187,7 +187,7 @@ public class RTPDefaultService implements IRTPService {
return sourcesAsString;
}
- private List<String> sourcesToString( List<Source> sources, boolean addInstalledInfo ) {
+ protected List<String> sourcesToString( List<Source> sources, boolean addInstalledInfo ) {
Collections.sort( sources, new ModelUtil().getSourceComparator() );
List<String> sourcesAsString = new ArrayList<String>();
for( Source source : sources ) {
@@ -204,7 +204,7 @@ public class RTPDefaultService implements IRTPService {
List<String> result = new ArrayList<String>();
for( SourceVersion sourceVersion : versions ) {
if( addInstalledInfo ) {
- String installedInfo = getInstallInfor( sourceVersion );
+ String installedInfo = getInstallInfo( sourceVersion );
result.add( installedInfo );
}
result.add( sourceVersion.toString() );
@@ -212,7 +212,7 @@ public class RTPDefaultService implements IRTPService {
return result;
}
- private String getInstallInfor( SourceVersion sourceVersion ) {
+ private String getInstallInfo( SourceVersion sourceVersion ) {
FeatureManager featureManager = p2Util.getFeatureManager();
boolean installed = featureManager.isInstalled( sourceVersion );
String installedInfo = installed
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
index df8f28a..34ab157 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
@@ -169,11 +169,13 @@ public class FeatureManager {
public boolean isInstalled( SourceVersion sourceVersion ) {
List<IInstallableUnit> result = new ArrayList<IInstallableUnit>();
IProfile profile = getProfile();
- for( Feature feature : sourceVersion.getFeatures() ) {
- IQueryResult<IInstallableUnit> query = profile.query( QueryUtil.createIUQuery( feature.getId(),
- Version.create( feature.getVersion() ) ),
- new NullProgressMonitor() );
- result.addAll( query.toSet() );
+ if( profile != null ) {
+ for( Feature feature : sourceVersion.getFeatures() ) {
+ IQueryResult<IInstallableUnit> query = profile.query( QueryUtil.createIUQuery( feature.getId(),
+ Version.create( feature.getVersion() ) ),
+ new NullProgressMonitor() );
+ result.addAll( query.toSet() );
+ }
}
return result.size() > 0;
}
diff --git a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java
index 0df013a..ac7249a 100644
--- a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java
+++ b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java
@@ -7,18 +7,17 @@
*******************************************************************************/
package org.eclipse.rtp.configurator.service.provider.internal;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.rtp.configurator.service.provider.internal.util.Fixture;
-import org.eclipse.rtp.core.model.Source;
import org.eclipse.rtp.core.model.SourceProvider;
import org.eclipse.rtp.core.util.ModelUtil;
import org.junit.Before;
@@ -32,6 +31,7 @@ public class ConfiguratorServiceSearchTest {
@Before
public void setUp() throws IOException {
configuratorService = new RTPDefaultService();
+ configuratorService.setUp();
InputStream stream = Fixture.readExampleSources();
provider = Fixture.getSourceProvider( stream );
ModelUtil.setSourceProvider( provider );
@@ -39,50 +39,55 @@ public class ConfiguratorServiceSearchTest {
@Test
public void testList() throws CoreException {
- List<String> listExpected = getSortedTestData();
+ List<String> sourcesExpected = getSortedTestData( true );
List<String> list = configuratorService.list();
- assertTrue( Arrays.equals( listExpected.toArray(), list.toArray() ) );
+ assertTrue( Arrays.equals( sourcesExpected.toArray(), list.toArray() ) );
}
@Test
public void testShow() throws CoreException {
- List<String> listExpected = getSortedTestData();
+ List<String> testData = getSortedTestData( false );
+ ArrayList<String> expectedList = new ArrayList<String>();
+ expectedList.add( testData.get( 0 ) );
+ expectedList.add( testData.get( 1 ) );
List<String> showParameters = new ArrayList<String>();
showParameters.add( "equinox" );
List<String> list = configuratorService.show( showParameters );
- assertTrue( Arrays.equals( new String[]{
- listExpected.get( 0 )
- }, list.toArray() ) );
+ assertListsEquals( expectedList, list );
}
@Test
public void testShowManyParameters() throws CoreException {
- List<String> listExpected = getSortedTestData();
+ List<String> testData = getSortedTestData( false );
+ ArrayList<String> expectedList = new ArrayList<String>();
+ expectedList.add( testData.get( 0 ) );
+ expectedList.add( testData.get( 1 ) );
List<String> showParameters = new ArrayList<String>();
showParameters.add( "equinox" );
List<String> list = configuratorService.show( showParameters );
- assertTrue( Arrays.equals( new String[]{
- listExpected.get( 0 )
- }, list.toArray() ) );
+ assertListsEquals( expectedList, list );
}
@Test
public void testSearch() throws CoreException {
- List<String> listExpected = getSortedTestData();
+ List<String> testData = getSortedTestData( false );
+ ArrayList<String> expectedList = new ArrayList<String>();
+ expectedList.add( testData.get( 2 ) );
+ expectedList.add( testData.get( 3 ) );
+ expectedList.add( testData.get( 4 ) );
List<String> searchParameters = new ArrayList<String>();
searchParameters.add( "ra" );
List<String> list = configuratorService.search( searchParameters );
- assertTrue( Arrays.equals( new String[]{
- listExpected.get( 1 )
- }, list.toArray() ) );
+ assertListsEquals( expectedList, list );
}
- private List<String> getSortedTestData() {
- List<String> listExpected = new ArrayList<String>();
- for( Source source : provider.getSources() ) {
- listExpected.add( source.toString() );
+ private void assertListsEquals( List<String> expectedList, List<String> list2 ) {
+ for( int i = 0; i < expectedList.size(); i++ ) {
+ assertEquals( expectedList.get( i ), list2.get( i ) );
}
- Collections.sort( listExpected );
- return listExpected;
+ }
+
+ private List<String> getSortedTestData( boolean addInstallInfo ) {
+ return configuratorService.sourcesToString( provider.getSources(), addInstallInfo );
}
}