Properties Parser Design

Design

A Testify Properties Parser service bundle is a packaged section of code that implements the BundleActivator and PropertiesParser Interfaces. Any unit testing is contained within this source code. Generally, the source code will consist of one java class (that runs the specific Properties Parser), a set of unit tests, and a pom file.

PropertiesParser Interface

The PropertiesParser interface provides one method shown below. It takes in a String of the location of the configuration file and sends a Test Properties Object containing the parsed properties back to the engine.

PropertiesParser
public TestProperties getTestProperties(String configFile)

BundleActivator Interface

The bundle activator interface provides two methods, start and stop. These methods are run when the bundle is started or stopped by the engine. The stop method can be left blank. The start method is used to register the Properties Parser service so that it can be called by the Properties Parser Handler. Below is the code needed to implement these methods and register the service. Replace {PROPERTIESPARSER_CLASS_NAME} with the name of the class followed by "()".

BundleActivator
@Override
public void start(BundleContext bundleContext) throws Exception {

	//Register the Properties Parser service
	bundleContext.registerService(PropertiesParser.class.getName(), new {PROPERTIESPARSER_CLASS_NAME}, null);

}
 
@Override
public void stop(BundleContext bundleContext) throws Exception {
}

POM File

Below is a POM file template for a Testify Properties Parser. The variables in "[ ]" will change depending on the specific Properties Parser, the creator's organization, and the version of Testify core. Additional dependencies may be needed depending on the Properties Parser. Also, under the maven-bundle-plugin, package exports, embedded dependencies, additional package imports, and other properties may be needed depending on the Properties Parser.

POM File
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.codice.testify</groupId>
        <artifactId>testify-parent</artifactId>
        <version>[PARENT_VERSION]</version>
    </parent>

    <groupId>org.codice.testify.propertiesparsers</groupId>
    <artifactId>[ARTIFACT]</artifactId>
    <version>[VERSION]</version>
    <packaging>bundle</packaging>
    <name>[ACTION NAME]</name>
    
	<scm>
        <connection>[CONNECTION]</connection>
        <developerConnection>[DEVELOPER_CONNECTION]</developerConnection>
        <url>[URL]</url>
    </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.compiler.plugin>3.1</version.compiler.plugin>
 
        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>1.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codice.testify</groupId>
            <artifactId>testify-core</artifactId>
            <version>[TESTIFY_CORE_VERSION]</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.5.3</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                        <Bundle-Description>[DESCRIPTION]</Bundle-Description>
                        <Bundle-Vendor>[CREATOR_ORGANIZATION]</Bundle-Vendor>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Bundle-Activator>[PACKAGE].[CLASSNAME]</Bundle-Activator>
                        <Import-Package>
                            org.codice.testify.objects,
                            org.codice.testify.propertiesParsers,
                            org.osgi.framework
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>