Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2010 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis
5
 *  Purpose: To test the Access Controls in metacat by JUnit
6
 *
7
 *   '$Author: tao $'
8
 *     '$Date: 2014-10-15 16:49:34 -0700 (Wed, 15 Oct 2014) $'
9
 * '$Revision: 8905 $'
10
 *
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
 */
25

    
26
package edu.ucsb.nceas.metacat.dataone;
27

    
28
import CNodeServiceTest;
29

    
30
import java.io.ByteArrayInputStream;
31
import java.io.InputStream;
32
import java.text.SimpleDateFormat;
33
import java.util.Calendar;
34
import java.util.Date;
35
import java.util.List;
36

    
37
import junit.framework.Test;
38
import junit.framework.TestSuite;
39

    
40
import org.apache.commons.io.IOUtils;
41
import org.dataone.client.v2.itk.D1Client;
42
import org.dataone.service.exceptions.BaseException;
43
import org.dataone.service.exceptions.NotAuthorized;
44
import org.dataone.service.exceptions.NotFound;
45
import org.dataone.service.exceptions.NotImplemented;
46
import org.dataone.service.exceptions.ServiceFailure;
47
import org.dataone.service.types.v1.AccessPolicy;
48
import org.dataone.service.types.v1.AccessRule;
49
import org.dataone.service.types.v1.Checksum;
50
import org.dataone.service.types.v1.DescribeResponse;
51
import org.dataone.service.types.v1.Event;
52
import org.dataone.service.types.v1.Identifier;
53
import org.dataone.service.types.v1.NodeReference;
54
import org.dataone.service.types.v1.NodeType;
55
import org.dataone.service.types.v1.ObjectFormatIdentifier;
56
import org.dataone.service.types.v1.ObjectList;
57
import org.dataone.service.types.v1.Permission;
58
import org.dataone.service.types.v1.Replica;
59
import org.dataone.service.types.v1.ReplicationPolicy;
60
import org.dataone.service.types.v1.ReplicationStatus;
61
import org.dataone.service.types.v1.Session;
62
import org.dataone.service.types.v1.Subject;
63
import org.dataone.service.types.v2.Log;
64
import org.dataone.service.types.v2.Node;
65
import org.dataone.service.types.v2.NodeList;
66
import org.dataone.service.types.v2.ObjectFormat;
67
import org.dataone.service.types.v2.ObjectFormatList;
68
import org.dataone.service.types.v2.SystemMetadata;
69
import org.dataone.service.util.Constants;
70

    
71
/**
72
 * A JUnit test for testing the dataone CNCore implementation
73
 */
