www.mockcentral.org mockcentral on sourceforge.net

the mockcentral editor eclipse plug-in

The MockCentralEditor Eclipse Plug-in provides an easy-to-use, fully featured editor for MockCentral configuration files that runs in Eclipse. It is designed to provide straightforward and intuitive controls and conforms to standard Eclipse editor behaviour and conventions. Installation is easy; just place the org.mockcentral.editor jar file into your plugins directory, restart Eclipse and you're ready to create and edit new MockCentral configuration files. Built on top of the MockCentralEditor-Core library, the plug-in makes extensive use of reflection to build mock objects and their method expections. Thus, any interface that you want to mock or any class you want to instantiate within your configuration files should be on the java build path of your project.

requirements

The MockCentral Plug-In requires java version 1.6 or higher and has been tested on Linux gtk2, Windows XP and OSX platforms with Eclipse versions 3.1.2 through 3.4.2

creating new configuration files

To create a new MockCentral configuration file, select "New..." and "MockCentral config file" from the file menu. A dialog will open allowing you to specify the file name and location and whether you want to open the editor on the file when finished.

opening and editing configuration files

To open a configuration file, select the file and choose "Open with..." and "MockCentral Editor" from the context menu. The plugin defines a distinct content type for MockCentral config files for which the editor is default (but any editor that can open xml files can also open them as well). Once the editor is open, you can use the various controls to start building your mock object libraries. The Outline view is linked to the editor, so using it to navigate through the file contents is quick and easy. The editor controls (for such things as adding new mock objects, setting fixture names, editing the parameters list of method expectations) are all designed to be very clear to use and obvious in purpose, so a detailed discussion of them has been omitted. Likewise, the user is prevented from doing things that would result in problems for the MockCentralServer (such as defining circular mock object references, duplicating JNDI names within fixtures, etc), so there is no official list of "don'ts" for using the editor.

creating new mock objects

Creating new mock objects is simple: within an open fixture, just click on the "Add.." button or use the "copy" and "paste" actions which will allow you to inherit all method expectations from a copied mock object defintion. PLEASE NOTE that any interface or class you want to reference in your configuration must be on the java build path of the enclosing project. Use the "Project...Properties...Java Build Path" menu sequence in Eclipse to add other projects, libraries and folders as necessary. ALSO NOTE: the MockCentral configuration file must reside within a Java Project only (not, for instance a Simple Project).

copying and pasting elements

Fixtures, mock objects and method expectations can easily be copied and pasted into other appropriate parts of a configuration file or among files generally. For example, you can use the context menu in a table displaying mock objects to copy one and paste it into another fixture or a fixture in another file. Both the Outline View and the various tables available in the editor offer this functionality.

creating new method expectations

When you click the "add.." button on the page used to edit the list of method expectations a wizard will open providing various options for generating new definitions: you can use the editor to auto-generate expectations for any or all interface or java.lang.Object methods (with default parameter and return values based on the method signature -- or simply null values) or you can manually enter a mocked method name. In each case, you can, of course, edit the generated data until the expectation(s) reflect(s) the behaviour, parameter values and expected method result you want.

preferences

There are several user-defined preferences for the editor, which you can access from the "Window/Preferences..." menu item:

a note about refactoring

Keep your configuration files up to date when you refactor classes by renaming or moving them. To do this, make sure when you rename or move a class, interface or package that you select the "update fully qualified name in Non-Java files" option.