Skip to content

Commit 1e6740f

Browse files
committed
Merge pull request #26 from indigo-dc/devel
Update tests to increment coverage
2 parents 76939a7 + 2f504b4 commit 1e6740f

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ The log4j.properties file of the tests can help you with the logger configuratio
3737

3838
1.4 USAGE
3939
-----------------
40-
The tests defined in the class **InfrastructureManagerApiClientTest** show how to use the im-java-api.
40+
The tests defined in the class **InfrastructureManagerTest** show how to use the im-java-api.
4141
Also check the following lines to see some examples of use:
4242

4343
### 1.4.1 Create the API client
4444
```
45-
InfrastructureManagerApiClient imClient = new InfrastructureManagerApiClient("IM_ENDPOINT", "AUTH_FILE_PATH");
45+
InfrastructureManager im = new InfrastructureManager("IM_ENDPOINT", "AUTH_FILE_PATH");
4646
```
47-
When creating a new client you have to specify a valid IM URL, and an authorization file path with the credentials required for the infrastrcture deployment.
47+
When creating a new client you have to specify a valid IM URL, and an authorization file path with the credentials required for the infrastructure deployment.
4848
More information about the authorization file can be found here: [Auth file](http://www.grycap.upv.es/im/doc/client.html#auth-file).
4949
You can also check the authorization file used for the tests that is available in 'src/test/resources/'.
5050

5151
### 1.4.2 Create and destroy an infrastructure
5252
```
5353
// Infrastructure creation based on a TOSCA file
54-
ServiceResponse response = getImApiClient().createInfrastructure(FileIO.readUTF8File(TOSCA_FILE_PATH));
54+
InfrastructureUri newInfrastructureUri = im.createInfrastructure(readFile(TOSCA_FILE_PATH), BodyContentType.TOSCA);
5555
... USE THE INFRASTRUCTURE ...
5656
// Infrastructure destruction
57-
imClient.destroyInfrastructure(getInfrastructureId());
57+
im.destroyInfrastructure(getInfrastructureId());
5858
```
59-
The **ServiceResponse** class returned by the **createInfrastructure** method contains all the information of the web service response. Check the **ServiceResponse** class methods for more information.
59+
The 'im' client always returns a POJO with the information of the call. If an error occurs, an **ImClientErrorException** is thrown. This exception contains the error message and the error code returned by the server.

src/test/java/es/upv/i3m/grycap/im/lang/ImMessagesTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@
33
import org.junit.Assert;
44
import org.junit.Test;
55

6+
import java.lang.reflect.Constructor;
7+
import java.lang.reflect.InvocationTargetException;
8+
69
public class ImMessagesTest {
710

11+
/**
12+
* Try to build a private class.
13+
*/
14+
@Test(expected = InvocationTargetException.class)
15+
public void testImMessagesBuilder() throws NoSuchMethodException,
16+
SecurityException, InstantiationException, IllegalAccessException,
17+
IllegalArgumentException, InvocationTargetException {
18+
19+
Constructor<ImMessages> constructor =
20+
ImMessages.class.getDeclaredConstructor(new Class[0]);
21+
constructor.setAccessible(true);
22+
constructor.newInstance(new Object[0]);
23+
}
24+
825
@Test
926
public void testMessages() {
1027
Assert.assertEquals("REST call with empty body content",

src/test/java/es/upv/i3m/grycap/im/pojo/PojoTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public void testInfOutputValuesEquals() {
1919
outputValues.put("test", "test");
2020
InfOutputValues outputs1 = new InfOutputValues(outputValues);
2121
InfOutputValues outputs2 = new InfOutputValues(outputValues);
22+
Assert.assertEquals(outputs1, outputs1);
2223
Assert.assertEquals(outputs1, outputs2);
2324
}
2425

@@ -39,6 +40,7 @@ public void testInfrastructureStateEquals() {
3940
new InfrastructureState("infState", infStates);
4041
InfrastructureState infState2 =
4142
new InfrastructureState("infState", infStates);
43+
Assert.assertEquals(infState1, infState1);
4244
Assert.assertEquals(infState1, infState2);
4345
}
4446

@@ -56,6 +58,7 @@ public void testInfrastructureStateNotEquals() {
5658
public void testInfrastructureUriEquals() {
5759
InfrastructureUri uri1 = new InfrastructureUri("uri");
5860
InfrastructureUri uri2 = new InfrastructureUri("uri");
61+
Assert.assertEquals(uri1, uri1);
5962
Assert.assertEquals(uri1, uri2);
6063
}
6164

@@ -89,6 +92,7 @@ public void testInfrastructureUrisEquals() {
8992
.asList(new InfrastructureUri("uri"), new InfrastructureUri("uri")));
9093
InfrastructureUris uris2 = new InfrastructureUris(Arrays
9194
.asList(new InfrastructureUri("uri"), new InfrastructureUri("uri")));
95+
Assert.assertEquals(uris1, uris1);
9296
Assert.assertEquals(uris1, uris2);
9397
}
9498

@@ -106,6 +110,7 @@ public void testInfrastructureUrisNotEquals() {
106110
public void testPropertyEquals() {
107111
Property prop1 = new Property("key", "value");
108112
Property prop2 = new Property("key", "value");
113+
Assert.assertEquals(prop1, prop1);
109114
Assert.assertEquals(prop1, prop2);
110115
}
111116

@@ -120,6 +125,7 @@ public void testPropertyNotEquals() {
120125
public void testErrorEquals() {
121126
ResponseError error1 = new ResponseError("message", 200);
122127
ResponseError error2 = new ResponseError("message", 200);
128+
Assert.assertEquals(error1, error1);
123129
Assert.assertEquals(error1, error2);
124130
}
125131

@@ -159,6 +165,7 @@ public void testVirtualMachineInfoEquals() throws FileException {
159165
VirtualMachineInfo vmInfo2 =
160166
new VirtualMachineInfo(Arrays.asList(property3, property4));
161167

168+
Assert.assertEquals(vmInfo1, vmInfo1);
162169
Assert.assertEquals(vmInfo1, vmInfo2);
163170
}
164171

0 commit comments

Comments
 (0)