I am using Ant version 1.9.7 and JUnit 4.12. My build.xml looks like this:
<target name="run-junit" depends="init, compile, compile-junit">
<junit printsummary="yes" >
<formatter type="xml"/>
<classpath><pathelement location="lib/junit-4.12.jar"/></classpath>
<batchtest fork="yes" todir="${out.dir}">
<fileset dir="${bin.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</target>
When running ant run-junit in a console it just gives me:
[junit] Running at.abc.def.ghi.ABCTest
[junit] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec
Test at.abc.def.ghi.ABCTest FAILED
But no more details. How can I resolve this?
To get more details about each failed test, use <formatter type="plain" usefile="false"/> instead of <formatter type="xml"/>:
<junit printsummary="yes">
<formatter type="plain" usefile="false"/>
<classpath><pathelement location="lib/junit-4.12.jar"/></classpath>
<batchtest fork="yes" todir="${out.dir}">
<fileset dir="${bin.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Using a "plain" formatter gives output similar to the following:
[junit] Running TestMyTest1
[junit] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
[junit]
[junit] Testcase: testMyTest took 0.003 sec
[junit] FAILED
[junit] expected:<firefox> but was:<null>
[junit] junit.framework.AssertionFailedError: expected:<firefox> but was:<null>
[junit] at TestMyTest1.testMyTest(TestMyTest1.java:17)
[junit]
[junit] Test TestMyTest1 FAILED
Related
My test suite was working fine until it was using the version 0.9.2.
I have a test runner with KarateOptions in it to specify the feature files that are to be executed
#KarateOptions(tags = {"~#ignore"},
features = {
"src/test/java/com/pro/api/tests/features/beforesuitescenarios/feature1.feature",
"src/test/java/com/pro/api/tests/features/customerscenarios/feature2.feature",
"src/test/java/com/pro/api/tests/features/servicerequestscenarios/feature3.feature",
"src/test/java/com/pro/api/tests/features/invoicescenarios/feature4.feature",
})
And the test runner for this was using cucumber runner,
#Test
public void testAllFeatures() throws Exception {
String karateOutputPath = "target/surefire-reports";
KarateStats stats = CucumberRunner.parallel(getClass(), 1, karateOutputPath);
generateReport(karateOutputPath);
assertTrue("There are scenario failures", stats.getFailCount() == 0);
}
I tried upgrading the framework to 0.9.5 and modified the runner like it's mentioned in the latest docs,
#Test
public void testAllFeatures() throws Exception {
String karateOutputPath = "target/surefire-reports";
Results stats = Runner.parallel(getClass(), 1, karateOutputPath);
generateReport(karateOutputPath);
assertTrue("There are scenario failures", stats.getFailCount() == 0);
}
Now when I execute this suite, The tests are getting executed properly. But after the test execution of all the feature files are completed, It is throwing an error for the line
Results stats = Runner.parallel(getClass(), 1, karateOutputPath);
With the following IllegalArgumentException,
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1,295.291 s <<<
FAILURE! - in com.pro.api.tests.features.TestRunner
[ERROR] testAllFeatures(com.pro.api.tests.features.TestRunner) Time elapsed: 1,295.22 s
<<< ERROR!
java.lang.IllegalArgumentException: Illegal group reference
at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:55)
What am I missing while calling the runner ? How to fix this issue ?
Further when I tried to add exception handler for the failing step, I got the following error log,
java.lang.IllegalArgumentException: Illegal group reference
at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1068)
at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:998)
at java.base/java.util.regex.Matcher.replaceFirst(Matcher.java:1408)
at java.base/java.lang.String.replaceFirst(String.java:2081)
at com.intuit.karate.core.Engine.saveTimelineHtml(Engine.java:500)
at com.intuit.karate.Runner.parallel(Runner.java:357)
at com.intuit.karate.Runner$Builder.parallel(Runner.java:181)
at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:56)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1,181.97 s <<< FAILURE! - in com.pro.api.tests.features.TestRunner
[ERROR] testAllFeatures(com.pro.api.tests.features.TestRunner) Time elapsed: 1,181.905 s <<< ERROR!
java.lang.NullPointerException
at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:61)
Something in saveTimelineHtml is failing
Thanks for the hint - this is indeed a bug in the timeline reporting code.
Issue reference: https://github.com/intuit/karate/issues/1085
So you need to wait for the next version, or there should be an RC version pretty soon so that you can try it out.
I have an Apache Camel route which invokes restlet component and would like to use the redelivery mechanism from the exception handler which performs some processing on every failure to update my database record which should be done on generic route. So, I'm trying to continue the exception in one route and handle the same exception in another route through direct component. But exception is not continuing to generic route.
1st route:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- CXF Rest Endpoint Declaration -->
<cxf:rsServer address="http://localhost:9092/rest/corp"
id="FetchCDFRestRequest" serviceClass="com.tcl.Service.Service" />
<bean class="com.tcl.ExceptionOccurredRefProcessor" id="exProc" />
<bean class="org.apache.camel.builder.DeadLetterChannelBuilder"
id="DLCErrorHandler">
<property name="deadLetterUri"
value="activemq:queue:DMS.FAILURES.DLQ" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
</bean>
<bean class="org.apache.camel.processor.RedeliveryPolicy"
id="redeliveryPolicy">
<property name="maximumRedeliveries"
value="3" />
<property name="maximumRedeliveryDelay" value="2000" />
<property name="retryAttemptedLogLevel" value="WARN" />
</bean>
<camelContext id="Corp"
xmlns="http://camel.apache.org/schema/spring">
<errorHandler id="eh" onExceptionOccurredRef="exProc">
<redeliveryPolicy id="redeliveryPolicy" />
</errorHandler>
<route id="MainRouteOppIDFolder" streamCache="true">
<from id="_CreateOppIDFolder"
uri="restlet:http://localhost:9092/rest/corp/createOppIDFolder?restletMethod=POST" />
----------
<to uri="restlet:http://localhost:9902/CreateOppIDFolder?restletMethod=POST" />
------------
<onException id="_onException1" useOriginalMessage="true">
<exception>java.lang.Exception</exception>
<handled>
<simple>false</simple>
</handled>
<log id="_log1" message="Cont... ex >>>>> ${exception.message} "/>
<to uri="direct:ExceptionHandle"/>
</onException>
</route>
</camelContext>
</beans>
2nd route:
<route errorHandlerRef="DLCErrorHandler" >
<from id="_from2" uri="direct:ExceptionHandle"/>
<log id="_log4" message="Req>>>>> ${body}"/>
<onException id="_onException2"
onExceptionOccurredRef="exProc" redeliveryPolicyRef="redeliveryPolicy">
<exception>java.lang.Exception</exception>
<handled>
<simple>true</simple>
</handled>
<log id="_log3" loggingLevel="INFO" message="Handled ex >>>>> ${exception.message} "/>
<choice id="_choice1">
<when id="_when1">
<simple>${header.errorMessage} contains 'Could not send Message' || ${header.errorMessage} contains 'Connection timed out'</simple>
<to id="_to1" pattern="OutOnly" uri="activemq:queue:DMS.FAILURES"/>
</when>
<otherwise id="_otherwise1">
<log id="_log5" loggingLevel="ERROR" message="Exception occured in otherwise block >>>>>> ${exception.stacktrace} "/>
</otherwise>
</choice>
</onException>
</route>
12:11:24.384 [Restlet-781390346] WARN o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580280046927-0-8 on ExchangeId: ID-DESKTOP-P2DBOO5-1580280046927-0-7).On delivery attempt: 0 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
12:11:24.392 [Restlet-781390346] INFO MainRouteOppIDFolder - Cont... ex >>>>> Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
12:11:24.396 [Restlet-781390346] INFO _route1 - Req>>>>> {
"oppID" : "10268216",
"salesOrganization" : "Commerical Finance",
"salesVertical" : "CEQ",
"productName" : "Construction Equipment Finance",
"applicantName" : "SGS INFRASTRUCTURE",
"docName" : null,
"appNature" : null,
"docType" : null,
"base64Content" : null
}
12:11:24.405 [Restlet-781390346] ERROR o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580280046927-0-8 on ExchangeId: ID-DESKTOP-P2DBOO5-1580280046927-0-7). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
. Processed by failure processor: FatalFallbackErrorHandler[Pipeline[[Channel[Log(MainRouteOppIDFolder)[Cont... ex >>>>> ${exception.message} ]], Channel[sendTo(direct://ExceptionHandle)], Channel[Log(MainRouteOppIDFolder)]]]]
Message History
RouteId ProcessorId Processor Elapsed (ms)
[MainRouteOppIDFold] [MainRouteOppIDFold] [restlet://http://localhost:9092/rest/corp/createOppIDFolder?restletMethod=POST] [ 21608]
[MainRouteOppIDFold] [_CreateOppIDFolder] [restlet:http://localhost:9902/CreateOppIDFolder?restletMethod=POST ] [ 21319]
[MainRouteOppIDFold] [_to2 ] [direct:ExceptionHandle ] [ 1]
[_route1 ] [_log4 ] [log ] [ 1]
Stacktrace
org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect```
**Any suggestions please?**
To be honest: I don't see your problem.
Your exception block does
<log id="_log1" message="Cont... ex >>>>> ${exception.message} "/>
<to uri="direct:ExceptionHandle"/>
The direct route does
<log id="_log4" message="Req>>>>> ${body}"/>
And your log shows
Cont... ex >>>>> [error message]
Req>>>>> [message body]
So everything works as you expect. Am I missing something?
Update due to comment
The onException block of the second route is NOT called as long as no Exception occurs in the second route. The second route normally receives a message and processes it.
You can still access the exception information on the message with ${exception}.
I am using the below Ant Target:
<target name="test-report" depends="compile-ommittedmanage-unittest" description="Generate Test Results as HTML">
<delete dir="${deploy}\html" />
<delete dir="${deploy}\xml" />
<delete dir="${deploy}\html\release" />
<mkdir dir="${deploy}\html" />
<mkdir dir="${deploy}\html\release" />
<mkdir dir="${deploy}\xml" />
<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator" />
<coverage>
<junit printsummary="on" haltonfailure="off" haltonerror="off" fork="yes" forkmode="once">
<batchtest fork="yes" todir="${deploy}\xml" filtertrace="on">
<fileset dir="${ommittedmanage-unittestbin}" includes="**/*Test*.class" />
</batchtest>
<formatter type="plain" usefile="false" />
<formatter type="xml" usefile="true" />
<classpath>
<path refid="ommittedManage.classpath" />
</classpath>
</junit>
</coverage>
<echo message="running JUnit Report" />
<junitreport todir="${deploy}\xml">
<fileset dir="${deploy}\xml">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${deploy}\html" />
</junitreport>
</target>
to try and generate XML and HTML reports. But there are no XML reports generated even though the Jenkins server I use, run through all the tests:
test-report:
[delete] Deleting directory C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\html
[delete] Deleting directory C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\xml
[mkdir] Created dir: C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\html
[mkdir] Created dir: C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\html\release
[mkdir] Created dir: C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\xml
[coverage] Enhancing junit with coverage
[junit] WARNING: multiple versions of ant detected in path for junit
[junit] jar:file:/C:/Users/jenkins/jenkins-dependencies/apache-ant-1.9.4-bin/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/Project.class
[junit] and jar:file:/C:/Users/jenkins/omitted/workspace/omitted%20Ant/deploy/classpath/ant.jar!/org/apache/tools/ant/Project.class
[junit] Running JUnitplayground.ParameterizedTest
[junit] Testsuite: JUnitplayground.ParameterizedTest
[junit] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,64 sec
[junit] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,64 sec
[junit] ------------- Standard Output ---------------
[junit] Addition with parameters : 1 and 2
[junit] Addition with parameters : 2 and 3
[junit] Addition with parameters : 3 and 4
[junit] Addition with parameters : 4 and 5
[junit] ------------- ---------------- ---------------
[junit]
[junit] Testcase: sumTest[0] took 0,015 sec
[junit] Testcase: sumTest[1] took 0 sec
[junit] Testcase: sumTest[2] took 0 sec
[junit] Testcase: sumTest[3] took 0 sec
[junit] Running com.omitted.coruscant.util.DateUtilUnitTest
[junit] Testsuite: com.omitted.coruscant.util.DateUtilUnitTest
[junit] Tests run: 43, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,188 sec
[junit] Tests run: 43, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,188 sec
[junit]
[junit] Testcase: testGetNextDay took 0 sec
[junit] Testcase: testIsSameInstant took 0 sec
[junit] Testcase: testGetFirstDayOfWeek took 0 sec
[junit] Testcase: testFormatUserDateTime took 0 sec
[junit] Testcase: testEndOfDay took 0 sec
[junit] Testcase: testDateTime took 0 sec
[junit] Testcase: testDifferenceHours took 0 sec
[junit] Testcase: testDifferenceMonth took 0 sec
[junit] Testcase: testMaxDateIfNullDate1 took 0 sec
[junit] Testcase: testOverlap took 0,094 sec
[junit] Testcase: testDay took 0 sec
[junit] Testcase: testGetCalendarFromDate took 0 sec
[junit] Testcase: testToday took 0 sec
[junit] Testcase: testGetDatePart took 0 sec
[junit] Testcase: testGetNextDayOrMidnight took 0 sec
[junit] Testcase: testLatestDate took 0 sec
[junit] Testcase: testBuildDate took 0 sec
[junit] Testcase: testIsForever took 0 sec
[junit] Testcase: testAddMonth took 0 sec
[junit] Testcase: testGetDayOfWeekIndex took 0 sec
[junit] Testcase: testFormatDate took 0 sec
[junit] Testcase: testIsOlderThanDays took 0 sec
[junit] Testcase: testDifferenceDays took 0 sec
[junit] Testcase: testCreateMonthEndingDatesBetween took 0 sec
[junit] Testcase: testDayOfWeek took 0 sec
[junit] Testcase: testIsBeforeOrSameDay took 0 sec
[junit] Testcase: testParseISODate took 0 sec
[junit] Testcase: testParseISOTime took 0 sec
[junit] Testcase: testCreateDayDatesBetween took 0 sec
[junit] Testcase: testParseISODateTime took 0,016 sec
[junit] Testcase: testIsOlderThanHours took 0 sec
[junit] Testcase: testIsLastDayOfMonth took 0 sec
[junit] Testcase: testNullIfmaxDate took 0 sec
[junit] Testcase: testToSqlTimestamp took 0 sec
[junit] Testcase: testGetOverlappingHours took 0 sec
[junit] Testcase: testEarliestDate took 0 sec
[junit] Testcase: testToSqlDate took 0 sec
[junit] Testcase: testMaxDateIfNullDate took 0 sec
[junit] Testcase: testCreatePeriodBreak took 0 sec
[junit] Testcase: testIsFirstDayOfMonth took 0 sec
[junit] Testcase: testGetHolidayYear took 0 sec
[junit] Testcase: testStartOfDay took 0 sec
[junit] Testcase: testLastDayOfMonth took 0 sec
[junit] Running com.omitted.manage.bl.AdressUtilUnitTest
[junit] Testsuite: com.omitted.manage.bl.AdressUtilUnitTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,015 sec
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,015 sec
[junit]
[junit] Testcase: testSynchAddressWithNullArguments took 0 sec
[junit] Running com.omitted.util.calc.FITest
[junit] Testsuite: com.omitted.util.calc.FITest
[junit] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,031 sec
[junit] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,031 sec
[junit]
[junit] Testcase: testEAN took 0 sec
[junit] Testcase: test took 0,015 sec
[junit] Running com.omitted.util.calc.IntrestTest
[junit] Testsuite: com.omitted.util.calc.IntrestTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,015 sec
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,015 sec
[junit]
[junit] Testcase: calulateInterestFeeByMonthTest took 0,015 sec
[junit] Running com.omitted.util.calc.JUnitEANValidationTest
[junit] Testsuite: com.omitted.util.calc.JUnitEANValidationTest
[junit] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,047 sec
[junit] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,047 sec
[junit] ------------- Standard Output ---------------
[junit] Checking validity of EAN Checksum: 5798009932600
[junit] Checking validity of EAN Checksum: 5798000428614
[junit] Checking validity of EAN Checksum: 5798000428256
[junit] Checking validity of EAN Checksum: 5798000428620
[junit] Checking validity of EAN Checksum: 5798000428621
[junit] Checking validity of EAN Checksum: 5798000428622
[junit] Checking validity of EAN Checksum: 5798000428623
[junit] Checking validity of EAN Checksum: 5798000428624
[junit] Checking validity of EAN Checksum: 5798000428625
[junit] Checking validity of EAN Checksum: 5798000428626
[junit] Checking validity of EAN Checksum: 5798000428627
[junit] Checking validity of EAN Checksum: 5798000428628
[junit] Checking validity of EAN Checksum: 5798000428629
[junit] Checking validity of EAN Checksum: 5798000428601
[junit] Checking validity of EAN Checksum: 4012195172451
[junit] Checking validity of EAN Checksum: 57980004286
[junit] EAN number must be 13 digits
[junit] Checking validity of EAN Checksum: 5798000428629123
[junit] EAN number must be 13 digits
[junit] ------------- ---------------- ---------------
[junit]
[junit] Testcase: testValidationOfFICheckCipher[0] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[1] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[2] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[3] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[4] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[5] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[6] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[7] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[8] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[9] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[10] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[11] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[12] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[13] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[14] took 0 sec
[junit] Testcase: testValidationOfFICheckCipher[15] took 0,016 sec
[junit] Testcase: testValidationOfFICheckCipher[16] took 0 sec
[junit] Running com.omitted.util.calc.JUnitFICheckCipherTest
[junit] Testsuite: com.omitted.util.calc.JUnitFICheckCipherTest
[junit] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,016 sec
[junit] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,016 sec
[junit] ------------- Standard Output ---------------
[junit] Checking Cipher: 2684014996532
[junit] Checking Cipher: 660405152
[junit] Checking Cipher: 33259336900139
[junit] ------------- ---------------- ---------------
[junit]
[junit] Testcase: testCalculationOfFICheckCipher[0] took 0 sec
[junit] Testcase: testCalculationOfFICheckCipher[1] took 0 sec
[junit] Testcase: testCalculationOfFICheckCipher[2] took 0 sec
[echo] running JUnit Report
[junitreport] Processing C:\Users\jenkins\omitted\workspace\omitted Ant\deploy\xml\TESTS-TestSuites.xml to C:\Windows\TEMP\null28497120
[junitreport] Loading stylesheet jar:file:/C:/Users/jenkins/jenkins-dependencies/apache-ant-1.9.4-bin/apache-ant-1.9.4/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Transform time: 1328ms
[junitreport] Deleting: C:\Windows\TEMP\null28497120
So since no XML is generated, I wager that's why empty HTML reports are generated. The reason I got the {deploy}\html\finish folder, is because the plugin responsible for publishing the HTML report, copies the files to a new location.
How would I make the XML reports generate proper?
I am fairly new to ant and the use of jenkins, so please excuse my noob mistakes.
I am using Spring MVC in my application.
For a certain ajax call, I need to return JSON response.
Normally you would do that using #ReponseBody annotation.
Here is the piece of code I have used.
#RequestMapping(value ="/getClients", headers="Accept=*/*", produces = "application/json")
public #ResponseBody List<Map<String, Object>> getClients(#ModelAttribute("searchText") String searchText, ModelMap model){
logger.debug("Entering getClients with searchtext as : {}", searchText);
List<Map<String, Object>> autoCompleterResult = null;
try{
autoCompleterResult = clientService.getClientsForAutoCompleter(searchText);
logger.debug("Grid Result is : {}", autoCompleterResult );
}catch(Exception e){
logger.error("Exception occured", e);
}
return autoCompleterResult;
}
This works with Spring 3.1.4, but doesn't works with Spring 3.2 version.
Or is there some specific configuration I need to do for this to work with Spring 3.2?
MVC Config
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<mvc:annotation-driven />
<mvc:resources location="/css/**" mapping="/css/" />
<mvc:resources location="/js/**" mapping="/js/" />
<mvc:resources location="/images/**" mapping="/images/" />
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<context:component-scan base-package="com.controllers" />
<context:property-placeholder location="classpath:application.properties"/>
PS : I have included Jackson jar in my class path.
Update
Stack Trace :
02 Aug 2013 11:55:00 DEBUG impl.DistributionPlatformRepositoryImpl (DistributionPlatformServiceImpl.java42) - Entering getPlatforms
02 Aug 2013 11:55:00 DEBUG impl.DistributionPlatformRepositoryImpl (DistributionPlatformRepositoryImpl.java40) - Entering getPlatforms
02 Aug 2013 11:55:00 DEBUG impl.DistributionPlatformRepositoryImpl (DistributionPlatformServiceImpl.java88) - Entering getPlatformsAaData
02 Aug 2013 11:55:00 DEBUG controllers.SearchPlatformController (SearchPlatformController.java56) - Grid Result is : {iTotalDisplayRecords=7, aaData=[[A, B, C, 7, D, E, C, In Active, 25], [A, T, B, 3, L, C, 001, In Active, 20]]}
02 Aug 2013 11:55:00 DEBUG annotation.ExceptionHandlerExceptionResolver (AbstractHandlerExceptionResolver.java132) - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> com.controllers.SearchPlatformController.getPlatforms(com.model.form.SearchPlatformForm,org.springframework.ui.ModelMap)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
02 Aug 2013 11:55:00 DEBUG annotation.ResponseStatusExceptionResolver (AbstractHandlerExceptionResolver.java132) - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> com.controllers.SearchPlatformController.getPlatforms(com.model.form.SearchPlatformForm,org.springframework.ui.ModelMap)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
02 Aug 2013 11:55:00 DEBUG support.DefaultHandlerExceptionResolver (AbstractHandlerExceptionResolver.java132) - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> com.controllers.SearchPlatformController.getPlatforms(com.model.form.SearchPlatformForm,org.springframework.ui.ModelMap)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
02 Aug 2013 11:55:00 DEBUG servlet.DispatcherServlet (DispatcherServlet.java999) - Null ModelAndView returned to DispatcherServlet with name 'managedaccounts': assuming HandlerAdapter completed request handling
02 Aug 2013 11:55:00 DEBUG servlet.DispatcherServlet (FrameworkServlet.java951) - Successfully completed request
Finally after lot of searching I was able solve this. All thanks to Stackoverflow.
Please refer to the following link :
https://stackoverflow.com/a/13939290/1061430
Basically following section was required to be included in the MVC config file :
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers -->
<property name="favorPathExtension" value="false" />
</bean>
Thanks again stackoverflow.
Just include the jackson jars into your project and spring will automatically detect it's presence and use it to serialize your objects.
Update
I saw someone has voted this answer down without clarifying why. This is a bit awkward. Especially since the statement is true ;)
So here's a piece quoted from http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/
Underneath the covers, Spring MVC delegates to a HttpMessageConverter to perform the serialization. In this case, Spring MVC invokes a MappingJacksonHttpMessageConverter built on the Jackson JSON processor. This implementation is enabled automatically when you use the mvc:annotation-driven configuration element with Jackson present in your classpath.
What version of Jackson you using? Jackson 2.1.0 works great with Spring 3.2 of me with next maven dependencies:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.0</version>
</dependency>
I want to separate tests into 3 different categories:
unit
componnet
system
Then I want to run them separately on different phases and display results of execution these tests into 3 different surefire reports, or maybe one but with tests resultsd divided into 3 different catagories.
How to achieve it with maven?
I know I can run tests separately using failsafe maven plugin. So it is not problem.
There only problem have I can devide report into 3 catagories.
I am using maven-surefire-plugin with junit categories.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<executions>
<execution>
<id>unit-tests</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>com.mycompany.mavenproject2.UnitTest</groups>
<reportsDirectory> ${project.build.directory}/surefire-reports/unit</reportsDirectory>
<reportNameSuffix>UNIT</reportNameSuffix>
</configuration>
</execution>
<execution>
<id>comp-tests</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>com.mycompany.mavenproject2.ComponentTest</groups>
<reportsDirectory> ${project.build.directory}/surefire-reports/comp</reportsDirectory>
<reportNameSuffix>COMPONENT</reportNameSuffix>
</configuration>
</execution>
<execution>
<id>sys-tests</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>com.mycompany.mavenproject2.SystemTest</groups>
<reportsDirectory> ${project.build.directory}/surefire-reports/sys</reportsDirectory>
<reportNameSuffix>SYSTEM</reportNameSuffix>
</configuration>
</execution>
</executions>
</plugin>
It works fine,except that it run first all tests not separating them into categories.
How to remove such behaviour?
Build produced an output.
T E S T S
Running com.mycompany.mavenproject2.AppTest
UnitTest
ComponentTest
SystemTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[surefire:test]
Surefire report directory: C:\Users\mz\Documents\NetBeansProjects\mavenproject2\target\surefire-reports\unit
T E S T S
Concurrency config is parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running com.mycompany.mavenproject2.AppTest
UnitTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[surefire:test]
Surefire report directory: C:\Users\mz\Documents\NetBeansProjects\mavenproject2\target\surefire-reports\comp
T E S T S
Concurrency config is parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running com.mycompany.mavenproject2.AppTest
ComponentTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[surefire:test]
Surefire report directory: C:\Users\mz\Documents\NetBeansProjects\mavenproject2\target\surefire-reports\sys
T E S T S
Concurrency config is parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running com.mycompany.mavenproject2.AppTest
SystemTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0