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:56:19 -0700 (Wed, 15 Oct 2014) $'
9
 * '$Revision: 8907 $'
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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