-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fetcher tests #4216
Fix fetcher tests #4216
Conversation
remove uncessary logging in l10n which makes fetcher test fail ISBN tests still fail both Fix arxiv tests, eprint now has url in front
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've a few remarks that should be fixed before merging. In particular, some of the fetcher need to be changed instead of the test cases...
@@ -51,8 +51,7 @@ private Localization() { | |||
*/ | |||
public static String lang(String key, String... params) { | |||
if (localizedMessages == null) { | |||
// I'm logging this because it should never happen | |||
LOGGER.error("Messages are not initialized before accessing key: " + key); | |||
// This will happen when running junit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this now a problem? While changing some localization-based stuff, I hit this error message sometimes during development and it was helpful to locate the problem. Hence, I would prefer if it could stay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the problem now is that you will hit a NotInitlaizedException in junit. Execute the isbn fetcher test for example and you will see it. It has somehow to do with the fact that the log4j tries to call another appender (GUI based in the end, though it's executed from the test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The appender are/can be configured separately for the tests, so removing the GUI-appender is worth a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the loging configuration, the xml file had to be renamed
@@ -41,7 +41,7 @@ public void setUp() { | |||
sliceTheoremPaper.setField("title", "Slice theorem for Fréchet group actions and covariant symplectic field theory"); | |||
sliceTheoremPaper.setField("date", "2014-05-09"); | |||
sliceTheoremPaper.setField("abstract", "A general slice theorem for the action of a Fr\\'echet Lie group on a Fr\\'echet manifolds is established. The Nash-Moser theorem provides the fundamental tool to generalize the result of Palais to this infinite-dimensional setting. The presented slice theorem is illustrated by its application to gauge theories: the action of the gauge transformation group admits smooth slices at every point and thus the gauge orbit space is stratified by Fr\\'echet manifolds. Furthermore, a covariant and symplectic formulation of classical field theory is proposed and extensively discussed. At the root of this novel framework is the incorporation of field degrees of freedom F and spacetime M into the product manifold F * M. The induced bigrading of differential forms is used in order to carry over the usual symplectic theory to this new setting. The examples of the Klein-Gordon field and general Yang-Mills theory illustrate that the presented approach conveniently handles the occurring symmetries."); | |||
sliceTheoremPaper.setField("eprint", "1405.2249v1"); | |||
sliceTheoremPaper.setField("eprint", "http://arxiv.org/abs/1405.2249v1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong... it should just insert the number (i.e. the fetcher should be fixed not the test)
@@ -142,7 +142,7 @@ public void searchEntryByOldId() throws Exception { | |||
expected.setField("title", "Multi-Electron Production at High Transverse Momenta in ep Collisions at HERA"); | |||
expected.setField("date", "2003-07-07"); | |||
expected.setField("abstract", "Multi-electron production is studied at high electron transverse momentum in positron- and electron-proton collisions using the H1 detector at HERA. The data correspond to an integrated luminosity of 115 pb-1. Di-electron and tri-electron event yields are measured. Cross sections are derived in a restricted phase space region dominated by photon-photon collisions. In general good agreement is found with the Standard Model predictions. However, for electron pair invariant masses above 100 GeV, three di-electron events and three tri-electron events are observed, compared to Standard Model expectations of 0.30 \\pm 0.04 and 0.23 \\pm 0.04, respectively."); | |||
expected.setField("eprint", "hep-ex/0307015v1"); | |||
expected.setField("eprint", "http://arxiv.org/abs/hep-ex/0307015v1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
@@ -189,7 +189,7 @@ public void searchWithMalformedIdThrowsException() throws Exception { | |||
public void searchIdentifierForSlicePaper() throws Exception { | |||
sliceTheoremPaper.clearField(FieldName.EPRINT); | |||
|
|||
assertEquals(ArXivIdentifier.parse("1405.2249v1"), finder.findIdentifier(sliceTheoremPaper)); | |||
assertEquals(ArXivIdentifier.parse("http://arxiv.org/abs/1405.2249v1"), finder.findIdentifier(sliceTheoremPaper)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should work just with the id...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reason as above, the bibtex code returns the url + id and will not be equal if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, then the implementation needs be changed to strip the url part ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strip was already implemented, but it checked for https and not http.
when(prefs.getKeywordSeparator()).thenReturn(','); | ||
} | ||
|
||
private final LibraryOfCongress fetcher = new LibraryOfCongress(prefs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize prefs and fetcher in setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -176,8 +178,7 @@ public void testPerformSearchByIdEmptyDOI() throws Exception { | |||
|
|||
@Test | |||
public void testPerformSearchByIdInvalidDoi() throws Exception { | |||
Optional<BibEntry> fetchedEntry = fetcher.performSearchById("this.doi.will.fail"); | |||
assertEquals(Optional.empty(), fetchedEntry); | |||
assertThrows(FetcherException.class, () -> fetcher.performSearchById("this.doi.will.fail")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about our conventions, but whether we throw an exception or return an empty result should be consistent across id fetchers (and it should be added as a general test for all id fetchers (there should be a test class for all id fetchers)). Personally, I would prefer an empty result instead of an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that our URLDownload throws a FileNotFound Exception on an 404 error, because you are trying to access an input stream of a non existent resource) and thus resulting in a fetcher exception which does not return anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default is an empty result if the ID cannot be found or used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the method in UrlDownload to return an empty stream when a 404 or 400 error (the latter one is thrown by medline) is encountered. I simply log the status response code + url .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you catch the Exception inside the fetcher? I don't like our URLDownload implementation anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that was done before but the fetcher exception just encapsulated a file not found exception with no way to getting the underlying http status code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with most of what @tobiasdiez already said
Fix logging configuration Fix eprint field of arxiv Return empty results when 404 or 400 encountered Add logging in that case
// remove leading https://arxiv.org/abs/ from abstract url to get arXiv ID | ||
String prefix = "https://arxiv.org/abs/"; | ||
// remove leading http://arxiv.org/abs/ from abstract url to get arXiv ID | ||
String prefix = "http://arxiv.org/abs/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no HTTPS anymore? We just changed this?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also in favor of removing both http and https prefixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetcher itself still uses https, but the prefix for the eprint field does not start with https but with http
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we only remove http prefixes not https (if there exists one at a point in time)?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added check for both
@@ -64,4 +64,10 @@ public void findSingleEntryUsingComplexOperators() throws FetcherException { | |||
assertEquals(Collections.singletonList(entry), result); | |||
} | |||
|
|||
@Test | |||
public void findNothing() throws Exception | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brackets alignment
I fixed all remainig issues. Error response 400 or 404 are logged in the error log. |
Ebook.de and Google Scholar work again. Chimbori fetcher is broken, but author is noticed and responded that it will be fixed soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a very small remark. Feel free to merge directly after fixing it.
private static final Logger LOGGER = LoggerFactory.getLogger(ArXiv.class); | ||
|
||
private static final String API_URL = "https://export.arxiv.org/api/query"; | ||
// remove leading http(s)://arxiv.org/abs/ from abstract url to get arXiv ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should not be here but in the method below
* upstream/master: Update dependencies (#4231) Update to latest release of richtextfx (#4213) Fix fetcher tests (#4216) single line text fields (#4138) Make it easier to rename and move files (#4200) Fix that swing dialogs are hidden behind main window (#4205) Fixed: #4166 add move & rename file (#4217) # Conflicts: # CHANGELOG.md
* upstream/master: (47 commits) Make attached files relative to the file directory (#4212) execute set visible in swing thread to avoid blocking Fix isbn chimbori test (#4234) Rewrite web search pane in JavaFX (#4203) Update dependencies (#4231) Update to latest release of richtextfx (#4213) Fix fetcher tests (#4216) single line text fields (#4138) Make it easier to rename and move files (#4200) Fix that swing dialogs are hidden behind main window (#4205) Fixed: #4166 add move & rename file (#4217) update gradle plugins and gradlen to 4.9 Update dependencies Remove unnecessary look and feel migration (#4204) Revert threading fix since this sometimes lead to freezes... Update year Fix a few more threading exceptions Refactor Convert CiteSeerX fetcher to new infrastructure (#4185) Make global font size customizable (#4178) ... # Conflicts: # src/main/java/org/jabref/gui/BasePanel.java # src/main/java/org/jabref/gui/JabRefFrame.java # src/main/java/org/jabref/gui/mergeentries/MergeEntries.java # src/main/resources/l10n/JabRef_en.properties
Fix fetcher test and fix l10n logging for test
@tobiasdiez could you please check if the zbMath and the MathSciNet tests are still correct?
I am getting 401 as I have no access.