Skip to content

Commit 33bfd61

Browse files
committed
UnitTest writing
1 parent 422a7e6 commit 33bfd61

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

api-gateway/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.cevher.ms</groupId>
1212
<artifactId>api-gateway</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
13+
<version>0.0.3</version>
1414
<name>api-gateway</name>
1515
<description>API Gateway Application</description>
1616
<properties>
@@ -49,6 +49,12 @@
4949
</exclusion>
5050
</exclusions>
5151
</dependency>
52+
<dependency>
53+
<groupId>junit</groupId>
54+
<artifactId>junit</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
5258
</dependencies>
5359
<dependencyManagement>
5460
<dependencies>

api-gateway/src/main/java/com/cevher/ms/cloud/gateway/FallBackController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ public class FallBackController {
88

99
@GetMapping("/userServiceFallBack")
1010
public String userServiceFallBack(){
11-
return "FallBack Controller!.. User Service is taking longer then Expected.";
11+
return "FallBack User Controller!.. User Service is taking longer then Expected.";
1212
}
1313

1414
@GetMapping("/departmentServiceFallBack")
1515
public String departmentServiceFallBack(){
16-
return "FallBack Controller!.. Department Service is taking longer then Expected.";
16+
return "FallBack Department Controller!.. Department Service is taking longer then Expected.";
1717
}
1818
@GetMapping("/taskServiceFallBack")
1919
public String taskServiceFallBack(){
20-
return "FallBack Controller!.. Task Service is taking longer then Expected.";
20+
return "FallBack Task Controller!.. Task Service is taking longer then Expected.";
2121
}
2222
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.cevher.ms.cloud.gateway;
2+
3+
import org.junit.Ignore;
4+
import org.junit.jupiter.api.Test;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.test.context.SpringBootTest;
7+
import org.springframework.boot.test.web.client.TestRestTemplate;
8+
import org.springframework.boot.web.server.LocalServerPort;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
12+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
13+
class APIGatewayApplicationTests {
14+
15+
@LocalServerPort
16+
private int port;
17+
18+
@Autowired
19+
private TestRestTemplate restTemplate;
20+
21+
@Test
22+
void contextLoads() {
23+
}
24+
25+
@Ignore("not yet ready , Please ignore.")
26+
@Test
27+
void fallBackUser() throws Exception {
28+
assertThat(this.restTemplate
29+
.getForObject("http://127.0.0.1:" + port + "/userServiceFallBack", String.class)
30+
).contains("FallBack User Controller");
31+
}
32+
33+
}

api-gateway/src/test/java/com/cevher/ms/cloud/gateway/CloudGatewayApplicationTests.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)