74
public class CNodeServiceTest extends D1NodeServiceTest {   
75
    
76
    /**
77
    * constructor for the test
78
    */
79
    public CNodeServiceTest(String name)
80
    {
81
        super(name);
82
    }
83

    
84
	/**
85
	 * Create a suite of tests to be run together
86
	 */
87
	public static Test suite() 
88
	{
89
		TestSuite suite = new TestSuite();
90
		suite.addTest(new CNodeServiceTest("initialize"));
91
		
92
		suite.addTest(new CNodeServiceTest("testChecksum"));
93
		suite.addTest(new CNodeServiceTest("testCreate"));
94
		suite.addTest(new CNodeServiceTest("testGet"));
95
		suite.addTest(new CNodeServiceTest("testGetFormat"));
96
		suite.addTest(new CNodeServiceTest("testGetLogRecords"));
97
		suite.addTest(new CNodeServiceTest("testGetSystemMetadata"));
98
		suite.addTest(new CNodeServiceTest("testIsAuthorized"));
99
		suite.addTest(new CNodeServiceTest("testListFormats"));
100
		suite.addTest(new CNodeServiceTest("testListNodes"));
101
		suite.addTest(new CNodeServiceTest("testObjectFormatNotFoundException"));
102
		suite.addTest(new CNodeServiceTest("testRegisterSystemMetadata"));
103
		suite.addTest(new CNodeServiceTest("testReplicationPolicy"));
104
		suite.addTest(new CNodeServiceTest("testReplicationStatus"));
105
		suite.addTest(new CNodeServiceTest("testReserveIdentifier"));
106
		suite.addTest(new CNodeServiceTest("testSearch"));
107
		suite.addTest(new CNodeServiceTest("testSetAccessPolicy"));
108
		suite.addTest(new CNodeServiceTest("testSetOwner"));
109
		suite.addTest(new CNodeServiceTest("readDeletedObject"));
110
	
111
		return suite;
112
	}
113
	
114
	
115
	/**
116
	 * test for registering standalone system metadata
117
	 */
118
	public Identifier testRegisterSystemMetadata() {
119
	    printTestHeader("testRegisterSystemMetadata");
120

    
121
	    try {
122
            Session session = getTestSession();
123
			Identifier guid = new Identifier();
124
			guid.setValue("testRegisterSystemMetadata." + System.currentTimeMillis());
125
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
126
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
127
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
128
			assertEquals(guid.getValue(), retGuid.getValue());
129
			return retGuid;
130
        } catch(Exception e) {
131
            fail("Unexpected error: " + e.getMessage());
132
        }
133
        return null;
134
	}
135
	
136
	/**
137
	 * test for getting system metadata
138
	 */
139
	public void testGetSystemMetadata() {
140
	    printTestHeader("testGetSystemMetadata");
141

    
142
	    try {
143
            Session session = getTestSession();
144
			Identifier guid = new Identifier();
145
			guid.setValue("testGetSystemMetadata." + System.currentTimeMillis());
146
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
147
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
148
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
149
			assertEquals(guid.getValue(), retGuid.getValue());
150
			// get it
151
			SystemMetadata retSysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
152
			// check it
153
			assertEquals(sysmeta.getIdentifier().getValue(), retSysmeta.getIdentifier().getValue());
154
        } catch(Exception e) {
155
            fail("Unexpected error: " + e.getMessage());
156
        }
157
	}
158
	
159
	public void testGetLogRecords() {
160
	    printTestHeader("testGetLogRecords");
161
	    try {
162

    
163
		    Session session = getTestSession();
164
		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
165
		    Date fromDate = sdf.parse("2010-01-01");
166
		    Date toDate = new Date();
167
		    Event event = Event.CREATE;
168
		    int start = 0;
169
		    int count = 1;
170
	    
171
		    Log log = CNodeService.getInstance(request).getLogRecords(session, fromDate, toDate, 
172
		    	event.xmlValue(), null, start, count);
173
		    assertNotNull(log);
174
		    assertTrue(log.getCount() == count);
175
		    assertTrue(log.getStart() == start);
176
		    assertTrue(log.getTotal() > 0);
177
	    } catch (Exception e) {
178
		    e.printStackTrace();
179
		    fail("Unexpected error: " + e.getMessage());
180
	    } 
181
	}
182
	
183
	public void testCreate() {
184
	    printTestHeader("testCreate");
185

    
186
	    try {
187
            Session session = getTestSession();
188
			Identifier guid = new Identifier();
189
			guid.setValue("testCreate." + System.currentTimeMillis());
190
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
191
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
192
			Identifier pid = CNodeService.getInstance(request).create(session, guid, object, sysmeta);
193
			assertEquals(guid, pid);
194
        } catch(Exception e) {
195
        	e.printStackTrace();
196
            fail("Unexpected error: " + e.getMessage());
197
        }
198
	}
199
	
200
	public void testGet() {
201
	    printTestHeader("testGet");
202

    
203
	    try {
204
            Session session = getTestSession();
205
			Identifier guid = new Identifier();
206
			guid.setValue("testGet." + System.currentTimeMillis());
207
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
208
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
209
			Identifier pid = CNodeService.getInstance(request).create(session, guid, object, sysmeta);
210
			assertEquals(guid.getValue(), pid.getValue());
211
			// get it
212
			InputStream retObject = CNodeService.getInstance(request).get(session, pid);
213
			// check it
214
			object.reset();
215
			assertTrue(IOUtils.contentEquals(object, retObject));
216
        } catch(Exception e) {
217
        	e.printStackTrace();
218
            fail("Unexpected error: " + e.getMessage());
219
        }
220
	}
221
	
222
	public void testChecksum() {
223
	    printTestHeader("testChecksum");
224

    
225
	    try {
226
            Session session = getTestSession();
227
			Identifier guid = new Identifier();
228
			guid.setValue("testChecksum." + System.currentTimeMillis());
229
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
230
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
231
			// save it
232
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
233
			assertEquals(guid.getValue(), retGuid.getValue());
234
			// check it
235
			Checksum checksum = CNodeService.getInstance(request).getChecksum(session, guid);
236
			assertEquals(sysmeta.getChecksum().getValue(), checksum.getValue());
237
        } catch(Exception e) {
238
            fail("Unexpected error: " + e.getMessage());
239
        }
240
	}
241
	
242
	public void testListNodes() {
243
	    printTestHeader("testListNodes");
244

    
245
	    try {
246
	    	CNodeService.getInstance(request).listNodes();
247
        } catch(NotImplemented e) {
248
        	// expecting not implemented
249
            assertTrue(true);
250
        } catch(Exception e) {
251
            fail("Unexpected error: " + e.getMessage());
252
        }
253
	}
254
	
255
	public void testReserveIdentifier() {
256
	    printTestHeader("testReserveIdentifier");
257

    
258
	    try {
259
            Session session = getTestSession();
260
			Identifier guid = new Identifier();
261
			guid.setValue("testReserveIdentifier." + System.currentTimeMillis());
262
			// reserve it
263
			Identifier resultPid = CNodeService.getInstance(request).reserveIdentifier(session, guid);
264
			assertNotNull(resultPid);
265
			assertEquals(guid.getValue(), resultPid.getValue());
266
	    } catch(NotImplemented ni) {
267
        	// this is not implemented in Metacat
268
            assertTrue(true);	
269
        } catch(Exception e) {
270
        	e.printStackTrace();
271
            fail("Unexpected error: " + e.getMessage());
272
        }
273
	}
274
	
275
	public void testSearch() {
276
	    printTestHeader("testSearch");
277

    
278
	    try {
279
            Session session = getTestSession();
280
			
281
			// search for objects, but expect a NotImplemented exception
282
			try {
283
				ObjectList objectList = CNodeService.getInstance(request).search(session, null, null);
284
			} catch (NotImplemented ne) {
285
				assertTrue(true);
286
				return;
287
			}
288
			fail("Metacat should not implement CN.search");
289
			
290
        } catch(Exception e) {
291
            fail("Unexpected error: " + e.getMessage());
292
        }
293
	}
294
	
295
	public void testSetOwner() {
296
	    printTestHeader("testSetOwner");
297

    
298
	    try {
299
            Session session = getTestSession();
300
			Identifier guid = new Identifier();
301
			guid.setValue("testSetOwner." + System.currentTimeMillis());
302
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
303
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
304
			long serialVersion = 1L;
305
			// save it
306
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
307
			assertEquals(guid.getValue(), retGuid.getValue());
308
			Subject rightsHolder = new Subject();
309
			rightsHolder.setValue("newUser");
310
			// set it
311
			Identifier retPid = CNodeService.getInstance(request).setRightsHolder(session, guid, rightsHolder, serialVersion);
312
			assertEquals(guid, retPid);
313
			// get it
314
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
315
			assertNotNull(sysmeta);
316
			// check it
317
			assertTrue(rightsHolder.equals(sysmeta.getRightsHolder()));
318
			
319
        } catch(Exception e) {
320
            fail("Unexpected error: " + e.getMessage());
321
        }
322
	}
323
	
324
	public void testSetAccessPolicy() {
325
	    printTestHeader("testSetAccessPolicy");
326

    
327
	    try {
328
            Session session = getTestSession();
329
			Identifier guid = new Identifier();
330
			guid.setValue("testSetAccessPolicy." + System.currentTimeMillis());
331
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
332
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
333
	    long serialVersion = 1L;
334

    
335
			// save it
336
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
337
			assertEquals(guid.getValue(), retGuid.getValue());
338
			AccessPolicy accessPolicy = new AccessPolicy();
339
			AccessRule accessRule = new AccessRule();
340
			accessRule.addPermission(Permission.WRITE);
341
			Subject publicSubject = new Subject();
342
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
343
			accessRule.addSubject(publicSubject);
344
			accessPolicy.addAllow(accessRule);
345
			// set it
346
			boolean result = CNodeService.getInstance(request).setAccessPolicy(session, guid, accessPolicy, serialVersion );
347
			assertTrue(result);
348
			// check it
349
			result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.WRITE);
350
			assertTrue(result);
351
        } catch(Exception e) {
352
            fail("Unexpected error: " + e.getMessage());
353
        }
354
	}
