Bug 1127203 - Rest test intermittent failure TranslationResourceRestTest.headersAfterTranslating
Summary: Rest test intermittent failure TranslationResourceRestTest.headersAfterTransl...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Zanata
Classification: Retired
Component: Component-Logic
Version: 3.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Alex Eng
QA Contact: Zanata-QA Mailling List
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-06 11:37 UTC by Damian Jansen
Modified: 2015-07-31 01:15 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-07-31 01:15:03 UTC
Embargoed:


Attachments (Terms of Use)

Description Damian Jansen 2014-08-06 11:37:50 UTC
Version-Release number of selected component (if applicable):
3.4

Description of problem:
Rest test intermittent failure in jenkins.

==
Regression

org.zanata.rest.service.TranslationResourceRestTest.headersAfterTranslating (from TestSuite)

Failing for the past 1 build (Since #1838 )
Took 0.19 sec.
Error Message

Expected: is "Administrator <root@localhost>"
     but: was ""
Stacktrace

java.lang.AssertionError: 
Expected: is "Administrator <root@localhost>"
     but: was ""
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
	at org.zanata.rest.service.TranslationResourceRestTest.headersAfterTranslating(TranslationResourceRestTest.java:914)
==
 
Also, this test contains asserting for-loops which are not appropriate in tests, for safety and readability. In this particular case if the collection is empty, or the headers don't match, the test will pass which is incorrect.

There are several instances of the same code behaviour in the above class, which should be altered to something like

for (HeaderEntry entry : header.getEntries()) {
    somehashmap.put(entry.getKey(), entry.getValue.trim())
}
assertThat(somehashmap.get(HeaderFields.KEY_LastTranslator), is("Administrator <root@localhost>"));
assertThat(somehashmap.get(HeaderFields.KEY_PoRevisionDate).length(),  greaterThan(0));

The behaviour of the above cannot otherwise be properly verified.

Comment 1 Zanata Migrator 2015-07-31 01:15:03 UTC
Migrated; check JIRA for bug status: http://zanata.atlassian.net/browse/ZNTA-380


Note You need to log in before you can comment on or make changes to this bug.