Development documentation

Schema location

The schema is located in the folder: src/main/resources.

Adding the schemas to the main project web site

During the site phase the schema is copied to the main site in the pineapple-project. The schema is copied to the directory /ns/plugin.

This is implemented in the pom.xml for the pineapple-infrastructure-test-plugin project

Generation of classes from XML schemas

The project uses JAXB through the Maven plugin cxf-xjc-plugin to generate classes from XML schema.

Customized package names

The generated classes are mapping into the package com.alpha.pineapple.model using the JAXB bindings file at: src/main/resources/bindings.xjb.

Customized type names

The JAXB bindings file also defines mappings of Schema type into Java types. The applied rule is to remove the postfixed Type from the Schema type in the corresponding Java types, i.e. from the schema type named NiceType a Java type named Nice is generated by JAXB.

Handling HTTPS connections

The test commands TestLoadBalancingCommand and TestStickynessCommand uses the command InvokeHttpGetMethodCommand for HTTP invocations.

The InvokeHttpGetMethodCommand uses the Apache HTTP Client. The HTTPClient is configured to used a SecureProtocolSocketFactory implementation which accepts all SSL certificates. The used implementation is EasySSLProtocolSocketFactory which is configured with the trust manager AcceptingSSLTrustManager which accepts all certificate chains.

The consequence is that certificate validation is disabled for SSL and all certificates are accepted. The certificates are not stored permanently in the key store of the used Java installation.

Internal configuration

Logging

The plugin uses Log4j for logging. Each project which links to this project must provide a Log4j configuration which is accessible at runtime as a result of the build process.

The plugin component does not provide a Log4j configuration as part of its production build. A log4j configuration file is defined in the project in the directory src/test/resources/log4.properties for testing.

The test configuration configures Log4j to write to the log file to ${user.home}/.pineapple/logs/pineapple.log.

Spring configuration file

The plugin contains a configuration file which defines a Spring application context. The Spring application context defines the input unmarshalling for the plugin. The file is located in src/main/resources/com.alpha.pineapple.plugin.net-config.xml.

JAXB binding file

JAXB bindings file used during generation of model objects from the plugin schema is located at src/main/resources/bindings.xjb.

Internationalization (I18N) configuration file

The plugin uses internationalization. Messages used by classes in the plugin are located in the file src/main/resources/com.alpha.pineapple.plugin.net-messages.properties.

Test

Unit test

Commonly used constants in the unit tests are defined in the class com.alpha.testutils.InfrastructurePluginTestConstants.

Integration test

Integration tests for the project are placed in the same packages as the unit tests. The integration tests are postfixed with IntegrationTest where the unit test have the postfix Test.

Example: The unit test for the class InvokeHTTPGetCommand is named InvokeHTTPGetCommandTest and the integration test is named InvokeHTTPGetCommandIntegrationTest.

Helper classes

Helper classes:

  • com.alpha.testutils.ObjectMotherContent
  • com.alpha.testutils.ObjectMotherHttpServer
com.alpha.testutils.ObjectMotherContent

com.alpha.testutils.ObjectMotherContent is an implementation of the ObjectMother pattern. The class provides helper functions for testing by creating content for operations.

com.alpha.testutils.ObjectMotherHttpServer

com.alpha.testutils.ObjectMotherHttpServer is an implementation of the ObjectMother pattern. The class provides helper functions for creating HTTP server instances.

The factory method ObjectMotherHttpServer.createHttpServer(..) creates a HTTP server which listens @ 127.0.0.1:3000. The HTTP server is configured with:

  • The com.alpha.testutils.jetty.SnifferServlet which responds at HTTP://127.0.0.1:3000/sniffer. All other URL's respond with an HTTP 404 status code.
  • The server also sets the JSESSIONID session tracking cookie when an valid URL is visited. Setting the cookie is implemented by the com.alpha.testutils.jetty.JSessionIdSetterFilter servlet filter.

The factory method ObjectMotherHttpServer.createHttpServerWithRedirect(..) a HTTP server which listens @ 127.0.0.1:3000. The HTTP server is configured with:

  • The com.alpha.testutils.jetty.SnifferServlet which responds at HTTP://127.0.0.1:3000/sniffer. All other URL's respond with an HTTP 404 status code.
  • The server also sets the JSESSIONID session tracking cookie when an valid URL is visited. Setting the cookie is implemented by the com.alpha.testutils.jetty.JSessionIdSetterFilter servlet filter.
  • A redirect servlet which redirects requests from HTTP://127.0.0.1:3000/redirect to HTTP://127.0.0.1:3000/sniffer. and returns HTTP 302 status code.

The class is used by integration tests. e.g. the class is used by the class InvokeHTTPGetCommandIntegrationTest.

Implementation

Plugin class

The package com.alpha.pineapple.plugin.net is the root package of the plugin and contains the plugin class PluginImpl.

Session class

No session class exists for this plugin.

Operation classes

The package com.alpha.pineapple.plugin.net.operation contains the operation classes for the plugin.

The plugin implement these default operations:

  • TestOperation implements the operation test.

Model helper classes

The package com.alpha.pineapple.plugin.net.model contains a helper class named AssertionValuesPropertyGetter which reads properties from the model class AssertionValues into a hash map and provides an interface for property lookup by name.

The class MapperImpl which implements the interface Mapper implements mapping between the schema generated classes to the command context using the proper command keys. The class is used by the operation class to map data to the command context prior to command invocation.