Testing your connector
You can test the newly built connector to check the code for errors before and after the deployment. The test results help you troubleshoot errors early in the connector development process. This prevents errors when using the connector.
To reduce the possibility of errors while building a connector, refer Best practices for connector development.
Before you begin
-
Install a Runtime in the
<atom_installation_directory>on a computer you can access.For more details on setting up a Runtime, refer to Basic runtime setup page.
-
If you use Eclipse, put the source code for your container implementation in an Eclipse project named
<CONNECTOR_IMPL>. -
Upload your connector files to a connector group and specify the connector name and label. The
<connector_type>, which serves as the destination directory for the connector on your Runtime, is automatically generated based on the specified connector name, label, and account name. -
Put breakpoints in your code wherever it makes sense. A starting point is to put them in your browser or connector implementations because they are entry points to your connector. Then, interact with your connector through the interface by browsing your connector for operations or by running a process that uses your connector.
The first time you browse a connector through your Runtime, the connector archive file is automatically downloaded to the <atom_installation_directory>\connector\<connector_type> directory. Replace the connector archive file in this directory with newer versions for faster development.
Automated unit, functional, and integration testing
The Connector SDK artifacts contain the connector-sdk-test-util.jar (refer to the Javadocs). There are a variety of classes in the jar, but the ConnectorTester class is the primary class. Use this class to set up an automated unit, functional, and integration testing for a connector implementation. Refer to the ExampleConnectorTest.java:
public class ExampleConnectorTest
{
public void testGetOperation() throws Exception
{
ExampleConnector connector = new ExampleConnector();
ConnectorTester tester = new ConnectorTester(connector);
// setup the operation context for a GET operation on an object with type "SomeType"
tester.setOperationContext(OperationType.GET, null, null, "SomeType", null);
// ... setup the expected output ...
List<SimpleOperationResult> expectedResults = ...;
tester.testExecuteGetOperation("37", expectedResults);
}
}
Test a connector using remote debugging
By setting up remote debugging, you can remotely test and debug your connector.
Set up remote debugging using custom system properties (Preferred method)
Add the following custom system properties. Refer to the Properties panel, Custom tab topic for more information.
-Xdebug
-Xnoagent
-Djava.compiler=NONE
-Xrunjdwp:transport=dt\_socket,server=y,suspend=n,address=5005
Set up remote debugging using atom.vmoptions (Alternative method)
-
Open the
<atom_installation_directory>/bin/atom.vmoptionsfile. -
Add the following lines:
-Xdebug
-Xnoagent
-Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
- The final line specifies port 5005 for remote debugging. You can change the port number if you have port conflicts on your computer.
- Log messages are held in a buffer until an error occurs, then are output to the
<atom_installation_directory>/logs/YYYY_MM_DD.container.logfile.
Test a connector using remote Java application debugging configuration in Eclipse
You do not have to use Eclipse to remotely debug and test a connector. Eclipse is provided just as an example. Any modern integrated software development environment (IDE) such as IntelliJ, NetBeans, etc. can be used and should support remote debugging and testing.
By creating a remote Java application debugging configuration in Eclipse, you can remotely test and debug your connector. Refer to the Using the remote Java application launch configuration topic in the Eclipse help for more information. Although the referenced Eclipse help topic is version-specific, it should assist you with setting up Java's remote debugging. Another helpful resource is the Java Troubleshooting Guide, describing the options needed in the Atom's vmoptions.
- The Host should be the name of the computer where the Atom is installed (
localhostif the Atom is installed locally). The Host inatom.vmoptionsmust match the Host field value set in Eclipse (Connection Type). - The Port in Eclipse should be set to the port you specified in your
atom.vmoptionsfile, which was 5005 in the previous example. - If the remote debug configuration (Host, Port) is not correct in either the Atom (
atom.vmoptions) or client (Eclipse), you will receive a connection error when attempting to use the debug configuration.
References
For a better understanding on testing your connector using remote debugging, refer to the Testing connectors using remote debugging video tutorial.