Revision 6790
Added by ben leinfelder over 12 years ago
NonAsciiCharacterTest.java | ||
---|---|---|
161 | 161 |
return accessBlock; |
162 | 162 |
|
163 | 163 |
} |
164 |
|
|
165 |
/** |
|
166 |
* Returns an xml squery that searches for the doc id in the |
|
167 |
* title of documents. This function is for eml-2.0.1+ only. For |
|
168 |
* other eml versions, this function might have to modified. |
|
169 |
*/ |
|
170 |
private String getTestEmlQuery(String titlePart, String emlVersion) { |
|
171 | 164 |
|
172 |
String docType; |
|
173 |
if (emlVersion.equals(EML2_0_1)) { |
|
174 |
docType = "eml://ecoinformatics.org/eml-2.0.1"; |
|
175 |
} else if (emlVersion.equals(EML2_1_0)) { |
|
176 |
docType = "eml://ecoinformatics.org/eml-2.1.0"; |
|
177 |
} else { //if (emlVersion.equals(EML2_1_1)) { |
|
178 |
docType = "eml://ecoinformatics.org/eml-2.1.1"; |
|
179 |
} |
|
180 |
|
|
181 |
String sQuery = ""; |
|
182 |
sQuery = |
|
183 |
"<pathquery version=\"1.0\">" + |
|
184 |
"<meta_file_id>unspecified</meta_file_id>" + |
|
185 |
"<querytitle>unspecified</querytitle>" + |
|
186 |
"<returnfield>dataset/title</returnfield>" + |
|
187 |
"<returndoctype>" + docType + "</returndoctype>" + |
|
188 |
"<querygroup operator=\"UNION\">" + |
|
189 |
"<queryterm casesensitive=\"false\" searchmode=\"contains\">" + |
|
190 |
"<value>" + titlePart + "</value>" + |
|
191 |
"<pathexpr>dataset/title</pathexpr>" + |
|
192 |
"</queryterm>" + |
|
193 |
"</querygroup>" + |
|
194 |
"</pathquery>"; |
|
195 |
|
|
196 |
return sQuery; |
|
197 |
} |
|
198 |
|
|
199 | 165 |
/** |
200 | 166 |
* Constructor to build the test |
201 | 167 |
* |
... | ... | |
847 | 813 |
} |
848 | 814 |
|
849 | 815 |
} |
850 |
|
|
851 |
/** |
|
852 |
* Query a document by looking for a part of the title in the title element. |
|
853 |
* Then check if the testTitle exists in the doc. |
|
854 |
* @param titlePart the part of the title of the doc to look for |
|
855 |
* @param testTitle the title containing special characters |
|
856 |
* @param result are we expecting SUCCESS or FAILURE |
|
857 |
* @param expextedKarmaFailure |
|
858 |
*/ |
|
859 |
private void queryDocWhichHasTitle(String titlePart, String testTitle, |
|
860 |
String emlVersion, boolean result) { |
|
861 |
try { |
|
862 |
String sQuery = getTestEmlQuery(titlePart, emlVersion); |
|
863 |
Reader queryReader = new StringReader(sQuery); |
|
864 |
Reader resultReader = m.query(queryReader); |
|
865 |
String queryResult = IOUtil.getAsString(resultReader, true); |
|
866 |
if (result) { |
|
867 |
if (!queryResult.contains(testTitle)) { |
|
868 |
debug("queryResult: " + queryResult); |
|
869 |
debug("does not contain title: " + testTitle); |
|
870 |
} |
|
871 | 816 |
|
872 |
assertTrue(queryResult.contains(testTitle)); |
|
873 |
} |
|
874 |
else { |
|
875 |
assertTrue(queryResult.indexOf("<error>") != -1); |
|
876 |
} |
|
877 |
} |
|
878 |
catch (MetacatInaccessibleException mie) { |
|
879 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
880 |
} |
|
881 |
catch (Exception e) { |
|
882 |
fail("General exception:\n" + e.getMessage()); |
|
883 |
} |
|
884 |
|
|
885 |
} |
|
886 |
|
|
887 | 817 |
/** |
888 | 818 |
* Create a hopefully unique docid for testing insert and update. Does |
889 | 819 |
* not include the 'revision' part of the id. |
Also available in: Unified diff
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)