Skip to content

Commit

Permalink
[improve][test] Bump TestNG to 7.6.1 (apache#18521)
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
  • Loading branch information
nodece authored and lifepuzzlefun committed Dec 9, 2022
1 parent f5666bf commit 765c918
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 20 deletions.
7 changes: 7 additions & 0 deletions build/run_integration_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ set -o pipefail
set -o errexit

JAVA_MAJOR_VERSION="$(java -version 2>&1 |grep " version " | awk -F\" '{ print $2 }' | awk -F. '{ if ($1=="1") { print $2 } else { print $1 } }')"
# Used to shade run test on Java 8, because the latest TestNG requires Java 11 or higher.
TESTNG_VERSION="7.3.0"

# lists all active maven modules with given parameters
# parses the modules from the "mvn initialize" output
Expand Down Expand Up @@ -95,6 +97,11 @@ test_group_shade_run() {
if [[ $JAVA_MAJOR_VERSION -gt 8 && $JAVA_MAJOR_VERSION -lt 17 ]]; then
additional_args="-Dmaven.compiler.source=$JAVA_MAJOR_VERSION -Dmaven.compiler.target=$JAVA_MAJOR_VERSION"
fi

if [[ $JAVA_MAJOR_VERSION -ge 8 && $JAVA_MAJOR_VERSION -lt 11 ]]; then
additional_args="$additional_args -Dtestng.version=$TESTNG_VERSION"
fi

mvn_run_integration_test --skip-build-deps --clean "$@" -Denforcer.skip=true -DShadeTests -DtestForkCount=1 -DtestReuseFork=false $additional_args
}

Expand Down
2 changes: 1 addition & 1 deletion buildtools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<surefire.version>3.0.0-M3</surefire.version>
<log4j2.version>2.18.0</log4j2.version>
<slf4j.version>1.7.32</slf4j.version>
<testng.version>7.3.0</testng.version>
<testng.version>7.6.1</testng.version>
<commons-lang3.version>3.11</commons-lang3.version>
<license-maven-plugin.version>4.1</license-maven-plugin.version>
<maven-shade-plugin.version>3.4.0</maven-shade-plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ flexible messaging model and an intuitive client API.</description>
<!-- Set docker-java.version to the version of docker-java used in Testcontainers -->
<docker-java.version>3.2.13</docker-java.version>
<kerby.version>1.1.1</kerby.version>
<testng.version>7.3.0</testng.version>
<testng.version>7.6.1</testng.version>
<mockito.version>3.12.4</mockito.version>
<javassist.version>3.25.0-GA</javassist.version>
<skyscreamer.version>1.5.0</skyscreamer.version>
Expand Down
6 changes: 6 additions & 0 deletions pulsar-client-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
<artifactId>pulsar-package-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 3 additions & 0 deletions pulsar-client-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>${pulsar.client.compiler.release}</maxJdkVersion>
<ignoredScopes>
<ignoreScope>test</ignoreScope>
</ignoredScopes>
</enforceBytecodeVersion>
</rules>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import io.netty.buffer.ByteBufAllocator;
import io.netty.util.ReferenceCountUtil;
import java.lang.reflect.Field;
Expand All @@ -36,7 +37,6 @@
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.impl.conf.ProducerConfigurationData;
import org.apache.pulsar.common.api.proto.MessageMetadata;
import org.junit.Assert;
import org.testng.annotations.Test;

public class BatchMessageContainerImplTest {
Expand Down Expand Up @@ -112,7 +112,7 @@ public void recoveryAfterOom() {
clientFiled.setAccessible(true);
clientFiled.set(producer, pulsarClient);
} catch (Exception e){
Assert.fail(e.getMessage());
fail(e.getMessage());
}

when(producer.getConfiguration()).thenReturn(producerConfigurationData);
Expand Down Expand Up @@ -155,7 +155,7 @@ public void testMessagesSize() throws Exception {
clientFiled.setAccessible(true);
clientFiled.set(producer, pulsarClient);
} catch (Exception e){
Assert.fail(e.getMessage());
fail(e.getMessage());
}

ByteBuffer payload = ByteBuffer.wrap("payload".getBytes(StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package org.apache.pulsar.client.impl;

import static org.testng.Assert.fail;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.ServiceUrlProvider;
import org.junit.Assert;
import org.testng.annotations.Test;

public class ClientBuilderImplTest {
Expand Down Expand Up @@ -90,7 +90,7 @@ public void testConnectionMaxIdleSeconds() throws Exception {
// test config not correct.
try {
PulsarClient.builder().connectionMaxIdleSeconds(30);
Assert.fail();
fail();
} catch (IllegalArgumentException e){
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@
*/
package org.apache.pulsar.client.impl;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import java.util.concurrent.TimeUnit;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.client.impl.conf.ProducerConfigurationData;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;

/**
* Unit tests of {@link ProducerStatsRecorderImpl}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package org.apache.pulsar.common.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import com.google.common.io.Resources;
import java.security.cert.X509Certificate;
import java.util.Arrays;
Expand Down
6 changes: 6 additions & 0 deletions pulsar-io/kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
<artifactId>jjwt-jackson</artifactId>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/
package org.apache.pulsar.packages.management.storage.bookkeeper.bookkeeper.test;

import static org.testng.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.apache.bookkeeper.test.ZooKeeperCluster;
import org.apache.bookkeeper.util.IOUtils;
import org.apache.bookkeeper.zookeeper.ZooKeeperClient;
Expand All @@ -33,7 +33,6 @@
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.apache.zookeeper.test.ClientBase;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -135,7 +134,7 @@ public void stopCluster() throws Exception {

if (this.serverFactory != null) {
this.serverFactory.shutdown();
Assert.assertTrue("waiting for server down", ClientBase.waitForServerDown(this.getZooKeeperConnectString(), (long)ClientBase.CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerDown(this.getZooKeeperConnectString(), (long)ClientBase.CONNECTION_TIMEOUT),"waiting for server down");
}

if (this.zks != null) {
Expand Down

0 comments on commit 765c918

Please sign in to comment.