KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > wsrp > test > TestRegistrationInterface


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  *
5  * Created on 15 janv. 2004
6  */

7 package org.exoplatform.services.wsrp.test;
8
9
10 import java.rmi.RemoteException JavaDoc;
11 import org.exoplatform.services.wsrp.type.ModifyRegistrationRequest;
12 import org.exoplatform.services.wsrp.type.RegistrationContext;
13 import org.exoplatform.services.wsrp.type.RegistrationState;
14
15 /**
16  * @author Mestrallet Benjamin
17  * benjmestrallet@users.sourceforge.net
18  */

19 public class TestRegistrationInterface extends BaseTest {
20
21
22   public TestRegistrationInterface(String JavaDoc s) {
23     super(s);
24   }
25
26   public void testRegistrationHandle() throws RemoteException JavaDoc {
27     RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData);
28     assertNotNull(returnedContext.getRegistrationHandle());
29   }
30
31   public void testIncorrectRegistrationData() throws RemoteException JavaDoc {
32     registrationData.setConsumerAgent("exoplatform.1a.0b");
33     try {
34       registrationOperationsInterface.register(registrationData);
35       fail("the registration of the consumer should return a WS Fault");
36     } catch (RemoteException JavaDoc e) {
37       //e.printStackTrace();
38
}
39   }
40
41   public void testModifyRegistration() throws Exception JavaDoc {
42     RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData);
43     assertNotNull(returnedContext.getRegistrationHandle());
44     resolveRegistrationContext(returnedContext);
45     ModifyRegistrationRequest modifyRegistration = getModifyRegistration(returnedContext);
46     RegistrationState rS = registrationOperationsInterface.modifyRegistration(modifyRegistration);
47     assertNull(rS.getRegistrationState());
48   }
49
50   public void testIncorrectModifyRegistration() throws Exception JavaDoc {
51     RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData);
52     registrationData.setConsumerAgent("exoplatform.1a.0b");
53     resolveRegistrationContext(returnedContext);
54     ModifyRegistrationRequest modifyRegistration = getModifyRegistration(returnedContext);
55     try {
56       registrationOperationsInterface.modifyRegistration(modifyRegistration);
57       fail("the modify registration of the consumer should return a WS Fault");
58     } catch (RemoteException JavaDoc e) {
59     }
60   }
61
62   public void testDeregister() throws Exception JavaDoc {
63     RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData);
64     returnedContext.getRegistrationHandle();
65     resolveRegistrationContext(returnedContext);
66     registrationOperationsInterface.deregister(returnedContext);
67     if (returnedContext.getRegistrationState() == null) {
68       ModifyRegistrationRequest modifyRegistration = getModifyRegistration(returnedContext);
69       try {
70         registrationOperationsInterface.modifyRegistration(modifyRegistration);
71         fail("the modify registration of the consumer should return a WS Fault");
72       } catch (RemoteException JavaDoc e) {
73       }
74     } else {
75       System.out.println("[test] can not try to modify registration here as the state is saved on consumer");
76     }
77   }
78
79   public void testIncorrectDeregister() throws Exception JavaDoc {
80     RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData);
81     resolveRegistrationContext(returnedContext);
82     returnedContext.setRegistrationHandle("chunkHandle");
83     try {
84       registrationOperationsInterface.deregister(returnedContext);
85       fail("the deregistration of the consumer should return a WS Fault");
86     } catch (RemoteException JavaDoc e) {
87     }
88   }
89
90   private ModifyRegistrationRequest getModifyRegistration(RegistrationContext registrationContext) {
91     ModifyRegistrationRequest modifyRegistration = new ModifyRegistrationRequest();
92     modifyRegistration.setRegistrationContext(registrationContext);
93     modifyRegistration.setRegistrationData(registrationData);
94     return modifyRegistration;
95   }
96
97 }
98
Popular Tags