If you look under target/surefire-reports what error message is reported for
the test?

Mike.

On 4/22/07, Rick Guo <[EMAIL PROTECTED]> wrote:

 Hi all, didn't find any info about the problem I met, I asked for your
help, thanks.



I'm just following the tutorial to add the Person, I chose SpringMVC
Modular archetype. The domain Object creation, the Dao and Service layer is
OK.

Then it comes the Spring MVC.

After create the following file:

*\source\myProject\web\src\test\java\...\controller\
PersonControllerTest.java*

*\source\myProject\web\src\main\java\...\controller\ PersonController.java
*

Adding the PersonController bean definition in *
\source\myProject\web\src\main\webapp\WEB-INF\dispatch-servlet.xml*



I could run mvn test –Dtest=PersonController successfully under *
\source\myProject\*

BUILD SUCCESSFUL



Moved on then create:

 *\..\web\src\main\webapp\WEB-INF\pages\persons.jsp*

Open *\..\web\src\main\/resources/ApplicationResources.properties* and add
i18n keys/values for the various "person" properties



When I run mvn jetty:run-war under \..\web\  The build is failure as the
following message.



E:\Source\myproject\web>mvn jetty:run-war

[INFO] Scanning for projects...

[INFO] Searching repository for plugin with prefix: 'jetty'.

[INFO]
-------------------------------------------------------------------------

---

[INFO] Building AppFuse Modular Application - Web (Spring MVC)

[INFO]    task-segment: [jetty:run-war]

[INFO]
-------------------------------------------------------------------------

---

[INFO] Preparing jetty:run-war

Downloading:
http://repo1.maven.org/maven2/cn/gov/yantaiinvest/construction/mypr

oject-core/1.0-SNAPSHOT/myproject-core-1.0-SNAPSHOT.pom

Downloading:
http://static.appfuse.org/repository/cn/gov/yantaiinvest/constructi

on/myproject-core/1.0-SNAPSHOT/myproject-core-1.0-SNAPSHOT.pom

[INFO] [warpath:add-classes {execution: default}]

[INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]

[INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]

[INFO] [resources:resources]

[INFO] Using default encoding to copy filtered resources.

[INFO] [compiler:compile]

[INFO] Compiling 1 source file to E:\Source\myproject\web\target\classes

[INFO] [resources:testResources]

[INFO] Using default encoding to copy filtered resources.

[INFO] [compiler:testCompile]

[INFO] Compiling 1 source file to
E:\Source\myproject\web\target\test-classes

[INFO] [dbunit:operation {execution: test-compile}]

[INFO] [surefire:test]

[INFO] Surefire report directory:
E:\Source\myproject\web\target\surefire-report

s



-------------------------------------------------------

 T E S T S

-------------------------------------------------------

Running
cn.gov.yantaiinvest.construction.webapp.controller.PersonControllerTest

[myproject] INFO [main] PersonControllerTest.loadContextLocations(51) |
Loading

additional configuration from: classpath*:/applicationContext-
resources.xml,clas

spath*:/applicationContext-dao.xml,classpath*:/applicationContext-
service.xml,cl


asspath*:/applicationContext.xml,/WEB-INF/applicationContext*.xml,/WEB-INF/dispa

tcher-servlet.xml

AbandonedObjectPool is used (
[EMAIL PROTECTED])



   LogAbandoned: false

   RemoveAbandoned: true

   RemoveAbandonedTimeout: 60

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.488 sec
<<< FA

ILURE!

Running cn.gov.yantaiinvest.construction.AppTest

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 sec



Results :



Tests in error:

  testHandleRequest(
cn.gov.yantaiinvest.construction.webapp.controller.PersonCon

trollerTest)



Tests run: 2, Failures: 0, Errors: 1, Skipped: 0



[INFO]
------------------------------------------------------------------------

[ERROR] BUILD FAILURE

[INFO]
------------------------------------------------------------------------

[INFO] There are test failures.





PersonControllerTest could still run successfully when run mvn test
–Dtest=PersonControllerTest from \myProject\

So I think there are some-PATH-thing wrong in the pom.xml. Anybody any
advice?



Some other wired thing when typed PersonControllerTest.java in IDEA6.0.5:

Run mvn IDEA:IDEA,I input all code above in IDEA. Everything seems ok
except the PersonControllerTest.java. It always has the red underline in
the project view and the file name tag.

The Warning infos in the java source file are generated by IDEA. They are
wired-All the imported class and local variables are warned unused?!

The MVN command is still work.

Anybody has met this probem?



------------------------------------- 
PersonControllerTest.java---------------------------------------

package cn.gov.yantaiinvest.construction.webapp.controller;



import org.springframework.web.servlet.ModelAndView;              //!
Warning: Unused import statement

import org.springframework.ui.ModelMap;
//! Warning: Unused import statement

import org.appfuse.webapp.controller.BaseControllerTestCase;   //!
Warning: Unused import statement

import java.util.List;
//! Warning: Unused import statement



public class PersonControllerTest extends BaseControllerTestCase {

    private PersonController c;
//!Warning: Private field 'c' is never used



    public void setPersonController(PersonController c) {

        this.c = c;

    }



    public void testHandleRequest() throws Exception {

        ModelAndView mav = c.handleRequest(null, null);
//!Warning: Private field 'mav' is never used

        ModelMap m = mav.getModelMap();
//!Warning: Private field 'm' is never used

        assertNotNull(m.get("personList"));

        assertTrue(((List)m.get("personList")).size() > 0);

    }

}







Rick Guo

4/22/2007

Reply via email to