You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Marvin Froeder (JIRA)" <ji...@codehaus.org> on 2012/07/02 19:18:21 UTC
[jira] (SUREFIRE-880) ObjectFactory no longer works with TestNG
6.5.2
Marvin Froeder created SUREFIRE-880:
---------------------------------------
Summary: ObjectFactory no longer works with TestNG 6.5.2
Key: SUREFIRE-880
URL: https://jira.codehaus.org/browse/SUREFIRE-880
Project: Maven Surefire
Issue Type: Bug
Components: TestNG support
Affects Versions: 2.12
Reporter: Marvin Froeder
Hello,
While running test with TestNG + powermock I found the following exception:
{noformat}
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
at org.testng.TestNG.configure(TestNG.java:1564)
at org.apache.maven.surefire.testng.conf.TestNGMapConfigurator.configure(TestNGMapConfigurator.java:95)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:115)
... 9 more
{noformat}
The following patch corrects the problem:
{noformat}
Index: pom.xml
===================================================================
--- pom.xml (revision 1354455)
+++ pom.xml (working copy)
@@ -49,6 +49,10 @@
<role>Java Developer</role>
</roles>
</contributor>
+ <contributor>
+ <name>Marvin Froeder</name>
+ <email>marvin@marvinformatics.com</email>
+ </contributor>
</contributors>
<mailingLists>
Property changes on: surefire-grouper
___________________________________________________________________
Added: svn:ignore
+ .classpath
.project
.settings
target
Index: surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java
===================================================================
--- surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java (revision 0)
+++ surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java (revision 0)
@@ -0,0 +1,54 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * TestNG 6.5.2 configurator. Changed objectFactory type to String
+ *
+ * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
+ */
+public class TestNG652Configurator
+ extends TestNGMapConfigurator
+{
+
+ Map getConvertedOptions( Map options )
+ throws TestSetFailedException
+ {
+ Map convertedOptions = super.getConvertedOptions( options );
+ for ( Iterator iterator = convertedOptions.entrySet().iterator(); iterator.hasNext(); )
+ {
+ Entry entry = (Entry) iterator.next();
+ String key = (String) entry.getKey();
+ if ( "-objectfactory".equals( key ) )
+ {
+ Class value = (Class) entry.getValue();
+ convertedOptions.put( key, value.getName() );
+ break;
+ }
+ }
+ return convertedOptions;
+ }
+}
\ No newline at end of file
Index: surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
===================================================================
--- surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (revision 1354455)
+++ surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (working copy)
@@ -33,6 +33,7 @@
import org.apache.maven.surefire.testng.conf.Configurator;
import org.apache.maven.surefire.testng.conf.TestNG4751Configurator;
import org.apache.maven.surefire.testng.conf.TestNG52Configurator;
+import org.apache.maven.surefire.testng.conf.TestNG652Configurator;
import org.apache.maven.surefire.testng.conf.TestNGMapConfigurator;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.NestedRuntimeException;
@@ -192,11 +193,16 @@
{
return new TestNG52Configurator();
}
- range = VersionRange.createFromVersionSpec( "[5.3,)" );
+ range = VersionRange.createFromVersionSpec( "[5.3,6.4]" );
if ( range.containsVersion( version ) )
{
return new TestNGMapConfigurator();
}
+ range = VersionRange.createFromVersionSpec( "[6.5,)" );
+ if ( range.containsVersion( version ) )
+ {
+ return new TestNG652Configurator();
+ }
throw new TestSetFailedException( "Unknown TestNG version " + version );
}
Index: surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java
===================================================================
--- surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java (revision 0)
+++ surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java (revision 0)
@@ -0,0 +1,44 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * 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 junit.framework.TestCase;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
+ */
+public class TestNG652ConfiguratorTest
+ extends TestCase
+{
+
+ public void testGetConvertedOptions()
+ throws Exception
+ {
+ TestNGMapConfigurator testNGMapConfigurator = new TestNG652Configurator();
+ Map raw = new HashMap();
+ raw.put( "objectfactory", "java.lang.String" );
+ Map convertedOptions = testNGMapConfigurator.getConvertedOptions( raw );
+ String objectfactory = (String) convertedOptions.get( "-objectfactory" );
+ assertNotNull( objectfactory );
+ }
+}
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] (SUREFIRE-880) ObjectFactory no longer works with TestNG
6.5.2
Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
[ https://jira.codehaus.org/browse/SUREFIRE-880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Olivier Lamy closed SUREFIRE-880.
---------------------------------
Resolution: Fixed
Fix Version/s: 2.13
Assignee: Olivier Lamy
applied.
Thanks!
> ObjectFactory no longer works with TestNG 6.5.2
> -----------------------------------------------
>
> Key: SUREFIRE-880
> URL: https://jira.codehaus.org/browse/SUREFIRE-880
> Project: Maven Surefire
> Issue Type: Bug
> Components: TestNG support
> Affects Versions: 2.12
> Reporter: Marvin Froeder
> Assignee: Olivier Lamy
> Fix For: 2.13
>
>
> Hello,
> While running test with TestNG + powermock I found the following exception:
> {noformat}
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
> at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
> at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
> at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
> at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
> Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
> at org.testng.TestNG.configure(TestNG.java:1564)
> at org.apache.maven.surefire.testng.conf.TestNGMapConfigurator.configure(TestNGMapConfigurator.java:95)
> at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
> at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
> at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:115)
> ... 9 more
> {noformat}
> The following patch corrects the problem:
> {noformat}
> Index: pom.xml
> ===================================================================
> --- pom.xml (revision 1354455)
> +++ pom.xml (working copy)
> @@ -49,6 +49,10 @@
> <role>Java Developer</role>
> </roles>
> </contributor>
> + <contributor>
> + <name>Marvin Froeder</name>
> + <email>marvin@marvinformatics.com</email>
> + </contributor>
> </contributors>
>
> <mailingLists>
> Property changes on: surefire-grouper
> ___________________________________________________________________
> Added: svn:ignore
> + .classpath
> .project
> .settings
> target
> Index: surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java
> ===================================================================
> --- surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java (revision 0)
> +++ surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java (revision 0)
> @@ -0,0 +1,54 @@
> +package org.apache.maven.surefire.testng.conf;
> +
> +/*
> + * 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.Iterator;
> +import java.util.Map;
> +import java.util.Map.Entry;
> +
> +import org.apache.maven.surefire.testset.TestSetFailedException;
> +
> +/**
> + * TestNG 6.5.2 configurator. Changed objectFactory type to String
> + *
> + * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
> + */
> +public class TestNG652Configurator
> + extends TestNGMapConfigurator
> +{
> +
> + Map getConvertedOptions( Map options )
> + throws TestSetFailedException
> + {
> + Map convertedOptions = super.getConvertedOptions( options );
> + for ( Iterator iterator = convertedOptions.entrySet().iterator(); iterator.hasNext(); )
> + {
> + Entry entry = (Entry) iterator.next();
> + String key = (String) entry.getKey();
> + if ( "-objectfactory".equals( key ) )
> + {
> + Class value = (Class) entry.getValue();
> + convertedOptions.put( key, value.getName() );
> + break;
> + }
> + }
> + return convertedOptions;
> + }
> +}
> \ No newline at end of file
> Index: surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
> ===================================================================
> --- surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (revision 1354455)
> +++ surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (working copy)
> @@ -33,6 +33,7 @@
> import org.apache.maven.surefire.testng.conf.Configurator;
> import org.apache.maven.surefire.testng.conf.TestNG4751Configurator;
> import org.apache.maven.surefire.testng.conf.TestNG52Configurator;
> +import org.apache.maven.surefire.testng.conf.TestNG652Configurator;
> import org.apache.maven.surefire.testng.conf.TestNGMapConfigurator;
> import org.apache.maven.surefire.testset.TestSetFailedException;
> import org.apache.maven.surefire.util.NestedRuntimeException;
> @@ -192,11 +193,16 @@
> {
> return new TestNG52Configurator();
> }
> - range = VersionRange.createFromVersionSpec( "[5.3,)" );
> + range = VersionRange.createFromVersionSpec( "[5.3,6.4]" );
> if ( range.containsVersion( version ) )
> {
> return new TestNGMapConfigurator();
> }
> + range = VersionRange.createFromVersionSpec( "[6.5,)" );
> + if ( range.containsVersion( version ) )
> + {
> + return new TestNG652Configurator();
> + }
>
> throw new TestSetFailedException( "Unknown TestNG version " + version );
> }
> Index: surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java
> ===================================================================
> --- surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java (revision 0)
> +++ surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG652ConfiguratorTest.java (revision 0)
> @@ -0,0 +1,44 @@
> +package org.apache.maven.surefire.testng.conf;
> +
> +/*
> + * 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 junit.framework.TestCase;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +/**
> + * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
> + */
> +public class TestNG652ConfiguratorTest
> + extends TestCase
> +{
> +
> + public void testGetConvertedOptions()
> + throws Exception
> + {
> + TestNGMapConfigurator testNGMapConfigurator = new TestNG652Configurator();
> + Map raw = new HashMap();
> + raw.put( "objectfactory", "java.lang.String" );
> + Map convertedOptions = testNGMapConfigurator.getConvertedOptions( raw );
> + String objectfactory = (String) convertedOptions.get( "-objectfactory" );
> + assertNotNull( objectfactory );
> + }
> +}
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira