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: leinfelder $'
8
 *     '$Date: 2011-11-08 15:49:41 -0800 (Tue, 08 Nov 2011) $'
9
 * '$Revision: 6622 $'
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 java.io.ByteArrayInputStream;
29
import java.io.InputStream;
30
import java.text.SimpleDateFormat;
31
import java.util.Date;
32

    
33
import javax.servlet.http.HttpServletRequest;
34

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

    
38
import org.apache.commons.io.IOUtils;
39
import org.apache.wicket.protocol.http.MockHttpServletRequest;
40
import org.dataone.service.util.Constants;
41
import org.dataone.service.exceptions.InsufficientResources;
42
import org.dataone.service.exceptions.InvalidRequest;
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.Event;
51
import org.dataone.service.types.v1.Identifier;
52
import org.dataone.service.types.v1.Log;
53
import org.dataone.service.types.v1.NodeReference;
54
import org.dataone.service.types.v1.ObjectFormat;
55
import org.dataone.service.types.v1.ObjectFormatIdentifier;
56
import org.dataone.service.types.v1.ObjectFormatList;
57
import org.dataone.service.types.v1.ObjectInfo;
58
import org.dataone.service.types.v1.ObjectList;
59
import org.dataone.service.types.v1.Permission;
60
import org.dataone.service.types.v1.Replica;
61
import org.dataone.service.types.v1.ReplicationPolicy;
62
import org.dataone.service.types.v1.ReplicationStatus;
63
import org.dataone.service.types.v1.Session;
64
import org.dataone.service.types.v1.Subject;
65
import org.dataone.service.types.v1.SystemMetadata;
66

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

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

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

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

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

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

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

    
221
	    try {
222
            Session session = getTestSession();
223
			Identifier guid = new Identifier();
224
			guid.setValue("testAssertRelation." + System.currentTimeMillis());
225
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
226
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
227
			Identifier describePid = new Identifier();
228
			describePid.setValue("describePid." + System.currentTimeMillis());
229
			sysmeta.setObsoletes(describePid);
230
			// save it
231
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
232
			assertEquals(guid.getValue(), retGuid.getValue());
233
			// save the other
234
			InputStream object2 = new ByteArrayInputStream("test".getBytes("UTF-8"));
235
			SystemMetadata describeSysmeta = createSystemMetadata(describePid, session.getSubject(), object2);
236
			Identifier retDescribePid = CNodeService.getInstance(request).registerSystemMetadata(session, describePid, describeSysmeta);
237
			assertEquals(describePid.getValue(), retDescribePid.getValue());
238
			// check it
239
			boolean result = CNodeService.getInstance(request).assertRelation(session, guid, "obsoletes", describePid);
240
			assertTrue(result);
241
        } catch(Exception e) {
242
        	e.printStackTrace();
243
            fail("Unexpected error: " + e.getMessage());
244
        }
245
	}
246
	
247
	public void testChecksum() {
248
	    printTestHeader("testChecksum");
249

    
250
	    try {
251
            Session session = getTestSession();
252
			Identifier guid = new Identifier();
253
			guid.setValue("testChecksum." + System.currentTimeMillis());
254
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
255
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
256
			// save it
257
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
258
			assertEquals(guid.getValue(), retGuid.getValue());
259
			// check it
260
			Checksum checksum = CNodeService.getInstance(request).getChecksum(session, guid);
261
			assertEquals(sysmeta.getChecksum().getValue(), checksum.getValue());
262
        } catch(Exception e) {
263
            fail("Unexpected error: " + e.getMessage());
264
        }
265
	}
266
	
267
	public void testListNodes() {
268
	    printTestHeader("testListNodes");
269

    
270
	    try {
271
	    	CNodeService.getInstance(request).listNodes();
272
        } catch(NotImplemented e) {
273
        	// expecting not implemented
274
            assertTrue(true);
275
        } catch(Exception e) {
276
            fail("Unexpected error: " + e.getMessage());
277
        }
278
	}
279
	
280
	public void testReserveIdentifier() {
281
	    printTestHeader("testReserveIdentifier");
282

    
283
	    try {
284
            Session session = getTestSession();
285
			Identifier guid = new Identifier();
286
			guid.setValue("testReserveIdentifier." + System.currentTimeMillis());
287
			// reserve it
288
			Identifier resultPid = CNodeService.getInstance(request).reserveIdentifier(session, guid);
289
			assertNotNull(resultPid);
290
			assertEquals(guid.getValue(), resultPid.getValue());
291
	    } catch(NotImplemented ni) {
292
        	// this is not implemented in Metacat
293
            assertTrue(true);	
294
        } catch(Exception e) {
295
        	e.printStackTrace();
296
            fail("Unexpected error: " + e.getMessage());
297
        }
298
	}
299
	