355
	
356
	public void testIsAuthorized() {
357
	    printTestHeader("testIsAuthorized");
358

    
359
	    try {
360
            Session session = getTestSession();
361
			Identifier guid = new Identifier();
362
			guid.setValue("testIsAuthorized." + System.currentTimeMillis());
363
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
364
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
365
			// save it
366
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
367
			assertEquals(guid.getValue(), retGuid.getValue());
368
			// check it
369
			Subject publicSubject = new Subject();
370
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
371
			session.setSubject(publicSubject);
372
			// public read
373
			boolean result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.READ);
374
			assertTrue(result);
375
			// not public write
376
			try {
377
				result = false;
378
				result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.WRITE);
379
				fail("Public WRITE should be denied");
380
			} catch (NotAuthorized nae) {
381
				result = true;
382
			}
383
			assertTrue(result);
384
        } catch(Exception e) {
385
            fail("Unexpected error: " + e.getMessage());
386
        }
387
	}
388
	
389
	public void testReplicationPolicy() {
390
	    printTestHeader("testReplicationPolicy");
391

    
392
	    try {
393
            Session session = getTestSession();
394
			Identifier guid = new Identifier();
395
			guid.setValue("testReplicationPolicy." + System.currentTimeMillis());
396
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
397
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
398
	    long serialVersion = 1L;
399

    
400
			// save it
401
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
402
			assertEquals(guid.getValue(), retGuid.getValue());
403
			
404
			ReplicationPolicy policy = new ReplicationPolicy();
405
			NodeReference node = new NodeReference();
406
			node.setValue("testNode");
407
			policy.addPreferredMemberNode(node );
408
			// set it
409
			boolean result = CNodeService.getInstance(request).setReplicationPolicy(session, guid, policy, serialVersion);
410
			assertTrue(result);
411
			// get it
412
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
413
			assertNotNull(sysmeta);
414
			// check it
415
			assertEquals(policy.getPreferredMemberNode(0).getValue(), sysmeta.getReplicationPolicy().getPreferredMemberNode(0).getValue());
416
			
417
        } catch(Exception e) {
418
            fail("Unexpected error: " + e.getMessage());
419
        }
420
	}
