Testing extension point implementation classes
Ensure that you unit test your extension point implementation code before you deploy the code to the production environment. The implementation of the Java™ methods can be unit that is tested by adding the main() method to the implementation class or through unit testing frameworks like JUnits.
About this task
You can create a JUnit test against each of the methods in the implemented interface. The methods for extension point interfaces take arguments through the argument interface. When extension points are started in real time, IBM® InfoSphere® Master Data Management Collaboration Server passes the populated argument objects to the extension point method. However, when you are unit testing, this is not the case.
You can use the mock object testing design pattern to provide these argument objects during testing. This means that you can create a mock implementation of the argument objects that a method takes and pass an instance of that in the method call. The mock objects can be created manually or by using mock object frameworks like EasyMock or JMock.
public class ItemInitialload implements ImportFunction
{
public void doImport(ImportFunctionArguments args)
{
Context ctx = PIMContextFactory.getCurrentContext();
......
try {
ItemInitialload.mainProcess(ctx, hmArgs);
} catch (Exception e) {
e.printStackTrace();
}
}
//setup required parameters when invoking the program.
public static void main(String[] args)
{
try {
hmArgs = getArgs();
m_ctx = PIMContextFactory.getContext("user", "password",
"MyCompany");
mainProcess(m_ctx, hmArgs);
System.exit(0);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void mainProcess (Context m_ctx, HashMap<String,String>
hmArgs) throws Exception {
......
}
}