Menu

Troubles with sample test cases

Anonymous
2002-09-13
2002-09-18
  • Anonymous

    Anonymous - 2002-09-13

    Hi,

    I'm new to StrutsTestCase, and I'm having a lot of troubles running the sample test cases that come with it.

    Below is the error message that I got:
    Parse Fatal Error at line 2 column -1: External entity not found: "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd".
    java.net.ConnectException: Connection timed out
            at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
            at org.apache.crimson.parser.Parser2.externalParameterEntity(Parser2.java:2870)
            at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1167)
            at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
            at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
            at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
            at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223)
            at javax.xml.parsers.SAXParser.parse(SAXParser.java:362)
            at javax.xml.parsers.SAXParser.parse(SAXParser.java:137)
            at org.apache.struts.digester.Digester.parse(Digester.java:755)
            at org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1332)
            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:466)
            at javax.servlet.GenericServlet.init(GenericServlet.java:258)
            at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:216)
            at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:259)
            at examples.TestLoginAction.testFailedLogin(TestLoginAction.java:50)
            at java.lang.reflect.Method.invoke(Native Method)
            at junit.framework.TestCase.runTest(TestCase.java:166)
            at junit.framework.TestCase.runBare(TestCase.java:140)
            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:131)
            at junit.framework.TestSuite.runTest(TestSuite.java:173)
            at junit.framework.TestSuite.run(TestSuite.java:168)
            at junit.swingui.TestRunner$17.run(TestRunner.java:644)

    Does anyone know how I can fix this problem?
    Thanks in advance.

    Cheers

     
    • Qingxian Wang

      Qingxian Wang - 2002-09-13

      Irwan,

      It looks to me that the program was trying to validate the XML file with DTD, but cannot get the Internet connection.  Does the PC whre the program was running has the Internet connection?

      Cheers

      Qingxian

       
    • Anonymous

      Anonymous - 2002-09-16

      Hi Qingxian,

      Thanks for the reply.
      Yes, it seems that it is a problem with the Internet connection. I tried this on my computer at home (dial-up) and it works, but it doesn't when I use uni computers (which is permanently connected to the net).
      Do you know what the problem might be?

      Another thing, what is the significance of the second line of struts-config.xml, where the <DOCTYPE struts-config.xml blah blah is defined?
      When I removed that line, the test cases gave me a lot of error message, but they actually work.

      Thanks,

      Irwan

       
      • Qingxian Wang

        Qingxian Wang - 2002-09-16

        Perhaps the firewall of the uni system prevented your program to connect to the Web site for DTD validation.

        The second line of the web.xml file defines the type of the XML document and the public ID with document tag definition (DTD) URL that is used to validate the XML document.

        Qingxian

         
    • Anonymous

      Anonymous - 2002-09-16

      Hi,

      If really it was the uni's firewall that causes that problem, do you know any workaround for this?

      Let's say I'll just delete the second line of struts-config.xml, is that OK? I mean, does it affect anything (the test cases)?

      Thanks

       
      • Qingxian Wang

        Qingxian Wang - 2002-09-16

        You should keep the DOCTYPE but you can delete the public system ID.

        Or, you can include the DTD file to your WAR file and to change the public system ID.

        Good luck.

        Qingxian

         
    • Anonymous

      Anonymous - 2002-09-17

      Hi,

      Sorry for bothering you again.
      I did some research on the DOCTYPE thing, and it seems that you have to specify a URL for the file, is that right?
      Is it possible to refer to a local file?

      Thanks,

      Irwan

       
      • Qingxian Wang

        Qingxian Wang - 2002-09-17

        Yes, it is.  The protocol for a local file is "file://", e.g. file://c:/yourDir/dtds/fdsfdfdfdfs.dtd

         
    • Anonymous

      Anonymous - 2002-09-18

      Hi Qingxian,

      Thanks a lot, now I can get the sample test cases to work properly without connecting to the net!
      Btw, for the file protocol thingy, you actually need 3 slashes (file:///) instead of just 2.
      Thanks again, now I'll move on to creating real test cases :)

      Cheers,

      Irwan

       
      • Qingxian Wang

        Qingxian Wang - 2002-09-18

        Congratulations!

        The reason why you need three "/" is bebause you are using non-windows file system, e.g. UNIX or Salaries, etc.  The third "/" is not part of the protocol definition but the directory seperator of your file system.

        Cheers

        Qingxian

         

Log in to post a comment.