2
* Copyright 1999-2002,2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
16
package org.apache.struts.webapp.example.memory;
18
import org.apache.struts.webapp.example.User;
19
import org.apache.struts.webapp.example.ExpiredPasswordException;
22
* <p>Help test exception handling by throwing exceptions when "magic" user names are requested.</p>
24
public final class TestUserDatabase extends MemoryUserDatabase {
28
* If the username is "expired" throw an ExpiredPasswordException
29
* to simulate a business exception.
30
* If the username is "arithmetic" throw an Aritmetic exception to
31
* simulate a system exception.
32
* Otherwise, delegate to MemoryDatabase.
36
public User findUser(String username) throws ExpiredPasswordException {
38
if ("expired".equals(username)) throw new ExpiredPasswordException("Testing ExpiredPasswordException ...");
39
if ("arithmetic".equals(username)) throw new ArithmeticException();
40
return super.findUser(username);