From: Caz D. <ph...@1P...> - 2003-08-13 14:26:05
|
Hello, A friend recently referred me to HtmlUnit, and I'm very much looking forwar= d to using it. I downloaded HtmlUnit 1.2.3 because of the new getAllForms(= ) method. I created a very simple test case (pasted below), but I got the = logging error (also pasted below) when I tried to run it with JUnit. It ha= ppens when it reaches this line: wc =3D new WebClient(); (wc is previously defined as type WebClient). I replaced my commons-logging-1.0.2 jar with the newest release, 1.0.3, but= that didn't help, so I went back to 1.0.2. I used the JUnit integrated wi= th IDEA at work, and also standalone JUnit on my home computer (v3.8.1, as = I recall), but received the same error. I briefly poked around in the Html= Unit source code, but I didn't see anything sticking out. Any thoughts?=20= =20 Though I'm experienced in Java, I'm fairly new to automated unit testing. = So if this is not an HtmlUnit-related issue, please accept my apologies. Thanks. Brandan Stack Trace: C:\j2sdk1.4.1\bin\javaw.exe -classpath C:\IntelliJ-IDEA-3.0.4\lib\junit.jar= ;C:\Projects\HttpUnitDemo\WEB-INF\classes;C:\j2sdk1.4.1\jre\lib\charsets.ja= r;C:\j2sdk1.4.1\jre\lib\jaws.jar;C:\j2sdk1.4.1\jre\lib\jce.jar;C:\j2sdk1.4.= 1\jre\lib\jsse.jar;C:\j2sdk1.4.1\jre\lib\rt.jar;C:\j2sdk1.4.1\jre\lib\sunrs= asign.jar;C:\j2sdk1.4.1\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.1\jre\lib\ext\lda= psec.jar;C:\j2sdk1.4.1\jre\lib\ext\localedata.jar;C:\j2sdk1.4.1\jre\lib\ext= \sunjce_provider.jar;C:\j2sdkee1.3.1\lib\j2ee.jar;C:\JUnit\junit.jar;C:\cac= tus\lib\cactus-1.5-beta1.jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\commons-h= ttpclient-2.0-beta2.jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\htmlunit-1.2.3= .jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\js-1.5R4.1.jar;C:\Projects\HttpUn= itDemo\WEB-INF\lib\nekohtml-0.7.7.jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\= xercesImpl-2.4.0.jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\xmlParserAPIs-2.2= .1.jar;C:\Projects\HttpUnitDemo\WEB-INF\lib\commons-logging.jar;C:\IntelliJ= -IDEA-3.0.4\lib\idea_rt.jar com.intellij.rt.execution.junit.ui.SwingTestRun= ner FirstHtmlUnitTester Exception caught in testProceedPage. Message: org.apache.commons.logging.L= ogConfigurationException: org.apache.commons.logging.LogConfigurationExcept= ion: Class org.apache.commons.logging.impl.Jdk14Logger does not implement L= og org.apache.commons.logging.LogConfigurationException: org.apache.commons.lo= gging.LogConfigurationException: org.apache.commons.logging.LogConfiguratio= nException: Class org.apache.commons.logging.impl.Jdk14Logger does not impl= ement Log at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryIm= pl.java:555) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryIm= pl.java:289) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryIm= pl.java:259) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390) at com.gargoylesoftware.htmlunit.ScriptEngine.<init>(ScriptEngine.java:53) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaSc= riptEngine.java:114) at com.gargoylesoftware.htmlunit.WebClient.createJavaScriptEngineIfPossibl= e(WebClient.java:159) at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:121) at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:106) at FirstHtmlUnitTester.testProceedPage(FirstHtmlUnitTester.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja= va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso= rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.swingui.TestRunner$16.run(TestRunner.java:623) Caused by: org.apache.commons.logging.LogConfigurationException: org.apache= .commons.logging.LogConfigurationException: Class org.apache.commons.loggin= g.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFac= toryImpl.java:420) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryIm= pl.java:548) ... 22 more Caused by: org.apache.commons.logging.LogConfigurationException: Class org.= apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFac= toryImpl.java:416) ... 23 more Process terminated with exit code 0 Sample Tester: import junit.framework.TestCase; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.WebClient; import java.net.URL; import java.net.MalformedURLException; import java.io.IOException; /** * * HTMLUnit Tester * * Test out HTMLUnit. * * * com.gargoylesoftware.htmlunit * com.gargoylesoftware.htmlunit.html * * Created by IntelliJ IDEA. * User: bjones * Date: Aug 11, 2003 * Time: 12:51:45 PM * To change this template use Options | File Templates. */ public class FirstHtmlUnitTester extends TestCase { private HtmlPage page =3D null; private WebClient wc =3D null; public void runTests() { testProceedPage(); } public void testProceedPage() { try { wc =3D new WebClient(); URL url =3D new URL("http://sourceforge.net/"); page =3D (HtmlPage) wc.getPage(url); System.out.println("Page title: " + page.getTitleText()); // System.out.println("Forms Length: " + page.getAllForms().siz= e()); assertEquals("SourceForge.net: Welcome", page.getTitleText().tr= im()); } catch (IOException e) { System.out.println("IOException caught in testProceedPage. Mes= sage: " + e.getMessage()); e.printStackTrace(); } } public static void main(String args[]) { FirstHtmlUnitTester fhut =3D new FirstHtmlUnitTester(); fhut.runTests(); =20=20=20=20=20=20=20=20 } } _____________________________________________________________ Sign up for FREE email from 1PhatCity at http://www.1PhatCity.com |