maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r1413023 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/mng-5382/ resources/mng-5382/src/ resources/mng-5382/src/main/ resources/mng-5382/src/main/java/ resources/mng-5382/src/main/jav...
Date Fri, 23 Nov 2012 18:40:10 GMT
Author: jvanzyl
Date: Fri Nov 23 18:40:08 2012
New Revision: 1413023

URL: http://svn.apache.org/viewvc?rev=1413023&view=rev
Log:
MNG-5382: Add an IT for @Inject used in plugins

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5382Jsr330Plugin.java
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/pom.xml
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Component.java
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Mojo.java
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=1413023&r1=1413022&r2=1413023&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
(original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
Fri Nov 23 18:40:08 2012
@@ -104,8 +104,8 @@ public class IntegrationTestSuite
         // -------------------------------------------------------------------------------------------------------------
         // Tests that don't run stable and need to be fixed
         // -------------------------------------------------------------------------------------------------------------
-        // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
-
+        // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137       

+        suite.addTestSuite( MavenITmng5382Jsr330Plugin.class );
         suite.addTestSuite( MavenITmng5338FileOptionToDirectory.class );
         suite.addTestSuite( MavenITmng5280SettingsProfilesRepositoriesOrderTest.class );
         suite.addTestSuite( MavenITmng5224InjectedSettings.class );

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5382Jsr330Plugin.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5382Jsr330Plugin.java?rev=1413023&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5382Jsr330Plugin.java
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5382Jsr330Plugin.java
Fri Nov 23 18:40:08 2012
@@ -0,0 +1,84 @@
+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;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5338">MNG-5338</a>.
+ *
+ * @author Olivier Lamy
+ */
+public class MavenITmng5382Jsr330Plugin
+    extends AbstractMavenIntegrationTestCase
+{
+
+    private File testDir;
+
+    public MavenITmng5382Jsr330Plugin()
+    {
+        super( "[3.1,)" );
+    }
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5382" );
+
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+        super.tearDown();
+    }
+
+    public void testJsr330PluginExecution()
+        throws Exception
+    {
+        //
+        // Build a plugin that uses a JSR330 plugin
+        //    
+        Verifier v0 = newVerifier( testDir.getAbsolutePath() );
+        v0.setAutoclean( false );
+        v0.deleteDirectory( "target" );
+        v0.deleteArtifacts( "org.apache.maven.its.mng5382" );
+        v0.executeGoal( "install" );
+        v0.verifyErrorFreeLog();
+        v0.resetStreams();
+        
+        //
+        // Execute the JSR330 plugin
+        //
+        Verifier v1 = newVerifier( testDir.getAbsolutePath() );
+        v1.setAutoclean( false );
+        v1.executeGoal( "org.apache.maven.its.mng5382:jsr330-maven-plugin:0.0.1-SNAPSHOT:hello"
);
+        v1.verifyErrorFreeLog();
+        v1.resetStreams();
+        v1.verifyTextInLog( "Hello! I am a component that is being used via constructor injection!
That's right, I'm a JSR330 badass." );
+
+    }
+
+}

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/pom.xml?rev=1413023&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/pom.xml
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/pom.xml
Fri Nov 23 18:40:08 2012
@@ -0,0 +1,83 @@
+<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.mng5382</groupId>
+  <artifactId>jsr330-maven-plugin</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>jsr330-maven-plugin Maven Plugin</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <mavenVersion>3.0.4</mavenVersion>
+    <mavenPluginPluginVersion>3.1</mavenPluginPluginVersion>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>${mavenVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>${mavenPluginPluginVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>${mavenPluginPluginVersion}</version>
+        <configuration>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+        <executions>
+          <execution>
+            <id>mojo-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>help-goal</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.sonatype.plugins</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <id>generate-index</id>
+            <goals>
+              <goal>main-index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Component.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Component.java?rev=1413023&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Component.java
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Component.java
Fri Nov 23 18:40:08 2012
@@ -0,0 +1,17 @@
+package org.apache.maven.plugins;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+@Named
+@Singleton
+public class Jsr330Component {
+
+  public void hello() {
+    System.out.println();
+    System.out.println();
+    System.out.println("Hello! I am a component that is being used via constructor injection!
That's right, I'm a JSR330 badass.");
+    System.out.println();
+    System.out.println();
+  }
+}

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Mojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Mojo.java?rev=1413023&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Mojo.java
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/src/main/java/org/apache/maven/plugins/Jsr330Mojo.java
Fri Nov 23 18:40:08 2012
@@ -0,0 +1,26 @@
+package org.apache.maven.plugins;
+
+import javax.inject.Inject;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+@Mojo(name = "hello", defaultPhase = LifecyclePhase.VALIDATE, requiresProject = false)
+public class Jsr330Mojo extends AbstractMojo {
+
+  private Jsr330Component component;
+  
+  @Inject
+  public Jsr330Mojo(Jsr330Component component) {
+    this.component = component;    
+  }
+  
+  public void execute() throws MojoExecutionException {    
+    //
+    // Say hello to the world, my little constructor injected component!
+    //
+    component.hello();
+  }
+}



Mime
View raw message