Skip to content

Commit 74190e3

Browse files
committed
Adding tests for each class.
1 parent 6b10f4b commit 74190e3

File tree

6 files changed

+98
-1
lines changed

6 files changed

+98
-1
lines changed

ambassador/pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>ambassador</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.testng</groupId>
16+
<artifactId>testng</artifactId>
17+
<version>RELEASE</version>
18+
<scope>test</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>junit</groupId>
22+
<artifactId>junit</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.junit.jupiter</groupId>
26+
<artifactId>junit-jupiter-api</artifactId>
27+
</dependency>
28+
</dependencies>
1329

1430

1531
</project>

ambassador/src/main/java/com/iluwatar/ambassador/Client.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public class Client {
3333
serviceAmbassador = new ServiceAmbassador();
3434
}
3535

36-
void useService(int value) {
36+
long useService(int value) {
3737
long result = serviceAmbassador.doRemoteFunction(value);
3838
System.out.println(result);
39+
return result;
3940
}
4041
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package com.iluwatar.ambassador;
24+
25+
import org.junit.jupiter.api.Test;
26+
27+
/**
28+
* Application test
29+
*/
30+
public class AppTest {
31+
32+
@Test
33+
public void test() {
34+
App.main(new String[]{});
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.iluwatar.ambassador;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class ClientTest {
6+
7+
@Test
8+
public void test() {
9+
10+
Client client = new Client();
11+
long result = client.useService(10);
12+
assert result == 100 || result == -1;
13+
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.iluwatar.ambassador;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class RemoteServiceTest {
6+
7+
@Test
8+
public void test() {
9+
10+
RemoteService remoteService = RemoteService.getRemoteService();
11+
long result = remoteService.doRemoteFunction(10);
12+
13+
assert result == 100 || result == -1;
14+
}
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.iluwatar.ambassador;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class ServiceAmbassadorTest {
6+
7+
@Test
8+
public void test() {
9+
ServiceAmbassador ambassador = new ServiceAmbassador();
10+
long result = ambassador.doRemoteFunction(10);
11+
assert result == 100 || result == -1;
12+
}
13+
}

0 commit comments

Comments
 (0)