Merge remote-tracking branch 'its/master' into merge-its

This commit is contained in:
Guillaume Nodet 2024-11-05 16:56:27 +01:00
commit 2f8f380da9
6516 changed files with 210780 additions and 0 deletions

12
its/.asf.yaml Normal file
View File

@ -0,0 +1,12 @@
# see https://s.apache.org/asfyaml
github:
description: "Apache Maven core ITs"
homepage: https://maven.apache.org/core-its
labels:
- java
- build-management
- maven
enabled_merge_buttons:
squash: true
merge: false
rebase: true

4
its/.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
# Auto detect text files and perform LF normalization
*.jar binary
*.war binary

29
its/.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,29 @@
#
# 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.
#
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

55
its/.github/workflows/maven-verify.yml vendored Normal file
View File

@ -0,0 +1,55 @@
# 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.
name: Java CI
on: [push, pull_request]
# clear all permissions for GITHUB_TOKEN
permissions: {}
jobs:
build:
# execute on any push or pull request from forked repo
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork )
strategy:
matrix:
os: [ubuntu-latest]
java: [11, 17, 21]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
- name: Set up Maven
run: mvn --errors --batch-mode --show-version wrapper:wrapper "-Dtype=only-script" "-Dmaven=3.9.7"
- name: Running integration tests
run: "./mvnw -B clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo"

19
its/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
.svn
target
/repo
.project
.classpath
.settings
bin
*.ipr
*.iml
*.iws
.DS_Store
.idea
jvz-*
.flattened-pom.xml
.checkstyle
dependency-reduced-pom.xml
.factorypath
.java-version
build-cache/

1
its/.mvn/readme.txt Normal file
View File

@ -0,0 +1 @@
.mvn directory should exist in project root

64
its/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,64 @@
#!groovy
pipeline {
agent any
// save some io during the build
options { durabilityHint('PERFORMANCE_OPTIMIZED') }
stages {
stage("Parallel Stage") {
parallel {
stage("Build / Test - mvn latest - JDK8 - ubuntu") {
agent { node { label 'ubuntu' } }
steps {
timeout( time: 180, unit: 'MINUTES' ) {
mavenBuild( "jdk_1.8_latest", "maven_latest")
}
}
}
stage("Build / Test - mvn latest - JDK11 - ubuntu") {
agent { node { label 'ubuntu' } }
steps {
timeout( time: 180, unit: 'MINUTES' ) {
mavenBuild( "jdk_11_latest", "maven_latest")
}
}
}
stage("Build / Test - mvn latest - JDK8 - windowx") {
agent { node { label 'Windows' } }
steps {
timeout( time: 180, unit: 'MINUTES' ) {
mavenBuild( "jdk_1.8_latest", "maven_latest")
}
}
}
stage("Build / Test - mvn latest - JDK11 - windows") {
agent { node { label 'Windows' } }
steps {
timeout( time: 180, unit: 'MINUTES' ) {
mavenBuild( "jdk_11_latest", "maven_latest")
}
}
}
}
}
}
}
def mavenBuild(jdk, mvnName) {
script {
try {
withMaven(jdk: "$jdk", maven: "$mvnName", publisherStrategy: 'EXPLICIT', mavenOpts: "-Xms2g -Xmx4g -Djava.awt.headless=true") {
if (isUnix()) {
sh "mvn -V clean install -Prun-its,embedded -B"
} else {
bat "mvn -V clean install -Prun-its,embedded -B"
}
}
}
finally
{
junit testResults: 'core-it-suite/target/surefire-reports/*.xml', allowEmptyResults: true
}
}
}

42
its/README.md Normal file
View File

@ -0,0 +1,42 @@
<!---
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.
-->
Maven Core Integration Tests
========
<https://maven.apache.org/core-its/>
If you want to run the integration tests against a custom build of Maven use the following command:
```
mvn clean install -Prun-its -Dmaven.repo.local=`pwd`/repo -DmavenDistro=/path/to/apache-maven-dist.zip
```
or if behind a proxy
```
mvn clean install -Prun-its -Dmaven.repo.local=`pwd`/repo -DmavenDistro=/path/to/apache-maven-dist.zip -Dproxy.active=true -Dproxy.type=http -Dproxy.host=... -Dproxy.port=... -Dproxy.user=... -Dproxy.pass=...
```
Using the script
Build Maven core with the profile `-PversionlessMavenDist`
Now Run the script: `sh ./run-its.sh`
Maven Developers List: dev@maven.apache.org

931
its/core-it-suite/pom.xml Normal file
View File

@ -0,0 +1,931 @@
<?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.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-its</artifactId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>core-it-suite</artifactId>
<name>Maven Core ITs suite</name>
<description>The effective Maven Integration Tests suite.</description>
<!--
By default, the project just packages the tests in an artifact. To actually run them, activate the profile "run-its":
mvn clean test -Prun-its
This will subject the Maven version running the build to the integration tests. If you would like to test a different
Maven distribution, you can use the system property "mavenHome" to specify the path of the Maven distribution to test:
mvn clean test -Prun-its -DmavenHome=<maven-under-test>
Alternatively, you can just specify the version of a previously installed/deployed Maven distribution which will be
downloaded, unpacked and tested:
mvn clean test -Prun-its -DmavenVersion=2.2.1
It's also possible to point the ITs at an already downloaded Maven distribution:
mvn clean test -Prun-its -DmavenDistro=<path-to-bin-archive>
To run the ITs using embedded Maven 3.x, additionally activate the profile "embedded".
ITs that don't require to fork Maven can also be run from the IDE using the Maven projects from the workspace if the
Maven dependencies are added to the test class path.
If you're behind a proxy, use the system properties proxy.host, proxy.port, proxy.user, proxy.pass and
proxy.nonProxyHosts to specify the required proxy setup for the ITs. Alternatively, set the system property
maven.it.central to a URL of a local repository manager (anonymous authentication only) that proxies the
required artifacts.
-->
<properties>
<surefireMemory>-Xmx384m</surefireMemory>
<!-- The original Maven distribution to test. -->
<mavenHome>${maven.home}</mavenHome>
<!-- The (possibly instrumented copy of the) Maven distribution we actually
use for the tests. -->
<preparedMavenHome>${mavenHome}</preparedMavenHome>
<!-- default properties used to filter the global settings -->
<maven.it.central>https://repo.maven.apache.org/maven2</maven.it.central>
<proxy.active>false</proxy.active>
<proxy.host>localhost</proxy.host>
<proxy.port>80</proxy.port>
<proxy.type>none</proxy.type>
<proxy.user />
<proxy.pass />
<proxy.nonProxyHosts>localhost</proxy.nonProxyHosts>
<slf4jVersion>1.6.1</slf4jVersion>
<jetty9Version>9.4.53.v20231009</jetty9Version>
<stubPluginVersion>0.1-stub-SNAPSHOT</stubPluginVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<!-- NOTE: Use compile scope for transitivity. -->
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
<!-- NOTE: Use compile scope for transitivity. -->
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<!-- TODO: not transitive in tests artifact, so must be left in main
scope <scope>test</scope> -->
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.9</version>
</dependency>
<!-- Jetty (as test HTTP server) -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
</dependency>
<!-- project dependencies -->
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>maven-it-plugin-bootstrap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-component</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-toolchain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-wagon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>maven-it-helper</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-extension</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-javaagent</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-rar-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-active-collection</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-ant-based</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-artifact</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-class-loader</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-context-passing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-collection</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-error</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-extension-consumer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-extension-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-fork</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-invalid-descriptor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-log-file</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-model-interpolation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-no-default-comp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-no-project</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-online</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-optional-mojos</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-packaging</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plugin-dependency</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-project</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-project-interpolation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-setter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-singleton-component</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-site</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-toolchain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-touch</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-uses-properties</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-uses-wagon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-all</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-utils-11</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-utils-new</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-component-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-log4j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-extension1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-extension2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-plexus-lifecycle</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-settings</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-extension</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-extension2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-plugin-dep</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5958-pkg-type-extension</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-6759-resolves-project-dependencies-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<filtering>true</filtering>
<directory>src/test/resources-filtered</directory>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<java>
<includes>
<include>src/main/java/**/*.java</include>
<include>src/test/java/**/*.java</include>
<include>src/test/resources/**/src/main/java/**/*.java</include>
<include>src/test/resources/**/src/test/java/**/*.java</include>
</includes>
<excludes>
<exclude>src/test/resources/mng-5208/project/sub-2/src/main/java/Bad.java</exclude>
</excludes>
</java>
<pom>
<includes>
<include>pom.xml</include>
<include>src/test/resources/**/pom.xml</include>
</includes>
<excludes>
<exclude>src/test/resources/mng-2254/latin-1/pom.xml</exclude>
<exclude>src/test/resources/mng-2362/latin-1/pom.xml</exclude>
<exclude>src/test/resources/mng-3839/pom.xml</exclude>
</excludes>
</pom>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/MavenIT*.java</include>
</includes>
<!-- test annotated by @Tag("disabled") will be skipped from executions -->
<excludedGroups>disabled</excludedGroups>
<forkCount>0</forkCount>
<reuseForks>true</reuseForks>
<skip>true</skip>
<systemPropertyVariables>
<maven.version>${maven.version}</maven.version>
<maven.home>${preparedMavenHome}</maven.home>
<!-- TODO: This is for now legacy as Verifier is confused otherwise -->
<maven.mainClass>org.apache.maven.cli.MavenCli</maven.mainClass>
<maven.it.global-settings.dir>${project.build.testOutputDirectory}</maven.it.global-settings.dir>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>parallel</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>suitesAndClasses</parallel>
<threadCount>6</threadCount>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-its</id>
<dependencies>
<!-- not really used but will force download in the local repo used -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven-repo-local</id>
<activation>
<property>
<name>maven.repo.local</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- Pass this through to the tests (if set!) to have them
pick the right repository -->
<maven.repo.local>${maven.repo.local}</maven.repo.local>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven-repo-local-layout</id>
<activation>
<property>
<name>maven.repo.local.layout</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- Pass this through to the tests (if set!) to have them
pick the right repository layout -->
<maven.repo.local.layout>${maven.repo.local.layout}</maven.repo.local.layout>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk-properties</id>
<activation>
<jdk>(,1.8)</jdk>
</activation>
<properties>
<surefireMemory>-Xmx384m -XX:MaxPermSize=192m</surefireMemory>
</properties>
</profile>
<profile>
<id>embedded</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>${surefireMemory}
-Dcom.sun.management.jmxremote=true</argLine>
<!-- NOTE: Maven plugins have access to the system class path
so keep it clean -->
<useSystemClassLoader>false</useSystemClassLoader>
<systemPropertyVariables>
<verifier.forkMode>auto</verifier.forkMode>
<emma.rt.control>false</emma.rt.control>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven-from-repo</id>
<activation>
<property>
<name>mavenVersion</name>
</property>
</activation>
<properties>
<mavenHome>${project.build.directory}/apache-maven</mavenHome>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>download-maven-distro</id>
<goals>
<goal>copy</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>${mavenVersion}</version>
<classifier>bin</classifier>
<type>zip</type>
<destFileName>maven-bin.zip</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>unpack-maven-distro</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<target>
<delete dir="${mavenHome}" />
<unzip dest="${mavenHome}" src="${project.build.directory}/maven-bin.zip">
<globmapper from="apache-maven-${mavenVersion}/*" handledirsep="true" to="*" />
</unzip>
<chmod dir="${mavenHome}/bin" includes="mvn,mvnDebug" perm="ugo+rx" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven-distro</id>
<activation>
<property>
<name>mavenDistro</name>
</property>
</activation>
<properties>
<mavenHome>${project.build.directory}/apache-maven</mavenHome>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>unpack-maven-distro</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<target>
<delete dir="${mavenHome}" />
<unzip dest="${mavenHome}" src="${mavenDistro}">
<regexpmapper from="^([^/]+)/(.*)$" handledirsep="true" to="\2" />
</unzip>
<chmod dir="${mavenHome}/bin" includes="mvn,mvnDebug" perm="ugo+rx" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>emma</id>
<properties>
<preparedMavenHome>${project.build.directory}/distro</preparedMavenHome>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-maven-distro</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<target>
<delete dir="${preparedMavenHome}" />
<copy overwrite="true" todir="${preparedMavenHome}">
<fileset dir="${mavenHome}" />
</copy>
<chmod dir="${preparedMavenHome}/bin" includes="mvn,mvnDebug" perm="ugo+rx" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>inject-emma-into-core-realm</id>
<goals>
<goal>copy</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>emma</groupId>
<artifactId>emma</artifactId>
<version>2.1.5320</version>
</artifactItem>
</artifactItems>
<outputDirectory>${preparedMavenHome}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
<artifactId>emma4it-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<jarSets>
<jarSet>
<directory>${preparedMavenHome}/lib</directory>
<includes>
<include>maven*.jar</include>
</includes>
</jarSet>
</jarSets>
<includes>
<include>org.apache.maven.*</include>
</includes>
<excludes>
<exclude>*.io.xpp3.*</exclude>
<exclude>*Exception</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>instrument</id>
<goals>
<goal>instrument</goal>
</goals>
<phase>process-test-classes</phase>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>coverage.ec</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>proxy</id>
<activation>
<property>
<name>proxy.host</name>
</property>
</activation>
<properties>
<proxy.type>http</proxy.type>
<proxy.active>true</proxy.active>
</properties>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,96 @@
-----
Maven Core Integration Tests Bootstrap
-----
Hervé Boutemy
-----
2017-04-04
-----
~~ 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.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
Maven Core Integration Tests Bootstrap
Core IT Bootstrapping downloads from Central repository every dependency (artifacts, plugins) required to let
Core ITs Suite run without downloading anything later (see {{{./index.html#Core_ITs_Suite_and_Dependencies_.28incl._Plugins.29}Core ITs Suite and dependencies}} rationale).
Content to download is defined in {{{https://github.com/apache/maven-integration-testing/tree/master/core-it-suite/src/test/resources/bootstrap}a series of bootstrap projects}}:
%{toc|section=1|fromDepth=2}
* Base Plugins And Their Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/target/resolve-plugins.txt}
* Group 1 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-1/target/resolve.txt}
* Group 2 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-2/target/resolve.txt}
* Group 3 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-3/target/resolve.txt}
* Group 4 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-4/target/resolve.txt}
* Group 5 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-5/target/resolve.txt}
* Group 6 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-6/target/resolve.txt}
* Group 7 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-7/target/resolve.txt}
* Group 8 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-8/target/resolve.txt}
* Group 9 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-9/target/resolve.txt}
* Group 10 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-10/target/resolve.txt}
* Group 11 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-11/target/resolve.txt}
* Group 12 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-12/target/resolve.txt}
* Group 13 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-13/target/resolve.txt}
* Group 14 Dependencies
%{snippet|file=${project.build.directory}/test-classes/bootstrap/group-14/target/resolve.txt}

