package org.gcube.informationsystem.collector.test; import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.gcube.informationsystem.collector.impl.utils.MetadataReader; import org.w3c.dom.Document; import org.xml.sax.SAXException; import com.sun.xml.bind.StringInputStream; import junit.framework.TestCase; public class MetadataReaderTest extends TestCase { MetadataReader reader; protected void setUp() throws Exception { Document metadata = this.createMetadata("Profile", "MySource", "600", "MyGroup", "MyKey", "MyEntry"); reader = new MetadataReader(metadata); } protected void tearDown() throws Exception { super.tearDown(); } public void testGetType() { System.out.println("Type: " + reader.getType()); } public void testGetSource() { System.out.println("Source: " + reader.getSource()); } public void testGetTerminationTime() { System.out.println("Termination time: " + reader.getTerminationTime().getTime().toString()); } public void testGetGroupKey() { System.out.println("Group Key: " + reader.getGroupKey()); } public void testGetEntryKey() { System.out.println("Entry Key: " + reader.getEntryKey()); } public void testGetKey() { System.out.println("Key: " + reader.getKey()); } private Document createMetadata(String type, String source, String tt, String groupkey, String key, String entrykey) throws SAXException, IOException, ParserConfigurationException { StringBuilder builder = new StringBuilder(); builder.append(""); builder.append("").append(type).append(""); builder.append("").append(source).append(""); builder.append("").append(tt).append(""); builder.append("").append(groupkey).append(""); builder.append("").append(entrykey).append(""); builder.append("").append(key).append(""); builder.append(""); builder.toString(); return DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new StringInputStream(builder.toString())); } }