300
	public void testSearch() {
301
	    printTestHeader("testSearch");
302

    
303
	    try {
304
            Session session = getTestSession();
305
			Identifier guid = new Identifier();
306
			guid.setValue("testSearch." + System.currentTimeMillis());
307
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
308
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
309
			
310
			// save it
311
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
312
			assertEquals(guid.getValue(), retGuid.getValue());
313
			// search for it
314
			ObjectList objectList = CNodeService.getInstance(request).search(session, null, null);
315
			// check it
316
			assertNotNull(objectList);
317
			boolean result = false;
318
			for (ObjectInfo objectInfo: objectList.getObjectInfoList()) {
319
				Identifier pid = objectInfo.getIdentifier();
320
				if (pid.getValue().equals(guid.getValue())) {
321
					result = true;
322
					break;
323
				}
324
			}
325
			assertTrue(result);
326
        } catch(Exception e) {
327
            fail("Unexpected error: " + e.getMessage());
328
        }
329
	}
330
	
331
	public void testSetOwner() {
332
	    printTestHeader("testSetOwner");
333

    
334
	    try {
335
            Session session = getTestSession();
336
			Identifier guid = new Identifier();
337
			guid.setValue("testSetOwner." + System.currentTimeMillis());
338
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
339
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
340
			long serialVersion = 1L;
341
			// save it
342
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
343
			assertEquals(guid.getValue(), retGuid.getValue());
344
			Subject rightsHolder = new Subject();
345
			rightsHolder.setValue("newUser");
346
			// set it
347
			Identifier retPid = CNodeService.getInstance(request).setOwner(session, guid, rightsHolder, serialVersion);
348
			assertEquals(guid, retPid);
349
			// get it
350
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
351
			assertNotNull(sysmeta);
352
			// check it
353
			assertEquals(rightsHolder.getValue(), sysmeta.getRightsHolder().getValue());
354
			
355
        } catch(Exception e) {
356
            fail("Unexpected error: " + e.getMessage());
357
        }
358
	}
359
	
360
	public void testSetAccessPolicy() {
361
	    printTestHeader("testSetAccessPolicy");
362

    
363
	    try {
364
            Session session = getTestSession();
365
			Identifier guid = new Identifier();
366
			guid.setValue("testSetAccessPolicy." + System.currentTimeMillis());
367
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
368
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
369
	    long serialVersion = 1L;
370

    
371
			// save it
372
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
373
			assertEquals(guid.getValue(), retGuid.getValue());
374
			AccessPolicy accessPolicy = new AccessPolicy();
375
			AccessRule accessRule = new AccessRule();
376
			accessRule.addPermission(Permission.WRITE);
377
			Subject publicSubject = new Subject();
378
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
379
			accessRule.addSubject(publicSubject);
380
			accessPolicy.addAllow(accessRule);
381
			// set it
382
			boolean result = CNodeService.getInstance(request).setAccessPolicy(session, guid, accessPolicy, serialVersion );
383
			assertTrue(result);
384
			// check it
385
			result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.WRITE);
386
			assertTrue(result);
387
        } catch(Exception e) {
388
            fail("Unexpected error: " + e.getMessage());
389
        }
390
	}
391
	
392
	public void testIsAuthorized() {
393
	    printTestHeader("testIsAuthorized");
394

    
395
	    try {
396
            Session session = getTestSession();
397
			Identifier guid = new Identifier();
398
			guid.setValue("testIsAuthorized." + System.currentTimeMillis());
399
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
400
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
401
			// save it
402
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
403
			assertEquals(guid.getValue(), retGuid.getValue());
404
			// check it
405
			Subject publicSubject = new Subject();
406
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
407
			session.setSubject(publicSubject);
408
			// public read
409
			boolean result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.READ);
410
			assertTrue(result);
411
			// not public write
412
			try {
413
				result = false;
414
				result = CNodeService.getInstance(request).isAuthorized(session, guid, Permission.WRITE);
415
				fail("Public WRITE should be denied");
416
			} catch (NotAuthorized nae) {
417
				result = true;
418
			}
419
			assertTrue(result);
420
        } catch(Exception e) {
421
            fail("Unexpected error: " + e.getMessage());
422
        }
423
	}
424
	
425
	public void testReplicationPolicy() {
426
	    printTestHeader("testReplicationPolicy");
427

    
428
	    try {
429
            Session session = getTestSession();
430
			Identifier guid = new Identifier();
431
			guid.setValue("testReplicationPolicy." + System.currentTimeMillis());
432
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
433
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
434
	    long serialVersion = 1L;
435

    
436
			// save it
437
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
438
			assertEquals(guid.getValue(), retGuid.getValue());
439
			
440
			ReplicationPolicy policy = new ReplicationPolicy();
441
			NodeReference node = new NodeReference();
442
			node.setValue("testNode");
443
			policy.addPreferredMemberNode(node );
444
			// set it
445
			boolean result = CNodeService.getInstance(request).setReplicationPolicy(session, guid, policy, serialVersion);
446
			assertTrue(result);
447
			// get it
448
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
449
			assertNotNull(sysmeta);
450
			// check it
451
			assertEquals(policy.getPreferredMemberNode(0).getValue(), sysmeta.getReplicationPolicy().getPreferredMemberNode(0).getValue());
452
			
453
        } catch(Exception e) {
454
            fail("Unexpected error: " + e.getMessage());
455
        }
456
	}