View File

@ -0,0 +1,79 @@
-----
Maven Core Integration Tests Suite
-----
Hervé Boutemy
-----
2011-09-04
-----
~~ 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.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
Maven Core Integration Tests Suite
This module provides the {{{./testapidocs/org/apache/maven/it/package-summary.html}effective Core Integration Tests suite}},
starting with {{{./bootstrap.html}bootstrap}}.
* Running Core ITs Suite
Follow the steps that are described in the {{{https://github.com/apache/maven-integration-testing/blob/master/README.md}README.md}}
of the official {{{https://github.com/apache/maven-integration-testing}Core ITs Suite}} repository.
* Core ITs Suite Results
ITs results are displayed on the console and can be published in the site through Surefire Report.
+----
mvn -Preporting site
+----
Currently deployed {{{./surefire-report.html}Surefire Report}} was generated with following environment:
%{snippet|file=${project.build.directory}/info.txt}
* Core ITs Suite and Dependencies (incl. Plugins)
A good IT does not depend on external repos like Central, it uses dedicated test plugins and test repositories.
The {{{https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/resources-filtered/settings.xml}default <<<settings.xml>>>}}
used by ITs helps to enforce this by pointing <<<central>>> at <<<file:target/null>>>,
which obviously can't resolve anything. This setup using a file-based dummy repo also helps execution time,
because this repo produces (expected) <<<404>>>s much faster than a HTTP-based repo.
The one place where access to Central is desired is by adding artifacts to the
{{{https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/resources/bootstrap.txt}bootstrap.txt}} file,
which is used to prime the local repo with any artifacts the ITs will need. This file should be kept sorted alphabetically for ease of use.
So some care needs to be taken when introducing new dependencies into the ITs themselves or {{{../core-it-support/}the support plugins}}.
Many times the failures that we encounter are discrepancies between actual artifact consumption required and
what is populated during bootstrapping. When forgetting, typical failures (as seen in ASF CI) will give following traces in log:
-------
[ERROR] testit(org.apache.maven.it.MavenITmng...) Time elapsed: 0.145 s <<< ERROR!
...
[ERROR] Failed to execute goal ... (...) on project ...: ... Could not find artifact ... in central (file:target/null) -> [Help 1]
-------
** Using Local Repository Manager
If you are using a local repository manager, configured in your <<<~/.m2/settings.xml>>> as a mirror of <<<central>>>, it will invalidate previous setup:
working Core ITs Suite can work on your laptop but fail on ASF CI because of missing artifact.
Comment out your mirror configuration to enable the expected local failure, then be able to debug and fix the issue.

View File

@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!--
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.
-->
<project xmlns="https://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd">
<body>
<menu name="Overview">
<item name="Introduction" href="index.html"/>
<item name="JavaDocs" href="testapidocs/org/apache/maven/it/package-summary.html"/>
<item name="Source Xref" href="xref-test/org/apache/maven/it/package-summary.html"/>
<!--item name="FAQ" href="faq.html"/-->
<item name="License" href="http://www.apache.org/licenses/"/>
</menu>
<menu name="Results">
<item name="Bootstrap" href="bootstrap.html"/>
<item name="Surefire Report" href="surefire-report.html"/>
</menu>
<menu ref="parent"/>
<menu ref="reports"/>
</body>
</project>

View File

@ -0,0 +1,235 @@
/*
* 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.maven.it;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Collections;
import com.google.common.io.ByteStreams;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.UserStore;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
/**
* An HTTP server that handles all requests on a given port from a specified source, optionally secured using BASIC auth
* by providing a username and password. The source can either be a URL or a directory. When a request is made the
* request is satisfied from the provided source.
*
* @author Jason van Zyl
*/
public class HttpServer {
static {
Log.initialized();
Logger rootLogger = Log.getRootLogger();
if (rootLogger instanceof StdErrLog) {
((StdErrLog) rootLogger).setLevel(StdErrLog.LEVEL_WARN);
}
}
private final Server server;
private final StreamSource source;
private final String username;
private final String password;
public HttpServer(int port, String username, String password, StreamSource source) {
this.username = username;
this.password = password;
this.source = source;
this.server = server(port);
}
public void start() throws Exception {
server.start();
// server.join();
}
public boolean isFailed() {
return server.isFailed();
}
public void stop() throws Exception {
server.stop();
}
public void join() throws Exception {
server.join();
}
public int port() {
return ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
}
private Server server(int port) {
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
Server server = new Server(threadPool);
server.setConnectors(new Connector[] {new ServerConnector(server)});
server.addBean(new ScheduledExecutorScheduler());
ServerConnector connector = (ServerConnector) server.getConnectors()[0];
connector.setIdleTimeout(30_000L);
connector.setPort(port);
StreamSourceHandler handler = new StreamSourceHandler(source);
if (username != null && password != null) {
HashLoginService loginService = new HashLoginService("Test Server");
UserStore userStore = new UserStore();
userStore.addUser(username, new Password(password), new String[] {"user"});
loginService.setUserStore(userStore);
server.addBean(loginService);
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
server.setHandler(security);
Constraint constraint = new Constraint();
constraint.setName("auth");
constraint.setAuthenticate(true);
constraint.setRoles(new String[] {"user", "admin"});
ConstraintMapping mapping = new ConstraintMapping();
mapping.setPathSpec("/*");
mapping.setConstraint(constraint);
security.setConstraintMappings(Collections.singletonList(mapping));
security.setAuthenticator(new BasicAuthenticator());
security.setLoginService(loginService);
security.setHandler(handler);
} else {
server.setHandler(handler);
}
return server;
}
public static HttpServerBuilder builder() {
return new HttpServerBuilder();
}
public static class HttpServerBuilder {
private int port;
private String username;
private String password;
private StreamSource source;
public HttpServerBuilder port(int port) {
this.port = port;
return this;
}
public HttpServerBuilder username(String username) {
this.username = username;
return this;
}
public HttpServerBuilder password(String password) {
this.password = password;
return this;
}
public HttpServerBuilder source(final String source) {
this.source = new StreamSource() {
@Override
public InputStream stream(String path) throws IOException {
return new URL(String.format("%s/%s", source, path)).openStream();
}
};
return this;
}
public HttpServerBuilder source(final File source) {
this.source = new StreamSource() {
@Override
public InputStream stream(String path) throws IOException {
return new FileInputStream(new File(source, path));
}
};
return this;
}
public HttpServer build() {
return new HttpServer(port, username, password, source);
}
}
public interface StreamSource {
InputStream stream(String path) throws IOException;
}
public static class StreamSourceHandler extends AbstractHandler {
private final StreamSource source;
public StreamSourceHandler(StreamSource source) {
this.source = source;
}
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("application/octet-stream");
response.setStatus(HttpServletResponse.SC_OK);
try (InputStream in = source.stream(target.substring(1));
OutputStream out = response.getOutputStream()) {
ByteStreams.copy(in, out);
}
baseRequest.setHandled(true);
}
}
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.builder() //
.port(0) //
.username("maven") //
.password("secret") //
.source(new File("/tmp/repo")) //
.build();
server.start();
}
}

View File

@ -0,0 +1,93 @@
/*
* 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.maven.it;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import org.apache.maven.shared.verifier.Verifier;
/**
* @author Benjamin Bentmann
*/
class ItUtils {
public static String calcHash(File file, String algo) throws Exception {
MessageDigest digester = MessageDigest.getInstance(algo);
DigestInputStream dis;
try (FileInputStream is = new FileInputStream(file)) {
dis = new DigestInputStream(is, digester);
for (byte[] buffer = new byte[1024 * 4]; dis.read(buffer) >= 0; ) {
// just read it
}
}
byte[] digest = digester.digest();
StringBuilder hash = new StringBuilder(digest.length * 2);
for (byte aDigest : digest) {
int b = aDigest & 0xFF;
if (b < 0x10) {
hash.append('0');
}
hash.append(Integer.toHexString(b));
}
return hash.toString();
}
public static String getLogContent(Verifier verifier) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Files.copy(Paths.get(verifier.getBasedir(), verifier.getLogFileName()), baos);
return baos.toString();
}
/**
* @see ItUtils#setUserHome(Verifier, Path)
*/
public static void setUserHome(Verifier verifier, File file) {
setUserHome(verifier, file.toPath());
}
/**
* Note that this only has effect when fork mode is set to true.
* Please make sure to call {@link Verifier#setForkJvm(boolean)} and set it to true
*/
public static void setUserHome(Verifier verifier, Path home) {
// NOTE: We set the user.home directory instead of say settings.security to reflect Maven's normal behavior
String path = home.toAbsolutePath().toString();
if (path.indexOf(' ') < 0) {
verifier.setEnvironmentVariable("MAVEN_OPTS", "-Duser.home=" + path);
} else {
verifier.setEnvironmentVariable("MAVEN_OPTS", "\"-Duser.home=" + path + "\"");
}
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0008SimplePluginTest extends AbstractMavenIntegrationTestCase {
public MavenIT0008SimplePluginTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Simple goal decoration where a plugin binds to a phase and the plugin must
* be downloaded from a remote repository before it can be executed. This
* test also checks to make sure that mojo parameters are aligned to the
* project basedir when their type is "java.io.File".
*
* @throws Exception in case of failure
*/
@Test
public void testit0008() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0008");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifact("org.apache.maven.its.plugins", "maven-it-plugin-touch", "1.0", "maven-plugin");
verifier.addCliArgument("process-sources");
verifier.execute();
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyFilePresent("target/test-basedir-alignment/touch.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0009GoalConfigurationTest extends AbstractMavenIntegrationTestCase {
public MavenIT0009GoalConfigurationTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test plugin configuration and goal configuration that overrides what the
* mojo has specified.
*
* @throws Exception in case of failure
*/
@Test
public void testit0009() throws Exception {
boolean supportSpaceInXml = matchesVersionRange("[3.1.0,)");
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0009");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyFilePresent(supportSpaceInXml ? "target/ pluginItem " : "target/pluginItem");
verifier.verifyFilePresent("target/goalItem");
verifier.verifyFileNotPresent("target/bad-item");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0010DependencyClosureResolutionTest extends AbstractMavenIntegrationTestCase {
public MavenIT0010DependencyClosureResolutionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Since the artifact resolution does not use the project builder, we must
* ensure that the full hierarchy of all dependencies is resolved. This
* includes the dependencies of the parent-pom's of dependencies.
*
* @throws Exception in case of failure
*/
@Test
public void testit0010() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0010");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0010");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven.its.it0010", "a", "0.1", "jar");
verifier.verifyArtifactPresent("org.apache.maven.its.it0010", "b", "0.2", "jar");
verifier.verifyArtifactPresent("org.apache.maven.its.it0010", "parent", "1.0", "pom");
List<String> artifacts = verifier.loadLines("target/compile.txt", "UTF-8");
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.it0010:a:jar:0.1"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.it0010:b:jar:0.2"));
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0011DefaultVersionByDependencyManagementTest extends AbstractMavenIntegrationTestCase {
public MavenIT0011DefaultVersionByDependencyManagementTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test specification of dependency versions via &lt;dependencyManagement/&gt;.
*
* @throws Exception in case of failure
*/
@Test
public void testit0011() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0011");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0011");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> artifacts = verifier.loadLines("target/compile.txt", "UTF-8");
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.it0011:a:jar:0.1"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.it0011:b:jar:0.2"));
}
}

View File

@ -0,0 +1,50 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0012PomInterpolationTest extends AbstractMavenIntegrationTestCase {
public MavenIT0012PomInterpolationTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test simple POM interpolation
*
* @throws Exception in case of failure
*/
@Test
public void testit0012() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0012");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("child-project/target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyFilePresent("target/touch-3.8.1.txt");
verifier.verifyFilePresent("child-project/target/child-touch-3.0.3.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0018DependencyManagementTest extends AbstractMavenIntegrationTestCase {
public MavenIT0018DependencyManagementTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Ensure that managed dependencies for dependency POMs are calculated
* correctly when resolved. Removes managed-dep-1.0.3 and checks it is
* redownloaded upon resolution of direct-dep.
*
* @throws Exception in case of failure
*/
@Test
public void testit0018() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0018");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven.its.it0018");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument(
"org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:compile");
verifier.execute();
verifier.verifyArtifactPresent("org.apache.maven.its.it0018", "managed-dep", "1.0.3", "jar");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0019PluginVersionMgmtBySuperPomTest extends AbstractMavenIntegrationTestCase {
public MavenIT0019PluginVersionMgmtBySuperPomTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that a version is managed by pluginManagement in the super POM
*
* @throws Exception in case of failure
*/
@Test
public void testit0019() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0019");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("process-resources");
verifier.execute();
verifier.verifyFilePresent("target/classes/test.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0021PomProfileTest extends AbstractMavenIntegrationTestCase {
public MavenIT0021PomProfileTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test pom-level profile inclusion (this one is activated by system
* property).
*
* @throws Exception in case of failure
*/
@Test
public void testit0021() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0021");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven.its.it0021");
verifier.getSystemProperties().setProperty("includeProfile", "true");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("-Pprofile-2");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven.its.it0021", "a", "0.1", "jar");
verifier.verifyArtifactPresent("org.apache.maven.its.it0021", "b", "0.1", "jar");
}
}

View File

@ -0,0 +1,53 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0023SettingsProfileTest extends AbstractMavenIntegrationTestCase {
public MavenIT0023SettingsProfileTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test profile inclusion from settings.xml (this one is activated by an id
* in the activeProfiles section).
*
* @throws Exception in case of failure
*/
@Test
public void testit0023() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0023");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/test.txt");
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-172">MNG-172</a>.
*
* @author John Casey
*
*/
public class MavenIT0024MultipleGoalExecutionsTest extends AbstractMavenIntegrationTestCase {
public MavenIT0024MultipleGoalExecutionsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test usage of &lt;executions/&gt; inside a plugin rather than &lt;goals/&gt;
* that are directly inside the plugin.
*
* @throws Exception in case of failure
*/
@Test
public void testit0024() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0024");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/plugin-exec-configuration.txt");
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-172">MNG-172</a>.
*
* @author John Casey
*
*/
public class MavenIT0025MultipleExecutionLevelConfigsTest extends AbstractMavenIntegrationTestCase {
public MavenIT0025MultipleExecutionLevelConfigsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test multiple goal executions with different execution-level configs.
*
* @throws Exception in case of failure
*/
@Test
public void testit0025() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0025");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/test.txt");
verifier.verifyFilePresent("target/test2.txt");
}
}