421
	
422
	public void testReplicationStatus() {
423
	    printTestHeader("testReplicationStatus");
424

    
425
	    try {
426
            Session session = getTestSession();
427
			Identifier guid = new Identifier();
428
			guid.setValue("testReplicationStatus." + System.currentTimeMillis());
429
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
430
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
431
			Replica replica = new Replica();
432
			NodeReference replicaMemberNode = new NodeReference();
433
			replicaMemberNode.setValue("testNode");
434
			replica.setReplicationStatus(ReplicationStatus.REQUESTED);
435
			replica.setReplicaMemberNode(replicaMemberNode);
436
			replica.setReplicaVerified(Calendar.getInstance().getTime());
437
			sysmeta.addReplica(replica );
438
			// save it
439
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
440
			assertEquals(guid.getValue(), retGuid.getValue());
441
			// set it
442
			ReplicationStatus status = ReplicationStatus.COMPLETED;
443
			BaseException failure = new NotAuthorized("000", "Mock exception for " + this.getClass().getName());
444
			boolean result = CNodeService.getInstance(request).setReplicationStatus(session, guid, replicaMemberNode, status, failure);
445
			assertTrue(result);
446
			// get it
447
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
448
			assertNotNull(sysmeta);
449
			// check it
450
			assertEquals(status, sysmeta.getReplica(0).getReplicationStatus());
451
			
452
        } catch(Exception e) {
453
            fail("Unexpected error: " + e.getMessage());
454
        }
455
	}
