Tuesday, June 25, 2013

How to run the sample program given in Getting Started with REST Web Service API?

Report on How to run the sample program given in Getting Started with REST Web Service API?
  • First we have to install maven on your system.

  • Added maven path to eclipse this is external maven. Don’t use embedded maven which is given in eclipse.

  • Note: I am saying not to use embedded maven because it is having a bug. If you use embedded maven for test then it always gives following report.
        SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
        SLF4J: Defaulting to no-operation (NOP) logger implementation
        SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  • But the thing is there is no need of SLF4J for running this code. We can simply remove this error by adding external maven

  • How to add external maven to eclipse.

  • Step1 Go to window in eclipse menu.
    Step2 Go to maven in the list and in it installations.
    Step3 Click on ADD and add folder of your external maven and click ok.
  • For the first time after adding external maven if we do mvn test it works fine. But for the second time we will get following error.


  • ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest log4j:WARN No appenders could be found for logger (com.jaspersoft.jasperserver.rest.sample.RestAPIUtils). log4j:WARN Please initialize the log4j system properly. INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] sending Request. url: http://localhost:8080/jasperserver/rest/resource req verb: PUT INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] response status line: HTTP/1.1 400 Bad Request Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.785 sec <<< FAILURE! com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest Time elapsed: 2.778 sec <<< FAILURE! java.lang.AssertionError: basic response check did not pass at org.junit.Assert.fail(Assert.java:91) at org.junit.Assert.assertTrue(Assert.java:43) at com.jaspersoft.jasperserver.rest.sample.RestAPIUtils.sendAndAssert(RestAPIUtils.java:123) at com.jaspersoft.jasperserver.rest.sample.RestAPIUtils.sendAndAssert(RestAPIUtils.java:117) at com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest.setUp(BasicResourceCRUDTest.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Results : Failed tests: com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest: basic response check did not pass Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.393s [INFO] Finished at: Wed Jun 26 11:59:09 IST 2013 [INFO] Final Memory: 9M/106M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project RESTCodeSample: There are test failures. [ERROR] [ERROR] Please refer to C:\Users\BizAct20\Desktop\restapicodesample\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  • This is because the folder is already created so before running second time we have to make sure that the folder is deleted or not.

  • No comments:

    Post a Comment