View File

@ -0,0 +1,51 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0030DepPomDepMgmtInheritanceTest extends AbstractMavenIntegrationTestCase {
public MavenIT0030DepPomDepMgmtInheritanceTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test for injection of dependencyManagement through parents of
* dependency poms.
*
* @throws Exception in case of failure
*/
@Test
public void testit0030() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0030");
Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.deleteArtifact("org.apache.maven.it", "maven-it-it0030", "1.0-SNAPSHOT", "jar");
verifier.deleteArtifact("org.apache.maven.it", "maven-it-it0030-child-hierarchy", "1.0-SNAPSHOT", "jar");
verifier.deleteArtifact("org.apache.maven.it", "maven-it-it0030-child-project1", "1.0-SNAPSHOT", "jar");
verifier.deleteArtifact("org.apache.maven.it", "maven-it-it0030-child-project2", "1.0-SNAPSHOT", "jar");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyFilePresent("child-hierarchy/project2/target/classes/org/apache/maven/it0001/Person.class");
verifier.verifyErrorFreeLog();
}
}

View File

@ -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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0032MavenPrerequisiteTest extends AbstractMavenIntegrationTestCase {
public MavenIT0032MavenPrerequisiteTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Tests that a specified Maven version requirement that is lower doesn't cause any problems
*
* @throws Exception in case of failure
*/
@Test
public void testit0032() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0032");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-607">MNG-607</a>.
*
* @author John Casey
*
*/
public class MavenIT0037AlternatePomFileSameDirTest extends AbstractMavenIntegrationTestCase {
public MavenIT0037AlternatePomFileSameDirTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test building with alternate pom file using '-f'
*
* @throws Exception in case of failure
*/
@Test
public void testit0037() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0037");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-f");
verifier.addCliArgument("pom2.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/passed.log");
verifier.verifyFileNotPresent("target/failed.log");
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-607">MNG-607</a>.
*
* @author John Casey
*
*/
public class MavenIT0038AlternatePomFileDifferentDirTest extends AbstractMavenIntegrationTestCase {
public MavenIT0038AlternatePomFileDifferentDirTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test building project from outside the project directory using '-f' option.
*
* @throws Exception in case of failure
*/
@Test
public void testit0038() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0038");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("project/target");
verifier.addCliArgument("-f");
verifier.addCliArgument("project/pom2.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("project/target/passed.log");
verifier.verifyFileNotPresent("target/failed.log");
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-598">MNG-598</a>.
*
* @author Brett Porter
*
*/
public class MavenIT0040PackagingFromPluginExtensionTest extends AbstractMavenIntegrationTestCase {
public MavenIT0040PackagingFromPluginExtensionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test the use of a packaging from a plugin
*
* @throws Exception in case of failure
*/
@Test
public void testit0040() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0040");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/maven-it-it0040-1.0-it.jar");
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-598">MNG-598</a>.
*
* @author Brett Porter
*
*/
public class MavenIT0041ArtifactTypeFromPluginExtensionTest extends AbstractMavenIntegrationTestCase {
public MavenIT0041ArtifactTypeFromPluginExtensionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test the use of a new type from a plugin
*
* @throws Exception in case of failure
*/
@Test
public void testit0041() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0041");
Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven", "maven-core-it-support", "1.2");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support", "1.2", "coreit-artifact");
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support", "1.2", "pom");
}
}

View File

@ -0,0 +1,53 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0051ReleaseProfileTest extends AbstractMavenIntegrationTestCase {
public MavenIT0051ReleaseProfileTest() {
super("(2.0.2,4.0.0-alpha-1)");
}
/**
* Test source attachment when -DperformRelease=true is specified.
*
* @throws Exception in case of failure
*/
@Test
public void testit0051() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0051");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-DperformRelease=true");
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/source-jar.txt");
verifier.verifyFilePresent("target/javadoc-jar.txt");
}
}

View File

@ -0,0 +1,53 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0052ReleaseProfileTest extends AbstractMavenIntegrationTestCase {
public MavenIT0052ReleaseProfileTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that source attachment doesn't take place when
* -DperformRelease=true is missing.
*
* @throws Exception in case of failure
*/
@Test
public void testit0052() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0052");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/jar-jar.txt");
verifier.verifyFileNotPresent("target/source-jar.txt");
verifier.verifyFileNotPresent("target/javadoc-jar.txt");
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0056MultipleGoalExecutionsTest extends AbstractMavenIntegrationTestCase {
public MavenIT0056MultipleGoalExecutionsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that multiple executions of a goal with different
* parameter values will succeed.
*
* @throws Exception in case of failure
*/
@Test
public void testit0056() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0056");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/first-exec.txt");
verifier.verifyFilePresent("target/second-exec.txt");
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0063SystemScopeDependencyTest extends AbstractMavenIntegrationTestCase {
public MavenIT0063SystemScopeDependencyTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test the use of a system scoped dependency to a (fake) tools.jar.
*
* @throws Exception in case of failure
*/
@Test
public void testit0063() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0063");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.getSystemProperties().setProperty("jre.home", new File(testDir, "jdk/jre").getPath());
verifier.addCliArgument(
"org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:compile");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> lines = verifier.loadLines("target/compile.txt", "UTF-8");
assertEquals(2, lines.size());
assertEquals(
new File(testDir, "jdk/lib/tools.jar").getCanonicalFile(),
new File((String) lines.get(1)).getCanonicalFile());
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0064MojoConfigViaSettersTest extends AbstractMavenIntegrationTestCase {
public MavenIT0064MojoConfigViaSettersTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test the use of a mojo that uses setters instead of private fields
* for the population of configuration values.
*
* @throws Exception in case of failure
*/
@Test
public void testit0064() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0064");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-setter:setter-touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/fooValue");
verifier.verifyFilePresent("target/barValue.baz");
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-885">MNG-885</a>.
*
* @author John Casey
*
*/
public class MavenIT0071PluginConfigWithDottedPropertyTest extends AbstractMavenIntegrationTestCase {
public MavenIT0071PluginConfigWithDottedPropertyTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verifies that dotted property references work within plugin
* configurations.
*
* @throws Exception in case of failure
*/
@Test
public void testit0071() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0071");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/foo2");
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-885">MNG-885</a>.
*
* @author John Casey
*
*/
public class MavenIT0072InterpolationWithDottedPropertyTest extends AbstractMavenIntegrationTestCase {
public MavenIT0072InterpolationWithDottedPropertyTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verifies that property references with dotted notation work within
* POM interpolation.
*
* @throws Exception in case of failure
*/
@Test
public void testit0072() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0072");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/pom.properties");
assertEquals("1.0-SNAPSHOT", props.getProperty("project.version"));
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Collection;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0085TransitiveSystemScopeTest extends AbstractMavenIntegrationTestCase {
public MavenIT0085TransitiveSystemScopeTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that system-scoped dependencies get resolved with system scope
* when they are resolved transitively via another (non-system)
* dependency. Inherited scope should not apply in the case of
* system-scoped dependencies, no matter where they are.
*
* @throws Exception in case of failure
*/
@Test
public void testit0085() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0085");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0085");
verifier.getSystemProperties().setProperty("test.home", testDir.getAbsolutePath());
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Collection<String> lines = verifier.loadLines("target/test.txt", "UTF-8");
assertTrue(lines.toString(), lines.contains("system.jar"));
}
}

View File

@ -0,0 +1,70 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-1898">MNG-1898</a>.
*
* @author John Casey
*
*/
public class MavenIT0086PluginRealmTest extends AbstractMavenIntegrationTestCase {
public MavenIT0086PluginRealmTest() {
super("(2.0.2,)");
}
/**
* Verify that a plugin dependency class/resource can be loaded from both the plugin classloader and the
* context classloader available to the plugin.
*
* @throws Exception in case of failure
*/
@Test
public void testit0086() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0086");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties pclProps = verifier.loadProperties("target/pcl.properties");
assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassA"));
assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassB"));
assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.SomeClass"));
assertNotNull(pclProps.getProperty("org/apache/maven/plugin/coreit/a.properties"));
assertEquals("1", pclProps.getProperty("org/apache/maven/plugin/coreit/a.properties.count"));
assertNotNull(pclProps.getProperty("org/apache/maven/plugin/coreit/b.properties"));
assertEquals("1", pclProps.getProperty("org/apache/maven/plugin/coreit/b.properties.count"));
assertNotNull(pclProps.getProperty("org/apache/maven/plugin/coreit/it.properties"));
assertEquals("2", pclProps.getProperty("org/apache/maven/plugin/coreit/it.properties.count"));
Properties tcclProps = verifier.loadProperties("target/tccl.properties");
assertEquals(pclProps, tcclProps);
}
}

View File

@ -0,0 +1,70 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-1898">MNG-1898</a>.
*
* @author John Casey
*
*/
public class MavenIT0087PluginRealmWithProjectLevelDepsTest extends AbstractMavenIntegrationTestCase {
public MavenIT0087PluginRealmWithProjectLevelDepsTest() {
super("(2.0.2,)");
}
/**
* Verify that a project-level plugin dependency class/resource can be loaded from both the plugin classloader
* and the context classloader available to the plugin.
*
* @throws Exception in case of failure
*/
@Test
public void testit0087() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0087");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0087");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties pclProps = verifier.loadProperties("target/pcl.properties");
assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassA"));
assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassB"));
assertNotNull(pclProps.getProperty("org.apache.maven.its.it0087.IT0087"));
assertNotNull(pclProps.getProperty("src/main/java/org/apache/maven/its/it0087/IT0087.java"));
assertEquals("1", pclProps.getProperty("src/main/java/org/apache/maven/its/it0087/IT0087.java.count"));
Properties tcclProps = verifier.loadProperties("target/tccl.properties");
assertEquals(pclProps, tcclProps);
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0090EnvVarInterpolationTest extends AbstractMavenIntegrationTestCase {
public MavenIT0090EnvVarInterpolationTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that ensures that envars are interpolated correctly into plugin
* configurations.
*
* @throws Exception in case of failure
*/
@Test
public void testit0090() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0090");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.setEnvironmentVariable("MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/env.properties");
assertEquals("MAVEN_TEST_ENVAR_VALUE", props.getProperty("stringParam"));
}
}

View File

