From 71da1ae2c862cdd10007493dd28d83e0bfa15341 Mon Sep 17 00:00:00 2001 From: yvesf Date: Wed, 9 Mar 2011 10:12:21 +0100 Subject: disable CSS; ignore htmlunit warnings --- .../horb/calendar/dualis/DualisConnection.java | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/main') diff --git a/src/main/java/de/dhbw/horb/calendar/dualis/DualisConnection.java b/src/main/java/de/dhbw/horb/calendar/dualis/DualisConnection.java index 224bd82..c60349f 100644 --- a/src/main/java/de/dhbw/horb/calendar/dualis/DualisConnection.java +++ b/src/main/java/de/dhbw/horb/calendar/dualis/DualisConnection.java @@ -1,6 +1,7 @@ package de.dhbw.horb.calendar.dualis; import java.io.IOException; +import java.net.URL; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -10,11 +11,18 @@ import java.util.TimeZone; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; +import org.w3c.css.sac.ErrorHandler; import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.IncorrectnessListener; +import com.gargoylesoftware.htmlunit.Page; +import com.gargoylesoftware.htmlunit.StatusHandler; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.DomAttr; +import com.gargoylesoftware.htmlunit.html.HTMLParserListener; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlForm; @@ -56,7 +64,55 @@ public class DualisConnection { final WebClient webClient = new WebClient(); final List events = new ArrayList(); + webClient.setIncorrectnessListener(new IncorrectnessListener() { + @Override + public void notify(String message, Object origin) { + System.out.println("======="); + System.out.println(origin.getClass()); + } + }); + // not used while setCssEnabled(false) + webClient.setCssErrorHandler(new ErrorHandler() { + @Override + public void warning(CSSParseException exception) + throws CSSException { + System.out.println("CSS Exception: " + exception.getMessage()); + } + + @Override + public void fatalError(CSSParseException exception) + throws CSSException { + System.out.println("CSS Exception: " + exception.getMessage()); + } + + @Override + public void error(CSSParseException exception) throws CSSException { + System.out.println("CSS Exception: " + exception.getMessage()); + } + }); + webClient.setStatusHandler(new StatusHandler() { + @Override + public void statusMessageChanged(Page page, String message) { + System.out + .println("DualisConnection.getEvents().new StatusHandler() {...}.statusMessageChanged()"); + } + }); + webClient.setHTMLParserListener(new HTMLParserListener() { + @Override + public void warning(String message, URL url, int line, int column, + String key) { + // ignore silently + } + + @Override + public void error(String message, URL url, int line, int column, + String key) { + // ignore silently + } + }); + webClient.setPrintContentOnFailingStatusCode(false); webClient.setJavaScriptEnabled(false); + webClient.setCssEnabled(false); loginPage = webClient.getPage(DUALIS_URL); try { loginForm = loginPage.getFormByName("cn_loginForm"); -- cgit v1.2.1