diff --git a/ambassador/pom.xml b/ambassador/pom.xml index b230a2736..fc3dbf37c 100644 --- a/ambassador/pom.xml +++ b/ambassador/pom.xml @@ -10,6 +10,22 @@ 4.0.0 ambassador + + + org.testng + testng + RELEASE + test + + + junit + junit + + + org.junit.jupiter + junit-jupiter-api + + \ No newline at end of file diff --git a/ambassador/src/main/java/com/iluwatar/ambassador/Client.java b/ambassador/src/main/java/com/iluwatar/ambassador/Client.java index 30bd834e6..39c0e7273 100644 --- a/ambassador/src/main/java/com/iluwatar/ambassador/Client.java +++ b/ambassador/src/main/java/com/iluwatar/ambassador/Client.java @@ -33,8 +33,9 @@ public class Client { serviceAmbassador = new ServiceAmbassador(); } - void useService(int value) { + long useService(int value) { long result = serviceAmbassador.doRemoteFunction(value); System.out.println(result); + return result; } } diff --git a/ambassador/src/test/java/com/iluwatar/ambassador/AppTest.java b/ambassador/src/test/java/com/iluwatar/ambassador/AppTest.java new file mode 100644 index 000000000..686a18af3 --- /dev/null +++ b/ambassador/src/test/java/com/iluwatar/ambassador/AppTest.java @@ -0,0 +1,36 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.iluwatar.ambassador; + +import org.junit.jupiter.api.Test; + +/** + * Application test + */ +public class AppTest { + + @Test + public void test() { + App.main(new String[]{}); + } +} diff --git a/ambassador/src/test/java/com/iluwatar/ambassador/ClientTest.java b/ambassador/src/test/java/com/iluwatar/ambassador/ClientTest.java new file mode 100644 index 000000000..e02321fea --- /dev/null +++ b/ambassador/src/test/java/com/iluwatar/ambassador/ClientTest.java @@ -0,0 +1,15 @@ +package com.iluwatar.ambassador; + +import org.junit.jupiter.api.Test; + +public class ClientTest { + + @Test + public void test() { + + Client client = new Client(); + long result = client.useService(10); + assert result == 100 || result == -1; + + } +} diff --git a/ambassador/src/test/java/com/iluwatar/ambassador/RemoteServiceTest.java b/ambassador/src/test/java/com/iluwatar/ambassador/RemoteServiceTest.java new file mode 100644 index 000000000..0e7b6a58d --- /dev/null +++ b/ambassador/src/test/java/com/iluwatar/ambassador/RemoteServiceTest.java @@ -0,0 +1,16 @@ +package com.iluwatar.ambassador; + +import org.junit.jupiter.api.Test; + +public class RemoteServiceTest { + + @Test + public void test() { + + RemoteService remoteService = RemoteService.getRemoteService(); + long result = remoteService.doRemoteFunction(10); + + assert result == 100 || result == -1; + } + +} diff --git a/ambassador/src/test/java/com/iluwatar/ambassador/ServiceAmbassadorTest.java b/ambassador/src/test/java/com/iluwatar/ambassador/ServiceAmbassadorTest.java new file mode 100644 index 000000000..9bd87d3f8 --- /dev/null +++ b/ambassador/src/test/java/com/iluwatar/ambassador/ServiceAmbassadorTest.java @@ -0,0 +1,13 @@ +package com.iluwatar.ambassador; + +import org.junit.jupiter.api.Test; + +public class ServiceAmbassadorTest { + + @Test + public void test() { + ServiceAmbassador ambassador = new ServiceAmbassador(); + long result = ambassador.doRemoteFunction(10); + assert result == 100 || result == -1; + } +}