package org.gcube.informationsystem.collector.test; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.TestCase; import org.gcube.informationsystem.collector.impl.resources.GCUBEProfileResource; import org.gcube.informationsystem.collector.impl.resources.DAIXResource.MalformedResourceException; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.xml.sax.InputSource; public class GCUBEProfileResourceTest extends TestCase { private GCUBEProfileResource resource; @Before public void setUp() throws Exception { resource = new GCUBEProfileResource(); } @After public void tearDown() throws Exception { } @Test public void testSetContentString() { StringBuilder builder = new StringBuilder(); builder.append(""); builder.append("3bb6e850-94d2-11df-8d06-8e825c7c7b8d"); builder.append("MetadataCollection"); builder.append(""); builder.append("/d4science.research-infrastructures.eu/FARM/FCPPS"); builder.append(""); builder.append(""); builder.append(""); builder.append(""); builder.append(""); try { resource.setContent(builder.toString()); } catch (MalformedResourceException e) { e.printStackTrace(); } } @Test public void testBaseDAIXResource() { //fail("Not yet implemented"); } @Test public void testGetResourceName() { //fail("Not yet implemented"); } @Test public void testSetResourceName() { resource.setResourceName("TestResouceName"); } @Test public void testGetResourceURI() { //fail("Not yet implemented"); } @Test public void testSetResourceURI() { //fail("Not yet implemented"); } @Test public void testGetContent() { //fail("Not yet implemented"); } @Test public void testSetContentDocument() { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); StringReader reader = new StringReader("GHN"); InputSource source = new InputSource(reader); resource.setContent(builder.parse(source)); } catch (Exception e) { e.printStackTrace(); } } @Test public void testSetCollectionName() { resource.setResourceType("testCollection"); } @Test public void testGetCollectionName() { this.testSetContentString(); try { System.out.println("Resource collection is " + resource.getCollectionName()); } catch (MalformedResourceException e) { e.printStackTrace(); } } @Test public void testToString() { this.testSetContentDocument(); System.out.println("Resource from DOM is: " + resource.toString()); //resource.setContent(null); this.testSetContentString(); System.out.println("Resource from String is: " + resource.toString()); } }