This chapter is intended for developers. There are no special prerequisites. Each part describes what a developer has to look at in specific for the OpenEngSB.
Following the guidelines of Maven Central, how a pom should be designed it is required to add the following tags into every and each pom file:
The following listings shows an example of these params for a typical OpenEngSB pom.
<modelVersion>4.0.0</modelVersion> <groupId>org.openengsb.core</groupId> <artifactId>openengsb-core-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <name>OpenEngSB :: Core :: Parent</name> <packaging>pom</packaging> <description>Parent project for all OpenEngSB Core classes</description> <url>http://www.openengsb.org</url> <licenses> <license> <name>Apache 2</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo</distribution> </license> </licenses> <scm> <connection>scm:git:git://github.com/openengsb/openengsb.git</connection> <developerConnection>scm:git:git@github.com:openengsb/openengsb.git</developerConnection> <url>http://github.com/openengsb/openengsb</url> </scm>
To use the same dependencies as the OPENENGSB project you have to import the shared-plugin-settings project into your dependency management section:
<dependencyManagement> <dependencies> <dependency> <groupId>org.openengsb.build</groupId> <artifactId>shared-plugin-settings</artifactId> <version>Version of OPENENGSB you use</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
This will import all the dependencies with the correct versions into the dependencyManagement section. You can now define the dependencies shared between your project and OPENENGSB in your dependencies section without setting the version.
If you want to test if specific text is shown in the UI extend LocalisedTest in your UI Test. The constructor automatically loads the correct ResourceBundle and via localization(String resourcename) you can load a localized version of a specific resource string. The default locale is used as to match the locale used by WicketTester.
The following listings show how to write tests according to the OpenEngSB coding style
@Test public void testBehaviorX_shouldReturnY() { //CODE }In addition to the normal behaviour the coder should also provide a test for the failure behavior.
@Test(expected = BehaviorException.class) public void testBehaviorX_shouldThrowException() { //CODE }
The OpenEngSB developers decided to use following testing tools:
![]() | Caution |
---|---|
Instead of using Assert.assertThat(....) or Mockito.mock(...) we use the static import variant: assertThat(...) and mock(...) |
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.is; [...] assertThat(realValue, is(expectedValue));
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockito.Mockito.times; [...] //mocking code ExampleMock exampleMock = mock(ExampleMock.class); when(exampleMock.methodX()).thenReturn(y); [...] //testing code //verification verify(manager, times(1).methodX(Y);