1
1
package org .javaee7 .jaxrs .singleton ;
2
2
3
- import static org .junit .Assert .assertEquals ;
4
-
5
- import java .net .MalformedURLException ;
6
- import java .net .URI ;
7
- import java .net .URL ;
8
- import java .util .StringTokenizer ;
9
-
10
- import javax .ws .rs .client .Client ;
11
- import javax .ws .rs .client .ClientBuilder ;
12
- import javax .ws .rs .client .Entity ;
13
- import javax .ws .rs .client .WebTarget ;
14
-
15
3
import org .jboss .arquillian .container .test .api .Deployment ;
16
4
import org .jboss .arquillian .junit .Arquillian ;
5
+ import org .jboss .arquillian .junit .InSequence ;
17
6
import org .jboss .arquillian .test .api .ArquillianResource ;
18
7
import org .jboss .shrinkwrap .api .ShrinkWrap ;
19
8
import org .jboss .shrinkwrap .api .spec .WebArchive ;
20
9
import org .junit .After ;
21
10
import org .junit .Before ;
22
- import org .junit .FixMethodOrder ;
23
11
import org .junit .Test ;
24
12
import org .junit .runner .RunWith ;
25
- import org .junit .runners .MethodSorters ;
13
+
14
+ import javax .ws .rs .client .Client ;
15
+ import javax .ws .rs .client .ClientBuilder ;
16
+ import javax .ws .rs .client .Entity ;
17
+ import javax .ws .rs .client .WebTarget ;
18
+ import java .net .MalformedURLException ;
19
+ import java .net .URI ;
20
+ import java .net .URL ;
21
+ import java .util .StringTokenizer ;
22
+
23
+ import static org .junit .Assert .assertEquals ;
26
24
27
25
/**
28
26
* @author Arun Gupta
29
27
*/
30
28
@ RunWith (Arquillian .class )
31
- @ FixMethodOrder (MethodSorters .NAME_ASCENDING )
32
29
public class AnnotatedSingletonResourceTest {
33
-
34
30
@ ArquillianResource
35
31
private URL base ;
36
32
37
- Client client ;
38
- WebTarget target ;
33
+ private Client client ;
34
+ private WebTarget target ;
39
35
40
36
@ Before
41
37
public void setUp () throws MalformedURLException {
42
38
client = ClientBuilder .newClient ();
43
39
target = client .target (URI .create (new URL (base , "webresources/annotated" ).toExternalForm ()));
44
- // target = client.target("http://localhost:8080/singleton/webresources/annotated");
45
40
}
46
41
47
42
@ After
48
43
public void tearDown () {
49
44
client .close ();
50
45
}
51
46
52
- @ Deployment (testable = false )
47
+ @ Deployment (testable = false )
53
48
public static WebArchive createDeployment () {
54
49
return ShrinkWrap .create (WebArchive .class )
55
- .addClasses (
56
- MyAnnotatedApplication .class ,
57
- AnnotatedSingletonResource .class );
50
+ .addClasses (
51
+ MyAnnotatedApplication .class ,
52
+ AnnotatedSingletonResource .class );
58
53
}
59
54
60
55
@ Test
61
- public void test1Post () {
56
+ @ InSequence (1 )
57
+ public void testPost () {
62
58
target .request ().post (Entity .text ("pineapple" ));
63
59
target .request ().post (Entity .text ("mango" ));
64
60
target .request ().post (Entity .text ("kiwi" ));
@@ -71,13 +67,15 @@ public void test1Post() {
71
67
}
72
68
73
69
@ Test
74
- public void test2Get () {
70
+ @ InSequence (2 )
71
+ public void testGet () {
75
72
String response = target .path ("2" ).request ().get (String .class );
76
73
assertEquals ("kiwi" , response );
77
74
}
78
75
79
76
@ Test
80
- public void test3Delete () {
77
+ @ InSequence (3 )
78
+ public void testDelete () {
81
79
target .path ("kiwi" ).request ().delete ();
82
80
83
81
String list = target .request ().get (String .class );
@@ -86,12 +84,12 @@ public void test3Delete() {
86
84
}
87
85
88
86
@ Test
89
- public void test4Put () {
87
+ @ InSequence (4 )
88
+ public void testPut () {
90
89
target .request ().put (Entity .text ("apple" ));
91
90
92
91
String list = target .request ().get (String .class );
93
92
StringTokenizer tokens = new StringTokenizer (list , "," );
94
93
assertEquals (4 , tokens .countTokens ());
95
94
}
96
-
97
95
}
0 commit comments