@ -0,0 +1,248 @@
/*
* 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.maven.it;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Downloads a snapshot dependency that was deployed with uniqueVersion = false, and checks it can be
* updated. See <a href="https://issues.apache.org/jira/browse/MNG-1908">MNG-1908</a>.
*/
@Disabled("flaky test, see MNG-3137")
public class MavenIT0108SnapshotUpdateTest extends AbstractMavenIntegrationTestCase {
public MavenIT0108SnapshotUpdateTest() {
super(ALL_MAVEN_VERSIONS);
}
private Verifier verifier;
private File artifact;
private File repository;
private File localRepoFile;
private static final int TIME_OFFSET = 50000;
@BeforeEach
protected void setUp() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0108");
verifier = newVerifier(testDir.getAbsolutePath());
localRepoFile = getLocalRepoFile(verifier);
deleteLocalArtifact(verifier, localRepoFile);
repository = new File(testDir, "repository");
recreateRemoteRepository(repository);
// create artifact in repository (TODO: into verifier)
artifact = new File(
repository,
"org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-core-it-support-1.0-SNAPSHOT.jar");
artifact.getParentFile().mkdirs();
FileUtils.fileWrite(artifact.getAbsolutePath(), "originalArtifact");
verifier.verifyArtifactNotPresent("org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar");
}
@Test
public void testSnapshotUpdated() throws Exception {
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyArtifactContent("originalArtifact");
// set in the past to ensure it is downloaded
localRepoFile.setLastModified(System.currentTimeMillis() - TIME_OFFSET);
FileUtils.fileWrite(artifact.getAbsolutePath(), "updatedArtifact");
verifier.addCliArgument("package");
verifier.execute();
verifyArtifactContent("updatedArtifact");
verifier.verifyErrorFreeLog();
}
@Test
public void testSnapshotUpdatedWithMetadata() throws Exception {
File metadata = new File(repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml");
FileUtils.fileWrite(
metadata.getAbsolutePath(), constructMetadata("1", System.currentTimeMillis() - TIME_OFFSET, true));
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyArtifactContent("originalArtifact");
FileUtils.fileWrite(artifact.getAbsolutePath(), "updatedArtifact");
metadata = new File(repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml");
FileUtils.fileWrite(metadata.getAbsolutePath(), constructMetadata("2", System.currentTimeMillis(), true));
verifier.addCliArgument("package");
verifier.execute();
verifyArtifactContent("updatedArtifact");
verifier.verifyErrorFreeLog();
}
@Test
public void testSnapshotUpdatedWithLocalMetadata() throws Exception {
File localMetadata = getMetadataFile("org/apache/maven", "maven-core-it-support", "1.0-SNAPSHOT");
FileUtils.deleteDirectory(localMetadata.getParentFile());
assertFalse(localMetadata.getParentFile().exists());
localMetadata.getParentFile().mkdirs();
File metadata = new File(repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml");
FileUtils.fileWrite(
metadata.getAbsolutePath(), constructMetadata("1", System.currentTimeMillis() - TIME_OFFSET, true));
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyArtifactContent("originalArtifact");
assertFalse(localMetadata.exists());
FileUtils.fileWrite(localRepoFile.getAbsolutePath(), "localArtifact");
FileUtils.fileWrite(
localMetadata.getAbsolutePath(),
constructLocalMetadata("org.apache.maven", "maven-core-it-support", System.currentTimeMillis(), true));
// update the remote file, but we shouldn't be looking
artifact.setLastModified(System.currentTimeMillis());
verifier.addCliArgument("package");
verifier.execute();
verifyArtifactContent("localArtifact");
verifier.verifyErrorFreeLog();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, -1);
FileUtils.fileWrite(
localMetadata.getAbsolutePath(),
constructLocalMetadata("org.apache.maven", "maven-core-it-support", cal.getTimeInMillis(), true));
FileUtils.fileWrite(
metadata.getAbsolutePath(), constructMetadata("2", System.currentTimeMillis() - 2000, true));
artifact.setLastModified(System.currentTimeMillis());
verifier.addCliArgument("package");
verifier.execute();
verifyArtifactContent("originalArtifact");
verifier.verifyErrorFreeLog();
}
@Test
public void testSnapshotUpdatedWithMetadataUsingFileTimestamp() throws Exception {
File metadata = new File(repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml");
FileUtils.fileWrite(
metadata.getAbsolutePath(), constructMetadata("1", System.currentTimeMillis() - TIME_OFFSET, false));
metadata.setLastModified(System.currentTimeMillis() - TIME_OFFSET);
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
verifyArtifactContent("originalArtifact");
FileUtils.fileWrite(artifact.getAbsolutePath(), "updatedArtifact");
metadata = new File(repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml");
FileUtils.fileWrite(metadata.getAbsolutePath(), constructMetadata("2", System.currentTimeMillis(), false));
verifier.addCliArgument("package");
verifier.execute();
verifyArtifactContent("updatedArtifact");
verifier.verifyErrorFreeLog();
}
private File getMetadataFile(String groupId, String artifactId, String version) {
return new File(verifier.getArtifactMetadataPath(groupId, artifactId, version, "maven-metadata-local.xml"));
}
private void verifyArtifactContent(String s) throws IOException, VerificationException {
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar");
verifier.verifyArtifactContent("org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar", s);
}
private static File deleteLocalArtifact(Verifier verifier, File localRepoFile) throws IOException {
verifier.deleteArtifact("org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar");
// this is to delete metadata - TODO: incorporate into deleteArtifact in verifier
FileUtils.deleteDirectory(localRepoFile.getParentFile());
return localRepoFile;
}
private static File getLocalRepoFile(Verifier verifier) {
return new File(verifier.getArtifactPath("org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar"));
}
private static void recreateRemoteRepository(File repository) throws IOException {
// create a repository (TODO: into verifier)
FileUtils.deleteDirectory(repository);
assertFalse(repository.exists());
repository.mkdirs();
}
private String constructMetadata(String buildNumber, long timestamp, boolean writeLastUpdated) {
String ts = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(new Date(timestamp));
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><metadata>\n" + "<groupId>org.apache.maven</groupId>\n"
+ "<artifactId>maven-core-it-support</artifactId>\n"
+ "<version>1.0-SNAPSHOT</version>\n" + "<versioning>\n"
+ "<snapshot>\n" + "<buildNumber>" + buildNumber + "</buildNumber>\n" + "</snapshot>\n"
+ (writeLastUpdated ? "<lastUpdated>" + ts + "</lastUpdated>\n" : "")
+ "</versioning>\n" + "</metadata>";
}
private String constructLocalMetadata(String groupId, String artifactId, long timestamp, boolean writeLastUpdated) {
String ts = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(new Date(timestamp));
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><metadata>\n" + " <groupId>" + groupId + "</groupId>\n"
+ " <artifactId>"
+ artifactId + "</artifactId>\n" + " <version>1.0-SNAPSHOT</version>\n" + " <versioning>\n"
+ " <snapshot>\n" + " <localCopy>true</localCopy>\n" + " </snapshot>\n"
+ (writeLastUpdated ? " <lastUpdated>" + ts + "</lastUpdated>\n" : "")
+ " </versioning>\n" + "</metadata>";
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0113ServerAuthzAvailableToWagonMgrInPluginTest extends AbstractMavenIntegrationTestCase {
public MavenIT0113ServerAuthzAvailableToWagonMgrInPluginTest() {
super("[2.0,3.0-alpha-1),[3.0-alpha-7,)");
}
/**
* Test that the auth infos given in the settings.xml are pushed into the wagon manager and are available
* to other components/plugins.
*
* @throws Exception in case of failure
*/
@Test
public void testit0113() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0113");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/auth.properties");
assertEquals("testuser", props.getProperty("test.username"));
assertEquals("testtest", props.getProperty("test.password"));
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0130CleanLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0130CleanLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "clean" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0130() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0130");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("clean");
verifier.execute();
verifier.verifyFilePresent("target/clean-clean.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0131SiteLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0131SiteLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "site" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0131() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0131");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("site-deploy");
verifier.execute();
verifier.verifyFilePresent("target/site-site.txt");
verifier.verifyFilePresent("target/site-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0132PomLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0132PomLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "pom" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0132() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0132");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
if (matchesVersionRange("(2.0.1,3.0-alpha-1)")) {
verifier.verifyFilePresent("target/site-attach-descriptor.txt");
}
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0133JarLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0133JarLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "jar" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0133() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0133");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/compiler-compile.txt");
verifier.verifyFilePresent("target/resources-test-resources.txt");
verifier.verifyFilePresent("target/compiler-test-compile.txt");
verifier.verifyFilePresent("target/surefire-test.txt");
verifier.verifyFilePresent("target/jar-jar.txt");
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0134WarLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0134WarLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "war" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0134() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0134");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/compiler-compile.txt");
verifier.verifyFilePresent("target/resources-test-resources.txt");
verifier.verifyFilePresent("target/compiler-test-compile.txt");
verifier.verifyFilePresent("target/surefire-test.txt");
verifier.verifyFilePresent("target/war-war.txt");
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0135EjbLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0135EjbLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "ejb" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0135() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0135");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/compiler-compile.txt");
verifier.verifyFilePresent("target/resources-test-resources.txt");
verifier.verifyFilePresent("target/compiler-test-compile.txt");
verifier.verifyFilePresent("target/surefire-test.txt");
verifier.verifyFilePresent("target/ejb-ejb.txt");
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0136RarLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0136RarLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "rar" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0136() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0136");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/compiler-compile.txt");
verifier.verifyFilePresent("target/resources-test-resources.txt");
verifier.verifyFilePresent("target/compiler-test-compile.txt");
verifier.verifyFilePresent("target/surefire-test.txt");
verifier.verifyFilePresent("target/rar-rar.txt");
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0137EarLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0137EarLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "ear" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0137() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0137");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/ear-generate-application-xml.txt");
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/ear-ear.txt");
verifier.verifyFilePresent("target/install-install.txt");
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0138PluginLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenIT0138PluginLifecycleTest() {
super("[2.0.0,)");
}
/**
* Test default binding of goals for "maven-plugin" lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testit0138() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0138");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("deploy");
verifier.execute();
verifier.verifyFilePresent("target/plugin-descriptor.txt");
verifier.verifyFilePresent("target/resources-resources.txt");
verifier.verifyFilePresent("target/compiler-compile.txt");
verifier.verifyFilePresent("target/resources-test-resources.txt");
verifier.verifyFilePresent("target/compiler-test-compile.txt");
verifier.verifyFilePresent("target/surefire-test.txt");
verifier.verifyFilePresent("target/jar-jar.txt");
verifier.verifyFilePresent("target/plugin-add-plugin-artifact-metadata.txt");
verifier.verifyFilePresent("target/install-install.txt");
if (matchesVersionRange("(,2.2.0)")) {
verifier.verifyFilePresent("target/plugin-update-registry.txt");
}
verifier.verifyFilePresent("target/deploy-deploy.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,90 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0139InterpolationWithProjectPrefixTest extends AbstractMavenIntegrationTestCase {
public MavenIT0139InterpolationWithProjectPrefixTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that expressions of the form ${project.*} resolve correctly to POM values.
*
* @throws Exception in case of failure
*/
@Test
public void testit0139() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0139");
File child = new File(testDir, "child");
Verifier verifier = newVerifier(child.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/interpolated.properties");
String prefix = "project.properties.";
assertEquals(child.getCanonicalFile(), new File(props.getProperty(prefix + "projectDir")).getCanonicalFile());
assertEquals("org.apache.maven.its.it0139.child", props.getProperty(prefix + "projectGroupId"));
assertEquals("child", props.getProperty(prefix + "projectArtifactId"));
assertEquals("2.0-alpha-1", props.getProperty(prefix + "projectVersion"));
assertEquals("jar", props.getProperty(prefix + "projectPackaging"));
assertEquals("child-name", props.getProperty(prefix + "projectName"));
assertEquals("child-desc", props.getProperty(prefix + "projectDesc"));
assertEquals("http://child.org/", props.getProperty(prefix + "projectUrl"));
assertEquals("2008", props.getProperty(prefix + "projectYear"));
assertEquals("child-org-name", props.getProperty(prefix + "projectOrgName"));
assertEquals("2.0.0", props.getProperty(prefix + "projectPrereqMvn"));
assertEquals("http://scm.org/", props.getProperty(prefix + "projectScmUrl"));
assertEquals("http://issue.org/", props.getProperty(prefix + "projectIssueUrl"));
assertEquals("http://ci.org/", props.getProperty(prefix + "projectCiUrl"));
assertEquals("child-dist-repo", props.getProperty(prefix + "projectDistRepoName"));
assertEquals("org.apache.maven.its.it0139", props.getProperty(prefix + "parentGroupId"));
assertEquals("parent", props.getProperty(prefix + "parentArtifactId"));
assertEquals("1.0", props.getProperty(prefix + "parentVersion"));
/*
* NOTE: We intentionally do not check whether the build paths have been basedir aligned, that's another
* story...
*/
if (matchesVersionRange("(2.0.8,)")) {
assertTrue(props.getProperty(prefix + "projectBuildOut").endsWith("bin"));
}
assertTrue(props.getProperty(prefix + "projectSiteOut").endsWith("doc"));
}
}

View File

@ -0,0 +1,92 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* <a href="https://issues.apache.org/jira/browse/MNG-7244">MNG-7244</a> removes the deprecation of
* <code>pom.X</code>.
* See {@link MavenITmng7244IgnorePomPrefixInExpressions}.
*
* @author Benjamin Bentmann
*/
public class MavenIT0140InterpolationWithPomPrefixTest extends AbstractMavenIntegrationTestCase {
public MavenIT0140InterpolationWithPomPrefixTest() {
super("[2.0,4.0.0-alpha-1)");
}
/**
* Test that expressions of the form ${pom.*} resolve correctly to POM values.
*
* @throws Exception in case of failure
*/
@Test
public void testit0140() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0140");
File child = new File(testDir, "child");
Verifier verifier = newVerifier(child.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/interpolated.properties");
String prefix = "project.properties.";
assertEquals(child.getCanonicalFile(), new File(props.getProperty(prefix + "projectDir")).getCanonicalFile());
assertEquals("org.apache.maven.its.it0140.child", props.getProperty(prefix + "projectGroupId"));
assertEquals("child", props.getProperty(prefix + "projectArtifactId"));
assertEquals("2.0-alpha-1", props.getProperty(prefix + "projectVersion"));
assertEquals("jar", props.getProperty(prefix + "projectPackaging"));
assertEquals("child-name", props.getProperty(prefix + "projectName"));
assertEquals("child-desc", props.getProperty(prefix + "projectDesc"));
assertEquals("http://child.org/", props.getProperty(prefix + "projectUrl"));
assertEquals("2008", props.getProperty(prefix + "projectYear"));
assertEquals("child-org-name", props.getProperty(prefix + "projectOrgName"));
assertEquals("2.0.0", props.getProperty(prefix + "projectPrereqMvn"));
assertEquals("http://scm.org/", props.getProperty(prefix + "projectScmUrl"));
assertEquals("http://issue.org/", props.getProperty(prefix + "projectIssueUrl"));
assertEquals("http://ci.org/", props.getProperty(prefix + "projectCiUrl"));
assertEquals("child-dist-repo", props.getProperty(prefix + "projectDistRepoName"));
assertEquals("org.apache.maven.its.it0140", props.getProperty(prefix + "parentGroupId"));
assertEquals("parent", props.getProperty(prefix + "parentArtifactId"));
assertEquals("1.0", props.getProperty(prefix + "parentVersion"));
/*
* NOTE: We intentionally do not check whether the build paths have been basedir aligned, that's another
* story...
*/
if (matchesVersionRange("(2.0.8,)")) {
assertTrue(props.getProperty(prefix + "projectBuildOut").endsWith("bin"));
}
assertTrue(props.getProperty(prefix + "projectSiteOut").endsWith("doc"));
}
}

View File

