1 17 package org.alfresco.example.webservice.authentication; 18 19 import javax.xml.rpc.ServiceException ; 20 21 import junit.framework.AssertionFailedError; 22 23 import org.alfresco.util.BaseTest; 24 25 31 public class AuthenticationServiceSystemTest extends BaseTest 32 { 33 private AuthenticationServiceSoapBindingStub binding; 34 35 38 @Override 39 protected void setUp() throws Exception 40 { 41 super.setUp(); 42 try 43 { 44 this.binding = (AuthenticationServiceSoapBindingStub)new AuthenticationServiceLocator().getAuthenticationService(); 45 } 46 catch (ServiceException jre) 47 { 48 if (jre.getLinkedCause() != null) 49 { 50 jre.getLinkedCause().printStackTrace(); 51 } 52 53 throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 54 } 55 56 assertNotNull("binding is null", this.binding); 57 58 binding.setTimeout(60000); 60 } 61 62 67 public void testSuccessfulLogin() throws Exception 68 { 69 try 70 { 71 AuthenticationResult value = this.binding.authenticate("admin", "admin"); 72 assertNotNull("result must not be null", value); 73 System.out.println("ticket = " + value.getTicket()); 74 } 75 catch (AuthenticationFault error) 76 { 77 throw new AssertionFailedError("AuthenticationFault Exception caught: " + error); 78 } 79 } 80 81 86 public void testFailedLogin() throws Exception 87 { 88 try 89 { 90 AuthenticationResult result = this.binding.authenticate("wrong", "credentials"); 91 fail("The credentials are incorrect so an AuthenticationFault should have been thrown"); 92 } 93 catch (AuthenticationFault error) 94 { 95 } 97 } 98 } 99 | Popular Tags |