457
	
458
	public void testReplicationStatus() {
459
	    printTestHeader("testReplicationStatus");
460

    
461
	    try {
462
            Session session = getTestSession();
463
			Identifier guid = new Identifier();
464
			guid.setValue("testReplicationStatus." + System.currentTimeMillis());
465
			InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
466
			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
467
      long serialVersion = 1L;
468
			Replica replica = new Replica();
469
			NodeReference replicaMemberNode = new NodeReference();
470
			replicaMemberNode.setValue("testNode");
471
			replica.setReplicationStatus(ReplicationStatus.REQUESTED);
472
			replica.setReplicaMemberNode(replicaMemberNode);
473
			replica.setReplicaVerified(new Date());
474
			sysmeta.addReplica(replica );
475
			// save it
476
			Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta);
477
			assertEquals(guid.getValue(), retGuid.getValue());
478
			// set it
479
			ReplicationStatus status = ReplicationStatus.COMPLETED;
480
			boolean result = CNodeService.getInstance(request).setReplicationStatus(session, guid, replicaMemberNode, status, serialVersion);
481
			assertTrue(result);
482
			// get it
483
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
484
			assertNotNull(sysmeta);
485
			// check it
486
			assertEquals(status, sysmeta.getReplica(0).getReplicationStatus());
487
			
488
        } catch(Exception e) {
489
            fail("Unexpected error: " + e.getMessage());
490
        }
491
	}
492
	
493
	/**
494
	 * Run an initial test that always passes to check that the test harness is
495
	 * working.
496
	 */
497
	public void initialize() 
498
	{
499
	    printTestHeader("initialize");
500
		assertTrue(1 == 1);
501
	}
502
	
503

    
504
	/**
505
	 * test to list the object formats registered in metacat
506
	 */
507
	public void testListFormats() {
508
		
509
    printTestHeader("testListFormats");
510
    
511
    // make sure we are set up
512
    setUpFormats();
513
    
514
    // there should be at least 59 formats in the list
515
  	int formatsCount = 59;
516
  	ObjectFormatList objectFormatList;
517
  	
518
  	try {
519
	    objectFormatList = CNodeService.getInstance(request).listFormats();
520
	  	assertTrue(objectFormatList.getTotal() >= formatsCount);
521
  	
522
  	} catch (ServiceFailure e) {
523
  		fail("Could not get the object format list: " + e.getMessage());
524

    
525
    } catch (InsufficientResources e) {
526
  		fail("Could not get the object format list: " + e.getMessage());
527

    
528
    } catch (NotImplemented e) {
529
  		fail("Could not get the object format list: " + e.getMessage());
530

    
531
    }
532
    
533
	}
534
	
535
  /**
536
   * Test getting a single object format from the registered list
537
   */
538
  public void testGetFormat() {
539
  	
540
    printTestHeader("testGetFormat");
541

    
542
    // make sure we are set up
543
    setUpFormats();
544
    
545
    String knownFormat = "text/plain";
546
    ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
547
    fmtid.setValue(knownFormat);
548
  	
549
    try {
550
	    
551
			String result = 
552
				CNodeService.getInstance(request).getFormat(fmtid).getFormatId().getValue();
553
	  	System.out.println("Expected result: " + knownFormat);
554
	  	System.out.println("Found    result: " + result);
555
	  	assertTrue(result.equals(knownFormat));
556
  
557
    } catch (NullPointerException npe) {	  
558
	    fail("The returned format was null: " + npe.getMessage());
559
    
560
    } catch (NotFound nfe) {     
561
    	fail("The format " + knownFormat + " was not found: " + nfe.getMessage());
562
    	
563
    } catch (ServiceFailure sfe) {
564
    	fail("The format " + knownFormat + " was not found: " + sfe.getMessage());
565

    
566
    } catch (InsufficientResources ise) {
567
    	fail("The format " + knownFormat + " was not found: " + ise.getMessage());
568
 
569
    } catch (NotImplemented nie) {
570
    	fail("The getFormat() method has not been implemented: " + nie.getMessage());
571

    
572
    }
573
  	
574
  }
575
	
576
  /**
577
   * Test getting a non-existent object format, returning NotFound
578
   */
579
  public void testObjectFormatNotFoundException() {
580
  
581
    printTestHeader("testObjectFormatNotFoundException");
582

    
583
    ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
584
  	String badFormat = "text/bad-format";
585
  	fmtid.setValue(badFormat);
586
  	
587
  	try {
588
  		
589
	    ObjectFormat objectFormat = 
590
	    	CNodeService.getInstance(request).getFormat(fmtid);
591
      
592
  	} catch (Exception e) {
593
	    
594
  		assertTrue(e instanceof NotFound);
595
  	}
596
  	
597
  }
598
 
599
}
(1-1/4)