Skip to content

Commit

Permalink
(test) convert EnvironmentLoaderServiceTest partly to integration test.
Browse files Browse the repository at this point in the history
 - remove usage of Powermock on Java-internal classes
 - add IT with a secondary ServiceLoadable WebEnvironment, replacing multipleServiceTest
 - add run-its profile to travis and Jenkinsfiles
  • Loading branch information
bmarwell committed Nov 23, 2020
1 parent 72f6076 commit 41436c8
Show file tree
Hide file tree
Showing 14 changed files with 399 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ target/
release.properties
pom.xml.*
-
/**/src/it/projects/*/build.log
/**/src/it/projects/*/target
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- 'true'

script:
- "mvn -e -Pci,docs install apache-rat:check -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
- "mvn -e -Pci,docs,run-its install apache-rat:check -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"

after_success:
- bash <(curl -s https://codecov.io/bash) -f test-coverage/target/site/jacoco-aggregate/jacoco.xml
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pipeline {
stage('Tests') {
steps {
echo 'Running tests'
sh 'mvn test'
sh 'mvn verify -Prun-its'
}
post {
always {
Expand Down Expand Up @@ -171,4 +171,4 @@ Is back to normal.
}
}

}
}
4 changes: 2 additions & 2 deletions Jenkinsfile-jdk11
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pipeline {
stage('Tests') {
steps {
echo 'Running tests'
sh 'mvn test'
sh 'mvn verify -Prun-its'
}
post {
always {
Expand Down Expand Up @@ -159,4 +159,4 @@ Is back to normal.
}
}

}
}
4 changes: 2 additions & 2 deletions Jenkinsfile-jdk14
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pipeline {
stage('Tests') {
steps {
echo 'Running tests'
sh 'mvn test'
sh 'mvn verify -Prun-its'
}
post {
always {
Expand Down Expand Up @@ -159,4 +159,4 @@ Is back to normal.
}
}

}
}
73 changes: 71 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<htmlunit.version>2.39.0</htmlunit.version>

<!-- Test 3rd-party dependencies: -->
<easymock.version>4.0.2</easymock.version>
<easymock.version>4.1</easymock.version>
<gmaven.version>1.8.0</gmaven.version>
<groovy.version>2.5.8</groovy.version>
<junit.version>4.12</junit.version>
Expand Down Expand Up @@ -284,6 +284,8 @@
<configuration>
<!-- note that this configuration needs to be maintain both in pluginManagement and reporting sections -->
<excludes>
<exclude>/**/src/it/projects/*/build.log</exclude>
<exclude>/**/src/it/projects/*/target/**</exclude>
<exclude>**/.externalToolBuilders/*</exclude>
<exclude>**/infinitest.filters</exclude>
<!-- Apparently some test in samples/spring-client generates velocity log - would better to reconfigure to output to target/ -->
Expand Down Expand Up @@ -433,7 +435,6 @@
<version>3.0.0-M3</version>
<configuration>
<printSummary>true</printSummary>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -1274,6 +1275,8 @@
<configuration>
<!-- note that this configuration needs to be maintain both in pluginManagement and reporting sections -->
<excludes>
<exclude>/**/src/it/projects/*/build.log</exclude>
<exclude>/**/src/it/projects/*/target/**</exclude>
<exclude>**/.externalToolBuilders/*</exclude>
<exclude>**/infinitest.filters</exclude>
<!-- Apparently some test in samples/spring-client generates velocity log - would better to reconfigure to output to target/ -->
Expand Down Expand Up @@ -1495,5 +1498,71 @@
</plugins>
</build>
</profile>
<profile>
<id>run-its</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyName>mrm.repository.url</propertyName>
<repositories>
<mockRepo>
<source>src/it/mrm/repository</source>
</mockRepo>
<proxyRepo/>
</repositories>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<environmentVariables>
<!--
! Prevent reading the .mavenrc or maven_pre.bat on Windows
! in integration tests.
-->
<MAVEN_SKIP_RC>1</MAVEN_SKIP_RC>
</environmentVariables>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<projectsDirectory>src/it/projects</projectsDirectory>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<settingsFile>src/it/mrm/settings.xml</settingsFile>
<filterProperties>
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
</filterProperties>
<goals>
<goal>clean</goal>
<goal>package</goal>
</goals>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
71 changes: 71 additions & 0 deletions web/src/it/mrm/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

<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">
<mirrors>
<mirror>
<id>mrm-maven-plugin</id>
<name>Mock Repository Manager</name>
<url>@mrm.repository.url@</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>it-repo</id>
<repositories>
<repository>
<id>snapshots</id>
<url>@mrm.repository.url@</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<url>@mrm.repository.url@</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>it-repo</activeProfile>
</activeProfiles>
</settings>
21 changes: 21 additions & 0 deletions web/src/it/projects/MultipleServiceLoader/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

invoker.java.version = 1.8+
invoker.goals = clean verify
68 changes: 68 additions & 0 deletions web/src/it/projects/MultipleServiceLoader/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you 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.
-->
<!--suppress osmorcNonOsgiMavenDependency -->
<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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.shiro.integrationtest</groupId>
<artifactId>multipleServiceLoader</artifactId>
<version>1.0.0</version>

<name>Apache Shiro :: Web :: IT :: multipleServiceLoader</name>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.7.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.5.13</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.shiro.web.it.loader;

import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.web.env.WebEnvironment;
import org.apache.shiro.web.filter.mgt.FilterChainResolver;
import org.apache.shiro.web.mgt.WebSecurityManager;

public class SecondaryWebEnvironment implements WebEnvironment {
@Override
public FilterChainResolver getFilterChainResolver() {
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getFilterChainResolver].");
}

@Override
public javax.servlet.ServletContext getServletContext() {
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getServletContext].");
}

@Override
public WebSecurityManager getWebSecurityManager() {
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getWebSecurityManager].");
}

@Override
public SecurityManager getSecurityManager() {
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getSecurityManager].");
}
}
Loading

0 comments on commit 41436c8

Please sign in to comment.