1 17 package org.alfresco.example.webservice.authoring; 18 19 import javax.xml.rpc.ServiceException ; 20 21 import junit.framework.AssertionFailedError; 22 23 import org.alfresco.example.webservice.BaseWebServiceSystemTest; 24 import org.alfresco.example.webservice.content.ContentServiceLocator; 25 import org.alfresco.example.webservice.content.ContentServiceSoapBindingStub; 26 import org.alfresco.example.webservice.types.Content; 27 import org.alfresco.example.webservice.types.ContentFormat; 28 import org.alfresco.example.webservice.types.ParentReference; 29 import org.alfresco.example.webservice.types.Predicate; 30 import org.alfresco.example.webservice.types.Reference; 31 import org.apache.axis.EngineConfiguration; 32 import org.apache.axis.configuration.FileProvider; 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 36 public class AuthoringServiceSystemTest extends BaseWebServiceSystemTest 37 { 38 private static Log logger = LogFactory.getLog(AuthoringServiceSystemTest.class); 39 40 private static String versionedNodeId; 41 private static final String INITIAL_VERSION_CONTENT = "Content of the initial version"; 42 private static final String FIRST_VERSION_CONTENT = "Content of the first version"; 43 private static final String SECOND_VERSION_CONTENT = "The content for the second version is completely different"; 44 private static final String THIRD_VERSION_CONTENT = "The third version is short!"; 45 46 private AuthoringServiceSoapBindingStub authoringService; 47 48 @Override 49 protected void setUp() throws Exception 50 { 51 super.setUp(); 52 53 try 54 { 55 EngineConfiguration config = new FileProvider(getResourcesDir(), "client-deploy.wsdd"); 56 this.authoringService = (AuthoringServiceSoapBindingStub)new AuthoringServiceLocator(config).getAuthoringService(); 57 } 58 catch (ServiceException jre) 59 { 60 if (jre.getLinkedCause() != null) 61 { 62 jre.getLinkedCause().printStackTrace(); 63 } 64 65 throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 66 } 67 68 assertNotNull("authoringService is null", this.authoringService); 69 70 this.authoringService.setTimeout(60000); 72 } 73 74 public void testCreateNode() throws Exception 75 { 76 ContentServiceSoapBindingStub contentService = null; 77 try 78 { 79 EngineConfiguration config = new FileProvider(getResourcesDir(), "client-deploy.wsdd"); 80 contentService = (ContentServiceSoapBindingStub)new ContentServiceLocator(config).getContentService(); 81 assertNotNull("contentService is null", contentService); 82 contentService.setTimeout(60000); 83 } 84 catch (Exception e) 85 { 86 fail("Could not instantiate the content service" + e.toString()); 87 } 88 89 ParentReference root = new ParentReference(); 91 root.setStore(STORE); 92 root.setUuid(companyHomeId); 93 94 String mimetype = "text/plain"; 95 Content content = contentService.create(root, "version-test.txt", new ContentFormat(mimetype, "UTF-8"), 96 INITIAL_VERSION_CONTENT.getBytes()); 97 assertNotNull("returned content should not be null", content); 98 assertNotNull("format should not be null", content.getFormat()); 99 assertEquals("Mimetype should match what was sent", mimetype, content.getFormat().getMimetype()); 100 versionedNodeId = content.getReference().getUuid(); 101 logger.debug("created new content with id: " + versionedNodeId); 102 } 103 104 109 public void testCheckout() throws Exception 110 { 111 Reference ref = new Reference(); 112 ref.setStore(STORE); 113 ref.setUuid(versionedNodeId); 114 Predicate predicate = new Predicate(); 115 predicate.setNodes(new Reference[] {ref}); 116 117 122 CheckoutResult result = this.authoringService.checkout(predicate, null); 123 assertNotNull("The result should not be null", result); 124 assertEquals("There should only be 1 original reference", 1, result.getOriginals().length); 125 assertEquals("There should only be 1 working copy reference", 1, result.getWorkingCopies().length); 126 } 127 128 133 public void testCheckin() throws Exception 134 { 135 try 136 { 137 this.authoringService.checkin(null, null, false); 138 fail("This method should have thrown an authoring fault"); 139 } 140 catch (AuthoringFault af) 141 { 142 } 144 } 145 146 151 public void testCheckinExternal() throws Exception 152 { 153 try 154 { 155 this.authoringService.checkinExternal(null, null, false, null, null); 156 fail("This method should have thrown an authoring fault"); 157 } 158 catch (AuthoringFault af) 159 { 160 } 162 } 163 164 169 public void testCancelCheckout() throws Exception 170 { 171 try 172 { 173 this.authoringService.cancelCheckout(null); 174 fail("This method should have thrown an authoring fault"); 175 } 176 catch (AuthoringFault af) 177 { 178 } 180 } 181 182 187 public void testLock() throws Exception 188 { 189 try 190 { 191 this.authoringService.lock(null, false, null); 192 fail("This method should have thrown an authoring fault"); 193 } 194 catch (AuthoringFault af) 195 { 196 } 198 } 199 200 205 public void testUnlock() throws Exception 206 { 207 try 208 { 209 this.authoringService.unlock(null, false); 210 fail("This method should have thrown an authoring fault"); 211 } 212 catch (AuthoringFault af) 213 { 214 } 216 } 217 218 223 public void testGetLockStatus() throws Exception 224 { 225 try 226 { 227 this.authoringService.getLockStatus(null); 228 fail("This method should have thrown an authoring fault"); 229 } 230 catch (AuthoringFault af) 231 { 232 } 234 } 235 236 241 public void testCreateVersion() throws Exception 242 { 243 try 244 { 245 this.authoringService.createVersion(null, null, false); 246 fail("This method should have thrown an authoring fault"); 247 } 248 catch (AuthoringFault af) 249 { 250 } 252 } 253 254 259 public void testGetVersionHistory() throws Exception 260 { 261 try 262 { 263 this.authoringService.getVersionHistory(null); 264 fail("This method should have thrown an authoring fault"); 265 } 266 catch (AuthoringFault af) 267 { 268 } 270 } 271 272 277 public void testRevertVersion() throws Exception 278 { 279 try 280 { 281 this.authoringService.revertVersion(null, null); 282 fail("This method should have thrown an authoring fault"); 283 } 284 catch (AuthoringFault af) 285 { 286 } 288 } 289 290 295 public void testDeleteAllVersions() throws Exception 296 { 297 try 298 { 299 this.authoringService.deleteAllVersions(null); 300 fail("This method should have thrown an authoring fault"); 301 } 302 catch (AuthoringFault af) 303 { 304 } 306 } 307 } 308 | Popular Tags |