Repository: maven-integration-testing
Updated Branches:
  refs/heads/master 0bd5bdc2e -> ebb8ac933


[MNG-6084] Add test for JSR250 support


Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/88276890
Tree: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/88276890
Diff: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/88276890

Branch: refs/heads/master
Commit: 88276890fbbebd8b2571c453d625c03e62e03dbb
Parents: 3ffb289
Author: dantran <dant...@apache.org>
Authored: Sun Sep 11 23:24:24 2016 -0700
Committer: Dan Tran <dant...@gmail.com>
Committed: Mon Nov 21 16:42:28 2016 -0800

----------------------------------------------------------------------
 .../it/MavenITmng6084Jsr250PluginTest.java      | 84 ++++++++++++++++++++
 .../src/test/resources/mng-6084/pom.xml         | 82 +++++++++++++++++++
 .../apache/maven/plugins/Jsr250Component.java   | 60 ++++++++++++++
 .../org/apache/maven/plugins/Jsr250Mojo.java    | 50 ++++++++++++
 4 files changed, 276 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88276890/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java
 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java
new file mode 100644
index 0000000..cea0aee
--- /dev/null
+++ 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java
@@ -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="https://issues.apache.org/jira/browse/MNG-6084";>MNG-6084</a>.
+ *
+ * @author Dan Tran
+ */
+public class MavenITmng6084Jsr250PluginTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    private File testDir;
+
+    public MavenITmng6084Jsr250PluginTest()
+    {
+        super( "[3.4.0-SNAPSHOT,)" );
+    }
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-6084" );
+
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+        super.tearDown();
+    }
+
+    public void testJsr330PluginExecution()
+        throws Exception
+    {
+        //
+        // Build a plugin that uses a JSR250 plugin
+        //
+        Verifier v0 = newVerifier( testDir.getAbsolutePath(), "remote" );
+        v0.setAutoclean( false );
+        v0.deleteDirectory( "target" );
+        v0.deleteArtifacts( "org.apache.maven.its.mng6084" );
+        v0.executeGoal( "install" );
+        v0.verifyErrorFreeLog();
+        v0.resetStreams();
+
+        //
+        // Execute the JSR250 plugin
+        //
+        Verifier v1 = newVerifier( testDir.getAbsolutePath(), "remote" );
+        v1.setAutoclean( false );
+        v1.executeGoal( 
"org.apache.maven.its.mng6084:jsr250-maven-plugin:0.0.1-SNAPSHOT:hello" );
+        v1.verifyErrorFreeLog();
+        v1.resetStreams();
+        v1.verifyTextInLog( "Hello! I am a component using JSR250 with 
@PostConstruct support" );
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88276890/core-it-suite/src/test/resources/mng-6084/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6084/pom.xml 
b/core-it-suite/src/test/resources/mng-6084/pom.xml
new file mode 100644
index 0000000..59f74a6
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6084/pom.xml
@@ -0,0 +1,82 @@
+<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.mng6084</groupId>
+  <artifactId>jsr250-maven-plugin</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>jsr250-maven-plugin Maven Plugin</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <mavenVersion>3.4.0-SNAPSHOT</mavenVersion>
+    <mavenPluginPluginVersion>3.2</mavenPluginPluginVersion>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>
+      <version>1.0</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>
+  </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>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88276890/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Component.java
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Component.java
 
b/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Component.java
new file mode 100644
index 0000000..a369f8f
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Component.java
@@ -0,0 +1,60 @@
+package org.apache.maven.plugins;
+
+/*
+ * 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 javax.inject.Named;
+import javax.inject.Singleton;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@Named
+@Singleton
+public class Jsr250Component
+{
+
+    @PostConstruct
+    public void init()
+    {
+        System.out.println();
+        System.out.println();
+        System.out.println( "Hello! I am a component using JSR250 with 
@PostConstruct support" );
+        System.out.println();
+        System.out.println();
+    }
+
+    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();
+    }
+
+    @PreDestroy
+    public void cleanup()
+    {
+        System.out.println();
+        System.out.println();
+        System.out.println( "Hello! I am a component using JSR250 with 
@PreDestroy support" );
+        System.out.println();
+        System.out.println();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88276890/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
 
b/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
new file mode 100644
index 0000000..4fbdaa2
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-6084/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
@@ -0,0 +1,50 @@
+package org.apache.maven.plugins;
+
+/*
+ * 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 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 Jsr250Mojo
+    extends AbstractMojo
+{
+
+    private Jsr250Component component;
+
+    @Inject
+    public Jsr250Mojo( Jsr250Component component )
+    {
+        this.component = component;
+    }
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        //
+        // Say hello to the world, my little constructor injected component!
+        //
+        component.hello();
+    }
+}

Reply via email to