-
Notifications
You must be signed in to change notification settings - Fork 21
/
TestClient.java
102 lines (80 loc) · 2.54 KB
/
TestClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package org.alm;
import static org.alm.Util.readAlmProperties;
import java.net.URI;
import junit.framework.Assert;
import org.alm.model.*;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class TestClient
{
private HttpServer server;
private Config config;
private Client client;
private TestSet testSet;
private TestInstances testInstances;
private org.alm.model.Test test;
private Run run;
public TestClient() throws Exception
{
config = new Config(readAlmProperties());
client = new Client(config);
}
@BeforeClass
public void setUp() throws Exception
{
final ResourceConfig rc = new ResourceConfig(AlmApiStub.class);
server = GrizzlyHttpServerFactory.createHttpServer(
URI.create(String.format("http://%s:%s/", config.host(), config.port())), rc);
}
@AfterClass
public void tearDown() throws Exception
{
if (server != null)
{
server.shutdownNow();
}
}
@Test
public void login() throws Exception
{
client.login();
}
@Test(dependsOnMethods = { "login" })
public void loadTestSet() throws Exception
{
testSet = client.loadTestSet("1");
Assert.assertNotNull(testSet);
}
@Test(dependsOnMethods = { "loadTestSet" })
public void loadTestInstances() throws Exception
{
testInstances = client.loadTestInstances(testSet);
Assert.assertNotNull(testInstances);
}
@Test(dependsOnMethods = { "loadTestInstances" })
public void loadTest() throws Exception
{
test = client.loadTest(testInstances.entities().get(0));
Assert.assertNotNull(test);
}
@Test(dependsOnMethods = { "loadTest" })
public void createRun() throws Exception
{
run = client.createRun(testInstances.entities().get(0), test);
Assert.assertNotNull(run);
}
@Test(dependsOnMethods = { "createRun" })
public void createRunSteps() throws Exception
{
client.createRunSteps(run, Util.createRunStepEntities());
}
@Test(dependsOnMethods = { "createRunSteps" })
public void logout() throws Exception
{
client.logout();
}
}