Skip to content

Commit ec24f77

Browse files
committed
Follow-up to previous commit.
1 parent 927d280 commit ec24f77

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

junit/io/sf/carte/doc/xml/dtd/DefaultEntityResolverTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public void resolveNonexistentDeclaration() {
189189

190190
@Test
191191
public void resolveNonexistent() {
192+
// No SystemId, so it should resolve to null
192193
InputSource isrc = null;
193194
try {
194195
isrc = resolver.resolveEntity("hi", null);
@@ -198,6 +199,17 @@ public void resolveNonexistent() {
198199
assertNull(isrc);
199200
}
200201

202+
@Test
203+
public void testRegisterNonExistentPathFromSubclass() throws SAXException, IOException {
204+
resolver.registerSystemIdFilename("http://www.example.com/some.dtd", "/dtd/example.dtd");
205+
try {
206+
resolver.resolveEntity(null, "http://www.example.com/some.dtd");
207+
fail("Must throw an exception.");
208+
} catch (SAXException e) {
209+
}
210+
classFixture(); // reset the resolver.
211+
}
212+
201213
@Test
202214
public void testRegisterInvalidPathFromSubclass() throws SAXException, IOException {
203215
try {

src/io/sf/carte/doc/xml/dtd/DefaultEntityResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ public final InputSource resolveEntity(String name, String publicId, String base
275275
if (systemId != null) {
276276
isrc.setSystemId(systemId);
277277
}
278+
} else {
279+
throw new SAXException("Could not find resource: " + fname);
278280
}
279281
} else if (systemId != null) {
280282
URL enturl;

0 commit comments

Comments
 (0)