Revision 5757
Added by ben leinfelder over 13 years ago
NonAsciiCharacterTest.java | ||
---|---|---|
161 | 161 |
return accessBlock; |
162 | 162 |
|
163 | 163 |
} |
164 |
|
|
165 |
/** |
|
166 |
* This function returns a valid eml document with no access rules |
|
167 |
* This function is for eml-2.0.1 only. For other eml versions, |
|
168 |
* this function might have to modified |
|
169 |
*/ |
|
170 |
private String getTestEmlDoc(String title, String emlVersion) { |
|
171 |
|
|
172 |
String testDocument = ""; |
|
173 |
|
|
174 |
String header; |
|
175 |
if (emlVersion == EML2_0_1) { |
|
176 |
header = testEml_201_Header; |
|
177 |
} else if (emlVersion == EML2_1_0) { |
|
178 |
header = testEml_210_Header; |
|
179 |
} else { // if (emlVersion == EML2_1_1) { |
|
180 |
header = testEml_211_Header; |
|
181 |
} |
|
182 |
|
|
183 |
testDocument += header; |
|
184 |
|
|
185 |
// if this is an EML 2.1.0 or later document, the document level access is |
|
186 |
// before the dataset element. |
|
187 |
if (emlVersion == EML2_1_0 || emlVersion == EML2_1_1) { |
|
188 |
testDocument += getAccessBlock("public", true, true, false, false, false); |
|
189 |
} |
|
190 |
testDocument += "<dataset scope=\"document\"><title>" + title + "</title>" |
|
191 |
+ testEmlCreatorBlock; |
|
192 |
|
|
193 |
testDocument += testEmlContactBlock; |
|
194 |
|
|
195 |
// if this is an EML 2.0.1 or earlier document, the document level access is |
|
196 |
// inside the dataset element. |
|
197 |
if (emlVersion != EML2_1_0) { |
|
198 |
testDocument += getAccessBlock("public", true, true, false, false, false); |
|
199 |
} |
|
200 |
testDocument += "</dataset>"; |
|
201 |
testDocument += "</eml:eml>"; |
|
202 |
|
|
203 |
return testDocument; |
|
204 |
} |
|
205 | 164 |
|
206 | 165 |
/** |
207 | 166 |
* Returns an xml squery that searches for the doc id in the |
... | ... | |
283 | 242 |
suite.addTest(new NonAsciiCharacterTest("numericCharacterReferenceFormat210Test")); |
284 | 243 |
suite.addTest(new NonAsciiCharacterTest("nonLatinUnicodeCharacter201Test")); |
285 | 244 |
suite.addTest(new NonAsciiCharacterTest("nonLatinUnicodeCharacter210Test")); |
286 |
suite.addTest(new NonAsciiCharacterTest("unicodeCharacterTest")); |
|
287 | 245 |
|
288 | 246 |
return suite; |
289 | 247 |
} |
... | ... | |
664 | 622 |
fail("General exception:\n" + e.getMessage()); |
665 | 623 |
} |
666 | 624 |
} |
667 |
|
|
668 |
/** |
|
669 |
* Test inserting and reading an EML 2.1.0 with Chinese |
|
670 |
*/ |
|
671 |
public void unicodeCharacterTest() { |
|
672 |
debug("\nRunning: unicodeCharacterTest"); |
|
673 |
try { |
|
674 |
|
|
675 |
String filePath = "test/clienttestfiles/unicodeEML.xml"; |
|
676 |
String testTitle = "測試中的數據包 (Test Chinese data package) _DOCID_"; |
|
677 |
String newdocid = generateDocid() + ".1"; |
|
678 |
testdocument = FileUtil.readFileToString(filePath, "UTF-8"); |
|
679 |
|
|
680 |
// include the docid |
|
681 |
testdocument = testdocument.replaceAll("_DOCID_", newdocid); |
|
682 |
testTitle = testTitle.replaceAll("_DOCID_", newdocid); |
|
683 |
|
|
684 |
// login |
|
685 |
m.login(username, password); |
|
686 |
|
|
687 |
// insert |
|
688 |
insertDocid(newdocid, testdocument, SUCCESS, false); |
|
689 | 625 |
|
690 |
// this tests reading the document back from disk |
|
691 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true); |
|
692 |
|
|
693 |
// this tests searching for the document in the database |
|
694 |
Thread.sleep(3000); |
|
695 |
queryDocWhichHasTitle(testTitle, testTitle, EML2_1_0, SUCCESS); |
|
696 |
|
|
697 |
// clean up |
|
698 |
deleteDocid(newdocid, SUCCESS, false); |
|
699 |
|
|
700 |
m.logout(); |
|
701 |
} |
|
702 |
catch (MetacatAuthException mae) { |
|
703 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
704 |
} |
|
705 |
catch (MetacatInaccessibleException mie) { |
|
706 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
707 |
} |
|
708 |
catch (Exception e) { |
|
709 |
fail("General exception:\n" + e.getMessage()); |
|
710 |
} |
|
711 |
} |
|
712 |
|
|
713 | 626 |
/** |
714 | 627 |
* Insert a document into metacat. The expected result is passed as result |
715 | 628 |
*/ |
Also available in: Unified diff
create another test for various i18n features including eml 2.1.1
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2495