-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PDF Exporter unit test to help with #2093
- Loading branch information
Showing
4 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
modules/PreviewExport/src/test/java/org/gephi/io/exporter/preview/PDFExporterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.gephi.io.exporter.preview; | ||
|
||
import java.awt.Color; | ||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import org.gephi.graph.GraphGenerator; | ||
import org.gephi.preview.api.PreviewController; | ||
import org.gephi.preview.api.PreviewProperties; | ||
import org.gephi.preview.api.PreviewProperty; | ||
import org.gephi.preview.spi.Renderer; | ||
import org.gephi.project.api.Workspace; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.openide.util.Lookup; | ||
|
||
public class PDFExporterTest { | ||
|
||
@Test | ||
public void testPDFExporter() throws IOException { | ||
Workspace workspace = GraphGenerator.build().withWorkspace() | ||
.generateSmallRandomGraph().addRandomPositions().getWorkspace(); | ||
|
||
PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class); | ||
PreviewProperties props = previewController.getModel(workspace).getProperties(); | ||
props.putValue(PreviewProperty.BACKGROUND_COLOR, Color.CYAN); | ||
|
||
PDFExporter pdfExporter = new PDFExporter(); | ||
pdfExporter.setWorkspace(workspace); | ||
File tempFile = new File("testPDFExporter.pdf"); | ||
tempFile.deleteOnExit(); | ||
FileOutputStream fos = new FileOutputStream(tempFile); | ||
pdfExporter.setOutputStream(fos); | ||
pdfExporter.execute(); | ||
fos.close(); | ||
|
||
Assert.assertTrue(tempFile.length() > 0); | ||
} | ||
} |