@ -0,0 +1,118 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0142DirectDependencyScopesTest extends AbstractMavenIntegrationTestCase {
/*
* NOTE: Class path ordering is another issue (MNG-1412), so we merely check set containment here.
*/
public MavenIT0142DirectDependencyScopesTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the different scopes of direct dependencies end up on the right class paths.
*
* @throws Exception in case of failure
*/
@Test
public void testit0142() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0142");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0142");
verifier.filterFile("pom-template.xml", "pom.xml", "UTF-8");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> compileArtifacts = verifier.loadLines("target/compile-artifacts.txt", "UTF-8");
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0142:system:jar:0.1"));
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0142:provided:jar:0.1"));
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0142:compile:jar:0.1"));
assertEquals(3, compileArtifacts.size());
List<String> compileClassPath = verifier.loadLines("target/compile-cp.txt", "UTF-8");
assertTrue(compileClassPath.toString(), compileClassPath.contains("classes"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("system-0.1.jar"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("provided-0.1.jar"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("compile-0.1.jar"));
assertEquals(4, compileClassPath.size());
List<String> runtimeArtifacts = verifier.loadLines("target/runtime-artifacts.txt", "UTF-8");
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0142:compile:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0142:runtime:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(),
runtimeArtifacts.contains("org.apache.maven.its.it0142:runtime:jar:retro:0.1"));
assertEquals(3, runtimeArtifacts.size());
List<String> runtimeClassPath = verifier.loadLines("target/runtime-cp.txt", "UTF-8");
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("classes"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("compile-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1-retro.jar"));
assertEquals(4, runtimeClassPath.size());
List<String> testArtifacts = verifier.loadLines("target/test-artifacts.txt", "UTF-8");
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:system:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:provided:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:compile:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:runtime:jar:0.1"));
assertTrue(
testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:runtime:jar:retro:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0142:test:jar:0.1"));
assertEquals(6, testArtifacts.size());
List<String> testClassPath = verifier.loadLines("target/test-cp.txt", "UTF-8");
assertTrue(testClassPath.toString(), testClassPath.contains("classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("system-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("provided-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("compile-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1-retro.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-0.1.jar"));
assertEquals(8, testClassPath.size());
}
}

View File

@ -0,0 +1,262 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import java.util.Map;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
*
* @author Benjamin Bentmann
*
*/
public class MavenIT0143TransitiveDependencyScopesTest extends AbstractMavenIntegrationTestCase {
/*
* NOTE: Class path ordering is another issue (MNG-1412), so we merely check set containment here.
*/
public MavenIT0143TransitiveDependencyScopesTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the different scopes of transitive dependencies end up on the right class paths when mediated from
* a compile-scope dependency.
*
* @throws Exception in case of failure
*/
@Test
public void testitCompileScope() throws Exception {
Verifier verifier = run("compile");
String targetDir = "target-compile";
/*
* NOTE: Transitive compile dependencies end up in compile scope to support the case of a class in the direct
* dependency that extends a class from the transitive dependency, i.e.
* project imports A from direct dependency and A extends B from transitive dependency.
*/
List<String> compileArtifacts = verifier.loadLines(targetDir + "/compile-artifacts.txt", "UTF-8");
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertEquals(2, compileArtifacts.size());
List<String> compileClassPath = verifier.loadLines(targetDir + "/compile-cp.txt", "UTF-8");
assertTrue(compileClassPath.toString(), compileClassPath.contains("classes"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("direct-0.1.jar"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("compile-0.1.jar"));
assertEquals(3, compileClassPath.size());
List<String> runtimeArtifacts = verifier.loadLines(targetDir + "/runtime-artifacts.txt", "UTF-8");
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, runtimeArtifacts.size());
List<String> runtimeClassPath = verifier.loadLines(targetDir + "/runtime-cp.txt", "UTF-8");
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("classes"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("direct-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("compile-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1.jar"));
assertEquals(4, runtimeClassPath.size());
List<String> testArtifacts = verifier.loadLines(targetDir + "/test-artifacts.txt", "UTF-8");
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, testArtifacts.size());
List<String> testClassPath = verifier.loadLines(targetDir + "/test-cp.txt", "UTF-8");
assertTrue(testClassPath.toString(), testClassPath.contains("classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("direct-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("compile-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1.jar"));
assertEquals(5, testClassPath.size());
}
/**
* Test that the different scopes of transitive dependencies end up on the right class paths when mediated from
* a provided-scope dependency.
*
* @throws Exception in case of failure
*/
@Test
public void testitProvidedScope() throws Exception {
Verifier verifier = run("provided");
String targetDir = "target-provided";
List<String> compileArtifacts = verifier.loadLines(targetDir + "/compile-artifacts.txt", "UTF-8");
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(
compileArtifacts.toString(), compileArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, compileArtifacts.size());
List<String> compileClassPath = verifier.loadLines(targetDir + "/compile-cp.txt", "UTF-8");
assertTrue(compileClassPath.toString(), compileClassPath.contains("classes"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("direct-0.1.jar"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("compile-0.1.jar"));
assertTrue(compileClassPath.toString(), compileClassPath.contains("runtime-0.1.jar"));
assertEquals(4, compileClassPath.size());
List<String> runtimeArtifacts = verifier.loadLines(targetDir + "/runtime-artifacts.txt", "UTF-8");
assertEquals(0, runtimeArtifacts.size());
List<String> runtimeClassPath = verifier.loadLines(targetDir + "/runtime-cp.txt", "UTF-8");
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("classes"));
assertEquals(1, runtimeClassPath.size());
List<String> testArtifacts = verifier.loadLines(targetDir + "/test-artifacts.txt", "UTF-8");
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, testArtifacts.size());
List<String> testClassPath = verifier.loadLines(targetDir + "/test-cp.txt", "UTF-8");
assertTrue(testClassPath.toString(), testClassPath.contains("classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("direct-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("compile-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1.jar"));
assertEquals(5, testClassPath.size());
}
/**
* Test that the different scopes of transitive dependencies end up on the right class paths when mediated from
* a runtime-scope dependency.
*
* @throws Exception in case of failure
*/
@Test
public void testitRuntimeScope() throws Exception {
Verifier verifier = run("runtime");
String targetDir = "target-runtime";
List<String> compileArtifacts = verifier.loadLines(targetDir + "/compile-artifacts.txt", "UTF-8");
assertEquals(0, compileArtifacts.size());
List<String> compileClassPath = verifier.loadLines(targetDir + "/compile-cp.txt", "UTF-8");
assertTrue(compileClassPath.toString(), compileClassPath.contains("classes"));
assertEquals(1, compileClassPath.size());
List<String> runtimeArtifacts = verifier.loadLines(targetDir + "/runtime-artifacts.txt", "UTF-8");
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(
runtimeArtifacts.toString(), runtimeArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, runtimeArtifacts.size());
List<String> runtimeClassPath = verifier.loadLines(targetDir + "/runtime-cp.txt", "UTF-8");
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("classes"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("direct-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("compile-0.1.jar"));
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1.jar"));
assertEquals(4, runtimeClassPath.size());
List<String> testArtifacts = verifier.loadLines(targetDir + "/test-artifacts.txt", "UTF-8");
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, testArtifacts.size());
List<String> testClassPath = verifier.loadLines(targetDir + "/test-cp.txt", "UTF-8");
assertTrue(testClassPath.toString(), testClassPath.contains("classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("direct-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("compile-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1.jar"));
assertEquals(5, testClassPath.size());
}
/**
* Test that the different scopes of transitive dependencies end up on the right class paths when mediated from
* a test-scope dependency.
*
* @throws Exception in case of failure
*/
@Test
public void testitTestScope() throws Exception {
Verifier verifier = run("test");
String targetDir = "target-test";
List<String> compileArtifacts = verifier.loadLines(targetDir + "/compile-artifacts.txt", "UTF-8");
assertEquals(0, compileArtifacts.size());
List<String> compileClassPath = verifier.loadLines(targetDir + "/compile-cp.txt", "UTF-8");
assertTrue(compileClassPath.toString(), compileClassPath.contains("classes"));
assertEquals(1, compileClassPath.size());
List<String> runtimeArtifacts = verifier.loadLines(targetDir + "/runtime-artifacts.txt", "UTF-8");
assertEquals(0, runtimeArtifacts.size());
List<String> runtimeClassPath = verifier.loadLines(targetDir + "/runtime-cp.txt", "UTF-8");
assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("classes"));
assertEquals(1, runtimeClassPath.size());
List<String> testArtifacts = verifier.loadLines(targetDir + "/test-artifacts.txt", "UTF-8");
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:direct:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:compile:jar:0.1"));
assertTrue(testArtifacts.toString(), testArtifacts.contains("org.apache.maven.its.it0143:runtime:jar:0.1"));
assertEquals(3, testArtifacts.size());
List<String> testClassPath = verifier.loadLines(targetDir + "/test-cp.txt", "UTF-8");
assertTrue(testClassPath.toString(), testClassPath.contains("classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("test-classes"));
assertTrue(testClassPath.toString(), testClassPath.contains("direct-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("compile-0.1.jar"));
assertTrue(testClassPath.toString(), testClassPath.contains("runtime-0.1.jar"));
assertEquals(5, testClassPath.size());
}
private Verifier run(String scope) throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0143");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target-" + scope);
verifier.deleteArtifacts("org.apache.maven.its.it0143");
Map<String, String> filterProps = verifier.newDefaultFilterMap();
filterProps.put("@scope@", scope);
verifier.filterFile("pom-template.xml", "pom.xml", "UTF-8", filterProps);
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.setLogFileName("log-" + scope + ".txt");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
return verifier;
}
}

View File

@ -0,0 +1,103 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* @author Benjamin Bentmann
*
*/
public class MavenIT0144LifecycleExecutionOrderTest extends AbstractMavenIntegrationTestCase {
public MavenIT0144LifecycleExecutionOrderTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the lifecycle phases execute in proper order.
*
* @throws Exception in case of failure
*/
@Test
public void testit0144() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0144");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArguments("post-clean", "deploy", "site-deploy");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> expected = new ArrayList<>();
expected.add("pre-clean");
expected.add("clean");
expected.add("post-clean");
expected.add("validate");
expected.add("initialize");
expected.add("generate-sources");
expected.add("process-sources");
expected.add("generate-resources");
expected.add("process-resources");
expected.add("compile");
expected.add("process-classes");
expected.add("generate-test-sources");
expected.add("process-test-sources");
expected.add("generate-test-resources");
expected.add("process-test-resources");
expected.add("test-compile");
if (matchesVersionRange("(2.0.4,)")) {
// MNG-1508
expected.add("process-test-classes");
}
expected.add("test");
if (matchesVersionRange("(2.1.0-M1,)")) {
// MNG-2097
expected.add("prepare-package");
}
expected.add("package");
if (matchesVersionRange("(2.0.1,)")) {
expected.add("pre-integration-test");
}
expected.add("integration-test");
if (matchesVersionRange("(2.0.1,)")) {
expected.add("post-integration-test");
}
expected.add("verify");
expected.add("install");
expected.add("deploy");
expected.add("pre-site");
expected.add("site");
expected.add("post-site");
expected.add("site-deploy");
List<String> phases = verifier.loadLines("target/phases.log", "UTF-8");
assertEquals(expected, phases);
}
}

View File

@ -0,0 +1,136 @@
/*
* 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.maven.it;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Map;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MavenIT0146InstallerSnapshotNaming extends AbstractMavenIntegrationTestCase {
private Server server;
private int port;
private final File testDir;
public MavenIT0146InstallerSnapshotNaming() throws IOException {
super("(2.0.2,)");
testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0146");
}
@BeforeEach
protected void setUp() throws Exception {
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(new File(testDir, "repo").getAbsolutePath());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {resourceHandler, new DefaultHandler()});
server = new Server(0);
server.setHandler(handlers);
server.start();
if (server.isFailed()) {
fail("Couldn't bind the server socket to a free port!");
}
port = ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
System.out.println("Bound server socket to the port " + port);
}
@AfterEach
protected void tearDown() throws Exception {
if (server != null) {
server.stop();
server.join();
}
}
@Test
public void testitRemoteDownloadTimestampedName() throws Exception {
Verifier verifier = newVerifier(testDir.getAbsolutePath());
Map<String, String> properties = verifier.newDefaultFilterMap();
properties.put("@host@", InetAddress.getLoopbackAddress().getCanonicalHostName());
properties.put("@port@", Integer.toString(port));
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", properties);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.deleteArtifacts("org.apache.maven.its.it0146");
verifier.addCliArgument("-X");
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/appassembler/repo/dep-0.1-20110726.105319-1.jar");
}
@Test
public void testitNonTimestampedNameWithInstalledSNAPSHOT() throws Exception {
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteArtifacts("org.apache.maven.its.it0146");
verifier.addCliArgument("-f");
verifier.addCliArgument("project/pom.xml");
verifier.deleteDirectory("project/target");
verifier.setLogFileName("log2.txt");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier = newVerifier(testDir.getAbsolutePath());
Map<String, String> properties = verifier.newDefaultFilterMap();
properties.put("@host@", InetAddress.getLoopbackAddress().getCanonicalHostName());
properties.put("@port@", Integer.toString(port));
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", properties);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.setLogFileName("log3.txt");
verifier.addCliArgument("-X");
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/appassembler/repo/dep-0.1-SNAPSHOT.jar");
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
public class MavenIT0199CyclicImportScopeTest extends AbstractMavenIntegrationTestCase {
public MavenIT0199CyclicImportScopeTest() {
super(ALL_MAVEN_VERSIONS);
}
@Test
public void testit0199() throws Exception {
// v1: parent not using BOM; explicit dep from componentB componentA
// v2: BOM introduced; componentB componentA picks up implicit version 1 from main@v1
// v3: components now inheriting indirectly from an older version of the BOM that includes them; componentB
// componentA version overridden
for (int i = 1; i <= 3; i++) {
build("v" + i + "/parent", null);
build("v" + i + "/componentA", "target/componentA-" + i + ".jar");
build("v" + i + "/componentB", "target/componentB-" + i + ".jar");
build("v" + i + "/main", "bundle/target/bundle-" + i + ".jar");
}
}
private void build(String module, String expectedArtifact) throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/cyclic-import-scope");
Verifier verifier = newVerifier(new File(testDir.getAbsolutePath(), module).getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("install");
verifier.execute();
if (expectedArtifact != null) {
verifier.verifyFilePresent(expectedArtifact);
}
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* Core IT Bootstrapping: downloads from central repository every dependency (artifacts, plugins) required to let
* ITs run without downloading anything later.
*
* @author Benjamin Bentmann
*
*/
public class MavenITBootstrapTest extends AbstractMavenIntegrationTestCase {
public MavenITBootstrapTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Bootstraps the integration tests by downloading required artifacts from central repository.
*
* @throws Exception in case of failure
*/
@Test
public void testBootstrap() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/bootstrap");
Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.setAutoclean(false);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("-Dbootstrap="
+ getClass().getResource("/bootstrap.txt").toURI().getPath());
// bootstrap plugin is bound to this phase, do not go further
// important: maven-plugin packaging will fail at package phase, as there is no Mojo present!
verifier.addCliArgument("process-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,130 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-95">MNG-95</a>.
*
* @author John Casey
*
*/
public class MavenITmng0095ReactorFailureBehaviorTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0095ReactorFailureBehaviorTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test fail-fast reactor behavior. Forces an exception to be thrown in
* the first module and checks that the second &amp; third module is not built and the overall build fails, too.
*
* @throws Exception in case of failure
*/
@Test
public void testitFailFast() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0095");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("subproject1/target");
verifier.deleteDirectory("subproject2/target");
verifier.deleteDirectory("subproject3/target");
verifier.addCliArgument("--fail-fast");
verifier.setLogFileName("log-ff.txt");
try {
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
} catch (VerificationException e) {
// expected
}
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyFileNotPresent("subproject1/target/touch.txt");
verifier.verifyFileNotPresent("subproject2/target/touch.txt");
verifier.verifyFileNotPresent("subproject3/target/touch.txt");
}
/**
* Test fail-never reactor behavior. Forces an exception to be thrown in
* the first module, but checks that the second &amp; third module is built and the overall build succeeds.
*
* @throws Exception in case of failure
*/
@Test
public void testitFailNever() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0095");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("subproject1/target");
verifier.deleteDirectory("subproject2/target");
verifier.deleteDirectory("subproject3/target");
verifier.addCliArgument("--fail-never");
verifier.setLogFileName("log-fn.txt");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyFileNotPresent("subproject1/target/touch.txt");
verifier.verifyFilePresent("subproject2/target/touch.txt");
verifier.verifyFilePresent("subproject3/target/touch.txt");
}
/**
* Test fail-at-end reactor behavior. Forces an exception to be thrown in
* the first module and checks that the second module is still built but the overall build finally fails
* and the third module (which depends on the failed module) is skipped.
*
* @throws Exception in case of failure
*/
@Test
public void testitFailAtEnd() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0095");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("subproject1/target");
verifier.deleteDirectory("subproject2/target");
verifier.deleteDirectory("subproject3/target");
verifier.addCliArgument("--fail-at-end");
verifier.setLogFileName("log-fae.txt");
try {
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
} catch (VerificationException e) {
// expected
}
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyFileNotPresent("subproject1/target/touch.txt");
verifier.verifyFilePresent("subproject2/target/touch.txt");
verifier.verifyFileNotPresent("subproject3/target/touch.txt");
}
}

View File

@ -0,0 +1,91 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-187">MNG-187</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng0187CollectedProjectsTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0187CollectedProjectsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that MavenProject.getCollectedProjects() provides access to the direct and indirect modules
* of the current project.
*
* @throws Exception in case of failure
*/
@Test
public void testit() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0187");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("sub-1/target");
verifier.deleteDirectory("sub-1/sub-2/target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props;
props = verifier.loadProperties("target/project.properties");
assertEquals("2", props.getProperty("project.collectedProjects.size"));
assertEquals(Arrays.asList(new String[] {"sub-1", "sub-2"}), getProjects(props));
props = verifier.loadProperties("sub-1/target/project.properties");
assertEquals("1", props.getProperty("project.collectedProjects.size"));
assertEquals(Arrays.asList(new String[] {"sub-2"}), getProjects(props));
props = verifier.loadProperties("sub-1/sub-2/target/project.properties");
assertEquals("0", props.getProperty("project.collectedProjects.size"));
assertEquals(Arrays.asList(new String[] {}), getProjects(props));
}
private List<String> getProjects(Properties props) {
List<String> projects = new ArrayList<>();
for (Object o : props.keySet()) {
String key = o.toString();
if (key.startsWith("project.collectedProjects.") && !key.endsWith(".size")) {
projects.add(props.getProperty(key));
}
}
Collections.sort(projects);
return projects;
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-249">MNG-249</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0249ResolveDepsFromReactorTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0249ResolveDepsFromReactorTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the reactor can establish the artifact location of known projects for dependencies.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0249() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0249");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> ccp = verifier.loadLines("test-component-c/target/compile.txt", "UTF-8");
assertTrue(ccp.toString(), ccp.contains("test-component-c/classes"));
assertTrue(ccp.toString(), ccp.contains("test-component-b/classes"));
assertTrue(ccp.toString(), ccp.contains("test-component-a/classes"));
List<String> rcp = verifier.loadLines("test-component-c/target/runtime.txt", "UTF-8");
assertTrue(rcp.toString(), rcp.contains("test-component-c/classes"));
assertTrue(rcp.toString(), rcp.contains("test-component-b/classes"));
assertTrue(rcp.toString(), rcp.contains("test-component-a/classes"));
List<String> tcp = verifier.loadLines("test-component-c/target/test.txt", "UTF-8");
assertTrue(tcp.toString(), tcp.contains("test-component-c/classes"));
assertTrue(tcp.toString(), tcp.contains("test-component-b/classes"));
assertTrue(tcp.toString(), tcp.contains("test-component-a/classes"));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-282">MNG-282</a>.
*
* @author John Casey
*
*/
public class MavenITmng0282NonReactorExecWhenProjectIndependentTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0282NonReactorExecWhenProjectIndependentTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test non-reactor behavior when plugin declares "@requiresProject false"
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG282() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0282");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("subproject/target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-no-project:light-touch");
verifier.execute();
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyFileNotPresent("subproject/target/touch.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-294">MNG-294</a>.
*
* @author John Casey
*
*/
public class MavenITmng0294MergeGlobalAndUserSettingsTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0294MergeGlobalAndUserSettingsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test merging of global- and user-level settings.xml files.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG294() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0294");
Verifier verifier = new Verifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("--settings");
verifier.addCliArgument("user-settings.xml");
// dedicated CLI option only available since MNG-3914
verifier.addCliArgument("--global-settings");
verifier.addCliArgument("global-settings.xml");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/test.txt");
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-377">MNG-377</a>.
*
* @author John Casey
*
*/
public class MavenITmng0377PluginLookupFromPrefixTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0377PluginLookupFromPrefixTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test usage of plugins.xml mapping file on the repository to resolve plugin artifactId from its prefix using the
* pluginGroups in the provided settings.xml.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG377() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0377");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0377");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("-Dtouch.outputFile=target/file.txt");
verifier.addCliArgument("itprefix:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/file.txt");
}
}

View File

@ -0,0 +1,111 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-449">MNG-449</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0449PluginVersionResolutionTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0449PluginVersionResolutionTest() {
super("[2.0,)");
}
/**
* Verify that versions for plugins are automatically resolved if not given in the POM by checking first LATEST and
* then RELEASE in the repo metadata when the plugin is invoked from the lifecycle.
*
* @throws Exception in case of failure
*/
@Test
public void testitLifecycleInvocation() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0449");
testDir = new File(testDir, "lifecycle");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
try {
verifier.deleteArtifacts("org.apache.maven.its.mng0449");
} catch (Exception e) {
// when we run Maven embedded, the plugin class realm locks the artifacts so we can't delete them
}
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.filterFile("../settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
// Maven 3.x prefers RELEASE over LATEST (see MNG-4206)
if (matchesVersionRange("(,3.0-alpha-3)")) {
verifier.verifyFileNotPresent("target/touch-release.txt");
verifier.verifyFilePresent("target/touch-snapshot.txt");
} else {
verifier.verifyFilePresent("target/touch-release.txt");
verifier.verifyFileNotPresent("target/touch-snapshot.txt");
}
verifier.verifyFilePresent("target/package.txt");
}
/**
* Verify that versions for plugins are automatically resolved if not given in the POM by checking LATEST and
* RELEASE in the repo metadata when the plugin is invoked directly from the command line.
*
* @throws Exception in case of failure
*/
@Test
public void testitCliInvocation() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0449");
testDir = new File(testDir, "direct");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
try {
verifier.deleteArtifacts("org.apache.maven.its.mng0449");
} catch (Exception e) {
// when we run Maven embedded, the plugin class realm locks the artifacts so we can't delete them
}
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.filterFile("../settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("org.apache.maven.its.mng0449:maven-it-plugin-a:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
// Maven 3.x prefers RELEASE over LATEST (see MNG-4206)
if (matchesVersionRange("(,3.0-alpha-3)")) {
verifier.verifyFileNotPresent("target/touch-release.txt");
verifier.verifyFilePresent("target/touch-snapshot.txt");
} else {
verifier.verifyFilePresent("target/touch-release.txt");
verifier.verifyFileNotPresent("target/touch-snapshot.txt");
}
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-461">MNG-461</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng0461TolerateMissingDependencyPomTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0461TolerateMissingDependencyPomTest() {
super("[2.0.3,3.0-alpha-1),[3.0-alpha-2,)");
}
/**
* Verify that dependency resolution only warns in case of missing dependency POMs but does not fail.
*
* @throws Exception in case of failure
*/
@Test
public void testit() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0461");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0461");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> classpath = verifier.loadLines("target/classpath.txt", "UTF-8");
assertTrue(classpath.toString(), classpath.contains("dep-0.1.jar"));
}
}

View File

@ -0,0 +1,86 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-469">MNG-469</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0469ReportConfigTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0469ReportConfigTest() {
super("[2.0.0,)");
}
/**
* Test that {@code <build>} configuration dominates {@code <reporting>} configuration for build goals.
*
* @throws Exception in case of failure
*/
@Test
public void testitBuildConfigDominantDuringBuild() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0469/test1");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT:config");
verifier.execute();
verifier.verifyFilePresent("target/build.txt");
verifier.verifyFileNotPresent("target/reporting.txt");
verifier.verifyErrorFreeLog();
}
/**
* Test that {@code <build>} configuration does not affect report goals.
*
* @throws Exception in case of failure
*/
@Test
public void testitBuildConfigIrrelevantForReports() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0469/test2");
Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.deleteDirectory("target");
verifier.setAutoclean(false);
if (matchesVersionRange("(,3.0-alpha-1)")) {
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-site:2.1-SNAPSHOT:generate");
verifier.execute();
verifier.verifyFilePresent("target/site/info.properties");
} else {
verifier.addCliArgument("validate");
verifier.execute();
Properties props = verifier.loadProperties("target/config.properties");
assertEquals("maven-it-plugin-site", props.getProperty("project.reporting.plugins.0.artifactId"));
assertNotEquals(
"fail.properties",
props.getProperty("project.reporting.plugins.0.configuration.children.infoFile.0.value"));
}
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-471">MNG-471</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0471CustomLifecycleTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0471CustomLifecycleTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test @execute with a custom lifecycle, including configuration
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG471() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0471");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArguments(
"org.apache.maven.its.plugins:maven-it-plugin-fork:fork",
"org.apache.maven.its.plugins:maven-it-plugin-fork:fork-goal");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/forked/touch.txt");
verifier.verifyFilePresent("target/forked2/touch.txt");
}
}

