Adding tests for each class.

This commit is contained in:
Ovidijus Okinskas 2018-06-04 21:20:04 +01:00 committed by O.Okinskas
parent 6b10f4bdd1
commit 74190e36bb
6 changed files with 98 additions and 1 deletions

View File

@ -10,6 +10,22 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>ambassador</artifactId>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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;
}
}

View File

@ -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[]{});
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}