1 36 package org.columba.ristretto.auth.mechanism; 37 38 import java.io.IOException ; 39 40 import junit.framework.TestCase; 41 42 import org.columba.ristretto.auth.AuthenticationException; 43 import org.columba.ristretto.auth.AuthenticationMechanism; 44 45 public class LoginMechanismTest extends TestCase { 46 47 public void testOK() throws IOException { 48 TestAuthServer server = new TestAuthServer(); 49 server.addCall("test".getBytes()); 50 server.addCall("foo".getBytes()); 51 AuthenticationMechanism mechanism = new LoginMechanism(); 52 53 try { 54 mechanism.authenticate(server,"test","foo".toCharArray()); 55 } catch (AuthenticationException e) { 56 e.printStackTrace(); 57 } 58 59 assertTrue( server.isOk()); 60 } 61 62 public void testFailure() throws IOException { 63 TestAuthServer server = new TestAuthServer(); 64 server.addCall("test".getBytes()); 65 server.addCall("oo".getBytes()); 66 AuthenticationMechanism mechanism = new LoginMechanism(); 67 68 try { 69 mechanism.authenticate(server,"test", "foo".toCharArray()); 70 } catch (AuthenticationException e) { 71 e.printStackTrace(); 72 } 73 74 assertFalse( server.isOk()); 75 } 76 } 77 78 79 | Popular Tags |