biz.xsoftware.mock
Class MockObjectFactory

java.lang.Object
  extended by biz.xsoftware.mock.MockObjectFactory

public abstract class MockObjectFactory
extends Object

The factory class used to create MockObjects from one or many interfaces.

Author:
Dean Hiller

Method Summary
static MockObject createMock(Class<?> theInterface)
          Creates a MockObject based on your interface.
static MockObject createMock(Class<?>[] interfaces)
          Creates a MockObject based on your interface.
static MockObject createMock(String id, Class<?> theInterface)
          Creates a MockObject based on your interface.
static MockObject createMock(String id, Class<?>[] interfaces)
          Creates a MockObject based on your interface.
abstract  MockObject createMockImpl(String id, Class<?>[] interfaces)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createMock

public static MockObject createMock(String id,
                                    Class<?> theInterface)
Creates a MockObject based on your interface. One way to use it for a mock listener is below.

See examples for other non-listener mock objects.
 MockSuperclass mockActionList = MockObjectFactory.createMock(ActionListener.class);
 button.addActionListener((ActionListener)mockActionList);
 button.setPressed(true);
 Object o = mockActionList.expectEvent("actionPerformed");
 ActionEvent evt = (ActionEvent)o;
 assertEquals(evt.getSource(), button);
 

Parameters:
theInterface - you want the mockObject to implement.
id - The object id used in the logs so you can differentiate mockobjects
Returns:
The mockObject that can receive events, and JUnit test cases can call expect event on.

createMock

public static MockObject createMock(Class<?> theInterface)
Creates a MockObject based on your interface. One way to use it for a mock listener is below.

See examples for other non-listener mock objects.
 MockSuperclass mockActionList = MockObjectFactory.createMock(ActionListener.class);
 button.addActionListener((ActionListener)mockActionList);
 button.setPressed(true);
 Object o = mockActionList.expectEvent("actionPerformed");
 ActionEvent evt = (ActionEvent)o;
 assertEquals(evt.getSource(), button);
 

Parameters:
theInterface - you want the mockObject to implement.
Returns:
The mockObject that can receive events, and JUnit test cases can call expect event on.

createMock

public static MockObject createMock(Class<?>[] interfaces)
Creates a MockObject based on your interface. One way to use it for mock listeners is below(This can help guarantee order between two different listeners).

See examples for other non-listener mock objects.
 Class[] c = new Class[] {ActionListener.class, WindowListener.class};
 MockSuperclass mockList = MockObjectFactory.createMock(c);
 button.addActionListener((ActionListener)mockList);
 window.addWindowListener((WindowListener)mockList);
 button.setPressed(true);
 Object o = mockList.expectEvent("actionPerformed");
 ActionEvent evt = (ActionEvent)o;
 assertEquals(evt.getSource(), button);
 

Parameters:
interfaces - The interfaces you want the mockObject to implement.
Returns:
The mockObject that can receive events, and JUnit test cases can call expect event on.

createMock

public static MockObject createMock(String id,
                                    Class<?>[] interfaces)
Creates a MockObject based on your interface. One way to use it for mock listeners is below(This can help guarantee order between two different listeners).

See examples for other non-listener mock objects.
 Class[] c = new Class[] {ActionListener.class, WindowListener.class};
 MockSuperclass mockList = MockObjectFactory.createMock(c);
 button.addActionListener((ActionListener)mockList);
 window.addWindowListener((WindowListener)mockList);
 button.setPressed(true);
 Object o = mockList.expectEvent("actionPerformed");
 ActionEvent evt = (ActionEvent)o;
 assertEquals(evt.getSource(), button);
 

Parameters:
interfaces - The interfaces you want the mockObject to implement.
Returns:
The mockObject that can receive events, and JUnit test cases can call expect event on.

createMockImpl

public abstract MockObject createMockImpl(String id,
                                          Class<?>[] interfaces)