View File

@ -0,0 +1,192 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-479">MNG-479</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0479OverrideCentralRepoTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0479OverrideCentralRepoTest() {
super("[2.0.3,3.0-alpha-1),[3.0-beta-3,)");
}
/**
* Verify that using the same repo id allows to override "central". This test checks the effective model.
*
* @throws Exception in case of failure
*/
@Test
public void testitModel() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0479");
// Phase 1: Ensure the test plugin is downloaded before the test cuts off access to central
File child1 = new File(testDir, "setup");
Verifier verifier = newVerifier(child1.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.execute();
verifier.verifyErrorFreeLog();
// Phase 2: Now run the test
File child2 = new File(testDir, "test");
verifier = newVerifier(child2.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/expression.properties");
Properties props = verifier.loadProperties("target/expression.properties");
int count = Integer.parseInt(props.getProperty("project.repositories", "0"));
assertTrue(count > 0);
for (int i = 0; i < count; i++) {
String key = "project.repositories." + i;
if ("central".equals(props.getProperty(key + ".id"))) {
assertEquals("mng-0479", props.getProperty(key + ".name"));
assertTrue(props.getProperty(key + ".url").endsWith("/target/mng-0479"));
assertEquals("false", props.getProperty(key + ".releases.enabled"));
assertEquals("ignore", props.getProperty(key + ".releases.checksumPolicy"));
assertEquals("always", props.getProperty(key + ".releases.updatePolicy"));
assertEquals("true", props.getProperty(key + ".snapshots.enabled"));
assertEquals("fail", props.getProperty(key + ".snapshots.checksumPolicy"));
assertEquals("never", props.getProperty(key + ".snapshots.updatePolicy"));
}
}
count = Integer.parseInt(props.getProperty("project.pluginRepositories", "0"));
for (int i = 0; i < count; i++) {
String key = "project.pluginRepositories." + i;
if ("central".equals(props.getProperty(key + ".id"))) {
assertEquals("mng-0479", props.getProperty(key + ".name"));
assertTrue(props.getProperty(key + ".url").endsWith("/target/mng-0479"));
assertEquals("false", props.getProperty(key + ".releases.enabled"));
assertEquals("ignore", props.getProperty(key + ".releases.checksumPolicy"));
assertEquals("always", props.getProperty(key + ".releases.updatePolicy"));
assertEquals("true", props.getProperty(key + ".snapshots.enabled"));
assertEquals("fail", props.getProperty(key + ".snapshots.checksumPolicy"));
assertEquals("never", props.getProperty(key + ".snapshots.updatePolicy"));
}
}
}
/**
* Verify that using the same repo id allows to override "central". This test checks the actual repo access.
*
* @throws Exception in case of failure
*/
@Test
public void testitResolution() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0479");
Verifier verifier = newVerifier(new File(testDir, "test-1").getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0479");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/touch.txt");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "parent", "0.1-SNAPSHOT", "pom");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "a", "0.1-SNAPSHOT", "jar");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "a", "0.1-SNAPSHOT", "pom");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "a-parent", "0.1-SNAPSHOT", "pom");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "b", "0.1-SNAPSHOT", "jar");
verifier.verifyArtifactPresent("org.apache.maven.its.mng0479", "b", "0.1-SNAPSHOT", "pom");
verifier = newVerifier(new File(testDir, "test-2").getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
try {
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
fail("Build should have failed to resolve parent POM");
} catch (VerificationException e) {
// expected
}
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0479", "parent", "0.1", "pom");
verifier = newVerifier(new File(testDir, "test-3").getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
try {
verifier.addCliArgument("org.apache.maven.its.mng0479:maven-mng0479-plugin:0.1-SNAPSHOT:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
fail("Build should have failed to resolve direct dependency");
} catch (VerificationException e) {
// expected
}
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0479", "a", "0.1", "jar");
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0479", "a", "0.1", "pom");
verifier = newVerifier(new File(testDir, "test-4").getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
try {
verifier.addCliArgument("org.apache.maven.its.mng0479:maven-mng0479-plugin:0.1-SNAPSHOT:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
fail("Build should have failed to resolve transitive dependency");
} catch (VerificationException e) {
// expected
}
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0479", "b", "0.1", "jar");
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0479", "b", "0.1", "pom");
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-496">MNG-496</a>.
*
* @author John Casey
*
*/
public class MavenITmng0496IgnoreUnknownPluginParametersTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0496IgnoreUnknownPluginParametersTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that unused configuration parameters from the POM don't cause the
* mojo to fail...they will show up as warnings in the -X output instead.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG496() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0496");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-log-file:2.1-SNAPSHOT:reset");
verifier.execute();
verifier.verifyFilePresent("target/file.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,70 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Collection;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-505">MNG-505</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0505VersionRangeTest extends AbstractMavenIntegrationTestCase {
/**
* Oleg 2009.04.30: the same functionality but simpler - no multiple ranges - syntax
* is tested in MNG-4150
*/
public MavenITmng0505VersionRangeTest() {
super("(,3.0-alpha-1),[3.0-alpha-3,)");
}
/**
* Test version range support.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG505() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0505");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0505");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Collection<String> artifacts = verifier.loadLines("target/artifacts.txt", "UTF-8");
assertEquals(4, artifacts.size());
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0505:a:jar:1.1"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0505:b:jar:1.0"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0505:c:jar:3.8"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0505:d:jar:2.1.1"));
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-507">MNG-507</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0507ArtifactRelocationTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0507ArtifactRelocationTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test artifact relocation.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG507() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0507");
Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven", "maven-core-it-support", "1.1");
verifier.deleteArtifacts("org.apache.maven", "maven-core-it-support-old-location", "1.1");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support", "1.1", "jar");
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support", "1.1", "pom");
verifier.verifyArtifactPresent("org.apache.maven", "maven-core-it-support-old-location", "1.1", "pom");
verifier.verifyArtifactNotPresent("org.apache.maven", "maven-core-it-support-old-location", "1.1", "jar");
List<String> artifacts = verifier.loadLines("target/artifacts.txt", "UTF-8");
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven:maven-core-it-support:jar:1.1"));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-522">MNG-522</a>.
*
* @author John Casey
*
*/
public class MavenITmng0522InheritedPluginMgmtConfigTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0522InheritedPluginMgmtConfigTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test for injection of inherited plugin management into plugin configuration.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG522() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0522");
Verifier verifier = newVerifier(new File(testDir, "child-project").getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("process-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/plugin-mngt-config-1.txt");
verifier.verifyFilePresent("target/plugin-mngt-config-2.txt");
}
}

View File

@ -0,0 +1,223 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.UserStore;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-553">MNG-553</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng0553SettingsAuthzEncryptionTest extends AbstractMavenIntegrationTestCase {
private File testDir;
private Server server;
private int port;
public MavenITmng0553SettingsAuthzEncryptionTest() {
super("[2.1.0,3.0-alpha-1),[3.0-alpha-3,4.0.0-beta-4]");
}
@BeforeEach
protected void setUp() throws Exception {
testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0553");
Constraint constraint = new Constraint(__BASIC_AUTH, "user");
constraint.setAuthenticate(true);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
HashLoginService userRealm = new HashLoginService("TestRealm");
UserStore userStore = new UserStore();
userStore.addUser("testuser", new Password("testtest"), new String[] {"user"});
userRealm.setUserStore(userStore);
server = new Server(0);
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setLoginService(userRealm);
securityHandler.setAuthMethod(__BASIC_AUTH);
securityHandler.setConstraintMappings(new ConstraintMapping[] {constraintMapping});
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setResourceBase(new File(testDir, "repo").getAbsolutePath());
HandlerList handlerList = new HandlerList();
handlerList.addHandler(securityHandler);
handlerList.addHandler(repoHandler);
handlerList.addHandler(new DefaultHandler());
server.setHandler(handlerList);
server.start();
if (server.isFailed()) {
fail("Couldn't bind the server socket to a free port!");
}
port = ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
System.out.println("Bound server socket to the port " + port);
}
@AfterEach
protected void tearDown() throws Exception {
if (server != null) {
server.stop();
server.join();
}
}
/**
* Test that the encrypted auth infos given in the settings.xml are decrypted.
*
* @throws Exception in case of failure
*/
@Test
public void testitBasic() throws Exception {
testDir = new File(testDir, "test-1");
Map<String, String> filterProps = new HashMap<>();
filterProps.put("@port@", Integer.toString(port));
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven.its.mng0553");
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
ItUtils.setUserHome(verifier, new File(testDir, "userhome"));
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar");
}
/**
* Test that the encrypted auth infos given in the settings.xml are decrypted when the master password resides
* in an external file.
*
* @throws Exception in case of failure
*/
@Test
public void testitRelocation() throws Exception {
testDir = new File(testDir, "test-2");
Map<String, String> filterProps = new HashMap<>();
filterProps.put("@port@", Integer.toString(port));
// NOTE: The upper-case scheme name is essential part of the test
String secUrl = "FILE://"
+ new File(testDir, "relocated-settings-security.xml").toURI().getRawPath();
filterProps.put("@relocation@", secUrl);
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven.its.mng0553");
verifier.verifyArtifactNotPresent("org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar");
// NOTE: The tilde ~ in the file name is essential part of the test
verifier.filterFile("security-template.xml", "settings~security.xml", "UTF-8", filterProps);
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
// NOTE: The selection of the Turkish language for the JVM locale is essential part of the test
verifier.setEnvironmentVariable(
"MAVEN_OPTS",
"-Dsettings.security=" + new File(testDir, "settings~security.xml").getAbsolutePath()
+ " -Duser.language=tr");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar");
}
/**
* Test that the CLI supports generation of encrypted (master) passwords.
*
* @throws Exception in case of failure
*/
@Test
public void testitEncryption() throws Exception {
requiresMavenVersion("[2.1.0,3.0-alpha-1),[3.0-alpha-7,)");
testDir = new File(testDir, "test-3");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
ItUtils.setUserHome(verifier, new File(testDir, "userhome"));
verifier.addCliArgument("--encrypt-master-password");
verifier.addCliArgument("test");
verifier.setLogFileName("log-emp.txt");
verifier.addCliArgument("-e");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> log = verifier.loadLines(verifier.getLogFileName(), null);
assertNotNull(findPassword(log));
verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
ItUtils.setUserHome(verifier, new File(testDir, "userhome"));
verifier.addCliArgument("--encrypt-password");
verifier.addCliArgument("testpass");
verifier.setLogFileName("log-ep.txt");
verifier.addCliArgument("-e");
verifier.execute();
verifier.verifyErrorFreeLog();
log = verifier.loadLines(verifier.getLogFileName(), null);
assertNotNull(findPassword(log));
}
private String findPassword(List<String> log) {
for (String line : log) {
if (line.matches(".*\\{[A-Za-z0-9+/=]+\\}.*")) {
return line;
}
}
return null;
}
}

View File

@ -0,0 +1,58 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-557">MNG-557</a>.
*
* @author John Casey
*
*/
public class MavenITmng0557UserSettingsCliOptionTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0557UserSettingsCliOptionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test --settings CLI option
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG557() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0557");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-touch:touch");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/test.txt");
}
}

View File

@ -0,0 +1,65 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-612">MNG-612</a>.
*
* @author Mark Hobson
*
*/
@Disabled
public class MavenITmng0612NewestConflictResolverTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0612NewestConflictResolverTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that ensures the newest-wins conflict resolver is used.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG612() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0612/dependency");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0612/plugin");
verifier = newVerifier(testDir.getAbsolutePath());
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0612/project");
verifier = newVerifier(testDir.getAbsolutePath());
verifier.addCliArgument("verify");
verifier.execute();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,65 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-666">MNG-666</a>.
*
* @author John Casey
*
*/
public class MavenITmng0666IgnoreLegacyPomTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0666IgnoreLegacyPomTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that maven-1 POMs will be ignored but not stop the resolution
* process.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG666() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0666");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0059");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
// don't verify error free log
verifier.verifyArtifactPresent("org.apache.maven.its.it0059", "test", "3.8.1", "jar");
List<String> artifacts = verifier.loadLines("target/artifacts.txt", "UTF-8");
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.it0059:test:jar:3.8.1"));
}
}

