You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/18 08:15:50 UTC

[GitHub] [maven-integration-testing] MartinKanters commented on a diff in pull request #205: [MNG-7568] Test for deactivating profile defined in settings and project

MartinKanters commented on code in PR #205:
URL: https://github.com/apache/maven-integration-testing/pull/205#discussion_r997871852


##########
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7568SettingsProfileDeactivationTest.java:
##########
@@ -0,0 +1,65 @@
+package org.apache.maven.it;
+
+/*
+ * 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.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+
+public class MavenITmng7568SettingsProfileDeactivationTest
+        extends AbstractMavenIntegrationTestCase
+{
+    private static final String PROJECT_PATH = "/mng-7568-inactive-profile-deactivation";
+
+    public MavenITmng7568SettingsProfileDeactivationTest()
+    {
+        super( "[3.0.4,4)" );
+    }
+
+    /**
+     * This test verifies that deactivating a profile defined in settings and in project
+     * does not cause unnecessary warning.
+     *
+     * @throws Exception in case of failure
+     */
+    public void testDeactivatingProfileExistingInSettingsAndInProject() throws Exception
+    {
+        final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+        final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+        verifier.addCliOption( "-s" );
+        verifier.addCliOption( "settings.xml" );
+        verifier.addCliOption( "-P" );
+        verifier.addCliOption( "-k-profile" );
+        verifier.setLogFileName( "test-mng7568.txt" );
+
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+
+        try
+        {
+            verifier.verifyTextInLog( "[WARNING] The requested profile \"k-profile\" could not be activated because it does not exist." );

Review Comment:
   Instead of this try-catch control-flow, you could also use/copy [the following method](https://github.com/apache/maven-integration-testing/blob/6d36ca06c00ae18c3acc43ec6d12d38a41e2e488/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6981ProjectListShouldIncludeChildrenTest.java#L82) to verify that the log line does not appear in the logs. 



##########
core-it-suite/src/test/resources/mng-7568-inactive-profile-deactivation/pom.xml:
##########
@@ -0,0 +1,37 @@
+<?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>
+
+    <groupId>org.apache.maven.its.mng7568</groupId>
+    <artifactId>profile-selection</artifactId>
+    <version>1.0</version>
+
+    <profiles>
+        <profile>
+            <id>k-profile</id>
+        </profile>
+    </profiles>
+
+</project>

Review Comment:
   Although it's not consistent over the whole project unfortunately, we prefer 2 spaces for xml files. Please adjust it here and in the settings.xml



##########
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7568SettingsProfileDeactivationTest.java:
##########
@@ -0,0 +1,65 @@
+package org.apache.maven.it;
+
+/*
+ * 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.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+
+public class MavenITmng7568SettingsProfileDeactivationTest
+        extends AbstractMavenIntegrationTestCase
+{
+    private static final String PROJECT_PATH = "/mng-7568-inactive-profile-deactivation";
+
+    public MavenITmng7568SettingsProfileDeactivationTest()
+    {
+        super( "[3.0.4,4)" );

Review Comment:
   I think we should be able to keep this test working for Maven 4, right? I don't think we covered this flow in any other ITs yet, so it's valuable to keep :) 



##########
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7568SettingsProfileDeactivationTest.java:
##########
@@ -0,0 +1,65 @@
+package org.apache.maven.it;
+
+/*
+ * 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.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+
+public class MavenITmng7568SettingsProfileDeactivationTest

Review Comment:
   Can you please add this file at the top of the IntegrationTestSuite class? (org.apache.maven.it.IntegrationTestSuite)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org