From d58ed3363fbb8180b2e5d13d517a24b6f590f429 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Sun, 24 Jan 2010 20:39:38 +0100 Subject: [PATCH] validate in 'relaxed folding' mode --- .../ical4j/validation/ValidationBySchemaTest.java | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/test/net/fortuna/ical4j/validation/ValidationBySchemaTest.java b/test/net/fortuna/ical4j/validation/ValidationBySchemaTest.java index 36bedf6..c774493 100644 --- a/test/net/fortuna/ical4j/validation/ValidationBySchemaTest.java +++ b/test/net/fortuna/ical4j/validation/ValidationBySchemaTest.java @@ -13,6 +13,7 @@ import javax.xml.parsers.ParserConfigurationException; import net.fortuna.ical4j.data.CalendarBuilder; import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.model.ValidationException; +import net.fortuna.ical4j.util.CompatibilityHints; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -37,10 +38,30 @@ public class ValidationBySchemaTest extends TestCase { .getLog(ValidationBySchemaTest.class); private static final int BUFFER = 2048; + + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + CompatibilityHints.setHintEnabled( + CompatibilityHints.KEY_RELAXED_UNFOLDING, true); + super.setUp(); + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ + protected void tearDown() throws Exception { + CompatibilityHints.clearHintEnabled( + CompatibilityHints.KEY_RELAXED_UNFOLDING); + super.tearDown(); + } + private String name; private String textContent; private boolean shouldPass; - + public ValidationBySchemaTest(String testMethod, String name, boolean shouldPass, String textContent) { super(testMethod); @@ -87,28 +108,21 @@ public class ValidationBySchemaTest extends TestCase { } } - public void testValidateBySchema() throws ValidationException, IOException, ParserException + public void testValidateBySchema() throws IOException { - LOG.info("Checking " + name + " calendar: " + textContent); - if (shouldPass) + boolean passed; + try { new CalendarBuilder().build(new ByteArrayInputStream(textContent.getBytes())).validate(true); + passed = true; } - else + catch (ParserException e) { - boolean failed = false; - try - { - new CalendarBuilder().build(new ByteArrayInputStream(textContent.getBytes())).validate(true); - } - catch (ParserException e) - { - failed = true; - } catch (ValidationException e) { - failed = true; - } - assertTrue(failed); + passed = false; + } catch (ValidationException e) { + passed = false; } + assertEquals("Test result inconsistent for rule " + name, shouldPass, !passed); } public static TestSuite suite() throws IOException, SAXException, ParserConfigurationException { -- 2.11.4.GIT