Skip to content

Commit

Permalink
Tidy the dependency (apache#981)
Browse files Browse the repository at this point in the history
tidy the maven dependency
* 1、Unify the version of `netty`
* 2、Use [caffine](https://github.com/ben-manes/caffeine) to instead of guava cache
* 3、Upgrade junit4 to [junit5](https://junit.org/junit5/docs/current/user-guide)
* 4、Remove testng (use [junit5](https://junit.org/junit5/docs/current/user-guide))
  • Loading branch information
lovepoem committed May 7, 2019
1 parent 054c879 commit 43fb0d3
Show file tree
Hide file tree
Showing 120 changed files with 1,326 additions and 1,553 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: java
sudo: false # faster builds

jdk:
- openjdk11
- openjdk8

cache:
Expand Down
5 changes: 0 additions & 5 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,5 @@
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion common/src/test/java/io/seata/common/XIDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Random;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.sql.SQLException;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -154,4 +154,4 @@ public void testNestedException9() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package io.seata.common.loader;

import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import org.junit.Assert;
import org.junit.Test;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -36,15 +36,17 @@ public class EnhancedServiceLoaderTest {
@Test
public void testLoadByClassAndClassLoader() {
Hello load = EnhancedServiceLoader.load(Hello.class, Hello.class.getClassLoader());
Assert.assertEquals(load.say(), "Bonjour");
Assertions.assertEquals(load.say(), "Bonjour");
}

/**
* Test load exception.
*/
@Test(expected = EnhancedServiceNotFoundException.class)
@Test
public void testLoadException() {
EnhancedServiceLoaderTest load = EnhancedServiceLoader.load(EnhancedServiceLoaderTest.class);
Assertions.assertThrows(EnhancedServiceNotFoundException.class, () -> {
EnhancedServiceLoaderTest load = EnhancedServiceLoader.load(EnhancedServiceLoaderTest.class);
});
}

/**
Expand All @@ -71,7 +73,7 @@ public void testLoadByClassAndActivateName() {
@Test
public void testLoadByClassAndClassLoaderAndActivateName() {
Hello englishHello = EnhancedServiceLoader
.load(Hello.class, "EnglishHello", EnhancedServiceLoaderTest.class.getClassLoader());
.load(Hello.class, "EnglishHello", EnhancedServiceLoaderTest.class.getClassLoader());
assertThat(englishHello.say()).isEqualTo("hello!");
}

Expand All @@ -93,8 +95,8 @@ public void getAllExtensionClass() {
@Test
public void getAllExtensionClass1() {
List<Class> allExtensionClass = EnhancedServiceLoader
.getAllExtensionClass(Hello.class, ClassLoader.getSystemClassLoader());
.getAllExtensionClass(Hello.class, ClassLoader.getSystemClassLoader());
assertThat(allExtensionClass).isNotEmpty();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Otis.z
Expand All @@ -41,4 +41,4 @@ public void testNewThread() {
assertThat(testNameThread.getName()).startsWith("testNameThread");
assertThat(testNameThread.isDaemon()).isTrue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
8 changes: 4 additions & 4 deletions common/src/test/java/io/seata/common/util/BlobUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import javax.sql.rowset.serial.SerialBlob;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -60,11 +60,11 @@ public void testBlob2string() throws SQLException {
* Test input stream 2 string.
*/
@Test
@Ignore
@Disabled
public void testInputStream2String() {
InputStream inputStream = BlobUtilsTest.class.getClassLoader().getResourceAsStream("test.txt");
assertThat(BlobUtils.inputStream2String(inputStream)).isEqualTo("abc\n"
+ ":\"klsdf\n"
+ "2ks,x:\".,-3sd˚ø≤ø¬≥");
}
}
}
4 changes: 2 additions & 2 deletions common/src/test/java/io/seata/common/util/NetUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.net.SocketAddress;
import java.net.UnknownHostException;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -161,4 +161,4 @@ public void testGetLocalAddress() {
assertThat(NetUtil.getLocalAddress()).isNotNull();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import javax.sql.rowset.serial.SerialBlob;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -78,7 +78,7 @@ public void testBlob2string() throws SQLException {
* Test input stream 2 string.
*/
@Test
@Ignore
@Disabled
public void testInputStream2String() throws IOException {
InputStream inputStream = StringUtilsTest.class.getClassLoader().getResourceAsStream("test.txt");
assertThat(StringUtils.inputStream2String(inputStream))
Expand Down
13 changes: 0 additions & 13 deletions config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,4 @@
<module>seata-config-zk</module>
<module>seata-config-all</module>
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
3 changes: 3 additions & 0 deletions config/seata-config-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-config-apollo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-config-zk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-config-nacos</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion config/seata-config-apollo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-config-core</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
Expand Down
1 change: 1 addition & 0 deletions config/seata-config-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
Expand Down
7 changes: 2 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-discovery-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -53,11 +55,6 @@
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<extensions>
Expand Down
32 changes: 15 additions & 17 deletions core/src/main/java/io/seata/core/rpc/netty/TmRpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
*/
package io.seata.core.rpc.netty;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.concurrent.EventExecutorGroup;
import io.seata.common.exception.FrameworkErrorCode;
import io.seata.common.exception.FrameworkException;
import io.seata.common.thread.NamedThreadFactory;
Expand All @@ -38,18 +35,19 @@
import io.seata.core.protocol.RegisterTMResponse;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.GlobalBeginResponse;
import io.seata.core.rpc.netty.NettyPoolKey.TransactionRole;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.concurrent.EventExecutorGroup;
import org.apache.commons.pool.impl.GenericKeyedObjectPool.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* The type Rpc client.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.seata.core.context;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
25 changes: 14 additions & 11 deletions core/src/test/java/io/seata/core/context/RootContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import io.seata.common.exception.ShouldNeverHappenException;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -70,17 +71,19 @@ public void testInGlobalTransaction() {
/**
* Test assert not in global transaction with exception.
*/
@Test(expected = ShouldNeverHappenException.class)
@Test
public void testAssertNotInGlobalTransactionWithException() {
try {
RootContext.assertNotInGlobalTransaction();
RootContext.bind(DEFAULT_XID);
RootContext.assertNotInGlobalTransaction();
} finally {
//clear
RootContext.unbind();
assertThat(RootContext.getXID()).isNull();
}
Assertions.assertThrows(ShouldNeverHappenException.class, () -> {
try {
RootContext.assertNotInGlobalTransaction();
RootContext.bind(DEFAULT_XID);
RootContext.assertNotInGlobalTransaction();
} finally {
//clear
RootContext.unbind();
assertThat(RootContext.getXID()).isNull();
}
});
}

/**
Expand Down
Loading

0 comments on commit 43fb0d3

Please sign in to comment.