456
	
457
	/**
458
	 * Run an initial test that always passes to check that the test harness is
459
	 * working.
460
	 */
461
	public void initialize() 
462
	{
463
	    printTestHeader("initialize");
464
		assertTrue(1 == 1);
465
	}
466
	
467
	/**
468
	 * We want to act as the CN itself
469
	 * @throws ServiceFailure 
470
	 * @throws Exception 
471
	 */
472
	@Override
473
	public Session getTestSession() throws Exception {
474
		Session session = super.getTestSession();
475
		
476
		// use the first CN we find in the nodelist
477
        NodeList nodeList = D1Client.getCN().listNodes();
478
        for (Node node : nodeList.getNodeList()) {
479
            if ( node.getType().equals(NodeType.CN) ) {
480
                
481
                List<Subject> subjects = node.getSubjectList();
482
                for (Subject subject : subjects) {
483
                   session.setSubject(subject);
484
                   // we are done here
485
                   return session;
486
                }
487
            }
488
        }
489
        // in case we didn't find it
490
        return session;
491
	}
492
	
493

    
494
	/**
495
	 * test to list the object formats registered in metacat
496
	 */
497
	public void testListFormats() {
498
		
499
    printTestHeader("testListFormats");
500
    
501
    // make sure we are set up
502
    setUpFormats();
503
    
504
    // there should be at least 59 formats in the list
505
  	int formatsCount = 59;
506
  	ObjectFormatList objectFormatList;
507
  	
508
  	try {
509
	    objectFormatList = CNodeService.getInstance(request).listFormats();
510
	  	assertTrue(objectFormatList.getTotal() >= formatsCount);
511
  	
512
  	} catch (ServiceFailure e) {
513
  		fail("Could not get the object format list: " + e.getMessage());
514

    
515
    } catch (NotImplemented e) {
516
  		fail("Could not get the object format list: " + e.getMessage());
517

    
518
    }
519
    
520
	}
521
	
522
  /**
523
   * Test getting a single object format from the registered list
524
   */
525
  public void testGetFormat() {
526
  	
527
    printTestHeader("testGetFormat");
528

    
529
    // make sure we are set up
530
    setUpFormats();
531
    
532
    String knownFormat = "text/plain";
533
    ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
534
    fmtid.setValue(knownFormat);
535
  	
536
    try {
537
	    
538
			String result = 
539
				CNodeService.getInstance(request).getFormat(fmtid).getFormatId().getValue();
540
	  	System.out.println("Expected result: " + knownFormat);
541
	  	System.out.println("Found    result: " + result);
542
	  	assertTrue(result.equals(knownFormat));
543
  
544
    } catch (NullPointerException npe) {	  
545
	    fail("The returned format was null: " + npe.getMessage());
546
    
547
    } catch (NotFound nfe) {     
548
    	fail("The format " + knownFormat + " was not found: " + nfe.getMessage());
549
    	
550
    } catch (ServiceFailure sfe) {
551
    	fail("The format " + knownFormat + " was not found: " + sfe.getMessage());
552

    
553
    } catch (NotImplemented nie) {
554
    	fail("The getFormat() method has not been implemented: " + nie.getMessage());
555

    
556
    }
557
  	
558
  }
