You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/09/12 01:37:05 UTC
svn commit: r814084 - in /maven/core-integration-testing/trunk:
core-it-suite/src/test/java/org/apache/maven/it/
core-it-suite/src/test/resources/mng-4356/
core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven...
Author: bentmann
Date: Fri Sep 11 23:37:04 2009
New Revision: 814084
URL: http://svn.apache.org/viewvc?rev=814084&view=rev
Log:
[MNG-4356] [regression] Active component maps with stateful per-lookup components broken
o Added IT
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml (with props)
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java Fri Sep 11 23:37:04 2009
@@ -0,0 +1,63 @@
+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.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4356">MNG-4356</a>.
+ *
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest()
+ {
+ super( ALL_MAVEN_VERSIONS );
+ }
+
+ /**
+ * Test that read operations on active collections of components do not cause a re-lookup of the components from
+ * the container which would prevent usage of stateful components that are usually instantiated per lookup.
+ */
+ public void testit()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4356" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ Properties props = verifier.loadProperties( "target/component.properties" );
+ assertEquals( "2", props.getProperty( "count" ) );
+ // the proper behavior of the collections is actually checked by the IT plugin, we merely check it was run
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4356NoNeedlessRelookupFromActiveCollectionTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml Fri Sep 11 23:37:04 2009
@@ -0,0 +1,57 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng4356</groupId>
+ <artifactId>test</artifactId>
+ <version>0.1</version>
+ <packaging>jar</packaging>
+
+ <name>Maven Integration Test :: MNG-4356</name>
+ <description>
+ Test that read operations on active collections of components do not cause a re-lookup of the components from
+ the container which would prevent usage of stateful components that are usually instantiated per lookup.
+ </description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-active-collection</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <outputFile>target/component.properties</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4356/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java Fri Sep 11 23:37:04 2009
@@ -0,0 +1,164 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Checks the general retrieval of components from active component collections.
+ *
+ * @goal check
+ * @phase validate
+ *
+ * @author Benjamin Bentmann
+ */
+public class CheckMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Project base directory used for manual path alignment.
+ *
+ * @parameter default-value="${basedir}"
+ * @readonly
+ */
+ private File basedir;
+
+ /**
+ * The available components, as a map.
+ *
+ * @component role="org.apache.maven.plugin.coreit.Component"
+ */
+ private Map componentMap;
+
+ /**
+ * The available components, as a list.
+ *
+ * @component role="org.apache.maven.plugin.coreit.Component"
+ */
+ private List componentList;
+
+ /**
+ * The path to the properties file to create.
+ *
+ * @parameter expression="${collections.outputFile}"
+ */
+ private File outputFile;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoFailureException If the output file could not be created.
+ */
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ Properties componentProperties = new Properties();
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Dumping component info" );
+
+ componentProperties.setProperty( "count", Integer.toString( componentList.size() ) );
+
+ if ( componentList.size() != componentMap.size() )
+ {
+ throw new MojoExecutionException( "Inconsistent collection: " + componentList + " vs " + componentMap );
+ }
+
+ for ( int i = componentList.size() - 1; i >= 0; i-- )
+ {
+ Object component = componentList.get( i );
+
+ if ( component != componentList.get( i ) )
+ {
+ throw new MojoExecutionException( "Invalid re-lookup of component from list: " + i );
+ }
+ }
+
+ int i = 0;
+ for ( Iterator it = componentMap.keySet().iterator(); it.hasNext(); i++ )
+ {
+ String roleHint = (String) it.next();
+ componentProperties.setProperty( "component." + i + ".hint", roleHint );
+
+ Object component = componentMap.get( roleHint );
+
+ if ( component != null )
+ {
+ String hash = Integer.toString( System.identityHashCode( component ) );
+ componentProperties.setProperty( "component." + i + ".hash", hash );
+ componentProperties.setProperty( "component." + roleHint + ".hash", hash );
+ }
+
+ if ( component != componentMap.get( roleHint ) )
+ {
+ throw new MojoExecutionException( "Invalid re-lookup of component from map: " + roleHint );
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] " + roleHint + " = " + component );
+ }
+
+ if ( !outputFile.isAbsolute() )
+ {
+ outputFile = new File( basedir, outputFile.getPath() );
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + outputFile );
+
+ OutputStream out = null;
+ try
+ {
+ outputFile.getParentFile().mkdirs();
+ out = new FileOutputStream( outputFile );
+ componentProperties.store( out, "MAVEN-CORE-IT-LOG" );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ // just ignore
+ }
+ }
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + outputFile );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java Fri Sep 11 23:37:04 2009
@@ -0,0 +1,30 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+/**
+ * A simple interface for our test components.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface Component
+{
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/Component.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java Fri Sep 11 23:37:04 2009
@@ -0,0 +1,31 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+/**
+ * A simple test component.
+ *
+ * @author Benjamin Bentmann
+ */
+public class DefaultComponent
+ implements Component
+{
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DefaultComponent.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml?rev=814084&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml Fri Sep 11 23:37:04 2009
@@ -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.
+-->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.plugin.coreit.Component</role>
+ <role-hint>stateless</role-hint>
+ <implementation>org.apache.maven.plugin.coreit.DefaultComponent</implementation>
+ <instantiation-strategy>singleton</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.plugin.coreit.Component</role>
+ <role-hint>stateful</role-hint>
+ <implementation>org.apache.maven.plugin.coreit.DefaultComponent</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ </components>
+</component-set>
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision