[SUREFIRE-1179] integration test
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/65b26d12 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/65b26d12 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/65b26d12 Branch: refs/heads/master Commit: 65b26d12051c5ddb973238ed10b3ae5d334159c9 Parents: f3bbccb Author: Tibor17 <[email protected]> Authored: Sun Sep 27 01:18:12 2015 +0200 Committer: Tibor17 <[email protected]> Committed: Wed Sep 30 00:53:53 2015 +0200 ---------------------------------------------------------------------- .../maven/surefire/its/Surefire1179IT.java | 43 ++++++++++++++ .../pom.xml | 60 ++++++++++++++++++++ .../src/test/java/debug/ParallelTest.java | 45 +++++++++++++++ 3 files changed, 148 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/65b26d12/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java new file mode 100644 index 0000000..6acb97b --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java @@ -0,0 +1,43 @@ +package org.apache.maven.surefire.its; + +/* + * 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.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * Fix for TestNG parameter -dataproviderthreadcount. + */ +public class Surefire1179IT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void suiteXmlForkCountTwoReuse() + { + unpack().executeTest().verifyErrorFreeLog().verifyTextInLog( " CONCURRENCY=10." ); + } + + private SurefireLauncher unpack() + { + return unpack( "surefire-1179-testng-parallel-dataprovider" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/65b26d12/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml new file mode 100644 index 0000000..90d2238 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml @@ -0,0 +1,60 @@ +<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> + <parent> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>it-parent</artifactId> + <version>1.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>surefire-1179-testng-parallel-dataprovider</artifactId> + <version>1.0</version> + <url>http://maven.apache.org</url> + <developers> + <developer> + <id>tibordigana</id> + <name>Tibor DigaÅa (tibor17)</name> + <email>[email protected]</email> + <roles> + <role>Committer</role> + </roles> + <timezone>Europe/Bratislava</timezone> + </developer> + </developers> + <dependencies> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.9.6</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <properties> + <property> + <name>parallel</name> + <value>methods</value> + </property> + <property> + <name>dataproviderthreadcount</name> + <value>10</value> + </property> + </properties> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/65b26d12/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/src/test/java/debug/ParallelTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/src/test/java/debug/ParallelTest.java b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/src/test/java/debug/ParallelTest.java new file mode 100644 index 0000000..6863f62 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1179-testng-parallel-dataprovider/src/test/java/debug/ParallelTest.java @@ -0,0 +1,45 @@ +package debug; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +public class ParallelTest +{ + private static final AtomicInteger concurrency = new AtomicInteger(); + + private static final AtomicInteger counter = new AtomicInteger(); + + @DataProvider( parallel = true, name = "dataProvider" ) + public Iterator<Object[]> dataProvider() + { + List<Object[]> data = new ArrayList<Object[]>(); + for ( int i = 0; i < 5000; i++ ) + { + data.add( new Object[]{ "ID_" + i } ); + } + return data.iterator(); + } + + @Test( dataProvider = "dataProvider" ) + public void testParallelDataProvider( String iterId ) + throws Exception + { + int methodCount = counter.incrementAndGet(); + int currentlyParallelCalls = concurrency.incrementAndGet(); + if ( methodCount % 100 == 0 ) + { + System.out.println( iterId + ": CONCURRENCY=" + currentlyParallelCalls + "." ); + } + TimeUnit.MILLISECONDS.sleep( 20 ); + concurrency.decrementAndGet(); + } +} \ No newline at end of file
