Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mentawai.util
Class MockAction  view MockAction download MockAction.java

java.lang.Object
  extended byorg.mentawai.util.MockAction
All Implemented Interfaces:
org.mentawai.core.Action

public class MockAction
extends java.lang.Object
implements org.mentawai.core.Action

A mock for facilitating action testing. It internally creates mocks for the input, output, session and context.

Example:

Testing the without this mock:
 MyAction action = new MyAction();
 Input input = new InputMap();
 Output output = new OutputMap();
 Context session = new ContextMap();
 Context application = new ContextMap();
 action.setInput(input);
 action.setOutput(output);
 action.setSession(session);
 action.setApplication(application);
 input.setValue("asdasdas", someValue)/
 String result = action.execute();
 assertEqual(result, "balblablablal");
 assertEqual(output.getValue("asdasd"),asdasdasdasdas);
 
with the mock:
 MyAction action = new MyAction();
 MockAction mockAction = new MockAction(action);
 mockAction.getInput().setValue("asdsaxa", adsdasdas);
 String result = mockAction.execute();
 assertEqual(result, "balblablablal");
 assertEqual(mockAction.getOutput().getValue("asdasd"),asdasdasdasdas);
 


Field Summary
private  org.mentawai.core.Action action
           
 
Fields inherited from interface org.mentawai.core.Action
ERROR, SUCCESS
 
Constructor Summary
MockAction(org.mentawai.core.Action action)
           
MockAction(java.lang.Class klass)
           
 
Method Summary
 java.lang.String callInnerAction(java.lang.String innerAction)
           
 java.lang.String execute()
          Executes the action, returning a result.
 org.mentawai.core.Action getAction()
           
 org.mentawai.core.Context getApplication()
          Gets this action application context.
 org.mentawai.core.Input getInput()
          Gets the action input.
 java.util.Locale getLocale()
          Gets the use locale for this action.
private  java.lang.reflect.Method getMethod(java.lang.String innerAction)
           
 org.mentawai.core.Output getOutput()
          Gets the action output.
 org.mentawai.core.Context getSession()
          Gets this action session context.
private  void init()
           
 void setApplication(org.mentawai.core.Context application)
          Sets the application context for this action.
 void setInput(org.mentawai.core.Input input)
          Sets the input for this action.
 void setLocale(java.util.Locale locale)
          Sets the user locale for this action.
 void setOutput(org.mentawai.core.Output output)
          Sets the output for this action.
 void setSession(org.mentawai.core.Context session)
          Sets the session context for this action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

private org.mentawai.core.Action action
Constructor Detail

MockAction

public MockAction(org.mentawai.core.Action action)

MockAction

public MockAction(java.lang.Class klass)
Method Detail

init

private void init()

execute

public java.lang.String execute()
                         throws java.lang.Exception
Description copied from interface: org.mentawai.core.Action
Executes the action, returning a result.

Specified by:
execute in interface org.mentawai.core.Action

callInnerAction

public java.lang.String callInnerAction(java.lang.String innerAction)
                                 throws java.lang.Exception

getMethod

private java.lang.reflect.Method getMethod(java.lang.String innerAction)

getAction

public org.mentawai.core.Action getAction()

getApplication

public org.mentawai.core.Context getApplication()
Description copied from interface: org.mentawai.core.Action
Gets this action application context.

Specified by:
getApplication in interface org.mentawai.core.Action

setApplication

public void setApplication(org.mentawai.core.Context application)
Description copied from interface: org.mentawai.core.Action
Sets the application context for this action.

Specified by:
setApplication in interface org.mentawai.core.Action

getInput

public org.mentawai.core.Input getInput()
Description copied from interface: org.mentawai.core.Action
Gets the action input.

Specified by:
getInput in interface org.mentawai.core.Action

setInput

public void setInput(org.mentawai.core.Input input)
Description copied from interface: org.mentawai.core.Action
Sets the input for this action.

Specified by:
setInput in interface org.mentawai.core.Action

getLocale

public java.util.Locale getLocale()
Description copied from interface: org.mentawai.core.Action
Gets the use locale for this action.

Specified by:
getLocale in interface org.mentawai.core.Action

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: org.mentawai.core.Action
Sets the user locale for this action.

Specified by:
setLocale in interface org.mentawai.core.Action

getOutput

public org.mentawai.core.Output getOutput()
Description copied from interface: org.mentawai.core.Action
Gets the action output.

Specified by:
getOutput in interface org.mentawai.core.Action

setOutput

public void setOutput(org.mentawai.core.Output output)
Description copied from interface: org.mentawai.core.Action
Sets the output for this action.

Specified by:
setOutput in interface org.mentawai.core.Action

getSession

public org.mentawai.core.Context getSession()
Description copied from interface: org.mentawai.core.Action
Gets this action session context.

Specified by:
getSession in interface org.mentawai.core.Action

setSession

public void setSession(org.mentawai.core.Context session)
Description copied from interface: org.mentawai.core.Action
Sets the session context for this action.

Specified by:
setSession in interface org.mentawai.core.Action