1 package org.apache.archiva.rest.services;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.archiva.rest.api.services.PingService;
23 import org.apache.cxf.jaxrs.client.WebClient;
24 import org.junit.Ignore;
25 import org.junit.Test;
26
27 import javax.ws.rs.ForbiddenException;
28
29
30
31
32
33 public class PingServiceTest
34 extends AbstractArchivaRestTest
35 {
36
37
38 @Test
39 public void ping()
40 throws Exception
41 {
42
43
44
45 String res = getPingService().ping();
46 assertEquals( "Yeah Baby It rocks!", res );
47 }
48
49 @Test( expected = ForbiddenException.class )
50 public void pingWithAuthzFailed()
51 throws Exception
52 {
53
54 try
55 {
56 String res = getPingService().pingWithAuthz();
57 fail( "not in exception" );
58 }
59 catch ( ForbiddenException e )
60 {
61 assertEquals( 403, e.getResponse().getStatus() );
62 throw e;
63 }
64 }
65
66 @Test
67 public void pingWithAuthz()
68 throws Exception
69 {
70
71 PingService service = getPingService();
72 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
73 WebClient.client( service ).header( "Authorization", authorizationHeader );
74 String res = service.pingWithAuthz();
75 assertEquals( "Yeah Baby It rocks!", res );
76 }
77
78 @Ignore( "FIXME guest failed ???" )
79 public void pingWithAuthzGuest()
80 throws Exception
81 {
82
83 PingService service = getPingService();
84 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
85 WebClient.client( service ).header( "Authorization", guestAuthzHeader );
86 String res = service.pingWithAuthz();
87 assertEquals( "Yeah Baby It rocks!", res );
88 }
89 }