Skip to content

Commit

Permalink
SEAMREPORTS-10: replaced JUnit with TestNG, added TestNG 'openoffice'…
Browse files Browse the repository at this point in the history
… group and an openoffice profile to isolate tests that require an installation of OpenOffice.
  • Loading branch information
agori committed Jun 25, 2011
1 parent 24ec409 commit 72f2071
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 59 deletions.
56 changes: 48 additions & 8 deletions impl/openoffice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
<packaging>jar</packaging>
<name>Seam Reports Implementation (OpenOffice Reporting)</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<excludedGroups>${testng.excludedGroups}</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<dependency>
Expand All @@ -26,7 +39,7 @@
<artifactId>jpdfunit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.odftoolkit</groupId>
<artifactId>simple-odf</artifactId>
Expand All @@ -51,14 +64,41 @@
<version>1.8.3</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14.6</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-testng</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
<repositories>
<repository>
<id>jodconverter</id>
<name>JODConverter Repository</name>
<url>http://maven.xwiki.org/externals/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>jodconverter</id>
<name>JODConverter Repository</name>
<url>http://maven.xwiki.org/externals/</url>
</repository>
</repositories>

<profiles>
<profile>
<id>openoffice</id>
<properties>
<testng.excludedGroups></testng.excludedGroups>
</properties>
</profile>
</profiles>

<properties>
<testng.excludedGroups>openoffice</testng.excludedGroups>
</properties>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import javax.inject.Inject;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.seam.reports.Report;
import org.jboss.seam.reports.ReportDefinition;
import org.jboss.seam.reports.ReportLoader;
Expand All @@ -42,12 +42,10 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odftoolkit.simple.TextDocument;
import org.testng.annotations.Test;

@RunWith(Arquillian.class)
public class OOReportsListTest {
public class OOReportsListTest extends Arquillian {

@Inject
@Resource("listTemplate.odf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import javax.inject.Inject;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.seam.reports.Report;
import org.jboss.seam.reports.ReportDefinition;
import org.jboss.seam.reports.ReportLoader;
Expand All @@ -42,12 +42,10 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odftoolkit.simple.TextDocument;
import org.testng.annotations.Test;

@RunWith(Arquillian.class)
public class OOReportsParagraphTest {
public class OOReportsParagraphTest extends Arquillian {

@Inject
@Resource("paragraphIteratorTemplate.odf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.inject.Inject;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.seam.reports.Report;
import org.jboss.seam.reports.ReportDefinition;
import org.jboss.seam.reports.ReportLoader;
Expand All @@ -43,13 +43,10 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odftoolkit.simple.TextDocument;
import org.testng.annotations.Test;

@RunWith(Arquillian.class)
public class OOReportsTableTest {
public class OOReportsTableTest extends Arquillian {

@Inject
@Resource("tableTemplate.odf")
Expand Down Expand Up @@ -138,8 +135,7 @@ public void hide() throws Exception {
assertTrue(tester.getContentRoot().toString().contains("Alberto Gori"));
}

@Test
@Ignore("Ignored until OpenOffice is installed on Hudson")
@Test(groups="openoffice")
public void fillRenderPdf() throws Exception {
Report report = processTemplate();
FileOutputStream fos = new FileOutputStream("target/output.pdf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
*/
package org.jboss.seam.reports.openoffice;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -29,7 +26,7 @@
import javax.inject.Inject;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.seam.reports.Report;
import org.jboss.seam.reports.ReportLoader;
import org.jboss.seam.reports.ReportRenderer;
Expand All @@ -39,16 +36,14 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odftoolkit.simple.TextDocument;
import org.testng.Assert;
import org.testng.annotations.Test;

import de.oio.jpdfunit.DocumentTester;
import de.oio.jpdfunit.document.util.TextSearchType;

@RunWith(Arquillian.class)
public class OOReportsTest {
public class OOReportsTest extends Arquillian {

@Inject
@Resource("varTemplate.odf")
Expand Down Expand Up @@ -90,8 +85,8 @@ public void fill() throws Exception {
fos.close();

TextDocument tester = TextDocument.loadDocument("target/output.odf");
assertTrue(tester.getContentRoot().toString().contains("Alberto Gori"));
assertFalse(tester.getStylesDom().toString().contains("facsimile.png"));
Assert.assertTrue(tester.getContentRoot().toString().contains("Alberto Gori"));
Assert.assertFalse(tester.getStylesDom().toString().contains("facsimile.png"));
}

@Test
Expand All @@ -106,12 +101,11 @@ public void addBackgroundImage() throws Exception {
fos.close();

TextDocument tester = TextDocument.loadDocument("target/outputWithBackgroundImage.odf");
assertTrue(tester.getContentRoot().toString().contains("Alberto Gori"));
assertTrue(tester.getStylesDom().toString().contains("facsimile.png"));
Assert.assertTrue(tester.getContentRoot().toString().contains("Alberto Gori"));
Assert.assertTrue(tester.getStylesDom().toString().contains("facsimile.png"));
}

@Test
@Ignore("Ignored until OpenOffice is installed on Hudson")
@Test(groups="openoffice")
public void renderToPDF() throws Exception {
OOSeamReport report = (OOSeamReport) reportLoader.loadReport(input);
Map<String, Object> parameters = new HashMap<String, Object>();
Expand All @@ -126,23 +120,5 @@ public void renderToPDF() throws Exception {
tester.assertContentContainsText("Hello Alberto Gori", TextSearchType.CONTAINS);
}

@Test
@Ignore("Ignored until OpenOffice is installed on Hudson")
public void renderToPDF_moreTimes(@Resource("varTemplate.odf") Instance<InputStream> varTemplate) throws Exception {

for (int i = 0; i < 10; ++i) {
InputStream templateStream = varTemplate.get();
OOSeamReport report = (OOSeamReport) reportLoader.loadReport(templateStream);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("name", "Alberto Gori");
report.getReportDefinition().fill(null, parameters);
report.getDelegate().addBackgroundImage(backgroundImage.toURI(), "Pictures/facsimile.png", "image/png");
FileOutputStream fos = new FileOutputStream("target/outputWithBackgroundImage" + i + ".pdf");
pdfRenderer.render(report, fos);
fos.close();
templateStream.close();

}
}

}

0 comments on commit 72f2071

Please sign in to comment.