Project

General

Profile

« Previous | Next » 

Revision 6796

adjust after refactoring tests that use EML queries

View differences:

InternationalizationTest.java
62 62
     * Returns an xml squery that searches for the doc id in the
63 63
     * title of documents. This function is for eml-2.0.1+ only. For 
64 64
     * other eml versions, this function might have to modified.
65
     * NOTE: this override includes the "value" i18n element for eml 2.1.1
65 66
     */
66
    private String getTestEmlQuery(String titlePart, String emlVersion) {
67
	@Override
68
    protected String getTestEmlQuery(String titlePart, String emlVersion) {
67 69

  
68 70
    	String docType;
69 71
    	if (emlVersion.equals(EML2_0_1)) {
......
502 504
        }
503 505

  
504 506
    }
505
    
506
    /**
507
     * Query a document by looking for a part of the title in the title element.
508
     * Then check if the testTitle exists in the doc.
509
     * @param titlePart the part of the title of the doc to look for
510
     * @param testTitle the title containing special characters
511
     * @param result are we expecting SUCCESS or FAILURE
512
     * @param expextedKarmaFailure
513
     */
514
    private void queryDocWhichHasTitle(String titlePart, String testTitle,
515
                                         String emlVersion, boolean result) {
516
        try {
517
            String sQuery = getTestEmlQuery(titlePart, emlVersion);
518
        	Reader queryReader = new StringReader(sQuery);
519
            Reader resultReader = m.query(queryReader);
520
            String queryResult = IOUtil.getAsString(resultReader, true);
521
            if (result) {
522
                if (!queryResult.contains(testTitle)) {
523
                    debug("queryResult: " + queryResult);
524
                    debug("does not contain title: " + testTitle);
525
                }
526 507

  
527
                assertTrue(queryResult.contains(testTitle));
528
            }
529
            else {
530
                assertTrue(queryResult.indexOf("<error>") != -1);
531
            }
532
        }
533
        catch (MetacatInaccessibleException mie) {
534
            fail("Metacat Inaccessible:\n" + mie.getMessage());
535
        }
536
        catch (Exception e) {
537
            fail("General exception:\n" + e.getMessage());
538
        }
539

  
540
    }
541

  
542 508
    /**
543 509
     * Create a hopefully unique docid for testing insert and update. Does
544 510
     * not include the 'revision' part of the id.

Also available in: Unified diff