559
	
560
  /**
561
   * Test getting a non-existent object format, returning NotFound
562
   */
563
  public void testObjectFormatNotFoundException() {
564
  
565
    printTestHeader("testObjectFormatNotFoundException");
566

    
567
    ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
568
  	String badFormat = "text/bad-format";
569
  	fmtid.setValue(badFormat);
570
  	
571
  	try {
572
  		
573
	    ObjectFormat objectFormat = 
574
	    	CNodeService.getInstance(request).getFormat(fmtid);
575
      
576
  	} catch (Exception e) {
577
	    
578
  		assertTrue(e instanceof NotFound);
579
  	}
580
  	
581
  }
582
  
583
  public void readDeletedObject() {
584
      printTestHeader("testCreate");
585

    
586
      try {
587
          Session session = getTestSession();
588
          Identifier guid = new Identifier();
589
          guid.setValue("testCreate." + System.currentTimeMillis());
590
          InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
591
          SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
592
          Identifier pid = CNodeService.getInstance(request).create(session, guid, object, sysmeta);
593
          assertEquals(guid, pid);
594
          
595
          Thread.sleep(3000);
596
          // use MN admin to delete
597
          session = getMNSession();
598
          Identifier deletedPid = CNodeService.getInstance(request).delete(session, pid);
599
          System.out.println("after deleting");
600
          assertEquals(pid.getValue(), deletedPid.getValue());
601
          // check that we cannot get the object
602
          session = getTestSession();
603
          InputStream deletedObject = null;
604
          try {
605
              //System.out.println("before read ===============");
606
              deletedObject = CNodeService.getInstance(request).get(session, deletedPid);
607
              //System.out.println("after read ===============");
608
          } catch (NotFound nf) {
609
              //System.out.println("the exception is1 "+nf.getMessage());
610
              //nf.printStackTrace();
611
              assertTrue(nf.getMessage().contains("deleted"));
612
          }
613
          try {
614
              //System.out.println("before read ===============");
615
              SystemMetadata sysmeta2 = CNodeService.getInstance(request).getSystemMetadata(session, deletedPid);
616
              //System.out.println("after read ===============");
617
          } catch (NotFound nf) {
618
              //System.out.println("the exception is "+nf.getMessage());
619
              //nf.printStackTrace();
620
              assertTrue(nf.getMessage().contains("deleted"));
621
          }
622
          
623
          try {
624
              //System.out.println("before read ===============");
625
              DescribeResponse describeResponse = CNodeService.getInstance(request).describe(session, pid);
626
              //System.out.println("after read ===============");
627
          } catch (NotFound nf) {
628
              //System.out.println("the exception is "+nf.getMessage());
629
              //nf.printStackTrace();
630
              assertTrue(nf.getMessage().contains("deleted"));
631
          }
632
          
633
          try {
634
              //System.out.println("before read ===============");
635
              Checksum checksum = CNodeService.getInstance(request).getChecksum(session, pid);
636
              //System.out.println("after read ===============");
637
          } catch (NotFound nf) {
638
              //System.out.println("the exception 3 is "+nf.getMessage());
639
              //nf.printStackTrace();
640
              assertTrue(nf.getMessage().contains("deleted"));
641
          }
642
          
643
          try {
644
              //System.out.println("before read ===============");
645
              boolean isAuthorized = 
646
                      CNodeService.getInstance(request).isAuthorized(session, pid, Permission.READ);
647
              //System.out.println("after read ===============");
648
          } catch (NotFound nf) {
649
              //System.out.println("the exception 4 is "+nf.getMessage());
650
              //nf.printStackTrace();
651
              assertTrue(nf.getMessage().contains("deleted"));
652
          }
653
          
654
         
655
          
656
          assertNull(deletedObject);
657
      } catch(Exception e) {
658
          e.printStackTrace();
659
          fail("Unexpected error: " + e.getMessage());
660
      }
661
  }
662
 
663
}
(1-1/7)