Repository: karaf Updated Branches: refs/heads/master 3b80a4b24 -> 166b9c6fb
[KARAF-2863] Fix the Spring features and the corresponding itests Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/166b9c6f Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/166b9c6f Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/166b9c6f Branch: refs/heads/master Commit: 166b9c6fbf9e2868c8714e6974936397d159c1eb Parents: 3b80a4b Author: Jean-Baptiste Onofré <[email protected]> Authored: Mon Mar 31 18:28:49 2014 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Mar 31 18:28:49 2014 +0200 ---------------------------------------------------------------------- .../spring/src/main/feature/feature.xml | 4 +- itests/pom.xml | 4 + .../apache/karaf/itests/KarafTestSupport.java | 25 ++++- .../itests/features/Spring3FeaturesTest.java | 109 ++++++++++++++++++ .../itests/features/Spring4FeaturesTest.java | 79 +++++++++++++ .../itests/features/SpringFeaturesTest.java | 110 ------------------- 6 files changed, 218 insertions(+), 113 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/assemblies/features/spring/src/main/feature/feature.xml ---------------------------------------------------------------------- diff --git a/assemblies/features/spring/src/main/feature/feature.xml b/assemblies/features/spring/src/main/feature/feature.xml index 1547ab4..530b196 100644 --- a/assemblies/features/spring/src/main/feature/feature.xml +++ b/assemblies/features/spring/src/main/feature/feature.xml @@ -22,7 +22,7 @@ <!-- Spring DM support --> <feature name="spring-dm" description="Spring DM support" version="${spring.osgi.version}" resolver="(obr)"> - <feature version="[2.5.6,5)">spring</feature> + <feature version="[2.5.6,4)">spring</feature> <bundle dependency="true" start-level="30">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/${cglib.bundle.version}</bundle> <bundle start-level="30">mvn:org.springframework.osgi/spring-osgi-io/${spring.osgi.version}</bundle> <bundle start-level="30">mvn:org.springframework.osgi/spring-osgi-core/${spring.osgi.version}</bundle> @@ -271,7 +271,7 @@ <feature name="spring-security" description="Spring Security 3.1.x support" version="${spring.security31.version}" resolver="(obr)"> <feature>war</feature> - <feature>spring-dm-web</feature> + <feature version="[3,4)">spring-web</feature> <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.aspectj/${aspectj.bundle.version}</bundle> <bundle start-level="30">mvn:org.springframework.security/spring-security-core/${spring.security31.version}</bundle> <bundle start-level="30">mvn:org.springframework.security/spring-security-config/${spring.security31.version}</bundle> http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/itests/pom.xml ---------------------------------------------------------------------- diff --git a/itests/pom.xml b/itests/pom.xml index 9c6b50b..aa74c4f 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -114,6 +114,8 @@ <configuration> <systemPropertyVariables> <org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level> + <spring32.version>${spring32.version}</spring32.version> + <spring40.version>${spring40.version}</spring40.version> </systemPropertyVariables> </configuration> </plugin> @@ -138,6 +140,8 @@ <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine> <systemPropertyVariables> <org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level> + <spring32.version>${spring32.version}</spring32.version> + <spring40.version>${spring40.version}</spring40.version> </systemPropertyVariables> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java ---------------------------------------------------------------------- diff --git a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java index 4669b1b..9d3b729 100644 --- a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java +++ b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java @@ -15,6 +15,7 @@ package org.apache.karaf.itests; import static org.junit.Assert.assertTrue; import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureSecurity; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; @@ -131,7 +132,9 @@ public class KarafTestSupport { replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", getConfigFile("/etc/org.ops4j.pax.logging.cfg")), editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", HTTP_PORT), editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", RMI_REG_PORT), - editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", RMI_SERVER_PORT) + editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", RMI_SERVER_PORT), + editConfigurationFilePut("etc/system.properties", "spring32.version", System.getProperty("spring32.version")), + editConfigurationFilePut("etc/system.properties", "spring40.version", System.getProperty("spring40.version")) }; } @@ -357,6 +360,16 @@ public class KarafTestSupport { Assert.fail("Feature " + featureName + " should be installed but is not"); } + public void assertFeatureInstalled(String featureName, String featureVersion) throws Exception { + Feature[] features = featureService.listInstalledFeatures(); + for (Feature feature : features) { + if (featureName.equals(feature.getName()) && featureVersion.equals(feature.getVersion())) { + return; + } + } + Assert.fail("Feature " + featureName + "/" + featureVersion + " should be installed but is not"); + } + public void assertFeaturesInstalled(String ... expectedFeatures) throws Exception { Set<String> expectedFeaturesSet = new HashSet<String>(Arrays.asList(expectedFeatures)); Feature[] features = featureService.listInstalledFeatures(); @@ -398,6 +411,16 @@ public class KarafTestSupport { assertFeatureInstalled(feature); } + protected void installAssertAndUninstallFeature(String feature, String version) throws Exception { + Set<Feature> featuresBefore = new HashSet<Feature>(Arrays.asList(featureService.listInstalledFeatures())); + try { + featureService.installFeature(feature, version); + assertFeatureInstalled(feature, version); + } finally { + uninstallNewFeatures(featuresBefore); + } + } + protected void installAssertAndUninstallFeature(String... feature) throws Exception { Set<Feature> featuresBefore = new HashSet<Feature>(Arrays.asList(featureService.listInstalledFeatures())); try { http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/itests/src/test/java/org/apache/karaf/itests/features/Spring3FeaturesTest.java ---------------------------------------------------------------------- diff --git a/itests/src/test/java/org/apache/karaf/itests/features/Spring3FeaturesTest.java b/itests/src/test/java/org/apache/karaf/itests/features/Spring3FeaturesTest.java new file mode 100644 index 0000000..57128bd --- /dev/null +++ b/itests/src/test/java/org/apache/karaf/itests/features/Spring3FeaturesTest.java @@ -0,0 +1,109 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.karaf.itests.features; + +import org.apache.karaf.itests.KarafTestSupport; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerMethod; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerMethod.class) +public class Spring3FeaturesTest extends KarafTestSupport { + + @Test + public void installSpringFeature() throws Exception { + installAssertAndUninstallFeature("spring", System.getProperty("spring32.version")); + } + + @Test + public void installSpringAspectsFeature() throws Exception { + installAssertAndUninstallFeature("spring-aspects", System.getProperty("spring32.version")); + } + + @Test + public void installSpringDmFeature() throws Exception { + installAssertAndUninstallFeature("spring-dm"); + } + + @Test + public void installSpringDmWebFeature() throws Exception { + installAssertAndUninstallFeature("spring-dm-web"); + } + + @Test + public void installSpringInstrumentFeature() throws Exception { + installAssertAndUninstallFeature("spring-instrument", System.getProperty("spring32.version")); + } + + @Test + public void installSpringJdbcFeature() throws Exception { + installAssertAndUninstallFeature("spring-jdbc", System.getProperty("spring32.version")); + } + + @Test + public void installSpringJmsFeature() throws Exception { + installAssertAndUninstallFeature("spring-jms", System.getProperty("spring32.version")); + } + + @Test + public void installSpringStrutsFeature() throws Exception { + installAssertAndUninstallFeature("spring-struts", System.getProperty("spring32.version")); + } + + @Test + public void installSpringTestFeature() throws Exception { + installAssertAndUninstallFeature("spring-test", System.getProperty("spring32.version")); + } + + @Test + public void installSpringOrmFeature() throws Exception { + installAssertAndUninstallFeature("spring-orm", System.getProperty("spring32.version")); + } + + @Test + public void installSpringOxmFeature() throws Exception { + installAssertAndUninstallFeature("spring-oxm", System.getProperty("spring32.version")); + } + + @Test + public void installSpringTxFeature() throws Exception { + installAssertAndUninstallFeature("spring-tx", System.getProperty("spring32.version")); + } + + @Test + public void installSpringWebFeature() throws Exception { + installAssertAndUninstallFeature("spring-web", System.getProperty("spring32.version")); + } + + @Test + public void installSpringWebPortletFeature() throws Exception { + installAssertAndUninstallFeature("spring-web-portlet", System.getProperty("spring32.version")); + } + + @Test + public void installSpringSecurityFeature() throws Exception { + installAssertAndUninstallFeature("spring-security"); + } + + @Test + public void installGeminiBlueprintFeature() throws Exception { + installAssertAndUninstallFeature("gemini-blueprint"); + } + + // TODO add combined/all Spring features installation tests + +} http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/itests/src/test/java/org/apache/karaf/itests/features/Spring4FeaturesTest.java ---------------------------------------------------------------------- diff --git a/itests/src/test/java/org/apache/karaf/itests/features/Spring4FeaturesTest.java b/itests/src/test/java/org/apache/karaf/itests/features/Spring4FeaturesTest.java new file mode 100644 index 0000000..39ad606 --- /dev/null +++ b/itests/src/test/java/org/apache/karaf/itests/features/Spring4FeaturesTest.java @@ -0,0 +1,79 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.karaf.itests.features; + +import org.apache.karaf.itests.KarafTestSupport; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerMethod; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerMethod.class) +public class Spring4FeaturesTest extends KarafTestSupport { + + @Test + public void installSpringFeature() throws Exception { + installAssertAndUninstallFeature("spring", System.getProperty("spring40.version")); + } + + @Test + public void installSpringAspectsFeature() throws Exception { + installAssertAndUninstallFeature("spring-aspects", System.getProperty("spring40.version")); + } + + @Test + public void installSpringInstrumentFeature() throws Exception { + installAssertAndUninstallFeature("spring-instrument", System.getProperty("spring40.version")); + } + + @Test + public void installSpringJdbcFeature() throws Exception { + installAssertAndUninstallFeature("spring-jdbc", System.getProperty("spring40.version")); + } + + @Test + public void installSpringJmsFeature() throws Exception { + installAssertAndUninstallFeature("spring-jms", System.getProperty("spring40.version")); + } + + @Test + public void installSpringTestFeature() throws Exception { + installAssertAndUninstallFeature("spring-test", System.getProperty("spring40.version")); + } + + @Test + public void installSpringOrmFeature() throws Exception { + installAssertAndUninstallFeature("spring-orm", System.getProperty("spring40.version")); + } + + @Test + public void installSpringOxmFeature() throws Exception { + installAssertAndUninstallFeature("spring-oxm", System.getProperty("spring40.version")); + } + + @Test + public void installSpringTxFeature() throws Exception { + installAssertAndUninstallFeature("spring-tx", System.getProperty("spring40.version")); + } + + @Test + public void installSpringWebFeature() throws Exception { + installAssertAndUninstallFeature("spring-web", System.getProperty("spring40.version")); + } + + // TODO add combined/all Spring features installation tests + +} http://git-wip-us.apache.org/repos/asf/karaf/blob/166b9c6f/itests/src/test/java/org/apache/karaf/itests/features/SpringFeaturesTest.java ---------------------------------------------------------------------- diff --git a/itests/src/test/java/org/apache/karaf/itests/features/SpringFeaturesTest.java b/itests/src/test/java/org/apache/karaf/itests/features/SpringFeaturesTest.java deleted file mode 100644 index bdec177..0000000 --- a/itests/src/test/java/org/apache/karaf/itests/features/SpringFeaturesTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.karaf.itests.features; - -import org.apache.karaf.itests.KarafTestSupport; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; - -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerClass.class) -public class SpringFeaturesTest extends KarafTestSupport { - - @Test - public void installSpringFeature() throws Exception { - installAssertAndUninstallFeature("spring"); - } - - @Test - public void installSpringAspectsFeature() throws Exception { - installAssertAndUninstallFeature("spring-aspects"); - } - - @Test - public void installSpringDmFeature() throws Exception { - installAssertAndUninstallFeature("spring-dm"); - } - - @Test - public void installSpringDmWebFeature() throws Exception { - installAssertAndUninstallFeature("spring-dm-web"); - } - - @Test - public void installSpringInstrumentFeature() throws Exception { - installAssertAndUninstallFeature("spring-instrument"); - } - - @Test - public void installSpringJdbcFeature() throws Exception { - installAssertAndUninstallFeature("spring-jdbc"); - } - - @Test - public void installSpringJmsFeature() throws Exception { - installAssertAndUninstallFeature("spring-jms"); - } - - @Test - public void installSpringStrutsFeature() throws Exception { - installAssertAndUninstallFeature("spring-struts"); - } - - @Test - public void installSpringTestFeature() throws Exception { - installAssertAndUninstallFeature("spring-test"); - } - - @Test - public void installSpringOrmFeature() throws Exception { - installAssertAndUninstallFeature("spring-orm"); - } - - @Test - public void installSpringOxmFeature() throws Exception { - installAssertAndUninstallFeature("spring-oxm"); - } - - @Test - public void installSpringTxFeature() throws Exception { - installAssertAndUninstallFeature("spring-tx"); - } - - @Test - public void installSpringWebFeature() throws Exception { - installAssertAndUninstallFeature("spring-web"); - } - - @Test - @Ignore - public void installSpringWebPortletFeature() throws Exception { - installAssertAndUninstallFeature("spring-web-portlet"); - } - - @Test - public void installSpringSecurityFeature() throws Exception { - installAssertAndUninstallFeature("spring-security"); - } - - @Test - @Ignore - public void installGeminiBlueprintFeature() throws Exception { - installAssertAndUninstallFeature("gemini-blueprint"); - } - -}
