1 5 6 package org.exoplatform.services.wsrp.testConsumer; 7 8 import org.exoplatform.services.wsrp.exceptions.WSRPException; 9 import org.exoplatform.services.wsrp.type.PortletDescription; 10 import org.exoplatform.services.wsrp.type.ServiceDescription; 11 12 18 19 public class TestProducer extends BaseTest{ 20 21 public void testBasicProperties(){ 22 assertEquals(PRODUCER_ID, producer.getID()); 23 assertEquals(PRODUCER_NAME, producer.getName()); 24 assertEquals(PRODUCER_PORTLET_MANAGEMENT_INTERFACE_ENDPOINT, producer.getPortletManagementInterfaceEndpoint()); 25 assertEquals(PRODUCER_REGISTRATION_INTERFACE_ENDPOINT, producer.getRegistrationInterfaceEndpoint()); 26 assertEquals(PRODUCER_SERVICE_DESCRIPTION_INTERFACE_ENDPOINT, producer.getServiceDescriptionInterfaceEndpoint()); 27 producer.getServiceDescriptionInterface(); 28 } 29 30 public void testServiceDescription() throws Exception { 31 assertNull(producer.getServiceDescription(false)); 32 producer.setDesiredLocales(desiredLocales); 33 ServiceDescription serviceDescription = producer.getServiceDescription(); 34 PortletDescription portletDescription = getHelloWorldPortlet(serviceDescription.getOfferedPortlets()); 35 assertEquals("Usual Hello World Portlet", portletDescription.getDescription().getValue()); 36 } 37 38 public void testPortletDescription() throws WSRPException { 39 producer.setDesiredLocales(new String [] {"fr"}); 40 PortletDescription portletDescription = producer.getPortletDescription("hello/HelloWorld"); 41 assertEquals("Salut le monde Portlet", portletDescription.getDescription().getValue()); 42 } 43 44 public void testRegistration() throws WSRPException { 45 assertTrue(producer.isRegistrationInterfaceSupported()); 46 producer.setDesiredLocales(desiredLocales); 47 ServiceDescription serviceDescription = producer.getServiceDescription(); 48 assertEquals(producer.isRegistrationRequired(), serviceDescription.isRequiresRegistration()); 49 assertNull(producer.getRegistrationData()); 50 assertNotNull(producer.register(registrationData)); 51 assertNotNull(producer.getRegistrationData()); 52 assertNotNull(producer.getRegistrationContext()); 53 producer.deregister(); 54 } 55 56 public void testPortletManagement(){ 57 assertTrue(producer.isPortletManagementInferfaceSupported()); 58 assertNotNull(producer.getPortletManagementInterface()); 59 } 60 61 private PortletDescription getHelloWorldPortlet(PortletDescription[] psArray) throws Exception { 62 for (int i = 0; i < psArray.length; i++) { 63 if("hello/HelloWorld".equals(psArray[i].getPortletHandle())) 64 return psArray[i]; 65 } 66 return null; 67 } 68 } 69 | Popular Tags |