Skip to content

Commit 6f2d8a0

Browse files
committed
Remove XML validation from NSArray/NSDictionary tests
Calling XML validation results in hitting the Apple web servers to load a DTD for plists http://www.apple.com/DTDs/PropertyList-1.0.dtd to correctly validate the XML file. Given that this test is not about whether it is possible to read or write property lists, but they're just being used to validate that they can read and write arrays from them, remove this part of the test. The property list gets parsed from the subsequent PropertyListSerialization call anyway, which will do the same error checking as if the document is valid (but probably with a hard-coded DTD instead of a network accessible one) Issue: SR-2793
1 parent d2212fe commit 6f2d8a0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

TestFoundation/TestNSArray.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,12 @@ class TestNSArray : XCTestCase {
483483
if isWritten {
484484
do {
485485
let plistDoc = try XMLDocument(contentsOf: URL(fileURLWithPath: testFilePath!, isDirectory: false), options: [])
486-
try plistDoc.validate()
487486
XCTAssert(plistDoc.rootElement()?.name == "plist")
488487
let plist = try PropertyListSerialization.propertyList(from: plistDoc.xmlData, options: [], format: nil) as! [Any]
489488
XCTAssert((plist[0] as? String) == d1[0] as? String)
490489
XCTAssert((plist[1] as? String) == d1[1] as? String)
491490
} catch {
492-
XCTFail("XMLDocument failes to read / validate contenets")
491+
XCTFail("Failed to read and parse XMLDocument")
493492
}
494493
} else {
495494
XCTFail("Write to file failed")

TestFoundation/TestNSDictionary.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,15 @@ class TestNSDictionary : XCTestCase {
168168
if let _ = testFilePath {
169169
let d1: NSDictionary = [ "foo": "bar", "baz": "qux"]
170170
let isWritten = d1.write(toFile: testFilePath!, atomically: true)
171-
if(isWritten){
172-
do{
171+
if isWritten {
172+
do {
173173
let plistDoc = try XMLDocument(contentsOf: URL(fileURLWithPath: testFilePath!, isDirectory: false), options: [])
174-
try plistDoc.validate()
175174
XCTAssert(plistDoc.rootElement()?.name == "plist")
176175
let plist = try PropertyListSerialization.propertyList(from: plistDoc.xmlData, options: [], format: nil) as! [String: Any]
177176
XCTAssert((plist["foo"] as? String) == d1["foo"] as? String)
178177
XCTAssert((plist["baz"] as? String) == d1["baz"] as? String)
179178
} catch {
180-
XCTFail("XMLDocument failes to read / validate contenets")
179+
XCTFail("Failed to read and parse XMLDocument")
181180
}
182181
} else {
183182
XCTFail("Write to file failed")

0 commit comments

Comments
 (0)