Project

General

Profile

« Previous | Next » 

Revision 6326

test listObjects()

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
30 30
import java.io.StringBufferInputStream;
31 31
import java.io.UnsupportedEncodingException;
32 32
import java.security.MessageDigest;
33
import java.text.SimpleDateFormat;
33 34
import java.util.Calendar;
34 35
import java.util.Date;
35 36

  
......
108 109
    suite.addTest(new MNodeServiceTest("testGetChecksum"));
109 110
    suite.addTest(new MNodeServiceTest("testGetSystemMetadata"));
110 111
    suite.addTest(new MNodeServiceTest("testDescribe"));
112
    suite.addTest(new MNodeServiceTest("testListObjects"));
111 113
    // MNCore tests
112 114
    suite.addTest(new MNodeServiceTest("testPing"));
113 115
    suite.addTest(new MNodeServiceTest("testGetLogRecords"));
......
586 588
	 * Testing listing objects on the Member Node
587 589
	 */
588 590
	public void testListObjects() {
589
    printTestHeader("testListObjects");
590

  
591
    ObjectList objectList = null;
592
    Session session = getTestSession();
593
    Date startTime = new Date("2010-01-01");
594
    Date endTime = new Date();
595
    ObjectFormat objectFormat = null;
596
    boolean replicaStatus = false;
597
    int start = 0;
598
    int count = 1000;
599
    
600
    try {
601
	    objectList = 
602
	    	MNodeService.getInstance().listObjects(session, startTime, endTime, 
603
	    		objectFormat, replicaStatus, start, count);
604
	    assertNotNull(objectList);
605
	    assertTrue(objectList.getCount() == 1000);
606
	    assertTrue(objectList.getStart() == 0);
607
	    assertTrue(objectList.getTotal() > 1);
591
	    printTestHeader("testListObjects");
592
	
593
	    try {
594
	
595
		    Session session = getTestSession();
596
		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
597
		    Date startTime = sdf.parse("2010-01-01");
598
		    Date endTime = new Date();
599
		    ObjectFormat objectFormat = null;
600
		    boolean replicaStatus = false;
601
		    int start = 0;
602
		    int count = 1;
608 603
	    
609
    } catch (NotAuthorized e) {
610
	    e.printStackTrace();
611
	    fail("Unexpected error: " + e.getMessage());
612

  
613
    } catch (InvalidRequest e) {
614
	    e.printStackTrace();
615
	    fail("Unexpected error: " + e.getMessage());
616
	    
617
    } catch (NotImplemented e) {
618
	    e.printStackTrace();
619
	    fail("Unexpected error: " + e.getMessage());
620
	    
621
    } catch (ServiceFailure e) {
622
	    e.printStackTrace();
623
	    fail("Unexpected error: " + e.getMessage());
624
	    
625
    } catch (InvalidToken e) {
626
	    e.printStackTrace();
627
	    fail("Unexpected error: " + e.getMessage());
628
	    
629
    }
604
		    // insert at least one object 
605
		    testCreate();
606
		    // now check that we have at least one
607
		    ObjectList objectList = 
608
		    	MNodeService.getInstance().listObjects(session, startTime, endTime, 
609
		    		objectFormat, replicaStatus, start, count);
610
		    assertNotNull(objectList);
611
		    assertTrue(objectList.getCount() == count);
612
		    assertTrue(objectList.getStart() == 0);
613
		    assertTrue(objectList.getTotal() > 1);
614
		    
615
	    } catch (Exception e) {
616
		    e.printStackTrace();
617
		    fail("Unexpected error: " + e.getMessage());
618
	
619
	    }
630 620
	}
631 621

  
632 622
	public void testGetCapabilities() {

Also available in: Unified diff