Skip to content

Commit

Permalink
✅ 策略模式在netty中的应用单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
sanshengshui committed Apr 11, 2020
1 parent ca92a61 commit 15e134d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 12 deletions.
17 changes: 5 additions & 12 deletions netty-design-patterns-chain of responsibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>

<parent>
<artifactId>let_netty_easy</artifactId>
<groupId>com.sanshengshui</groupId>
Expand All @@ -38,6 +27,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cn.mushuwei.chain;

import org.junit.jupiter.api.Test;

/**
* @author james mu
* @date 2020/4/10 18:18
*/
public class AppTest {

@Test
public void test() {
App.main(new String[]{});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cn.mushuwei.chain;

import cn.mushuwei.chain.quest.Request;
import cn.mushuwei.chain.quest.RequestType;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author james mu
* @date 2020/4/10 18:04
*/
public class ITCompanyTest {

private static final List<Request> REQUESTS =
Arrays.asList(new Request(RequestType.PRODUCT_MANGER, "业务决策、目标拆分、需求分析和协同落地"),
new Request(RequestType.SOFTWARE_ENGINNER,"负责架构设计与开发,能够带领团队进行技术攻关"),
new Request(RequestType.QA_ENGINNER, "缺陷跟踪、软件质量度量及风险预估"));

@Test
public void testMakeQuest() {
ITCompany itCompany = new ITCompany();

REQUESTS.forEach(request -> {
itCompany.makeRequest(request);
assertTrue(
request.isHandled(),
"公司新项目所有需求希望被处理, 但是 [" + request + "] 没有!"
);
});
}
}
15 changes: 15 additions & 0 deletions netty-design-patterns-singleton/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>let_netty_easy</artifactId>
<groupId>com.sanshengshui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>netty-design-patterns-singleton</artifactId>


</project>
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<java.version>1.8</java.version>
<slf4j-api.version>1.7.30</slf4j-api.version>
<logback.version>1.2.3</logback.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
</properties>


Expand Down Expand Up @@ -60,6 +61,7 @@

<!-- 高级 - Netty特性,源码篇 start-->
<module>netty-design-patterns-chain of responsibility</module>
<module>netty-design-patterns-singleton</module>
<!-- 高级 - Netty特性,源码篇 end -->

</modules>
Expand All @@ -81,6 +83,12 @@
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 15e134d

Please sign in to comment.