View File

@ -0,0 +1,86 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-674">MNG-674</a> and
* <a href="https://issues.apache.org/jira/browse/MNG-4997">MNG-4997</a>.
*
* @author John Casey
*
*/
public class MavenITmng0674PluginParameterAliasTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0674PluginParameterAliasTest() {
super("[3.0,)");
}
/**
* Test parameter alias usage for lifecycle-bound goal execution.
*
* @throws Exception in case of failure
*/
@Test
public void testitLifecycle() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0674");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.setLogFileName("log-lifecycle.txt");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/config.properties");
assertEquals("MNG-674-1", props.getProperty("aliasParam"));
assertEquals("MNG-674-2", props.getProperty("aliasDefaultExpressionParam"));
assertEquals("MNG-4997", props.getProperty("aliasStringParams.0"));
}
/**
* Test parameter alias usage for direct goal execution from CLI.
*
* @throws Exception in case of failure
*/
@Test
public void testitCli() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0674");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.setLogFileName("log-cli.txt");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-configuration:config");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/config.properties");
assertEquals("MNG-674-1", props.getProperty("aliasParam"));
assertEquals("MNG-674-2", props.getProperty("aliasDefaultExpressionParam"));
assertEquals("MNG-4997", props.getProperty("aliasStringParams.0"));
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-680">MNG-680</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0680ParentBasedirTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0680ParentBasedirTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the basedir of the parent is set correctly.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG680() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0680");
testDir = testDir.getCanonicalFile();
File subDir = new File(testDir, "subproject");
Verifier verifier = newVerifier(subDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/basedir.properties");
assertEquals(subDir, new File(props.getProperty("project.basedir")));
assertEquals(testDir, new File(props.getProperty("project.parent.basedir")));
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-761">MNG-761</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0761MissingSnapshotDistRepoTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0761MissingSnapshotDistRepoTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that a deployment of a snapshot falls back to a non-snapshot repository if no snapshot repository is
* specified.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG761() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0761");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0761");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/repo/org/apache/maven/its/mng0761/test/1.0-SNAPSHOT/test-1.0-*.jar");
}
}

View File

