1 7 package org.exoplatform.services.wsrp.test; 8 9 10 import org.exoplatform.services.wsrp.type.*; 11 12 16 public class TestGetServiceDescriptionInterface extends BaseTest{ 17 18 public TestGetServiceDescriptionInterface(String s) { 19 super(s); 20 } 21 22 public void testGetDescription() throws Exception { 23 PortletDescription ps = getHelloWorldPortlet("en"); 24 assertEquals("Usual Hello World Portlet", ps.getDescription().getValue()); 25 26 ps = getHelloWorldPortlet("fr"); 27 assertEquals("Salut le monde Portlet", ps.getDescription().getValue()); 28 } 29 30 public void testGetDisplayName() throws Exception { 31 PortletDescription ps = getHelloWorldPortlet("en"); 32 assertEquals("HelloWorldPortlet", ps.getDisplayName().getValue()); 33 34 ps = getHelloWorldPortlet("fr"); 35 assertEquals("SalutLeMondePortlet", ps.getDisplayName().getValue()); 36 } 37 38 public void testGetTitle() throws Exception { 39 PortletDescription ps = getHelloWorldPortlet("en"); 40 assertEquals("HelloWorld title", ps.getTitle().getValue()); 41 42 ps = getHelloWorldPortlet("fr"); 43 assertEquals("Bonjour le monde Portlet", ps.getTitle().getValue()); 44 } 45 46 public void testGetShortTitle() throws Exception { 47 PortletDescription ps = getHelloWorldPortlet("en"); 48 assertEquals("Hello World", ps.getShortTitle().getValue()); 49 50 ps = getHelloWorldPortlet("fr"); 51 assertEquals("Bonjour", ps.getShortTitle().getValue()); 52 } 53 54 public void testGetKeyWords() throws Exception { 55 PortletDescription ps = getHelloWorldPortlet("en"); 56 assertEquals("sample", ps.getKeywords(0).getValue()); 57 assertEquals("hello", ps.getKeywords(1).getValue()); 58 59 ps = getHelloWorldPortlet("fr"); 60 assertEquals("exemple", ps.getKeywords(0).getValue()); 61 assertEquals("bonjour", ps.getKeywords(1).getValue()); 62 } 63 64 public void testGetPortletHandle() throws Exception { 65 PortletDescription ps = getHelloWorldPortlet("en"); 66 assertEquals("hello/HelloWorld", ps.getPortletHandle()); 67 } 68 69 public void testGetGroupId() throws Exception { 70 PortletDescription ps = getHelloWorldPortlet("en"); 71 assertEquals("hello", ps.getGroupID()); 72 } 73 74 public void testGetMarkup() throws Exception { 75 PortletDescription ps = getHelloWorldPortlet("en"); 76 MarkupType mT = ps.getMarkupTypes(0); 77 78 assertEquals("text/html", mT.getMimeType()); 79 assertEquals("wsrp:config", mT.getModes(0)); 80 assertEquals("wsrp:help", mT.getModes(2)); 81 assertEquals("wsrp:minimized", mT.getWindowStates(0)); 82 assertEquals("wsrp:normal", mT.getWindowStates(1)); 83 assertEquals("wsrp:maximized", mT.getWindowStates(2)); 84 assertEquals("wsrp:half-page", mT.getWindowStates(3)); 85 assertEquals("en", mT.getLocales()[0]); 86 } 87 88 public void testPortletNeedsSecureTransportation() throws Exception { 89 PortletDescription ps = getHelloWorldPortlet("en"); 90 assertEquals(false, ps.getDefaultMarkupSecure().booleanValue()); 91 assertEquals(false, ps.getOnlySecure().booleanValue()); 92 } 93 94 public void testRequiresRegistration() throws Exception { 95 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 96 getServiceDescription.setDesiredLocales(new String []{"en"}); 97 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 98 assertEquals(true, sd.isRequiresRegistration()); 99 } 100 101 public void testGetCustomModes() throws Exception { 102 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 103 getServiceDescription.setDesiredLocales(new String []{"en"}); 104 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 105 ItemDescription[] iDArray = sd.getCustomModeDescriptions(); 106 107 ItemDescription iD = iDArray[0]; 108 assertEquals("config",iD.getItemName()); 109 assertEquals("en",iD.getDescription().getLang()); 110 assertEquals("to let admin config portlets",iD.getDescription().getValue()); 111 112 iD = iDArray[1]; 113 assertEquals("config",iD.getItemName()); 114 assertEquals("fr",iD.getDescription().getLang()); 115 } 116 117 public void testGetCustomWindowStates() throws Exception { 118 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 119 getServiceDescription.setDesiredLocales(new String []{"en"}); 120 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 121 ItemDescription[] iDArray = sd.getCustomWindowStateDescriptions(); 122 123 ItemDescription iD = iDArray[0]; 124 assertEquals("half-page",iD.getItemName()); 125 assertEquals("en",iD.getDescription().getLang()); 126 assertEquals("portlet takes half of the page",iD.getDescription().getValue()); 127 128 iD = iDArray[1]; 129 assertEquals("half-page",iD.getItemName()); 130 assertEquals("fr",iD.getDescription().getLang()); 131 assertEquals("portlet sure une demi page",iD.getDescription().getValue()); 132 133 iD = iDArray[2]; 134 assertEquals("max-per-column",iD.getItemName()); 135 assertEquals("en",iD.getDescription().getLang()); 136 assertEquals("portlet the whole column",iD.getDescription().getValue()); 137 } 138 139 public void testGetSupportedLocales() throws Exception { 140 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 141 getServiceDescription.setDesiredLocales(new String []{"en"}); 142 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 143 String [] localesArray = sd.getLocales(); 144 assertEquals("en", localesArray[0]); 145 assertEquals("fr", localesArray[1]); 146 } 147 148 public void testGetUserAttributes() throws Exception { 149 PortletDescription ps = getHelloWorldPortlet("en"); 150 assertEquals("workInfo/telephone", ps.getUserProfileItems(0)); 151 } 152 153 private PortletDescription getHelloWorldPortlet(String locale) throws Exception { 154 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 155 getServiceDescription.setDesiredLocales(new String []{locale}); 156 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 157 PortletDescription[] psArray = sd.getOfferedPortlets(); 158 for (int i = 0; i < psArray.length; i++) { 159 if("hello/HelloWorld".equals(psArray[i].getPortletHandle())) 160 return psArray[i]; 161 } 162 return null; 163 } 164 165 } 166 | Popular Tags |