Author: vrubezhny
Date: 2012-01-18 08:23:21 -0500 (Wed, 18 Jan 2012)
New Revision: 37938
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLValidatorTest.java
Log:
JBIDE-10472
CLONE - XHTML Validator hangs eclipse
JUnit Test org.jboss.tools.jsf.test.validation.XHTMLValidatorTest is made up-to-date
according to new XHTML/Non-XHTML file detection algorithm and XHTML validator
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLValidatorTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLValidatorTest.java 2012-01-18
12:44:14 UTC (rev 37937)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/XHTMLValidatorTest.java 2012-01-18
13:23:21 UTC (rev 37938)
@@ -58,14 +58,15 @@
XHTMLValidationTestMessages.XHTML_LARGE_GOOD_TAGNAME));
LOCALIZED_LARGE_ERROR_MESSAGES.add(MessageFormat.format(JSFValidationMessage.XHTML_VALIDATION_NO_START_TAG,
XHTMLValidationTestMessages.XHTML_LARGE_WRONG_TAGNAME));
+ LOCALIZED_LARGE_ERROR_MESSAGES.add(JSFValidationMessage.XHTML_VALIDATION_BAD_ENTITY);
}
protected static String LOCALIZED_BROKEN_ERROR_MESSAGE =
XHTMLValidationTestMessages.XHTML_MARKUP_IS_BROKEN_ERROR;
// "Bad" file validation time should be not greater than "Good" file
validation time multiplied by 10
- protected static final double NOT_BAD_DIFF_PERCENTAGE = 1000.0;
+ protected static final double NOT_BAD_DIFF_PERCENTAGE = 2000.0;
// Each validation session should take less that 1 second (1000ms)
- protected static final long MAX_VALIDATION_TIME = 1000;
+ protected static final long MAX_VALIDATION_TIME = 2000;
IProject project;
@@ -130,7 +131,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 2, messages == null
? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 1, messages == null
? 0 : messages.size());
for (Object m : messages) {
assertTrue("Wrong type of validation message is returned", (m instanceof
Message));
Message message = (Message)m;
@@ -149,7 +150,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 2, messages == null
? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 0, messages == null
? 0 : messages.size());
for (Object m : messages) {
assertTrue("Wrong type of validation message is returned", (m instanceof
Message));
Message message = (Message)m;
@@ -198,7 +199,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 1, messages == null
? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 0, messages == null
? 0 : messages.size());
for (Object m : messages) {
assertTrue("Wrong type of validation message is returned", (m instanceof
Message));
Message message = (Message)m;
@@ -207,7 +208,7 @@
}
// Check that the difference between good and bad files validation time is not greater
that NOT_BAD_DIFF_PERCENTAGE (%) of a good value
- double diff = 100*badValidationTime/goodValidationTime;
+ double diff = 100*(badValidationTime+1)/(goodValidationTime + 1);
System.out.println("(With broken content) Validation time difference: " +
diff + "%");
assertTrue("Validation time difference between good and wrong DOCTYPE declaration
is greater than " + NOT_BAD_DIFF_PERCENTAGE + "%", (diff <
NOT_BAD_DIFF_PERCENTAGE));
} finally {
@@ -231,7 +232,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
List messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 0, messages == null
? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 1, messages == null
? 0 : messages.size());
// Validate file with bad DOCTYPE declaration and no XHTML Syntax errors
file = createTestFile(XHTMLValidationTestMessages.XHTML_LARGE_CONTENT_TEMPLATE,
@@ -248,7 +249,7 @@
assertEquals("Wrong number of error messages reported", 0, messages == null
? 0 : messages.size());
// Check that the difference between good and bad files validation time is not greater
that NOT_BAD_DIFF_PERCENTAGE (%) of a good value
- double diff = 100*badValidationTime/goodValidationTime;
+ double diff = 100*(badValidationTime+1)/(goodValidationTime + 1);
System.out.println("(Large With no errors) Validation time difference: " +
diff + "%");
assertTrue("Validation time difference between good and wrong content is greater
than " + NOT_BAD_DIFF_PERCENTAGE + "%", (diff <
NOT_BAD_DIFF_PERCENTAGE));
@@ -264,7 +265,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 180, messages ==
null ? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 1, messages == null
? 0 : messages.size());
for (Object m : messages) {
assertTrue("Wrong type of validation message is returned", (m instanceof
Message));
Message message = (Message)m;
@@ -284,7 +285,7 @@
assertNotNull("No validation result is returned", result);
assertNotNull("No validation result is returned",
result.getReporter(null));
messages = result.getReporter(null).getMessages();
- assertEquals("Wrong number of error messages reported", 180, messages ==
null ? 0 : messages.size());
+ assertEquals("Wrong number of error messages reported", 0, messages == null
? 0 : messages.size());
for (Object m : messages) {
assertTrue("Wrong type of validation message is returned", (m instanceof
Message));
Message message = (Message)m;
@@ -292,7 +293,7 @@
assertTrue("Unexpected error message found: " + message.getText(),
LOCALIZED_LARGE_ERROR_MESSAGES.contains(message.getText()));
}
// Check that the difference between good and bad files validation time is not greater
that NOT_BAD_DIFF_PERCENTAGE (%) of a good value
- diff = 100*badValidationTime/goodValidationTime;
+ diff = 100*(badValidationTime+1)/(goodValidationTime + 1);
System.out.println("(Large With errors) Validation time difference: " + diff
+ "%");
assertTrue("Validation time difference between good and wrong content is greater
than " + NOT_BAD_DIFF_PERCENTAGE + "%", (diff <
NOT_BAD_DIFF_PERCENTAGE));
} finally {