| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbiz.xsoftware.mock.MockObjectFactory
public abstract class MockObjectFactory
The factory class used to create MockObjects from one or many interfaces.
| 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 | 
|---|
public static MockObject createMock(String id,
                                    Class<?> theInterface)
 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);
 
theInterface - you want the mockObject to implement.id - The object id used in the logs so you can differentiate mockobjects
public static MockObject createMock(Class<?> theInterface)
 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);
 
theInterface - you want the mockObject to implement.
public static MockObject createMock(Class<?>[] interfaces)
 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);
 
interfaces - The interfaces you want the mockObject to implement.
public static MockObject createMock(String id,
                                    Class<?>[] interfaces)
 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);
 
interfaces - The interfaces you want the mockObject to implement.
public abstract MockObject createMockImpl(String id,
                                          Class<?>[] interfaces)
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||