Skip to content

Commit

Permalink
Fix issue #7 and add new integration test for FSM
Browse files Browse the repository at this point in the history
  • Loading branch information
zaplatynski committed May 19, 2016
1 parent d37e4f3 commit df7b3df
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 17 deletions.
4 changes: 0 additions & 4 deletions console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@
<name>${display.name} Console</name>
<packaging>jar</packaging>

<build>
<finalName>${jar.finalName}</finalName>
</build>

</project>
14 changes: 14 additions & 0 deletions fsm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
Expand Down
3 changes: 0 additions & 3 deletions fsm/src/assembly/fsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
<include>${project.groupId}:toolbar</include>
</includes>
<useTransitiveFiltering>true</useTransitiveFiltering>
<outputFileNameMapping>
${project.groupId}-${project.artifactId}-${project.version}
</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
4 changes: 2 additions & 2 deletions fsm/src/main/resources/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</public>
</components>
<resources>
<resource scope="module">lib/${project.groupId}-console-${project.version}.jar</resource>
<resource scope="module">lib/${project.groupId}-toolbar-${project.version}.jar</resource>
<resource scope="module">lib/console-${project.version}.jar</resource>
<resource scope="module">lib/toolbar-${project.version}.jar</resource>
</resources>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package de.marza.firstspirit.modules.logging.fsm;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;

import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertTrue;


public class FsmIT {

private static final String MODULE_DESCRIPTOR = "META-INF/module.xml";
private static Properties pomProperties;

@Rule
public ErrorCollector errors = new ErrorCollector();

@BeforeClass
public static void setUpBefore() throws Exception {
pomProperties = new Properties();
final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
final InputStream inputStream = systemClassLoader.getResourceAsStream("moduleTest.properties");
pomProperties.load(inputStream);
}

/**
* Check if FSM is valid
*/
@Test
public void testisFSMValid() throws Exception {
final File directory = new File("target");
final Collection<File> files = FileUtils.listFiles(directory, new WildcardFileFilter("*.fsm"), null);
assertTrue("FSM doesn't contain any files", files.iterator().hasNext());
if (files.iterator().hasNext()) {
final ZipFile _fsmZip = new ZipFile(files.iterator().next());
final ZipEntry license = _fsmZip.getEntry("LICENSE");
errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", license,
is(notNullValue()));
final ZipEntry moduleXML = _fsmZip.getEntry(MODULE_DESCRIPTOR);
errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", moduleXML,
is(notNullValue()));
final ZipEntry consoleLib = _fsmZip.getEntry("lib/console-"
+ pomProperties.getProperty("version") + ".jar");
errors.checkThat("Couldn't find lib in fsm file", consoleLib, is(notNullValue()));
final ZipEntry toolbarLib = _fsmZip.getEntry("lib/toolbar-"
+ pomProperties.getProperty("version") + ".jar");
errors.checkThat("Couldn't find lib in fsm file", toolbarLib, is(notNullValue()));
}

}

}
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<global.version>1.0.8</global.version>
<global.version>1.0.9</global.version>
<display.name>The Second-Hand Log</display.name>
<jar.finalName>${project.groupId}-${project.artifactId}-${project.version}</jar.finalName>
<module.description>A tiny extension for the FirstSpirit CMS for displaying a log console
</module.description>
<main.developer>Marian Zaplatynski</main.developer>
Expand Down
7 changes: 1 addition & 6 deletions toolbar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
</dependency>

</dependencies>

<build>
<finalName>${jar.finalName}</finalName>
</build>



<profiles>
<profile>
<id>FirstSpiritVersion</id>
Expand Down

0 comments on commit df7b3df

Please sign in to comment.