You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/12/26 14:48:15 UTC

[maven-integration-testing] 01/01: [MNG-6071] GetResource should return not null for custom pom

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-6071
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git

commit d2c36a6a42e7e21265458e277805046aad6366f8
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat May 25 23:14:41 2019 +0200

    [MNG-6071] GetResource should return not null for custom pom
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |  1 +
 .../it/MavenITmng6071GetResourceWithCustomPom.java | 37 ++++++++++++++++++++
 core-it-suite/src/test/resources/mng-6071/pom.xml  | 28 +++++++++++++++
 .../src/test/java/com/mycompany/app/AppTest.java   | 40 ++++++++++++++++++++++
 4 files changed, 106 insertions(+)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 6d61985..882c025 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -107,6 +107,7 @@ public class IntegrationTestSuite
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng6071GetResourceWithCustomPom.class );
         suite.addTestSuite( MavenITmng6759TransitiveDependencyRepositoriesTest.class );
         suite.addTestSuite( MavenITmng6720FailFastTest.class );
         suite.addTestSuite( MavenITmng6506PackageAnnotationTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6071GetResourceWithCustomPom.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6071GetResourceWithCustomPom.java
new file mode 100644
index 0000000..f6c5b3e
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6071GetResourceWithCustomPom.java
@@ -0,0 +1,37 @@
+package org.apache.maven.it;
+
+import org.apache.maven.it.util.ResourceExtractor;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6071">MNG-6071</a>:
+ * check that getClass().getResource("/") returns consistent results when Maven is run with <code>-f ./pom.xml</code>.
+ */
+public class MavenITmng6071GetResourceWithCustomPom
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng6071GetResourceWithCustomPom()
+    {
+        super( "[3.6.2-SNAPSHOT,)" );
+    }
+
+    /**
+     * check when path to POM set by <code>-f ./pom.xml</code>
+     */
+    @Test
+    public void testRunCustomPomWithDot( )
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6071" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.getCliOptions().add( "-f ./pom.xml" );
+        verifier.setForkJvm( true );
+        verifier.executeGoal( "verify" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-6071/pom.xml b/core-it-suite/src/test/resources/mng-6071/pom.xml
new file mode 100644
index 0000000..adc780b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6071/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>mng-6071</groupId>
+  <artifactId>mng-6071</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>my-app</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6071/src/test/java/com/mycompany/app/AppTest.java b/core-it-suite/src/test/resources/mng-6071/src/test/java/com/mycompany/app/AppTest.java
new file mode 100644
index 0000000..8e62a78
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6071/src/test/java/com/mycompany/app/AppTest.java
@@ -0,0 +1,40 @@
+package com.mycompany.app;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+{
+    @Test
+    public void shouldAnswerWithTrue()
+    {
+        URL resource = getClass().getResource( "/" );
+        System.out.println( resource );
+        assertNotNull( resource );
+    }
+}