test the correct setting of publicID and systemID on Document, based on
the startDTD event of LexicalHandler, implemented in DocumentBuilder

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java
new file mode 100644
index 0000000..f7708f9
--- /dev/null
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************

+ * Copyright (c) 2011 Florian Thienel and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * Contributors:

+ * 		Florian Thienel - initial API and implementation

+ *******************************************************************************/

+package org.eclipse.vex.core.internal.dom;

+

+import static org.junit.Assert.*;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.assertNull;

+

+import java.net.URL;

+

+import org.eclipse.vex.core.tests.TestResources;

+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;

+import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;

+import org.junit.Test;

+

+/**

+ * @author Florian Thienel

+ */

+public class DocumentReaderTest {

+	

+	@Test

+	public void readDocumentWithDtdPublic() throws Exception {

+		final DocumentReader reader = new DocumentReader();

+		reader.setWhitespacePolicyFactory(IWhitespacePolicyFactory.NULL);

+		final Document document = reader.read(TestResources.get("documentWithDtdPublic.xml"));

+		assertEquals("-//Eclipse Foundation//DTD Vex Test//EN", document.getPublicID());

+		assertEquals("test1.dtd", document.getSystemID());

+	}

+

+	@Test

+	public void testname() throws Exception {

+		final DocumentReader reader = new DocumentReader();

+		reader.setWhitespacePolicyFactory(IWhitespacePolicyFactory.NULL);

+		final URL documentUrl = TestResources.get("documentWithDtdSystem.xml");

+		final Document document = reader.read(documentUrl);

+		assertNull(document.getPublicID());

+		assertEquals("test1.dtd", document.getSystemID());

+	}

+	

+	@Test

+	public void resolveDtdWithSystemId() throws Exception {

+		final URL documentUrl = TestResources.get("documentWithDtdSystem.xml");

+		final ContentModelManager modelManager = ContentModelManager.getInstance();

+		final URL dtdUrl = new URL(documentUrl, "test1.dtd");

+		final CMDocument dtd = modelManager.createCMDocument(dtdUrl.toString(), null);

+		assertNotNull(dtd.getElements().getNamedItem("section"));

+	}

+}

diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestSuite.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestSuite.java
index 0df4c9c..de69eba 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestSuite.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestSuite.java
@@ -21,6 +21,7 @@
 import org.eclipse.vex.core.internal.css.RuleTest;
 import org.eclipse.vex.core.internal.dom.BlockElementBoxTest;
 import org.eclipse.vex.core.internal.dom.DTDValidatorTest;
+import org.eclipse.vex.core.internal.dom.DocumentReaderTest;
 import org.eclipse.vex.core.internal.dom.DocumentWriterTest;
 import org.eclipse.vex.core.internal.dom.GapContentTest;
 import org.eclipse.vex.core.internal.dom.NamespaceStackTest;
@@ -45,6 +46,7 @@
 		super("Vex Core Tests");
 		addTest(new JUnit4TestAdapter(NamespaceStackTest.class));
 		addTest(new JUnit4TestAdapter(NamespaceTest.class));
+		addTest(new JUnit4TestAdapter(DocumentReaderTest.class));
 		addTest(new JUnit4TestAdapter(SchemaValidatorTest.class));
 		addTestSuite(CssTest.class);
 		addTestSuite(PropertyTest.class);
diff --git a/org.eclipse.vex.core.tests/testResources/documentWithDtdPublic.xml b/org.eclipse.vex.core.tests/testResources/documentWithDtdPublic.xml
new file mode 100644
index 0000000..70c9dd4
--- /dev/null
+++ b/org.eclipse.vex.core.tests/testResources/documentWithDtdPublic.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>

+<!DOCTYPE section PUBLIC "-//Eclipse Foundation//DTD Vex Test//EN" "test1.dtd">

+<section>

+	<title>Testdocument with DTD (Public Identifier)</title>

+	<para>This is a Testdocument using a DTD which is referenced by a public identifier.</para>

+</section>
\ No newline at end of file
diff --git a/org.eclipse.vex.core.tests/testResources/documentWithDtdSystem.xml b/org.eclipse.vex.core.tests/testResources/documentWithDtdSystem.xml
new file mode 100644
index 0000000..7637e16
--- /dev/null
+++ b/org.eclipse.vex.core.tests/testResources/documentWithDtdSystem.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>

+<!DOCTYPE section SYSTEM "test1.dtd">

+<section>

+	<title>Testdocument with DTD (System Identifier)</title>

+	<para>This is a Testdocument using a DTD which is referenced by a system identifier.</para>

+</section>
\ No newline at end of file