Skip to content

Commit 41436c8

Browse files
committed
(test) convert EnvironmentLoaderServiceTest partly to integration test.
- 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
1 parent 72f6076 commit 41436c8

File tree

14 files changed

+399
-50
lines changed

14 files changed

+399
-50
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ target/
4040
release.properties
4141
pom.xml.*
4242
-
43+
/**/src/it/projects/*/build.log
44+
/**/src/it/projects/*/target

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install:
2727
- 'true'
2828

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

3232
after_success:
3333
- bash <(curl -s https://codecov.io/bash) -f test-coverage/target/site/jacoco-aggregate/jacoco.xml

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pipeline {
7979
stage('Tests') {
8080
steps {
8181
echo 'Running tests'
82-
sh 'mvn test'
82+
sh 'mvn verify -Prun-its'
8383
}
8484
post {
8585
always {
@@ -171,4 +171,4 @@ Is back to normal.
171171
}
172172
}
173173

174-
}
174+
}

Jenkinsfile-jdk11

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pipeline {
7979
stage('Tests') {
8080
steps {
8181
echo 'Running tests'
82-
sh 'mvn test'
82+
sh 'mvn verify -Prun-its'
8383
}
8484
post {
8585
always {
@@ -159,4 +159,4 @@ Is back to normal.
159159
}
160160
}
161161

162-
}
162+
}

Jenkinsfile-jdk14

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pipeline {
7979
stage('Tests') {
8080
steps {
8181
echo 'Running tests'
82-
sh 'mvn test'
82+
sh 'mvn verify -Prun-its'
8383
}
8484
post {
8585
always {
@@ -159,4 +159,4 @@ Is back to normal.
159159
}
160160
}
161161

162-
}
162+
}

pom.xml

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<htmlunit.version>2.39.0</htmlunit.version>
109109

110110
<!-- Test 3rd-party dependencies: -->
111-
<easymock.version>4.0.2</easymock.version>
111+
<easymock.version>4.1</easymock.version>
112112
<gmaven.version>1.8.0</gmaven.version>
113113
<groovy.version>2.5.8</groovy.version>
114114
<junit.version>4.12</junit.version>
@@ -284,6 +284,8 @@
284284
<configuration>
285285
<!-- note that this configuration needs to be maintain both in pluginManagement and reporting sections -->
286286
<excludes>
287+
<exclude>/**/src/it/projects/*/build.log</exclude>
288+
<exclude>/**/src/it/projects/*/target/**</exclude>
287289
<exclude>**/.externalToolBuilders/*</exclude>
288290
<exclude>**/infinitest.filters</exclude>
289291
<!-- Apparently some test in samples/spring-client generates velocity log - would better to reconfigure to output to target/ -->
@@ -433,7 +435,6 @@
433435
<version>3.0.0-M3</version>
434436
<configuration>
435437
<printSummary>true</printSummary>
436-
<useSystemClassLoader>false</useSystemClassLoader>
437438
</configuration>
438439
</plugin>
439440
<plugin>
@@ -1274,6 +1275,8 @@
12741275
<configuration>
12751276
<!-- note that this configuration needs to be maintain both in pluginManagement and reporting sections -->
12761277
<excludes>
1278+
<exclude>/**/src/it/projects/*/build.log</exclude>
1279+
<exclude>/**/src/it/projects/*/target/**</exclude>
12771280
<exclude>**/.externalToolBuilders/*</exclude>
12781281
<exclude>**/infinitest.filters</exclude>
12791282
<!-- Apparently some test in samples/spring-client generates velocity log - would better to reconfigure to output to target/ -->
@@ -1495,5 +1498,71 @@
14951498
</plugins>
14961499
</build>
14971500
</profile>
1501+
<profile>
1502+
<id>run-its</id>
1503+
<build>
1504+
<plugins>
1505+
<plugin>
1506+
<groupId>org.codehaus.mojo</groupId>
1507+
<artifactId>mrm-maven-plugin</artifactId>
1508+
<version>1.1.0</version>
1509+
<executions>
1510+
<execution>
1511+
<goals>
1512+
<goal>start</goal>
1513+
<goal>stop</goal>
1514+
</goals>
1515+
</execution>
1516+
</executions>
1517+
<configuration>
1518+
<propertyName>mrm.repository.url</propertyName>
1519+
<repositories>
1520+
<mockRepo>
1521+
<source>src/it/mrm/repository</source>
1522+
</mockRepo>
1523+
<proxyRepo/>
1524+
</repositories>
1525+
</configuration>
1526+
</plugin>
1527+
<plugin>
1528+
<groupId>org.apache.maven.plugins</groupId>
1529+
<artifactId>maven-invoker-plugin</artifactId>
1530+
<configuration>
1531+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
1532+
<environmentVariables>
1533+
<!--
1534+
! Prevent reading the .mavenrc or maven_pre.bat on Windows
1535+
! in integration tests.
1536+
-->
1537+
<MAVEN_SKIP_RC>1</MAVEN_SKIP_RC>
1538+
</environmentVariables>
1539+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
1540+
<projectsDirectory>src/it/projects</projectsDirectory>
1541+
<pomIncludes>
1542+
<pomInclude>*/pom.xml</pomInclude>
1543+
</pomIncludes>
1544+
<settingsFile>src/it/mrm/settings.xml</settingsFile>
1545+
<filterProperties>
1546+
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
1547+
</filterProperties>
1548+
<goals>
1549+
<goal>clean</goal>
1550+
<goal>package</goal>
1551+
</goals>
1552+
</configuration>
1553+
<executions>
1554+
<execution>
1555+
<id>integration-test</id>
1556+
<goals>
1557+
<goal>install</goal>
1558+
<goal>integration-test</goal>
1559+
<goal>verify</goal>
1560+
</goals>
1561+
</execution>
1562+
</executions>
1563+
</plugin>
1564+
</plugins>
1565+
</build>
1566+
</profile>
14981567
</profiles>
14991568
</project>

