aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-10-22 07:56:01 (EDT)
committerbveliev2011-10-22 07:56:01 (EDT)
commitaa0fd5a0bdaecd9c5ca337471d6739c616b48a21 (patch)
tree4ed4cca4677b3195b1a9a2fa67b96ebcd5509f8e
parentad0480267e6d84e1335fedc5ebd1182df5e0a7c4 (diff)
downloadorg.eclipse.rtp-aa0fd5a0bdaecd9c5ca337471d6739c616b48a21.zip
org.eclipse.rtp-aa0fd5a0bdaecd9c5ca337471d6739c616b48a21.tar.gz
org.eclipse.rtp-aa0fd5a0bdaecd9c5ca337471d6739c616b48a21.tar.bz2
NEW - bug 361728: [Configurator] Configuration URL should be
configurable via a system property https://bugs.eclipse.org/bugs/show_bug.cgi?id=361728
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml2
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java16
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtil.java (renamed from bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java)18
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java4
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java4
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java2
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtilTest.java16
7 files changed, 41 insertions, 21 deletions
diff --git a/bundles/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml b/bundles/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml
index 27cfcb4..5af8f2b 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml
+++ b/bundles/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.core.service.provider.model">
- <implementation class="org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil"/>
+ <implementation class="org.eclipse.rtp.configurator.service.provider.internal.util.ModelUtil"/>
<reference bind="setUnMarshaller" cardinality="1..1" interface="org.eclipse.rtp.core.model.SourceUnMarshaller" name="SourceUnMarshaller" policy="static" unbind="unsetUnMarshaller"/>
</scr:component>
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
index d486c99..76d606d 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
@@ -22,7 +22,7 @@ import org.eclipse.rtp.configurator.core.IConfiguratorService;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureInstallException;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureManager;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.RepositoryManager;
-import org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil;
+import org.eclipse.rtp.configurator.service.provider.internal.util.ModelUtil;
import org.eclipse.rtp.configurator.service.provider.internal.util.P2Util;
import org.eclipse.rtp.core.model.Source;
import org.eclipse.rtp.core.model.SourceVersion;
@@ -73,7 +73,7 @@ public class DefaultConfiguratorService implements IConfiguratorService {
}
private SourceVersion getSourceVersions( List<String> parameter ) {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<String> sourceName = new ArrayList<String>();
sourceName.add( parameter.get( 0 ) );
List<Source> searchSources = searchSources( sourceName, sources );
@@ -141,7 +141,7 @@ public class DefaultConfiguratorService implements IConfiguratorService {
FeatureManager featureManager )
{
List<SourceVersion> result = new ArrayList<SourceVersion>();
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<Source> sourceToUinstall = searchSources( anyListOf, sources );
for( Source source : sourceToUinstall ) {
result.addAll( source.getVersions() );
@@ -172,14 +172,14 @@ public class DefaultConfiguratorService implements IConfiguratorService {
@Override
public List<String> search( List<String> anyListOf ) {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<Source> result = searchSources( anyListOf, sources );
return getSortedSources( result );
}
@Override
public List<String> show( List<String> anyListOf ) {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<String> showSource = new ArrayList<String>();
showSource.add( anyListOf.get( 0 ) );
List<Source> result = searchSources( showSource, sources );
@@ -188,14 +188,14 @@ public class DefaultConfiguratorService implements IConfiguratorService {
@Override
public List<String> list() throws CoreException {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
List<String> sourcesAsString = getSortedSources( sources );
return sourcesAsString;
}
@Override
public IStatus update( List<String> anyListOf ) {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
System.out.println( "Searching for updates" );
List<Source> sourceToUpdate = searchSources( anyListOf, sources );
System.out.println( "Update started" );
@@ -206,7 +206,7 @@ public class DefaultConfiguratorService implements IConfiguratorService {
@Override
public IStatus updateWorld() {
- List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<Source> sources = ModelUtil.getSourceProvider().getSources();
System.out.println( "Update started" );
IStatus result = updateSources( sources );
System.out.println( "Update successful" );
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtil.java
index 48c6016..321926e 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtil.java
@@ -15,18 +15,18 @@ import org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator;
import org.eclipse.rtp.core.model.SourceProvider;
import org.eclipse.rtp.core.model.SourceUnMarshaller;
-public class ConfiguratorModelUtil {
+public class ModelUtil {
+ private static final String CONFIGURATION_URL = "configuration.url";
private static SourceUnMarshaller sourceUnMarshaller;
private static SourceProvider sourceProvider;
- private static String defaultModeURL = "http://foo";
public static void setUnMarshaller( SourceUnMarshaller sourceUnMarshaller ) {
- ConfiguratorModelUtil.sourceUnMarshaller = sourceUnMarshaller;
+ ModelUtil.sourceUnMarshaller = sourceUnMarshaller;
}
public static void unsetUnMarshaller( SourceUnMarshaller sourceUnMarshaller ) {
- ConfiguratorModelUtil.sourceUnMarshaller = null;
+ ModelUtil.sourceUnMarshaller = null;
}
public static SourceUnMarshaller getSourceUnMarshaller() {
@@ -34,20 +34,20 @@ public class ConfiguratorModelUtil {
}
public static void setSourceProvider( SourceProvider sourceProvider ) {
- ConfiguratorModelUtil.sourceProvider = sourceProvider;
+ ModelUtil.sourceProvider = sourceProvider;
}
public static SourceProvider getSourceProvider() {
if( sourceProvider == null ) {
sourceProvider = getDefaultModel();
}
- return ConfiguratorModelUtil.sourceProvider;
+ return ModelUtil.sourceProvider;
}
private static SourceProvider getDefaultModel() {
SourceProvider result = null;
String[] modelURLs = new String[]{
- defaultModeURL, getLocalURL()
+ getConfigurationURL(), getLocalURL()
};
for( int i = 0; i < modelURLs.length && result == null; i++ ) {
try {
@@ -73,4 +73,8 @@ public class ConfiguratorModelUtil {
}
return result;
}
+
+ protected static String getConfigurationURL() {
+ return ProviderActivator.getBundleContext().getProperty( CONFIGURATION_URL );
+ }
}
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 afa2f30..00c885d 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
@@ -17,7 +17,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil;
+import org.eclipse.rtp.configurator.service.provider.internal.util.ModelUtil;
import org.eclipse.rtp.configurator.service.provider.internal.util.Fixture;
import org.eclipse.rtp.core.model.Source;
import org.eclipse.rtp.core.model.SourceProvider;
@@ -34,7 +34,7 @@ public class ConfiguratorServiceSearchTest {
configuratorService = new DefaultConfiguratorService();
InputStream stream = Fixture.readExampleSources();
provider = Fixture.getSourceProvider( stream );
- ConfiguratorModelUtil.setSourceProvider( provider );
+ ModelUtil.setSourceProvider( provider );
}
@Test
diff --git a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
index 38f2b73..e7d28a6 100644
--- a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
+++ b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
@@ -29,7 +29,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureInstallException;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureManager;
import org.eclipse.rtp.configurator.service.provider.internal.deploy.RepositoryManager;
-import org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil;
+import org.eclipse.rtp.configurator.service.provider.internal.util.ModelUtil;
import org.eclipse.rtp.configurator.service.provider.internal.util.Fixture;
import org.eclipse.rtp.configurator.service.provider.internal.util.P2Util;
import org.eclipse.rtp.core.model.SourceProvider;
@@ -53,7 +53,7 @@ public class ConfiguratorServiceTest {
configuratorService.setP2Util( p2UtilMock );
InputStream inputStream = Fixture.readExampleSources();
sourceProvider = Fixture.getSourceProvider( inputStream );
- ConfiguratorModelUtil.setSourceProvider( sourceProvider );
+ ModelUtil.setSourceProvider( sourceProvider );
}
@Test
diff --git a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
index 5bc3998..c3c7840 100644
--- a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
+++ b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/Fixture.java
@@ -24,7 +24,7 @@ public class Fixture {
}
public static SourceProvider getSourceProvider( InputStream inputStream ) {
- SourceUnMarshaller marshaller = ConfiguratorModelUtil.getSourceUnMarshaller();
+ SourceUnMarshaller marshaller = ModelUtil.getSourceUnMarshaller();
return marshaller.marshal( inputStream );
}
}
diff --git a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtilTest.java b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtilTest.java
new file mode 100644
index 0000000..dfdf8ff
--- /dev/null
+++ b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/util/ModelUtilTest.java
@@ -0,0 +1,16 @@
+package org.eclipse.rtp.configurator.service.provider.internal.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ModelUtilTest {
+
+ @Test
+ public void testModelUrlReadFromProperty() {
+ String expectedURL = "http://test.com";
+ System.setProperty( "configuration.url", expectedURL );
+ String configurationURL = ModelUtil.getConfigurationURL();
+ assertEquals( expectedURL, configurationURL );
+ }
+}