You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/01/06 21:15:09 UTC
maven-integration-testing git commit: [MNG-6298] 3.5.2:
ClassNotFoundException: javax.annotation.security.RolesAllowed [Forced
Update!]
Repository: maven-integration-testing
Updated Branches:
refs/heads/MNG-6298 55db62ff5 -> 1e9932917 (forced update)
[MNG-6298] 3.5.2: ClassNotFoundException: javax.annotation.security.RolesAllowed
Added IT for MNG-6298
Signed-off-by: Karl Heinz Marbaise <kh...@apache.org>
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/1e993291
Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/1e993291
Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/1e993291
Branch: refs/heads/MNG-6298
Commit: 1e99329172cab30c55acaf89d08058c693ed3037
Parents: 1797b9e
Author: Bengt Söderberg <be...@purplescout.se>
Authored: Mon Dec 4 19:49:17 2017 +0100
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Sat Jan 6 22:15:01 2018 +0100
----------------------------------------------------------------------
.../apache/maven/it/IntegrationTestSuite.java | 1 +
.../MavenITmng6298RolesAllowedNotFoundTest.java | 83 ++++++++++++++++++++
.../mng-6298-rolesallowed-not-found/pom.xml | 82 +++++++++++++++++++
.../apache/maven/plugins/Jsr250Component.java | 60 ++++++++++++++
.../org/apache/maven/plugins/Jsr250Mojo.java | 52 ++++++++++++
5 files changed, 278 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/1e993291/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
----------------------------------------------------------------------
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 c8bced7..a9b344e 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( MavenITmng6330RelativePath.class );
+ suite.addTestSuite( MavenITmng6298RolesAllowedNotFoundTest.class );
suite.addTestSuite( MavenITmng6240PluginExtensionAetherProvider.class );
suite.addTestSuite( MavenITmng6223FindBasedir.class );
suite.addTestSuite( MavenITmng6189SiteReportPluginsWarningTest.class );
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/1e993291/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6298RolesAllowedNotFoundTest.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6298RolesAllowedNotFoundTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6298RolesAllowedNotFoundTest.java
new file mode 100644
index 0000000..610d949
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6298RolesAllowedNotFoundTest.java
@@ -0,0 +1,83 @@
+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 java.io.File;
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6298">MNG-6298</a>.
+ * Most of code reused from mng-6084. Bugfix came after release, old test case still valid for its release.
+ */
+public class MavenITmng6298RolesAllowedNotFoundTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ private File testDir;
+
+ public MavenITmng6298RolesAllowedNotFoundTest()
+ {
+ super( "[3.5.3,)" );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6298-rolesallowed-not-found" );
+
+ }
+
+ protected void tearDown()
+ throws Exception
+ {
+
+ super.tearDown();
+ }
+
+ public void testRolesAllowedShouldNotResultInClassCastException()
+ throws Exception
+ {
+ //
+ // Build a plugin that uses JSR 250 annotations
+ //
+ Verifier v0 = newVerifier( testDir.getAbsolutePath(), "remote" );
+ v0.setAutoclean( false );
+ v0.deleteDirectory( "target" );
+ v0.deleteArtifacts( "org.apache.maven.its.mng6298" );
+ v0.executeGoal( "install" );
+ v0.verifyErrorFreeLog();
+ v0.resetStreams();
+
+ //
+ // Execute the JSR 250 plugin
+ //
+ Verifier v1 = newVerifier( testDir.getAbsolutePath(), "remote" );
+ v1.setAutoclean( false );
+ v1.executeGoal( "org.apache.maven.its.mng6298:jsr250-maven-plugin:0.0.1-SNAPSHOT:hello" );
+ v1.verifyErrorFreeLog();
+ v1.resetStreams();
+ v1.verifyTextInLog( "Hello! I am a component using JSR 250 with @PostConstruct support" );
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/1e993291/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/pom.xml b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/pom.xml
new file mode 100644
index 0000000..e092ee4
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/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.mng6298</groupId>
+ <artifactId>jsr250-maven-plugin</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>JSR 250 Maven Plugin</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <mavenVersion>3.5.0</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/1e993291/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Component.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Component.java b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Component.java
new file mode 100644
index 0000000..526e05c
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/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 JSR 250 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 JSR 330 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 JSR 250 with @PreDestroy support" );
+ System.out.println();
+ System.out.println();
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/1e993291/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
new file mode 100644
index 0000000..8cea40d
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6298-rolesallowed-not-found/src/main/java/org/apache/maven/plugins/Jsr250Mojo.java
@@ -0,0 +1,52 @@
+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 javax.annotation.security.RolesAllowed;
+
+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
+ {
+ if (!(this instanceof RolesAllowed)) {
+ // triggers ClassNotFoundException if plugins lack access to javax.annotation.security
+ } else {
+ component.hello();
+ }
+ }
+}