web/src/it/mrm/settings.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<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">
23+
<mirrors>
24+
<mirror>
25+
<id>mrm-maven-plugin</id>
26+
<name>Mock Repository Manager</name>
27+
<url>@mrm.repository.url@</url>
28+
<mirrorOf>*</mirrorOf>
29+
</mirror>
30+
</mirrors>
31+
<profiles>
32+
<profile>
33+
<id>it-repo</id>
34+
<repositories>
35+
<repository>
36+
<id>snapshots</id>
37+
<url>@mrm.repository.url@</url>
38+
<releases>
39+
<enabled>true</enabled>
40+
<checksumPolicy>ignore</checksumPolicy>
41+
<updatePolicy>never</updatePolicy>
42+
</releases>
43+
<snapshots>
44+
<enabled>true</enabled>
45+
<checksumPolicy>ignore</checksumPolicy>
46+
<updatePolicy>always</updatePolicy>
47+
</snapshots>
48+
</repository>
49+
</repositories>
50+
<pluginRepositories>
51+
<pluginRepository>
52+
<id>snapshots</id>
53+
<url>@mrm.repository.url@</url>
54+
<releases>
55+
<enabled>true</enabled>
56+
<checksumPolicy>ignore</checksumPolicy>
57+
<updatePolicy>never</updatePolicy>
58+
</releases>
59+
<snapshots>
60+
<enabled>true</enabled>
61+
<checksumPolicy>ignore</checksumPolicy>
62+
<updatePolicy>always</updatePolicy>
63+
</snapshots>
64+
</pluginRepository>
65+
</pluginRepositories>
66+
</profile>
67+
</profiles>
68+
<activeProfiles>
69+
<activeProfile>it-repo</activeProfile>
70+
</activeProfiles>
71+
</settings>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
invoker.java.version = 1.8+
21+
invoker.goals = clean verify
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
<!--suppress osmorcNonOsgiMavenDependency -->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
23+
24+
<modelVersion>4.0.0</modelVersion>
25+
<groupId>org.apache.shiro.integrationtest</groupId>
26+
<artifactId>multipleServiceLoader</artifactId>
27+
<version>1.0.0</version>
28+
29+
<name>Apache Shiro :: Web :: IT :: multipleServiceLoader</name>
30+
<packaging>jar</packaging>
31+
32+
<properties>
33+
<maven.compiler.source>8</maven.compiler.source>
34+
<maven.compiler.target>8</maven.compiler.target>
35+
</properties>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>org.apache.shiro</groupId>
40+
<artifactId>shiro-web</artifactId>
41+
<version>1.7.1-SNAPSHOT</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>javax.servlet</groupId>
45+
<artifactId>javax.servlet-api</artifactId>
46+
<version>3.1.0</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter</artifactId>
51+
<version>5.6.2</version>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.hamcrest</groupId>
56+
<artifactId>hamcrest-library</artifactId>
57+
<version>2.2</version>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.mockito</groupId>
62+
<artifactId>mockito-core</artifactId>
63+
<version>3.5.13</version>
64+
<scope>test</scope>
65+
</dependency>
66+
</dependencies>
67+
68+
</project>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.shiro.web.it.loader;
21+
22+
import org.apache.shiro.mgt.SecurityManager;
23+
import org.apache.shiro.web.env.WebEnvironment;
24+
import org.apache.shiro.web.filter.mgt.FilterChainResolver;
25+
import org.apache.shiro.web.mgt.WebSecurityManager;
26+
27+
public class SecondaryWebEnvironment implements WebEnvironment {
28+
@Override
29+
public FilterChainResolver getFilterChainResolver() {
30+
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getFilterChainResolver].");
31+
}
32+
33+
@Override
34+
public javax.servlet.ServletContext getServletContext() {
35+
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getServletContext].");
36+
}
37+
38+
@Override
39+
public WebSecurityManager getWebSecurityManager() {
40+
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getWebSecurityManager].");
41+
}
42+
43+
@Override
44+
public SecurityManager getSecurityManager() {
45+
throw new UnsupportedOperationException("not yet implemented: [org.apache.shiro.web.it.loader.SecondaryWebEnvironment::getSecurityManager].");
46+
}
47+
}

0 commit comments

Comments
 (0)