public class Login
extends java.lang.Object
Login.xml
specification.
This uses the State Pattern (a Design Pattern from Gamma, et al.) for its
implementation. All requests are delegated to an abstract State, which
has concrete subclasses LoggedOut and LoggedIn, which respond to certain
requests and ignore others. This is a good implementation strategy to
ensure that no information is returned by a service, when it is in an
inappropriate state.
Otherwise, a Map is used to represent the table of known users and
passwords; one of these corresponds to the valid test user from the
Login.xml
specification. This simple example performs
no other actions apart from controlling the logged state of the user.
Suggestions are given for how to modify the source code to seed faults deliberately, which will be detected during testing.
Constructor and Description |
---|
Login()
Creates this Login service.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getScenario()
Returns the last scenario that was enacted.
|
java.lang.String |
getState()
Returns the last state that was entered.
|
void |
login(java.lang.String username,
java.lang.String password)
Attempts to log a user into the system.
|
void |
logout()
Attempts to log a user out of the system.
|
void |
timeout()
Attempts to time a user out of the system.
|
public Login()
public java.lang.String getScenario()
public java.lang.String getState()
public void login(java.lang.String username, java.lang.String password)
username
- the user name.password
- the password.public void logout()
public void timeout()