From: <bo...@us...> - 2009-06-05 10:45:08
|
Revision: 343 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=343&view=rev Author: bodewig Date: 2009-06-05 10:45:00 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Use explicit instanceOf matchers Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2009-06-02 14:13:03 UTC (rev 342) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2009-06-05 10:45:00 UTC (rev 343) @@ -26,6 +26,7 @@ import javax.xml.transform.sax.SAXSource; import org.w3c.dom.Document; import static org.hamcrest.core.Is.*; +import static org.hamcrest.core.IsInstanceOf.*; import static org.hamcrest.core.IsNull.*; import static org.junit.Assert.*; import org.junit.Test; @@ -45,9 +46,9 @@ // it looks as if SAXSource.sourceToInputSource cannot deal // with a DOMSource, so we cannot use the parse method Source s = Input.fromDocument(d).build(); - assertThat(s, is(DOMSource.class)); + assertThat(s, instanceOf(DOMSource.class)); Object o = ((DOMSource) s).getNode(); - assertThat(o, is(Document.class)); + assertThat(o, instanceOf(Document.class)); Document d2 = (Document) o; assertThat(d2, notNullValue()); assertThat(d2.getDocumentElement().getTagName(), is("animal")); @@ -113,9 +114,9 @@ .build()) .build(); // again, transformed is a DOMSource, cannot use parse() - assertThat(s, is(DOMSource.class)); + assertThat(s, instanceOf(DOMSource.class)); Object o = ((DOMSource) s).getNode(); - assertThat(o, is(Document.class)); + assertThat(o, instanceOf(Document.class)); Document d2 = (Document) o; assertThat(d2, notNullValue()); assertThat(d2.getDocumentElement().getTagName(), is("furry")); Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java 2009-06-02 14:13:03 UTC (rev 342) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java 2009-06-05 10:45:00 UTC (rev 343) @@ -16,7 +16,7 @@ import java.io.File; import javax.xml.transform.stream.StreamSource; import net.sf.xmlunit.exceptions.XMLUnitException; -import static org.hamcrest.core.Is.*; +import static org.hamcrest.core.IsInstanceOf.*; import static org.junit.Assert.*; import org.junit.Test; @@ -61,7 +61,7 @@ v.validateInstance(new StreamSource(new File("src/tests/resources/BookXsdGenerated.xml"))); fail("should have thrown an exception"); } catch (Exception e) { - assertThat(e, is(XMLUnitException.class)); + assertThat(e, instanceOf(XMLUnitException.class)); } } @@ -72,7 +72,7 @@ v.validateInstance(new StreamSource(new File("src/tests/resources/BookXsdGenerated.xml"))); fail("should have thrown an exception"); } catch (Exception e) { - assertThat(e, is(XMLUnitException.class)); + assertThat(e, instanceOf(XMLUnitException.class)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 08:48:30
|
Revision: 365 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=365&view=rev Author: bodewig Date: 2010-04-29 08:48:24 +0000 (Thu, 29 Apr 2010) Log Message: ----------- test for convert Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:48:24 UTC (rev 365) @@ -0,0 +1,60 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.util; + +import java.io.File; +import java.io.FileInputStream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamSource; +import org.hamcrest.core.IsNull; +import org.junit.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import static org.junit.Assert.assertThat; +import static org.hamcrest.core.Is.is; + +public class ConvertTest { + + private static final String TEST_FILE = "src/tests/resources/test1.xml"; + + private static void convertAndAssert(Source s) throws Exception { + DocumentBuilder b = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document d = b.parse(Convert.toInputSource(s)); + assertThat(d, IsNull.notNullValue()); + assertThat(d.getDocumentElement().getTagName(), is("animal")); + } + + @Test public void streamSourceToInputSource() throws Exception { + convertAndAssert(new StreamSource(new File(TEST_FILE))); + } + + @Test public void domSourceToInputSource() throws Exception { + DocumentBuilder b = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document d = b.parse(new File(TEST_FILE)); + convertAndAssert(new DOMSource(d)); + } + + @Test public void saxSourceToInputSource() throws Exception { + InputSource s = new InputSource(new FileInputStream(TEST_FILE)); + convertAndAssert(new SAXSource(s)); + } + +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 08:58:12
|
Revision: 366 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=366&view=rev Author: bodewig Date: 2010-04-29 08:58:05 +0000 (Thu, 29 Apr 2010) Log Message: ----------- take advantage of Connvert.toInputSource Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 08:58:05 UTC (rev 366) @@ -0,0 +1,21 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit; + +public final class Resources { + public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; + + private Resources() { } + +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 08:48:24 UTC (rev 365) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 08:58:05 UTC (rev 366) @@ -22,50 +22,42 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; import org.w3c.dom.Document; +import net.sf.xmlunit.Resources; +import net.sf.xmlunit.util.Convert; +import org.junit.Test; + import static org.hamcrest.core.Is.*; import static org.hamcrest.core.IsInstanceOf.*; import static org.hamcrest.core.IsNull.*; import static org.junit.Assert.*; -import org.junit.Test; public class InputTest { - private static final String TEST_FILE = "src/tests/resources/test1.xml"; - private static Document parse(Source s) throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - return b.parse(SAXSource.sourceToInputSource(s)); + return b.parse(Convert.toInputSource(s)); } @Test public void shouldParseADocument() throws Exception { - Document d = parse(Input.fromFile(TEST_FILE).build()); - // it looks as if SAXSource.sourceToInputSource cannot deal - // with a DOMSource, so we cannot use the parse method + Document d = parse(Input.fromFile(Resources.ANIMAL_FILE).build()); Source s = Input.fromDocument(d).build(); - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("animal")); + allIsWellFor(s); } @Test public void shouldParseAnExistingFileByName() throws Exception { - allIsWellFor(Input.fromFile(TEST_FILE).build()); + allIsWellFor(Input.fromFile(Resources.ANIMAL_FILE).build()); } @Test public void shouldParseAnExistingFileByFile() throws Exception { - allIsWellFor(Input.fromFile(new File(TEST_FILE)).build()); + allIsWellFor(Input.fromFile(new File(Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseAnExistingFileFromStream() throws Exception { FileInputStream is = null; try { - is = new FileInputStream(TEST_FILE); + is = new FileInputStream(Resources.ANIMAL_FILE); allIsWellFor(Input.fromStream(is).build()); } finally { if (is != null) { @@ -77,7 +69,7 @@ @Test public void shouldParseAnExistingFileFromReader() throws Exception { FileReader r = null; try { - r = new FileReader(TEST_FILE); + r = new FileReader(Resources.ANIMAL_FILE); allIsWellFor(Input.fromReader(r).build()); } finally { if (r != null) { @@ -96,15 +88,15 @@ } @Test public void shouldParseFileFromURIString() throws Exception { - allIsWellFor(Input.fromURI("file:" + TEST_FILE).build()); + allIsWellFor(Input.fromURI("file:" + Resources.ANIMAL_FILE).build()); } @Test public void shouldParseFileFromURI() throws Exception { - allIsWellFor(Input.fromURI(new URI("file:" + TEST_FILE)).build()); + allIsWellFor(Input.fromURI(new URI("file:" + Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseFileFromURL() throws Exception { - allIsWellFor(Input.fromURL(new URL("file:" + TEST_FILE)).build()); + allIsWellFor(Input.fromURL(new URL("file:" + Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseATransformationFromSource() throws Exception { @@ -113,13 +105,7 @@ .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl") .build()) .build(); - // again, transformed is a DOMSource, cannot use parse() - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("furry")); + allIsWellFor(s, "furry"); } @Test public void shouldParseATransformationFromBuilder() throws Exception { @@ -127,24 +113,23 @@ Source s = Input.byTransforming(input) .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl")) .build(); - // again, transformed is a DOMSource, cannot use parse() - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("furry")); + allIsWellFor(s, "furry"); } private static void allIsWellFor(Source s) throws Exception { + allIsWellFor(s, "animal"); + } + + private static void allIsWellFor(Source s, String rootElementName) + throws Exception { assertThat(s, notNullValue()); Document d = parse(s); assertThat(d, notNullValue()); - assertThat(d.getDocumentElement().getTagName(), is("animal")); + assertThat(d.getDocumentElement().getTagName(), is(rootElementName)); } private static byte[] readTestFile() throws Exception { - FileInputStream is = new FileInputStream(TEST_FILE); + FileInputStream is = new FileInputStream(Resources.ANIMAL_FILE); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int read = -1; Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:48:24 UTC (rev 365) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:58:05 UTC (rev 366) @@ -21,6 +21,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import net.sf.xmlunit.Resources; import org.hamcrest.core.IsNull; import org.junit.Test; import org.w3c.dom.Document; @@ -31,8 +32,6 @@ public class ConvertTest { - private static final String TEST_FILE = "src/tests/resources/test1.xml"; - private static void convertAndAssert(Source s) throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); @@ -42,18 +41,18 @@ } @Test public void streamSourceToInputSource() throws Exception { - convertAndAssert(new StreamSource(new File(TEST_FILE))); + convertAndAssert(new StreamSource(new File(Resources.ANIMAL_FILE))); } @Test public void domSourceToInputSource() throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document d = b.parse(new File(TEST_FILE)); + Document d = b.parse(new File(Resources.ANIMAL_FILE)); convertAndAssert(new DOMSource(d)); } @Test public void saxSourceToInputSource() throws Exception { - InputSource s = new InputSource(new FileInputStream(TEST_FILE)); + InputSource s = new InputSource(new FileInputStream(Resources.ANIMAL_FILE)); convertAndAssert(new SAXSource(s)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 15:37:51
|
Revision: 370 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=370&view=rev Author: bodewig Date: 2010-04-29 15:37:45 +0000 (Thu, 29 Apr 2010) Log Message: ----------- Add unit tests for XPathEngine Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 10:15:52 UTC (rev 369) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 15:37:45 UTC (rev 370) @@ -15,6 +15,7 @@ public final class Resources { public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; + public static final String BLAME_FILE = "src/tests/resources/test.blame.html"; private Resources() { } Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-04-29 15:37:45 UTC (rev 370) @@ -0,0 +1,107 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.xpath; + +import java.util.HashMap; +import java.util.Iterator; +import javax.xml.transform.Source; +import net.sf.xmlunit.Resources; +import net.sf.xmlunit.builder.Input; +import net.sf.xmlunit.exceptions.XMLUnitException; +import org.junit.Before; +import org.junit.Test; +import org.w3c.dom.Node; + +import static org.junit.Assert.*; + +public class JAXPXPathEngineTest { + + private Source source; + + @Before public void readSource() throws Exception { + source = Input.fromFile(Resources.BLAME_FILE).build(); + } + + @Test public void selectNodesWithNoMatches() { + Iterable<Node> i = new JAXPXPathEngine().selectNodes("foo", source); + assertNotNull(i); + assertFalse(i.iterator().hasNext()); + } + + @Test public void selectNodesWithSingleMatch() { + Iterable<Node> i = new JAXPXPathEngine().selectNodes("//ul", source); + assertNotNull(i); + Iterator<Node> it = i.iterator(); + assertTrue(it.hasNext()); + assertEquals("ul", it.next().getNodeName()); + assertFalse(it.hasNext()); + } + + @Test public void selectNodesWithMultipleMatchs() { + Iterable<Node> i = new JAXPXPathEngine().selectNodes("//li", source); + assertNotNull(i); + int count = 0; + for (Iterator<Node> it = i.iterator(); it.hasNext(); ) { + count++; + assertEquals("li", it.next().getNodeName()); + } + assertEquals(4, count); + } + + @Test(expected=XMLUnitException.class) + public void selectNodesWithInvalidXPath() { + new JAXPXPathEngine().selectNodes("//li[", source); + } + + @Test public void evaluateWithNoMatches() { + assertEquals("", new JAXPXPathEngine().evaluate("foo", source)); + } + + @Test public void evaluateWithSingleMatch() { + assertEquals("Don't blame it on the...", + new JAXPXPathEngine().evaluate("//title", source)); + } + + @Test public void evaluateWithMultipleMatchs() { + assertEquals("sunshine", + new JAXPXPathEngine().evaluate("//li", source)); + } + + @Test(expected=XMLUnitException.class) + public void evaluateWithInvalidXPath() { + new JAXPXPathEngine().evaluate("//li[", source); + } + + @Test public void selectNodesWithNS() { + JAXPXPathEngine e = new JAXPXPathEngine(); + source = Input.fromMemory("<n:d xmlns:n='urn:test:1'><n:e/></n:d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("x", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/x:d/x:e", source); + assertTrue(it.iterator().hasNext()); + } + + @Test public void selectNodesWithDefaultNS() { + JAXPXPathEngine e = new JAXPXPathEngine(); + source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("x", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/x:d/x:e", source); + assertTrue(it.iterator().hasNext()); + } +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-30 09:24:33
|
Revision: 372 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=372&view=rev Author: bodewig Date: 2010-04-30 09:24:27 +0000 (Fri, 30 Apr 2010) Log Message: ----------- use a better name for test resources constants Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/TestResources.java Removed Paths: ------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java Deleted: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-30 09:08:03 UTC (rev 371) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-30 09:24:27 UTC (rev 372) @@ -1,22 +0,0 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -package net.sf.xmlunit; - -public final class Resources { - public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; - public static final String BLAME_FILE = "src/tests/resources/test.blame.html"; - - private Resources() { } - -} Copied: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/TestResources.java (from rev 370, trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java) =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/TestResources.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/TestResources.java 2010-04-30 09:24:27 UTC (rev 372) @@ -0,0 +1,22 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit; + +public final class TestResources { + public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; + public static final String BLAME_FILE = "src/tests/resources/test.blame.html"; + + private TestResources() { } + +} Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-30 09:08:03 UTC (rev 371) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-30 09:24:27 UTC (rev 372) @@ -23,7 +23,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import org.w3c.dom.Document; -import net.sf.xmlunit.Resources; +import net.sf.xmlunit.TestResources; import net.sf.xmlunit.util.Convert; import org.junit.Test; @@ -41,23 +41,23 @@ } @Test public void shouldParseADocument() throws Exception { - Document d = parse(Input.fromFile(Resources.ANIMAL_FILE).build()); + Document d = parse(Input.fromFile(TestResources.ANIMAL_FILE).build()); Source s = Input.fromDocument(d).build(); allIsWellFor(s); } @Test public void shouldParseAnExistingFileByName() throws Exception { - allIsWellFor(Input.fromFile(Resources.ANIMAL_FILE).build()); + allIsWellFor(Input.fromFile(TestResources.ANIMAL_FILE).build()); } @Test public void shouldParseAnExistingFileByFile() throws Exception { - allIsWellFor(Input.fromFile(new File(Resources.ANIMAL_FILE)).build()); + allIsWellFor(Input.fromFile(new File(TestResources.ANIMAL_FILE)).build()); } @Test public void shouldParseAnExistingFileFromStream() throws Exception { FileInputStream is = null; try { - is = new FileInputStream(Resources.ANIMAL_FILE); + is = new FileInputStream(TestResources.ANIMAL_FILE); allIsWellFor(Input.fromStream(is).build()); } finally { if (is != null) { @@ -69,7 +69,7 @@ @Test public void shouldParseAnExistingFileFromReader() throws Exception { FileReader r = null; try { - r = new FileReader(Resources.ANIMAL_FILE); + r = new FileReader(TestResources.ANIMAL_FILE); allIsWellFor(Input.fromReader(r).build()); } finally { if (r != null) { @@ -88,15 +88,15 @@ } @Test public void shouldParseFileFromURIString() throws Exception { - allIsWellFor(Input.fromURI("file:" + Resources.ANIMAL_FILE).build()); + allIsWellFor(Input.fromURI("file:" + TestResources.ANIMAL_FILE).build()); } @Test public void shouldParseFileFromURI() throws Exception { - allIsWellFor(Input.fromURI(new URI("file:" + Resources.ANIMAL_FILE)).build()); + allIsWellFor(Input.fromURI(new URI("file:" + TestResources.ANIMAL_FILE)).build()); } @Test public void shouldParseFileFromURL() throws Exception { - allIsWellFor(Input.fromURL(new URL("file:" + Resources.ANIMAL_FILE)).build()); + allIsWellFor(Input.fromURL(new URL("file:" + TestResources.ANIMAL_FILE)).build()); } @Test public void shouldParseATransformationFromSource() throws Exception { @@ -129,7 +129,7 @@ } private static byte[] readTestFile() throws Exception { - FileInputStream is = new FileInputStream(Resources.ANIMAL_FILE); + FileInputStream is = new FileInputStream(TestResources.ANIMAL_FILE); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int read = -1; Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-30 09:08:03 UTC (rev 371) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-30 09:24:27 UTC (rev 372) @@ -21,7 +21,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; -import net.sf.xmlunit.Resources; +import net.sf.xmlunit.TestResources; import org.hamcrest.core.IsNull; import org.junit.Test; import org.w3c.dom.Document; @@ -41,18 +41,18 @@ } @Test public void streamSourceToInputSource() throws Exception { - convertAndAssert(new StreamSource(new File(Resources.ANIMAL_FILE))); + convertAndAssert(new StreamSource(new File(TestResources.ANIMAL_FILE))); } @Test public void domSourceToInputSource() throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document d = b.parse(new File(Resources.ANIMAL_FILE)); + Document d = b.parse(new File(TestResources.ANIMAL_FILE)); convertAndAssert(new DOMSource(d)); } @Test public void saxSourceToInputSource() throws Exception { - InputSource s = new InputSource(new FileInputStream(Resources.ANIMAL_FILE)); + InputSource s = new InputSource(new FileInputStream(TestResources.ANIMAL_FILE)); convertAndAssert(new SAXSource(s)); } Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-04-30 09:08:03 UTC (rev 371) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-04-30 09:24:27 UTC (rev 372) @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.Iterator; import javax.xml.transform.Source; -import net.sf.xmlunit.Resources; +import net.sf.xmlunit.TestResources; import net.sf.xmlunit.builder.Input; import net.sf.xmlunit.exceptions.XMLUnitException; import org.junit.Before; @@ -30,7 +30,7 @@ private Source source; @Before public void readSource() throws Exception { - source = Input.fromFile(Resources.BLAME_FILE).build(); + source = Input.fromFile(TestResources.BLAME_FILE).build(); } @Test public void selectNodesWithNoMatches() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |