Project

General

Profile

« Previous | Next » 

Revision 6790

query for deleted metadata when testing that replication communicated the deletion. to check data, we try to update the data object on the target node (which should fail)

View differences:

MCTestCase.java
181 181
			+ "  </instrument>                                                    "
182 182
			+ "</inline>                                                          ";
183 183

  
184
    
185
    /**
186
     * Returns an xml squery that searches for the doc id in the
187
     * title of documents. This function is for eml-2.0.1+ only. For 
188
     * other eml versions, this function might have to modified.
189
     */
190
    protected String getTestEmlQuery(String titlePart, String emlVersion) {
191

  
192
    	String docType;
193
    	if (emlVersion.equals(EML2_0_1)) {
194
    		docType = "eml://ecoinformatics.org/eml-2.0.1";
195
    	} else if (emlVersion.equals(EML2_1_0)) {
196
    		docType = "eml://ecoinformatics.org/eml-2.1.0";
197
    	} else { //if (emlVersion.equals(EML2_1_1)) {
198
    		docType = "eml://ecoinformatics.org/eml-2.1.1";
199
    	}
200
    	
201
        String sQuery = "";
202
        sQuery = 
203
        	"<pathquery version=\"1.0\">" +
204
        		"<meta_file_id>unspecified</meta_file_id>" +
205
        		"<querytitle>unspecified</querytitle>" + 
206
        		"<returnfield>dataset/title</returnfield>" +
207
        		"<returndoctype>" + docType + "</returndoctype>" +
208
        		"<querygroup operator=\"UNION\">" +
209
        			"<queryterm casesensitive=\"false\" searchmode=\"contains\">" +
210
        				"<value>" + titlePart + "</value>" +
211
        				"<pathexpr>dataset/title</pathexpr>" +
212
        			"</queryterm>" +
213
        		"</querygroup>" +
214
        	"</pathquery>";
215

  
216
        return sQuery;
217
    }
218
	
219
	/**
220
     * Query a document by looking for a part of the title in the title element.
221
     * Then check if the testTitle exists in the doc.
222
     * @param titlePart the part of the title of the doc to look for
223
     * @param testTitle the title containing special characters
224
     * @param result are we expecting SUCCESS or FAILURE
225
     * @param expextedKarmaFailure
226
     */
227
    protected void queryDocWhichHasTitle(String titlePart, String testTitle,
228
                                         String emlVersion, boolean result) {
229
        try {
230
            String sQuery = getTestEmlQuery(titlePart, emlVersion);
231
        	Reader queryReader = new StringReader(sQuery);
232
            Reader resultReader = m.query(queryReader);
233
            String queryResult = IOUtil.getAsString(resultReader, true);
234
            if (result) {
235
                if (!queryResult.contains(testTitle)) {
236
                    debug("queryResult: " + queryResult);
237
                    debug("does not contain title: " + testTitle);
238
                }
239

  
240
                assertTrue(queryResult.contains(testTitle));
241
            }
242
            else {
243
                assertTrue(queryResult.indexOf("<error>") != -1);
244
            }
245
        }
246
        catch (MetacatInaccessibleException mie) {
247
            fail("Metacat Inaccessible:\n" + mie.getMessage());
248
        }
249
        catch (Exception e) {
250
            fail("General exception:\n" + e.getMessage());
251
        }
252

  
253
    }
254
	
184 255
	/*
185 256
	 * Retrus an access block base on params passed and the defaul perm order -
186 257
	 * allow first

Also available in: Unified diff