​​​IBM ACE v12: Adding policies to your Test Case​ 

Introduction

In certain scenarios, you may require a policy to effectively test your nodes. This could be a database connection policy or a custom-defined policy. This post outlines the steps involved in enabling such policies.

Prerequisites

  • Existing work directory (I will call it “TEST_SERVER”)
  • Policy projects
  • Test project

Configure an existing work directory for your test project

If you don’t configure an existing work directory for your test project, a temporary test project will be generated for your test project during the execution of the test cases. Before you start your run, the toolkit will check if there is already a work directory. If so, it will first clear the existing the existing work directory and generate a new one. This prevents you from adding policies to your test project. 

The solution for this is to configure an exiting work directory for your test project. You can do this by:

  1. Right click on your test project
  2. Click on: Run As -> Run Configurations
  3. In the tab Integration Server JUnit -> <name of your test project>
  4. Select: Use an existing work directory and browse to your work directory

Test Server Configuration

The initial step is to incorporate the necessary policy into your test server used for unit testing. For this example, we’ve moved the “GlobalRegistry” and “DefaultPolicies” to the overrides folder within our test service. Refer to the screenshot below:

Java Code Implementation

Next, include the following code snippet within your test case:

public void Dummy_TestCase_001() throws TestException {
//Get Policy
try {
MbPolicy pol = MbPolicy.getPolicy(“UserDefined”, “{DefaultPolicies}:UserDefinedPolicy”);
MbPolicy pol2 = MbPolicy.getPolicy(“JDBCProviders”, “{GlobalPolicies}:DbPolicy”);
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Define the SpyObjectReference
SpyObjectReference nodeReference = new SpyObjectReference().application(“App_Name”)
.messageFlow(“broker.schema.message.flow”).node(“Node-Name”);

Clean Project

Before executing your test case, ensure a clean project build.

Conclusion

By following these steps, you can effectively add policies to your test cases, enabling comprehensive testing of your nodes.

Note:

  • Replace placeholders like “JDBCProviders”, “{ PolicyProject }: CustomPolicy “, “App_Name”, “broker.schema.message.flow”, and “Node-Name” with appropriate values specific to your environment.
  • Consider adding error handling and logging for robust test cases.

 

IBM Integration Specialists

Enabling Digital Transformations.

Let's get in touch...

info@integrationdesigners.com

​ Find us here

Belgium
Veldkant 33B
2550 Kontich

Netherlands
Cruquiusweg 110F
1019 AK Amsterdam

© 2019 Integration Designers - Privacy policy - Part of Cronos Group CBX