-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from fact-project/fix_168
Fix 168
- Loading branch information
Showing
4 changed files
with
81 additions
and
8 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
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,61 @@ | ||
/** | ||
* | ||
*/ | ||
package fact.io; | ||
|
||
import junit.framework.Assert; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import stream.Data; | ||
import stream.Keys; | ||
import stream.data.DataFactory; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
|
||
|
||
/** | ||
* @author maxnoe | ||
*/ | ||
public class FITSWriterTest { | ||
static Logger log = LoggerFactory.getLogger(FITSWriterTest.class); | ||
|
||
@Test | ||
public void testFitsWriterNoItems() throws Exception { | ||
FITSWriter fitsWriter = new FITSWriter(); | ||
File f = File.createTempFile("test_fits", ".fits"); | ||
log.info(f.getAbsolutePath()); | ||
|
||
URL url = new URL("file:" + f.getAbsolutePath()); | ||
fitsWriter.setUrl(url); | ||
fitsWriter.init(null); | ||
fitsWriter.finish(); | ||
} | ||
|
||
@Test | ||
public void testFitsWriter() throws Exception { | ||
FITSWriter fitsWriter = new FITSWriter(); | ||
File f = File.createTempFile("test_fits", ".fits"); | ||
log.info(f.getAbsolutePath()); | ||
|
||
URL url = new URL("file:" + f.getAbsolutePath()); | ||
fitsWriter.setUrl(url); | ||
fitsWriter.setKeys(new Keys("*")); | ||
|
||
fitsWriter.init(null); | ||
|
||
Data item = DataFactory.create(); | ||
item.put("EventNum", 1); | ||
item.put("TriggerType", 4); | ||
item.put("NROI", 300); | ||
item.put("NPIX", 1440); | ||
item.put("x", 0.0); | ||
item.put("y", 5.0); | ||
item.put("array", new double[]{1.0, 2.0, 3.0}); | ||
|
||
fitsWriter.process(item); | ||
Assert.assertEquals(fitsWriter.getNumEventsWritten(), 1); | ||
fitsWriter.finish(); | ||
} | ||
} |