Project

General

Profile

« Previous | Next » 

Revision 6360

remove CrudServiceTest reference in main Metacat test (about to remove from svn)

View differences:

test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java
27 27
package edu.ucsb.nceas.metacattest;
28 28

  
29 29
import edu.ucsb.nceas.MCTestCase;
30
import edu.ucsb.nceas.metacat.dataone.CrudServiceTest;
31 30
import edu.ucsb.nceas.metacat.properties.PropertyService;
32 31
import edu.ucsb.nceas.utilities.HttpMessage;
33 32
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
......
39 38
import java.net.*;
40 39
import java.util.*;
41 40

  
42
import org.dataone.service.types.AuthToken;
43
import org.dataone.service.types.Identifier;
44 41

  
45 42
/**
46 43
 * A JUnit test for testing Step class processing
......
123 120
		suite.addTest(new MetaCatServletTest("testReadXMLDocumentZipFormat", serial));
124 121

  
125 122
		suite.addTest(new MetaCatServletTest("testDeleteXMLDocument", serial));
126
		
127
		// test delete using GUID
128
		number = Math.random() * 100000;
129
		serial = Integer.toString(((new Double(number)).intValue()));
130
		suite.addTest(new MetaCatServletTest("testDeleteDocumentByGUID", serial));
131

  
123
	
132 124
		// insert invalid xml document
133 125
		number = Math.random() * 100000;
134 126
		serial = Integer.toString(((new Double(number)).intValue()));
......
418 410

  
419 411
	}
420 412

  
421
    /**
422
     * Test to delete a document by GUID (not docid).  This exercises 
423
     * MetacatServlet.handleDeleteAction()'s handling of GUIDs.
424
     */
425
    public void testDeleteDocumentByGUID() {
426
        debug("\nRunning: testDeleteDocumentByGUID test");
427

  
428
        try {
429
            String user = PropertyService.getProperty("test.mcUser");
430
            String passwd = PropertyService.getProperty("test.mcPassword");
431
            
432
            CrudServiceTest crudServiceTest = new CrudServiceTest("testDeleteDocumentByGUID");
433
            String guid = "";
434
            AuthToken token = null;
435
            String result = "";
436
            // create a document via the CRUD service to get a GUID
437
            try {
438
                token = crudServiceTest.getToken(user, passwd);
439
                String testDocument = crudServiceTest.getTestDoc();
440
                Identifier identifier = crudServiceTest.createDoc(token, testDocument);
441
                guid = identifier.getValue();
442
            } catch (Exception e) {
443
                fail("Could not create test document to delete: " + e.getMessage());
444
            }
445

  
446
            // delete the document via the Metacat servlet with the GUID
447
            try {
448
                Properties props = new Properties();
449
                props.put("action", "delete");
450
                props.put("docid", guid);
451
                props.put("sessionid", token.getToken());
452
                debug("Trying to delete by GUID: " + guid);
453
                result = getMetacatString(props);
454
            } catch (Exception e) {
455
                fail("Couldn't delete GUID: " + guid);
456
            }
457
            assertTrue(result.indexOf("<success>") > 0);
458
        } catch (PropertyNotFoundException pnfe) {
459
            fail("Could not find property: " + pnfe.getMessage());
460
        }
461
    }
462 413
    
463 414
	/**
464 415
	 * Test logout action

Also available in: Unified diff