Project

General

Profile

« Previous | Next » 

Revision 6315

test CN.get()

View differences:

test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
35 35
import junit.framework.Test;
36 36
import junit.framework.TestSuite;
37 37

  
38
import org.apache.commons.io.IOUtils;
38 39
import org.dataone.client.ObjectFormatCache;
39 40
import org.dataone.service.Constants;
40 41
import org.dataone.service.exceptions.InsufficientResources;
......
106 107
		suite.addTest(new CNodeServiceTest("testAssertRelation"));
107 108
		suite.addTest(new CNodeServiceTest("testChecksum"));
108 109
		suite.addTest(new CNodeServiceTest("testCreate"));
110
		suite.addTest(new CNodeServiceTest("testGet"));
109 111
		suite.addTest(new CNodeServiceTest("testGetFormat"));
110 112
		suite.addTest(new CNodeServiceTest("testListFormats"));
111 113
		suite.addTest(new CNodeServiceTest("testListNodes"));
......
167 169
        }
168 170
	}
169 171
	
172
	public void testGet() {
173
	    printTestHeader("testGet");
174

  
175
	    try {
176
            Session session = getTestSession();
177
			Identifier guid = new Identifier();
178
			guid.setValue("testGet." + System.currentTimeMillis());
179
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject());
180
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
181
			Identifier pid = CNodeService.getInstance().create(session, guid, object, sysmeta);
182
			assertEquals(guid, pid);
183
			// get it
184
			InputStream retObject = CNodeService.getInstance().get(session, pid);
185
			// check it
186
			assertTrue(IOUtils.contentEquals(object, retObject));
187
        } catch(Exception e) {
188
        	e.printStackTrace();
189
            fail("Unexpected error: " + e.getMessage());
190
        }
191
	}
192
	
170 193
	public void testAssertRelation() {
171 194
	    printTestHeader("testAssertRelation");
172 195

  

Also available in: Unified diff