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 2019/01/04 22:16:43 UTC

[GitHub] eolivelli commented on a change in pull request #134: [MNG-6294] Convert MavenPluginValidator into a plexus component

eolivelli commented on a change in pull request #134: [MNG-6294] Convert MavenPluginValidator into a plexus component
URL: https://github.com/apache/maven/pull/134#discussion_r245435453
 
 

 ##########
 File path: maven-core/src/test/java/org/apache/maven/plugin/MavenPluginValidatorTest.java
 ##########
 @@ -0,0 +1,70 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * @author Michael Simacek
+ */
+public class MavenPluginValidatorTest
+        extends PlexusTestCase
+{
+    private MavenPluginValidator mavenPluginValidator;
+
+    @Override
+    protected void setUp()
+            throws Exception
+    {
+        super.setUp();
+        mavenPluginValidator = (MavenPluginValidator) lookup( MavenPluginValidator.class );
+    }
+
+    public void testValidate()
+    {
+        Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
+                "jar", null, new DefaultArtifactHandler() );
+        PluginDescriptor descriptor = new PluginDescriptor();
+        descriptor.setGroupId( "org.apache.maven.its.plugins" );
+        descriptor.setArtifactId( "maven-it-plugin" );
+        descriptor.setVersion( "0.1" );
+        List<String> errors = new ArrayList<>();
+        mavenPluginValidator.validate( plugin, descriptor, errors );
+        assertTrue( errors.isEmpty() );
+    }
+
+    public void testInvalid()
+    {
+        Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
+                "jar", null, new DefaultArtifactHandler() );
+        PluginDescriptor descriptor = new PluginDescriptor();
+        descriptor.setGroupId( "org.apache.maven.its.plugins" );
+        descriptor.setArtifactId( "maven-it-plugin" );
+        List<String> errors = new ArrayList<>();
+        mavenPluginValidator.validate( plugin, descriptor, errors );
+        assertFalse( errors.isEmpty() );
 
 Review comment:
   nit: we should test more the "errors" result, it is not clear that we are catching the error we are generating with the lines above.
   We have three validations which can fire an error, we should test every of them.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services