1 17 package org.alfresco.webservice.test; 18 19 import junit.framework.AssertionFailedError; 20 import junit.framework.TestCase; 21 22 import org.alfresco.webservice.authentication.AuthenticationFault; 23 import org.alfresco.webservice.authentication.AuthenticationResult; 24 import org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub; 25 import org.alfresco.webservice.util.WebServiceFactory; 26 27 33 public class AuthenticationServiceSystemTest extends TestCase 34 { 35 40 public void testSuccessfulLogin() throws Exception 41 { 42 try 43 { 44 AuthenticationResult value = WebServiceFactory.getAuthenticationService().startSession("admin", "admin"); 45 assertNotNull("result must not be null", value); 46 System.out.println("ticket = " + value.getTicket()); 47 } 48 catch (AuthenticationFault error) 49 { 50 throw new AssertionFailedError("AuthenticationFault Exception caught: " + error); 51 } 52 } 53 54 59 public void testFailedLogin() throws Exception 60 { 61 try 62 { 63 WebServiceFactory.getAuthenticationService().startSession("wrong", "credentials"); 64 fail("The credentials are incorrect so an AuthenticationFault should have been thrown"); 65 } 66 catch (AuthenticationFault error) 67 { 68 } 70 } 71 72 77 public void testEndSession() throws Exception 78 { 79 AuthenticationServiceSoapBindingStub authenticationService = WebServiceFactory.getAuthenticationService(); 80 81 AuthenticationResult result = authenticationService.startSession("admin", "admin"); 83 authenticationService.endSession(result.getTicket()); 84 85 try 86 { 87 authenticationService.endSession("badSessionId"); 89 fail("An exception should have been thrown since we are trying to end an invalid session"); 90 } 91 catch (Throwable exception) 92 { 93 } 95 } 96 } 97 | Popular Tags |