Commit 1b505140 authored by R.W.Majeed's avatar R.W.Majeed

More detailed test for configuration parsing

parent 47f5554b
package de.sekmi.histream.conf;
import java.io.File;
import javax.xml.bind.JAXB;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
......@@ -8,6 +11,12 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* Configuration for HIStream processing. Uses javax.xml.bind for loading XML files
* via
* @author Raphael
*
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://some/namespace",
......@@ -27,4 +36,11 @@ public class Configuration {
public PluginConfig[] getPlugins(){return plugins;}
public PluginRef[] getDestinations(){return destination;}
public PluginRef[] getSources(){return source;}
public static final Configuration fromFile(File file){
return JAXB.unmarshal(file, Configuration.class);
}
}
......@@ -14,5 +14,11 @@ public class PluginRef {
@XmlIDREF
@XmlSchemaType(name = "IDREF")
protected PluginConfig plugin;
/**
* Returns a reference to a plugin configuration.
* @return plugin configuration
*/
public PluginConfig getPlugin(){return plugin;}
}
......@@ -2,7 +2,6 @@ package de.sekmi.histream;
import java.io.File;
import javax.xml.bind.JAXB;
import org.junit.Assert;
import org.junit.Test;
......@@ -13,7 +12,11 @@ public class TestLoadConfig {
@Test
public void loadNewConfig(){
Configuration config = JAXB.unmarshal(new File("src/test/resources/histream.xml"), Configuration.class);
Configuration config = Configuration.fromFile(new File("src/test/resources/histream.xml"));
Assert.assertNotNull(config);
Assert.assertEquals(6, config.getPlugins().length);
Assert.assertEquals(1, config.getDestinations().length);
Assert.assertEquals(config.getPlugins()[2], config.getDestinations()[0].getPlugin());
}
}
......@@ -7,12 +7,12 @@
<plugin class="de.sekmi.histream.i2b2.PostgresVisitStore">
<property name="user">i2b2demodata</property>
</plugin>
<plugin class="de.sekmi.histream.i2b2.services.HiveServer">
<plugin class="de.sekmi.histream.i2b2.I2b2Inserter">
<property name="user">i2b2demodata</property>
</plugin>
<plugin class="de.sekmi.histream.impl.SAXObservationProvider">
</plugin>
<plugin class="de.sekmi.histream.i2b2.I2b2Inserter">
<plugin class="de.sekmi.histream.i2b2.services.HiveServer">
<property name="user">i2b2demodata</property>
</plugin>
<plugin class="de.sekmi.histream.hl7.MLLPListener">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment