1 7 package org.exoplatform.services.wsrp.test; 8 9 10 import java.rmi.RemoteException ; 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 19 public class TestRegistrationInterface extends BaseTest { 20 21 22 public TestRegistrationInterface(String s) { 23 super(s); 24 } 25 26 public void testRegistrationHandle() throws RemoteException { 27 RegistrationContext returnedContext = registrationOperationsInterface.register(registrationData); 28 assertNotNull(returnedContext.getRegistrationHandle()); 29 } 30 31 public void testIncorrectRegistrationData() throws RemoteException { 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 e) { 37 } 39 } 40 41 public void testModifyRegistration() throws Exception { 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 { 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 e) { 59 } 60 } 61 62 public void testDeregister() throws Exception { 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 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 { 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 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 |