Execução de teste unitário de Action do Struts usando Ant

2 respostas
M

Pessoal,

Tenho um buildfile Ant com um target para execução dos testes unitários (JUnit) de meu projeto.

Quando tento executar esta task, recebo a seguinte mensagem de erro no console:

[junit] Running br.gov.dac.sintac.empresa.action.ActionItemManutencaoTest
    [junit] 16:49:59,035 ERROR Digester:1459 - Parse Fatal Error at line 2 column -1: Relative URI "tiles-config_1_1.dtd"; can not be resolved without a base URI.
    [junit] org.xml.sax.SAXParseException: Relative URI "tiles-config_1_1.dtd"; can not be resolved without a base URI.
    [junit]     at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
    [junit]     at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
    [junit]     at org.apache.crimson.parser.Parser2.resolveURI(Parser2.java:2952)
    [junit]     at org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2924)
    [junit]     at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1309)
    [junit]     at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)
    [junit]     at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
    [junit]     at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
    [junit]     at org.apache.commons.digester.Digester.parse(Digester.java:1567)
    [junit]     at org.apache.struts.tiles.xmlDefinition.XmlParser.parse(XmlParser.java:279)
    [junit]     at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.parseXmlFile(I18nFactorySet.java:526)
    [junit]     at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.parseXmlFiles(I18nFactorySet.java:467)
    [junit]     at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.createDefaultFactory(I18nFactorySet.java:271)
    [junit]     at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.initFactory(I18nFactorySet.java:246)
    [junit]     at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.initFactory(I18nFactorySet.java:196)
    [junit]     at org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper.init(ComponentDefinitionsFactoryWrap
per.java:104)
    [junit]     at org.apache.struts.tiles.TilesUtilImpl.createDefinitionsFactory(TilesUtilImpl.java:138)
    [junit]     at org.apache.struts.tiles.TilesUtil.createDefinitionsFactory(TilesUtil.java:167)
    [junit]     at org.apache.struts.tiles.TilesPlugin.initDefinitionsFactory(TilesPlugin.java:224)
    [junit]     at org.apache.struts.tiles.TilesPlugin.init(TilesPlugin.java:139)
    [junit]     at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:839)
    [junit]     at org.apache.struts.action.ActionServlet.init(ActionServlet.java:332)
    [junit]     at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    [junit]     at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
    [junit]     at servletunit.struts.MockStrutsTestCase.setActionForm(MockStrutsTestCase.java:887)
    [junit]     at br.gov.dac.sintac.empresa.action.ActionItemManutencaoTest.testFiltrar(Unknown Source)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [junit]     at java.lang.reflect.Method.invoke(Method.java:324)
    [junit]     at junit.framework.TestCase.runTest(TestCase.java:154)
    [junit]     at junit.framework.TestCase.runBare(TestCase.java:127)
    [junit]     at junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit]     at junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit]     at junit.framework.TestResult.run(TestResult.java:109)
    [junit]     at junit.framework.TestCase.run(TestCase.java:118)
    [junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
    [junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:289)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:656)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:558)
    [junit] 16:49:59,195 ERROR TilesPlugin:230 - Can't create Tiles definition factory for module ''.
    [junit] 16:49:59,195 ERROR MockStrutsTestCase:330 - Error initializing action servlet
    [junit] javax.servlet.ServletException: Error while parsing file '/WEB-INF/tiles-defs.xml'. Relative URI "tiles-config_1_
1.dtd"; can not be resolved without a base URI.
    [junit]     at org.apache.struts.tiles.TilesPlugin.initDefinitionsFactory(TilesPlugin.java:235)
    [junit]     at org.apache.struts.tiles.TilesPlugin.init(TilesPlugin.java:139)
    [junit]     at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:839)
    [junit]     at org.apache.struts.action.ActionServlet.init(ActionServlet.java:332)
    [junit]     at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    [junit]     at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:326)
    [junit]     at servletunit.struts.MockStrutsTestCase.setActionForm(MockStrutsTestCase.java:887)
    [junit]     at br.gov.dac.sintac.empresa.action.ActionItemManutencaoTest.testFiltrar(Unknown Source)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

No arquivo tiles-defs.xml, o DOCTYPE está especificado assim:

<!DOCTYPE component-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "tiles-config_1_1.dtd">

Mas, se eu colocar o path absoluto do ‘tiles-config_1_1.dtd’ funciona perfeitamente:

Alguém sabe o que preciso fazer para que o DTD seja encontrado especificando o path relativo ao invés do absoluto?

2 Respostas

J

Oi

Coloque o endereço absoluto da DTD no repositório online dela :wink:

Hummm, testes unitários com Struts? Se for 1.0 nao da nao… acho que 1.1 tb nao da muito certo nao.

T+

M

Como assim? Não entendi… :cry:

Criado 3 de janeiro de 2005
Ultima resposta 3 de jan. de 2005
Respostas 2
Participantes 2