@ -0,0 +1,175 @@
/*
* 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.maven.it;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-768">MNG-768</a>.
*
* @author John Casey
*
*/
public class MavenITmng0768OfflineModeTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0768OfflineModeTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test offline mode.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG768() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0768");
final List<String> requestedUris = Collections.synchronizedList(new ArrayList<>());
Handler repoHandler = new AbstractHandler() {
public void handle(
String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException {
System.out.println("Handling " + request.getMethod() + " " + request.getRequestURL());
requestedUris.add(request.getRequestURI());
PrintWriter writer = response.getWriter();
response.setStatus(HttpServletResponse.SC_OK);
if (request.getRequestURI().endsWith(".pom")) {
writer.println("<project>");
writer.println(" <modelVersion>4.0.0</modelVersion>");
writer.println(" <groupId>org.apache.maven.its.mng0768</groupId>");
writer.println(" <artifactId>dep</artifactId>");
writer.println(" <version>0.1</version>");
writer.println("</project>");
} else if (request.getRequestURI().endsWith(".jar")) {
writer.println("empty");
} else if (request.getRequestURI().endsWith(".md5")
|| request.getRequestURI().endsWith(".sha1")) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
((Request) request).setHandled(true);
}
};
Server server = new Server(0);
server.setHandler(repoHandler);
try {
server.start();
if (server.isFailed()) {
fail("Couldn't bind the server socket to a free port!");
}
int port = ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
{
// phase 1: run build in online mode to fill local repo
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0768");
verifier.setLogFileName("log1.txt");
Properties props = new Properties();
props.put("@port@", Integer.toString(port));
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", props);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument(
"org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:compile");
verifier.execute();
verifier.verifyFilePresent("target/compile.txt");
verifier.verifyErrorFreeLog();
}
requestedUris.clear();
{
// phase 2: run build in offline mode to check it still passes, without network accesses
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-o");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.setLogFileName("log2.txt");
verifier.addCliArgument(
"org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:compile");
verifier.execute();
verifier.verifyFilePresent("target/compile.txt");
verifier.verifyErrorFreeLog();
}
assertTrue(requestedUris.toString(), requestedUris.isEmpty());
{
// phase 3: delete test artifact and run build in offline mode to check it fails now
// NOTE: Adding the settings again to offer Maven the bad choice of using the remote repo
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0768");
verifier.addCliArgument("-o");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.setLogFileName("log3.txt");
try {
verifier.addCliArgument(
"org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:compile");
verifier.execute();
verifier.verifyErrorFreeLog();
fail("Build did not fail to resolve missing dependency although Maven ought to work offline!");
} catch (VerificationException e) {
// expected, should fail
}
}
System.out.println("Bound server socket to the port " + port);
assertTrue(requestedUris.toString(), requestedUris.isEmpty());
} finally {
server.stop();
server.join();
}
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-773">MNG-773</a>.
*
* @author John Casey
*
*/
public class MavenITmng0773SettingsProfileReactorPollutionTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0773SettingsProfileReactorPollutionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that profiles from settings.xml do not pollute module lists across projects in a reactorized build.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG773() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0773");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,58 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-781">MNG-781</a>.
*
* @author John Casey
*
*/
public class MavenITmng0781PluginConfigVsExecConfigTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0781PluginConfigVsExecConfigTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that plugin-level configuration instances are not nullified by
* execution-level configuration instances.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0781() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0781");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("process-resources");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("target/exec-level.txt");
verifier.verifyFilePresent("target/resources-resources.txt");
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-786">MNG-786</a>.
*
* @author John Casey
*
*/
public class MavenITmng0786ProfileAwareReactorTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0786ProfileAwareReactorTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that direct invocation of a mojo from the command line still
* results in the processing of modules included via profiles.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0786() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0786");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("sub1/target");
verifier.deleteDirectory("sub2/target");
verifier.addCliArgument("-Dexpression.outputFile=target/expression.properties");
verifier.addCliArgument("-Dactivate=anything");
verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval");
verifier.execute();
verifier.verifyFilePresent("sub1/target/expression.properties");
verifier.verifyFilePresent("sub2/target/expression.properties");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-814">MNG-814</a>.
*
* @author John Casey
*
*/
public class MavenITmng0814ExplicitProfileActivationTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0814ExplicitProfileActivationTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test activation of a profile from the command line.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG814() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0814");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-P");
verifier.addCliArgument("test-profile");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties("target/profile.properties");
assertEquals("PASSED", props.getProperty("project.properties.testProp"));
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-818">MNG-818</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0818WarDepsNotTransitiveTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0818WarDepsNotTransitiveTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that depending on a WAR doesn't also get its dependencies transitively.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0818() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0818");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.it0080");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Collection<String> artifacts = verifier.loadLines("target/artifacts.txt", "UTF-8");
assertEquals(Collections.singletonList("org.apache.maven.its.it0080:war:war:0.1"), artifacts);
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Collection;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-820">MNG-820</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0820ConflictResolutionTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0820ConflictResolutionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that the collector selecting a particular version gets the correct subtree
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0820() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0820");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0820");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Collection<String> artifacts = verifier.loadLines("target/artifacts.txt", "UTF-8");
assertEquals(3, artifacts.size());
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0820:d:jar:2.0"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0820:c:jar:1.4"));
assertTrue(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0820:a:jar:1.0"));
assertFalse(artifacts.toString(), artifacts.contains("org.apache.maven.its.mng0505:b:jar:1.0"));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-823">MNG-823</a>.
*
* @author John Casey
*
*/
public class MavenITmng0823MojoContextPassingTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0823MojoContextPassingTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Tests context passing between mojos in the same plugin.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0823() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0823");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArguments(
"org.apache.maven.its.plugins:maven-it-plugin-context-passing:throw",
"org.apache.maven.its.plugins:maven-it-plugin-context-passing:catch");
verifier.execute();
verifier.verifyFilePresent("target/thrown-value");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,116 @@
/*
* 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.maven.it;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-828">MNG-828</a>.
*
* @author Slawomir Jaranowski
*/
public class MavenITmng0828PluginConfigValuesInDebugTest extends AbstractMavenIntegrationTestCase {
private static final String NL = System.lineSeparator();
public MavenITmng0828PluginConfigValuesInDebugTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that plain plugin configuration values are listed correctly in debug mode.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0828() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0828");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-X");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
String log = FileUtils.fileRead(new File(verifier.getBasedir(), verifier.getLogFileName()));
checkLog(log, "[DEBUG] (f) aliasDefaultExpressionParam = test");
checkLog(log, "[DEBUG] (f) basedir = " + testDir.getCanonicalPath());
checkLog(
log,
"[DEBUG] (f) beanParam = org.apache.maven.plugin.coreit.Bean[fieldParam=field, setterParam=setter, setterCalled=true]");
checkLog(log, "[DEBUG] (f) booleanParam = true");
checkLog(log, "[DEBUG] (f) byteParam = 42");
checkLog(log, "[DEBUG] (f) byteParam = 42");
checkLog(log, "[DEBUG] (f) characterParam = X");
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S a", Locale.US).parse("2008-11-09 11:59:03.0 AM");
checkLog(log, "[DEBUG] (f) dateParam = " + date);
checkLog(log, "[DEBUG] (f) defaultParam = maven-core-it");
checkLog(log, "[DEBUG] (f) defaultParamWithExpression = org.apache.maven.its.mng0828:test1:1.0-SNAPSHOT");
// new line of dumping dom is not guaranteed, but all items should be present
checkLog(log, "[DEBUG] (f) domParam = <domParam><echo>one</echo>");
checkLog(log, "<echo>two</echo>");
checkLog(log, "<echo>three</echo>");
checkLog(log, "<echo>four</echo>");
checkLog(log, "</domParam>");
checkLog(log, "[DEBUG] (f) doubleParam = -1.5");
checkLog(log, "[DEBUG] (f) fieldParam = field");
checkLog(log, "[DEBUG] (f) fileParam = " + new File(testDir, "pom.xml").getCanonicalPath());
checkLog(log, "[DEBUG] (f) floatParam = 0.0");
checkLog(log, "[DEBUG] (f) integerParam = 0");
checkLog(log, "[DEBUG] (f) listParam = [one, two, three, four]");
checkLog(log, "[DEBUG] (f) longParam = 9876543210");
// Map items order is not guaranteed, so only check begin of params ...
checkLog(log, "[DEBUG] (f) mapParam = {key");
checkLog(
log,
"[DEBUG] (f) propertiesFile = "
+ new File(testDir, "target/plugin-config.properties").getCanonicalPath());
// Properties item order is not guaranteed, so only check begin of params ...
checkLog(log, "[DEBUG] (f) propertiesParam = {key");
checkLog(log, "[DEBUG] (f) setParam = [item]");
checkLog(log, "[DEBUG] (f) shortParam = -12345");
checkLog(log, "[DEBUG] (f) stringParam = Hello World!");
checkLog(log, "[DEBUG] (f) stringParams = [one, two, three, four]");
checkLog(log, "[DEBUG] (f) urlParam = http://maven.apache.org/");
checkLog(log, "[DEBUG] (s) setterParam = setter");
}
private void checkLog(String log, String expected) {
assertTrue(
NL + ">>>" + NL + log + "<<<" + NL + NL + "does not contains: " + NL + expected + NL,
log.contains(expected));
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-836">MNG-836</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0836PluginParentResolutionTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0836PluginParentResolutionTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that parent POMs referenced by a plugin POM can be resolved from ordinary repos, i.e. non-plugin repos.
* As a motivation for this, imagine the plugin repository hosts only snapshots while the ordinary repository
* hosts releases and a snapshot plugin might easily use a released parent.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG836() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0836");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng836");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
// Maven 3.x aims to separate plugins and project dependencies (MNG-4191)
if (matchesVersionRange("(,3.0-alpha-1),(3.0-alpha-1,3.0-alpha-7)")) {
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
} else {
try {
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
fail("Plugin parent POM was erroneously resolved from non-plugin repository.");
} catch (VerificationException e) {
// expected
}
}
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-848">MNG-848</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0848UserPropertyOverridesDefaultValueTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0848UserPropertyOverridesDefaultValueTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that execution/system properties take precedence over default value of plugin parameters.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG848() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0848");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-Dconfig.aliasDefaultExpressionParam=PASSED");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties configProps = verifier.loadProperties("target/config.properties");
assertEquals("maven-core-it", configProps.getProperty("defaultParam"));
assertEquals("PASSED", configProps.getProperty("aliasDefaultExpressionParam"));
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-866">MNG-866</a> and
* <a href="https://issues.apache.org/jira/browse/MNG-160">MNG-160</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0866EvaluateDefaultValueTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0866EvaluateDefaultValueTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that expressions inside the default value of plugin parameters are evaluated.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG866() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0866");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties configProps = verifier.loadProperties("target/config.properties");
assertEquals("maven-core-it", configProps.getProperty("defaultParam"));
assertEquals(
"org.apache.maven.its.mng0866:test:1.0-SNAPSHOT",
configProps.getProperty("defaultParamWithExpression"));
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-870">MNG-870</a>.
*
* @author Benjamin Bentmann
*
*/
public class MavenITmng0870ReactorAwarePluginDiscoveryTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0870ReactorAwarePluginDiscoveryTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that the reactor can resolve plugins that have just been built by a previous module and are not yet
* installed to the local repo.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0870() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0870");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("project/target");
verifier.deleteArtifacts("org.apache.maven.its.mng0870");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyFilePresent("project/target/touch.txt");
}
}

View File

@ -0,0 +1,79 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.List;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-947">MNG-947</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng0947OptionalDependencyTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0947OptionalDependencyTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Verify that direct optional dependencies are included in the project class paths while transitive optional
* dependencies are excluded.
*
* @throws Exception in case of failure
*/
@Test
public void testit() throws Exception {
// failingMavenVersions("(,3.1.0-alpha-1)");
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0947");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0947");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
List<String> compile = verifier.loadLines("target/compile.txt", "UTF-8");
assertTrue(compile.toString(), compile.contains("org.apache.maven.its.mng0947:d:jar:0.1 (optional)"));
assertTrue(compile.toString(), compile.contains("org.apache.maven.its.mng0947:e:jar:0.1 (optional)"));
assertEquals(2, compile.size());
List<String> runtime = verifier.loadLines("target/runtime.txt", "UTF-8");
assertTrue(runtime.toString(), runtime.contains("org.apache.maven.its.mng0947:c:jar:0.1"));
assertTrue(runtime.toString(), runtime.contains("org.apache.maven.its.mng0947:d:jar:0.1 (optional)"));
assertTrue(runtime.toString(), runtime.contains("org.apache.maven.its.mng0947:e:jar:0.1 (optional)"));
assertEquals(3, runtime.size());
List<String> test = verifier.loadLines("target/test.txt", "UTF-8");
assertTrue(test.toString(), test.contains("org.apache.maven.its.mng0947:c:jar:0.1"));
assertTrue(test.toString(), test.contains("org.apache.maven.its.mng0947:d:jar:0.1 (optional)"));
assertTrue(test.toString(), test.contains("org.apache.maven.its.mng0947:e:jar:0.1 (optional)"));
assertEquals(3, test.size());
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-956">MNG-956</a>.
*
* @author Brett Porter
*
*/
public class MavenITmng0956ComponentInjectionViaProjectLevelPluginDepTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0956ComponentInjectionViaProjectLevelPluginDepTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test component injection from project-level plugin dependencies.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0956() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0956");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteArtifacts("org.apache.maven.its.mng0956");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("--settings");
verifier.addCliArgument("settings.xml");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Properties apiProps = verifier.loadProperties("target/component.properties");
assertEquals("true", apiProps.getProperty("org.apache.maven.plugin.coreit.DefaultTestComponent"));
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-985">MNG-985</a>.
*
* @author John Casey
*
*/
public class MavenITmng0985NonExecutedPluginMgmtGoalsTest extends AbstractMavenIntegrationTestCase {
public MavenITmng0985NonExecutedPluginMgmtGoalsTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that plugins in pluginManagement aren't included in the build
* unless they are referenced by groupId/artifactId within the plugins
* section of a pom.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG0985() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0985");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyFileNotPresent("target/unexpected.txt");
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,90 @@
/*
* 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.maven.it;
import java.io.File;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-1021">MNG-1021</a>.
*
* @author John Casey
*
*/
public class MavenITmng1021EqualAttachmentBuildNumberTest extends AbstractMavenIntegrationTestCase {
public MavenITmng1021EqualAttachmentBuildNumberTest() {
super(ALL_MAVEN_VERSIONS);
}
/**
* Test that source attachments have the same build number and timestamp as the main
* artifact when deployed.
*
* @throws Exception in case of failure
*/
@Test
public void testitMNG1021() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-1021");
Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("repo");
verifier.deleteArtifacts("org.apache.maven.its.mng1021");
verifier.addCliArgument("-Dmaven.consumer.pom=false");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyArtifactPresent("org.apache.maven.its.mng1021", "test", "1-SNAPSHOT", "pom");
verifier.verifyArtifactPresent("org.apache.maven.its.mng1021", "test", "1-SNAPSHOT", "jar");
String dir = "repo/org/apache/maven/its/mng1021/test/";
String snapshot = getSnapshotVersion(new File(testDir, dir + "1-SNAPSHOT"));
assertTrue(snapshot, snapshot.endsWith("-1"));
verifier.verifyFilePresent(dir + "maven-metadata.xml");
verifier.verifyFilePresent(dir + "maven-metadata.xml.md5");
verifier.verifyFilePresent(dir + "maven-metadata.xml.sha1");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/maven-metadata.xml");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/maven-metadata.xml.md5");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/maven-metadata.xml.sha1");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".pom");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".pom.md5");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".pom.sha1");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".jar");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".jar.md5");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + ".jar.sha1");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar.md5");
verifier.verifyFilePresent(dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar.sha1");
}
private String getSnapshotVersion(File artifactDir) {
File[] files = artifactDir.listFiles();
for (File file : files) {
String name = file.getName();
if (name.endsWith(".pom")) {
return name.substring("test-".length(), name.length() - ".pom".length());
}
}
throw new IllegalStateException("POM not found in " + artifactDir);
}
}

Some files were not shown because too many files have changed in this diff Show More