    1   /* Copyright 2004, 2005 Acegi Technology Pty Limited
    2    *
    3    * Licensed under the Apache License, Version 2.0 (the "License");
    4    * you may not use this file except in compliance with the License.
    5    * You may obtain a copy of the License at
    6    *
    7    *     http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    * Unless required by applicable law or agreed to in writing, software
    10   * distributed under the License is distributed on an "AS IS" BASIS,
    11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12   * See the License for the specific language governing permissions and
    13   * limitations under the License.
    14   */
    15
    16  package org.acegisecurity.event.authentication;
    17
    18  import junit.framework.TestCase;
    19
    20  import org.acegisecurity.Authentication;
    21  import org.acegisecurity.LockedException;
    22  import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
    23
    24
    25  /***
    26   * Tests {@link LoggerListener}.
    27   *
    28   * @author Ben Alex
    29   * @version $Id: LoggerListenerTests.java,v 1.2 2005/11/17 00:56:47 benalex Exp $
    30   */
    31  public class LoggerListenerTests extends TestCase {
    32      //~ Methods ================================================================
    33
    34      public final void setUp() throws Exception {
    35          super.setUp();
    36      }
    37
    38      public static void main(String[] args) {
    39          junit.textui.TestRunner.run(LoggerListenerTests.class);
    40      }
    41
    42      public void testLogsEvents() {
    43          AuthenticationFailureDisabledEvent event = new AuthenticationFailureDisabledEvent(getAuthentication(),
    44                  new LockedException("TEST"));
    45          LoggerListener listener = new LoggerListener();
    46          listener.onApplicationEvent(event);
    47          assertTrue(true);
    48      }
    49
    50      private Authentication getAuthentication() {
    51          UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("Principal",
    52                  "Credentials");
    53          authentication.setDetails("127.0.0.1");
    54
    55          return authentication;
    56      }
    57  }