Author: [email protected] Date: Wed May 4 12:52:24 2011 New Revision: 1089
Log: AMDATU-379 First drop of web itest framework with some basic tests Added: trunk/amdatu-web/itest/ (props changed) trunk/amdatu-web/itest/base/ (props changed) trunk/amdatu-web/itest/base/pom.xml trunk/amdatu-web/itest/base/src/ trunk/amdatu-web/itest/base/src/main/ trunk/amdatu-web/itest/base/src/main/java/ trunk/amdatu-web/itest/base/src/main/java/org/ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebFixture.java trunk/amdatu-web/itest/base/src/test/ trunk/amdatu-web/itest/base/src/test/java/ trunk/amdatu-web/itest/pom.xml trunk/amdatu-web/itest/tests/ (props changed) trunk/amdatu-web/itest/tests/pom.xml trunk/amdatu-web/itest/tests/src/ trunk/amdatu-web/itest/tests/src/main/ trunk/amdatu-web/itest/tests/src/main/java/ trunk/amdatu-web/itest/tests/src/test/ trunk/amdatu-web/itest/tests/src/test/java/ trunk/amdatu-web/itest/tests/src/test/java/org/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestService.java trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestServiceImpl.java trunk/amdatu-web/maven-settings-bamboo.xml Modified: trunk/amdatu-web/pom.xml Added: trunk/amdatu-web/itest/base/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/base/pom.xml Wed May 4 12:52:24 2011 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.itest</artifactId> + <version>0.2.1-SNAPSHOT</version> + </parent> + <artifactId>org.amdatu.web.itest.base</artifactId> + <packaging>bundle</packaging> + <name>Amdatu Web - Integration Tests base</name> + + <!-- + This modules is intended to contain Amdatu Web integration test + fixture and utility logic that will be provisioned as a bundle + into the PaxExam integration tests runtime. It is used by the + Amdatu Web tests module and possibly other itest modules that + depend on Amdatu Web. + --> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> + <Export-Package>${pom.artifactId}</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Added: trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebFixture.java ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebFixture.java Wed May 4 12:52:24 2011 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.web.itest.base; + +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + +import org.ops4j.pax.exam.Option; + +public class WebFixture { + + public static Option provision() { + return org.ops4j.pax.exam.CoreOptions.provision( + mavenBundle().groupId("javax.servlet").artifactId("servlet-api").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.itest.base").versionAsInProject(), + mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.http.jetty").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.dispatcher").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.httpcontext").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.jsp").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.resource").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.jaxrs").versionAsInProject(), + mavenBundle().groupId("org.amdatu.web").artifactId("org.amdatu.web.wink").versionAsInProject() + ); + } +} Added: trunk/amdatu-web/itest/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/pom.xml Wed May 4 12:52:24 2011 @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web</artifactId> + <version>0.2.1-SNAPSHOT</version> + </parent> + <artifactId>org.amdatu.web.itest</artifactId> + <packaging>pom</packaging> + <name>Amdatu Web - Integration Tests reactor</name> + + <properties> + <org.amdatu.core.version>0.2.1-SNAPSHOT</org.amdatu.core.version> + <org.apache.felix.http.version>2.2.0</org.apache.felix.http.version> + </properties> + + <modules> + <module>base</module> + <module>tests</module> + </modules> + + <dependencyManagement> + <dependencies> + + <!-- + Amdatu core itest base is crosscutting to both the base and tests + module. This brings in the all dependencies required to work with + the core fixture. Scope is intentionally set to compile in this + section so that depending (on the base) itest modules will in turn + recieve these transitive dependencies. + --> + <dependency> + <groupId>org.amdatu.core</groupId> + <artifactId>org.amdatu.core.itest.base</artifactId> + <version>${org.amdatu.core.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + + <!-- + Artifacts that make up the Amdatu Web feature crosscutting for both the + base and tests modules. Scopes are intentionally set to compile in this + section so that depending (on the base) itest modules will in turn recieve + these transitive dependencies. + --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.http.jetty</artifactId> + <version>${org.apache.felix.http.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.dispatcher</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.httpcontext</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.resource</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jsp</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jaxrs</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.wink</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + + <!-- + See explanation in the dependencyManagement section above. + --> + <dependency> + <groupId>org.amdatu.core</groupId> + <artifactId>org.amdatu.core.itest.base</artifactId> + <type>bundle</type> + </dependency> + + <!-- + See explanation in the dependencyManagement section above. + --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.http.jetty</artifactId> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.dispatcher</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.httpcontext</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.resource</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jsp</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jaxrs</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.wink</artifactId> + <type>bundle</type> + </dependency> + </dependencies> + +</project> \ No newline at end of file Added: trunk/amdatu-web/itest/tests/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/tests/pom.xml Wed May 4 12:52:24 2011 @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.itest</artifactId> + <version>0.2.1-SNAPSHOT</version> + </parent> + <artifactId>org.amdatu.web.itest.tests</artifactId> + <packaging>jar</packaging> + <name>Amdatu Web - Integration Tests tests</name> + + <!-- + This modules is solely intended to contain Amdatu Web integration + tests. It should not be extended depended upon. The test classes will + be deployed by PaxExam into the runtime as a probe. + --> + + <dependencyManagement> + <dependencies> + <!-- + Amdatu Web itest base to be used by the tests. + --> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.itest.base</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <type>bundle</type> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <!-- + See explanation in the dependencyManagement section above. + --> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.itest.base</artifactId> + <type>bundle</type> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- + Outside the itest profile just skip surefire. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <!-- + Outside the itest profile show some help. + --> + <profile> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <defaultGoal>initialize</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>show-help</id> + <phase>initialize</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <echo> + <![CDATA[ +================================================ +Please activate the "itest" profile if you whish +to run the Amdatu Web integration tests +================================================ + ]]> + </echo> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <!-- + In the itest profile launch surefire in the + integration-test phase. + --> + <profile> + <id>itest</id> + <build> + <plugins> + <plugin> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>maven-paxexam-plugin</artifactId> + <executions> + <execution> + <phase>integration-test</phase> + <id>generate-depends-file</id> + <goals> + <goal>generate-depends-file</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>run-integration-test</id> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <systemPropertyVariables> + </systemPropertyVariables> + <skip>false</skip> + </configuration> + </execution> + </executions> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file Added: trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java Wed May 4 12:52:24 2011 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.web.itest.tests; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.LibraryOptions.junitBundles; + +import java.util.Properties; + +import org.amdatu.core.itest.base.CoreFixture; +import org.amdatu.core.itest.base.TestContext; +import org.amdatu.core.tenant.TenantManagementService; +import org.amdatu.core.tenant.TenantStorageProvider; +import org.amdatu.web.itest.base.WebFixture; +import org.amdatu.web.itest.tests.mock.TestService; +import org.amdatu.web.itest.tests.mock.TestServiceImpl; +import org.apache.felix.dm.Component; +import org.apache.felix.dm.ServiceDependency; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.Configuration; +import org.ops4j.pax.exam.junit.ExamReactorStrategy; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.log.LogService; + +@RunWith(JUnit4TestRunner.class) +@ExamReactorStrategy(AllConfinedStagedReactorFactory.class) +public class WebTest { + + @Configuration + public Option[] config() { + return options( + junitBundles(), + CoreFixture.provisionWithFsStorage(), + WebFixture.provision()); + } + + public TestContext testContextSetUp(BundleContext bundleContext) throws Exception { + assertThat(bundleContext, is(notNullValue())); + TestContext testContext = new TestContext(bundleContext); + + // quickfix to let startlevel complete felix bundle locking issues + Thread.sleep(1000); + + // Run the configurations + CoreFixture.configure(testContext); + + return testContext; + } + + @Test + public void testWithServiceDependencies(BundleContext bundleContext) throws Exception { + TestContext testContext = testContextSetUp(bundleContext); + + TenantManagementService tenantManagementService = testContext.getService(TenantManagementService.class); + assertThat("Expected a TenantManagementService", tenantManagementService, is(notNullValue())); + + testContext.tearDown(); + } + + @Test + public void testWithServiceDependencies2(BundleContext bundleContext) throws Exception { + TestContext testContext = testContextSetUp(bundleContext); + + Component component = testContext.getDependencyManager().createComponent(); + component.setInterface(TestService.class.getName(), null); + component.setImplementation(TestServiceImpl.class); + + ServiceDependency serviceDependency = testContext.getDependencyManager().createServiceDependency(); + serviceDependency.setService(LogService.class); + serviceDependency.setRequired(false); + component.add(serviceDependency); + + testContext.addComponent(component); + + TestService testInterface = testContext.getService(TestService.class); + assertThat(testInterface, is(notNullValue())); + + testContext.tearDown(); + } + +} Added: trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestService.java ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestService.java Wed May 4 12:52:24 2011 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.web.itest.tests.mock; + +public interface TestService { + +} Added: trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestServiceImpl.java ============================================================================== --- (empty file) +++ trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/mock/TestServiceImpl.java Wed May 4 12:52:24 2011 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.web.itest.tests.mock; + +public class TestServiceImpl implements TestService { + + public void init() { + } + + public void start() { + } + + public void stop() { + } + + public void destroy() { + } +} Added: trunk/amdatu-web/maven-settings-bamboo.xml ============================================================================== --- (empty file) +++ trunk/amdatu-web/maven-settings-bamboo.xml Wed May 4 12:52:24 2011 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> + <localRepository>/vol/www/bamboo/build/maven-repository</localRepository> +</settings> Modified: trunk/amdatu-web/pom.xml ============================================================================== --- trunk/amdatu-web/pom.xml (original) +++ trunk/amdatu-web/pom.xml Wed May 4 12:52:24 2011 @@ -89,6 +89,7 @@ <module>jsp</module> <module>rest-jaxrs</module> <module>rest-wink</module> + <module>itest</module> </modules> </project> \ No newline at end of file _______________________________________________ Amdatu-commits mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-commits
