containsDuplicate(BibDatabase database, BibEntr
* @param s2 The second string
* @return a value in the interval [0, 1] indicating the degree of match.
*/
- public static double correlateByWords(String s1, String s2) {
- String[] w1 = s1.split("\\s");
- String[] w2 = s2.split("\\s");
- int n = Math.min(w1.length, w2.length);
+ public static double correlateByWords(final String s1, final String s2) {
+ final String[] w1 = s1.split("\\s");
+ final String[] w2 = s2.split("\\s");
+ final int n = Math.min(w1.length, w2.length);
int misses = 0;
for (int i = 0; i < n; i++) {
double corr = similarity(w1[i], w2[i]);
@@ -256,7 +315,7 @@ public static double correlateByWords(String s1, String s2) {
misses++;
}
}
- double missRate = (double) misses / (double) n;
+ final double missRate = (double) misses / (double) n;
return 1 - missRate;
}
@@ -265,22 +324,26 @@ public static double correlateByWords(String s1, String s2) {
* Calculates the similarity (a number within 0 and 1) between two strings.
* http://stackoverflow.com/questions/955110/similarity-string-comparison-in-java
*/
- private static double similarity(String first, String second) {
- String longer = first;
- String shorter = second;
+ private static double similarity(final String first, final String second) {
+ final String longer;
+ final String shorter;
if (first.length() < second.length()) {
longer = second;
shorter = first;
+ } else {
+ longer = first;
+ shorter = second;
}
- int longerLength = longer.length();
+ final int longerLength = longer.length();
// both strings are zero length
if (longerLength == 0) {
return 1.0;
}
- double sim = (longerLength - new StringSimilarity().editDistanceIgnoreCase(longer, shorter)) / (double) longerLength;
- LOGGER.debug("Longer string: " + longer + " Shorter string: " + shorter + " Similarity: " + sim);
- return sim;
+ final double distanceIgnoredCase = new StringSimilarity().editDistanceIgnoreCase(longer, shorter);
+ final double similarity = (longerLength - distanceIgnoredCase) / (double) longerLength;
+ LOGGER.debug("Longer string: " + longer + " Shorter string: " + shorter + " Similarity: " + similarity);
+ return similarity;
}
}
diff --git a/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java b/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java
index 6afe53acbe0..a8b0e1b61c4 100644
--- a/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java
+++ b/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java
@@ -29,6 +29,15 @@ public class BibtexNameFormatter {
private BibtexNameFormatter() {
}
+ /**
+ * Formats the nth author of the author name list by a given format string
+ *
+ * @param authorsNameList The string from an author field
+ * @param whichName index of the list, starting with 1
+ * @param formatString TODO
+ * @param warn collects the warnings, may-be-null
+ * @return
+ */
public static String formatName(String authorsNameList, int whichName, String formatString, Warn warn) {
AuthorList al = AuthorList.parse(authorsNameList);
@@ -40,11 +49,7 @@ public static String formatName(String authorsNameList, int whichName, String fo
}
/**
- *
- * @param author
- * @param format
- * @param warn may-be-null
- * @return
+ * @param warn collects the warnings, may-be-null
*/
public static String formatName(Author author, String format, Warn warn) {
diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java
index 37c71543d3e..c21c37ddc8c 100644
--- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java
+++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java
@@ -78,19 +78,6 @@ public BibtexParser(ImportFormatPreferences importFormatPreferences, FileUpdateM
metaDataParser = new MetaDataParser(fileMonitor);
}
- /**
- * Shortcut usage to create a Parser and read the input.
- *
- * @param in the Reader to read from
- * @param fileMonitor
- * @throws IOException
- * @deprecated inline this method
- */
- @Deprecated
- public static ParserResult parse(Reader in, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) throws IOException {
- return new BibtexParser(importFormatPreferences, fileMonitor).parse(in);
- }
-
/**
* Parses BibtexEntries from the given string and returns one entry found (or null if none found)
*
diff --git a/src/main/java/org/jabref/logic/remote/client/RemoteListenerClient.java b/src/main/java/org/jabref/logic/remote/client/RemoteListenerClient.java
index ab319ffcaf0..ce2b24998f3 100644
--- a/src/main/java/org/jabref/logic/remote/client/RemoteListenerClient.java
+++ b/src/main/java/org/jabref/logic/remote/client/RemoteListenerClient.java
@@ -35,8 +35,8 @@ public static boolean sendToActiveJabRefInstance(String[] args, int remoteServer
if (!Protocol.IDENTIFIER.equals(identifier)) {
String port = String.valueOf(remoteServerPort);
- String error = Localization.lang("Cannot use port %0 for remote operation; another application may be using it. Try specifying another port.", port);
- System.out.println(error);
+ String errorMessage = Localization.lang("Cannot use port %0 for remote operation; another application may be using it. Try specifying another port.", port);
+ LOGGER.error(errorMessage);
return false;
}
protocol.sendMessage(String.join("\n", args));
diff --git a/src/main/java/org/jabref/logic/xmp/XMPUtil.java b/src/main/java/org/jabref/logic/xmp/XMPUtil.java
index 73d63a4b1b1..97be1498ec9 100644
--- a/src/main/java/org/jabref/logic/xmp/XMPUtil.java
+++ b/src/main/java/org/jabref/logic/xmp/XMPUtil.java
@@ -1033,7 +1033,7 @@ public static boolean hasMetadata(Path path, XMPPreferences xmpPreferences) {
try (InputStream inputStream = Files.newInputStream(path, StandardOpenOption.READ)) {
return hasMetadata(inputStream, xmpPreferences);
} catch (IOException e) {
- LOGGER.error("XMP reading failed", e);
+ // happens if no metadata is found, no reason to log the exception
return false;
}
}
@@ -1056,7 +1056,7 @@ public static boolean hasMetadata(InputStream inputStream, XMPPreferences xmpPre
LOGGER.info("Encryption not supported by XMPUtil");
return false;
} catch (IOException e) {
- LOGGER.error("XMP reading failed", e);
+ // happens if no metadata is found, no reason to log the exception
return false;
}
}
diff --git a/src/main/java/org/jabref/model/search/matchers/AndMatcher.java b/src/main/java/org/jabref/model/search/matchers/AndMatcher.java
index c39b3c36ffc..81839607ad0 100644
--- a/src/main/java/org/jabref/model/search/matchers/AndMatcher.java
+++ b/src/main/java/org/jabref/model/search/matchers/AndMatcher.java
@@ -1,26 +1,15 @@
package org.jabref.model.search.matchers;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.search.SearchMatcher;
/**
- * Subclass of MatcherSet that ANDs or ORs between its rules, returning 0 or
- * 1.
+ * A set of matchers that returns true if all matcher match the given entry.
*/
public class AndMatcher extends MatcherSet {
@Override
- public boolean isMatch(BibEntry bibEntry) {
- int score = 0;
-
- // We let each rule add a maximum of 1 to the score.
- for (SearchMatcher rule : matchers) {
- if (rule.isMatch(bibEntry)) {
- score++;
- }
- }
-
- // Then an AND rule demands that score == number of rules
- return score == matchers.size();
+ public boolean isMatch(BibEntry entry) {
+ return matchers.stream()
+ .allMatch(rule -> rule.isMatch(entry));
}
}
diff --git a/src/main/java/org/jabref/model/search/matchers/OrMatcher.java b/src/main/java/org/jabref/model/search/matchers/OrMatcher.java
index ffd2ebf1e28..c0a0eddf1d9 100644
--- a/src/main/java/org/jabref/model/search/matchers/OrMatcher.java
+++ b/src/main/java/org/jabref/model/search/matchers/OrMatcher.java
@@ -1,26 +1,15 @@
package org.jabref.model.search.matchers;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.search.SearchMatcher;
/**
- * Subclass of MatcherSet that ANDs or ORs between its rules, returning 0 or
- * 1.
+ * A set of matchers that returns true if any matcher matches the given entry.
*/
public class OrMatcher extends MatcherSet {
@Override
- public boolean isMatch(BibEntry bibEntry) {
- int score = 0;
-
- // We let each rule add a maximum of 1 to the score.
- for (SearchMatcher rule : matchers) {
- if (rule.isMatch(bibEntry)) {
- score++;
- }
- }
-
- // OR rule demands score > 0.
- return score > 0;
+ public boolean isMatch(BibEntry entry) {
+ return matchers.stream()
+ .anyMatch(rule -> rule.isMatch(entry));
}
}
diff --git a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java
index ab802782ddf..c0a54568f82 100644
--- a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java
+++ b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java
@@ -16,6 +16,8 @@ public class DuplicateCheckTest {
private BibEntry simpleArticle;
private BibEntry unrelatedArticle;
+ private BibEntry simpleInbook;
+ private BibEntry simpleIncollection;
@Before
public void setUp() {
@@ -27,6 +29,19 @@ public void setUp() {
.withField(FieldName.AUTHOR, "Completely Different")
.withField(FieldName.TITLE, "Holy Moly Uffdada und Trallalla")
.withField(FieldName.YEAR, "1992");
+ simpleInbook = new BibEntry(BibtexEntryTypes.INBOOK.getName())
+ .withField(FieldName.TITLE, "Alice in Wonderland")
+ .withField(FieldName.AUTHOR, "Charles Lutwidge Dodgson")
+ .withField(FieldName.CHAPTER, "Chapter One – Down the Rabbit Hole")
+ .withField(FieldName.LANGUAGE, "English")
+ .withField(FieldName.PUBLISHER, "Macmillan")
+ .withField(FieldName.YEAR, "1865");
+ simpleIncollection = new BibEntry(BibtexEntryTypes.INCOLLECTION.getName())
+ .withField(FieldName.TITLE, "Innovation and Intellectual Property Rights")
+ .withField(FieldName.AUTHOR, "Ove Grandstrand")
+ .withField(FieldName.BOOKTITLE, "The Oxford Handbook of Innovation")
+ .withField(FieldName.PUBLISHER, "Oxford University Press")
+ .withField(FieldName.YEAR, "2004");
}
@Test
@@ -142,6 +157,51 @@ public void twoEntriesWithSameDoiButDifferentTypesAreDuplicates() {
assertTrue(DuplicateCheck.isDuplicate(simpleArticle, duplicateWithDifferentType, BibDatabaseMode.BIBTEX));
}
+ @Test
+ public void twoInbooksWithDifferentChaptersAreNotDuplicates() {
+ twoEntriesWithDifferentSpecificFieldsAreNotDuplicates(simpleInbook, FieldName.CHAPTER,
+ "Chapter One – Down the Rabbit Hole",
+ "Chapter Two – The Pool of Tears");
+ }
+
+ @Test
+ public void twoInbooksWithDifferentPagesAreNotDuplicates() {
+ twoEntriesWithDifferentSpecificFieldsAreNotDuplicates(simpleInbook, FieldName.PAGES, "1-20", "21-40");
+ }
+
+ @Test
+ public void twoIncollectionsWithDifferentChaptersAreNotDuplicates() {
+ twoEntriesWithDifferentSpecificFieldsAreNotDuplicates(simpleIncollection, FieldName.CHAPTER, "10", "9");
+ }
+
+ @Test
+ public void twoIncollectionsWithDifferentPagesAreNotDuplicates() {
+ twoEntriesWithDifferentSpecificFieldsAreNotDuplicates(simpleIncollection, FieldName.PAGES, "1-20", "21-40");
+ }
+
+ private void twoEntriesWithDifferentSpecificFieldsAreNotDuplicates(final BibEntry cloneable,
+ final String fieldType,
+ final String firstValue,
+ final String secondValue) {
+ final BibEntry entry1 = (BibEntry) cloneable.clone();
+ entry1.setField(fieldType, firstValue);
+
+ final BibEntry entry2 = (BibEntry) cloneable.clone();
+ entry2.setField(fieldType, secondValue);
+
+ assertFalse(DuplicateCheck.isDuplicate(entry1, entry2, BibDatabaseMode.BIBTEX));
+ }
+
+ @Test
+ public void inbookWithoutChapterCouldBeDuplicateOfInbookWithChapter() {
+ final BibEntry inbook1 = (BibEntry) simpleInbook.clone();
+ final BibEntry inbook2 = (BibEntry) simpleInbook.clone();
+ inbook2.setField(FieldName.CHAPTER, "");
+
+ assertTrue(DuplicateCheck.isDuplicate(inbook1, inbook2, BibDatabaseMode.BIBTEX));
+ assertTrue(DuplicateCheck.isDuplicate(inbook2, inbook1, BibDatabaseMode.BIBTEX));
+ }
+
@Test
public void twoBooksWithDifferentEditionsAreNotDuplicates() {
BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK.getName());
diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
index b346f548901..b963f63c4de 100644
--- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
+++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
@@ -280,7 +280,7 @@ public void parseRecognizesEntryInParenthesis() throws IOException {
@Test
public void parseRecognizesEntryWithBigNumbers() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{canh05," + "isbn = 1234567890123456789,\n"
- + "isbn2 = {1234567890123456789},\n" + "small = 1234,\n" + "}"), importFormatPreferences, fileMonitor);
+ + "isbn2 = {1234567890123456789},\n" + "small = 1234,\n" + "}"));
Collection parsed = result.getDatabase().getEntries();
BibEntry entry = parsed.iterator().next();
@@ -367,10 +367,9 @@ public void parseRecognizesMultipleEntries() throws IOException {
secondEntry.setField("author", "Norton Bar");
expected.add(secondEntry);
- ParserResult result = BibtexParser.parse(
+ ParserResult result = parser.parse(
new StringReader("@article{canh05," + " author = {Crowston, K. and Annabi, H.},\n"
- + " title = {Title A}}\n" + "@inProceedings{foo," + " author={Norton Bar}}"),
- importFormatPreferences, fileMonitor);
+ + " title = {Title A}}\n" + "@inProceedings{foo," + " author={Norton Bar}}"));
List parsed = result.getDatabase().getEntries();
assertEquals(expected, parsed);
@@ -467,8 +466,7 @@ public void parseRecognizesHeaderButIgnoresEncoding() throws IOException {
+ " title = {Effective work practices for floss development: A model and propositions}," + "\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n"
+ " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29}," + "\n"
- + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"),
- importFormatPreferences, fileMonitor);
+ + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"));
Collection parsed = result.getDatabase().getEntries();
BibEntry entry = parsed.iterator().next();
@@ -497,8 +495,7 @@ public void parseRecognizesFormatedEntry() throws IOException {
+ " title = {Effective work practices for floss development: A model and propositions}," + "\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n"
+ " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29},"
- + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"),
- importFormatPreferences, fileMonitor);
+ + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"));
Collection parsed = result.getDatabase().getEntries();
BibEntry entry = parsed.iterator().next();
@@ -600,8 +597,7 @@ public void parseReturnsEmptyListIfNoEntryRecognized() throws IOException {
+ " title = {Effective work practices for floss development: A model and propositions}," + "\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n"
+ " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29},"
- + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"),
- importFormatPreferences, fileMonitor);
+ + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"));
Collection parsed = result.getDatabase().getEntries();
@@ -622,8 +618,7 @@ public void parseReturnsEmptyListIfNoEntryExistent() throws IOException {
public void parseRecognizesDuplicateBibtexKeys() throws IOException {
ParserResult result = parser
.parse(new StringReader("@article{canh05," + " author = {Crowston, K. and Annabi, H.},\n"
- + " title = {Title A}}\n" + "@inProceedings{canh05," + " author={Norton Bar}}"),
- importFormatPreferences, fileMonitor);
+ + " title = {Title A}}\n" + "@inProceedings{canh05," + " author={Norton Bar}}"));
List duplicateKeys = result.getDuplicateKeys();
@@ -710,8 +705,7 @@ public void parseIgnoresArbitraryContentAfterEntry() throws IOException {
@Test
public void parseWarnsAboutUnmatchedContentInEntryWithoutComma() throws IOException {
- ParserResult result = parser.parse(new StringReader("@article{test,author={author bracket } too much}"),
- importFormatPreferences, fileMonitor);
+ ParserResult result = parser.parse(new StringReader("@article{test,author={author bracket } too much}"));
List entries = result.getDatabase().getEntries();
@@ -720,8 +714,7 @@ public void parseWarnsAboutUnmatchedContentInEntryWithoutComma() throws IOExcept
@Test
public void parseWarnsAboutUnmatchedContentInEntry() throws IOException {
- ParserResult result = parser.parse(new StringReader("@article{test,author={author bracket }, too much}"),
- importFormatPreferences, fileMonitor);
+ ParserResult result = parser.parse(new StringReader("@article{test,author={author bracket }, too much}"));
List entries = result.getDatabase().getEntries();
@@ -801,8 +794,7 @@ public void parseIgnoresAndWarnsAboutEntryWithFieldsThatAreNotSeperatedByComma()
public void parseIgnoresAndWarnsAboutCorruptedEntryButRecognizeOthers() throws IOException {
ParserResult result = parser.parse(
new StringReader(
- "@article{test,author={author missing bracket}" + "@article{test,author={Ed von Test}}"),
- importFormatPreferences, fileMonitor);
+ "@article{test,author={author missing bracket}" + "@article{test,author={Ed von Test}}"));
Collection parsed = result.getDatabase().getEntries();
BibEntry entry = parsed.iterator().next();
@@ -943,12 +935,11 @@ public void parseRecognizesMultipleStrings() throws IOException {
@Test
public void parseRecognizesStringAndEntry() throws IOException {
- ParserResult result = BibtexParser.parse(
+ ParserResult result = parser.parse(
new StringReader("" + "@string{bourdieu = {Bourdieu, Pierre}}"
+ "@book{bourdieu-2002-questions-sociologie, " + " Address = {Paris}," + " Author = bourdieu,"
+ " Isbn = 2707318256," + " Publisher = {Minuit}," + " Title = {Questions de sociologie},"
- + " Year = 2002" + "}"),
- importFormatPreferences, fileMonitor);
+ + " Year = 2002" + "}"));
BibtexString parsedString = result.getDatabase().getStringValues().iterator().next();
@@ -1120,8 +1111,9 @@ public void parseConvertsMultipleTabsToSpace() throws IOException {
public void parsePreservesMultipleSpacesInNonWrappableField() throws IOException {
when(importFormatPreferences.getFieldContentParserPreferences().getNonWrappableFields())
.thenReturn(Collections.singletonList("file"));
- ParserResult result = BibtexParser
- .parse(new StringReader("@article{canh05,file = {ups sala}}"), importFormatPreferences, fileMonitor);
+ BibtexParser parser = new BibtexParser(importFormatPreferences, fileMonitor);
+ ParserResult result = parser
+ .parse(new StringReader("@article{canh05,file = {ups sala}}"));
Collection parsedEntries = result.getDatabase().getEntries();
BibEntry parsedEntry = parsedEntries.iterator().next();
@@ -1131,8 +1123,7 @@ public void parsePreservesMultipleSpacesInNonWrappableField() throws IOException
@Test
public void parsePreservesTabsInAbstractField() throws IOException {
- ParserResult result = parser.parse(new StringReader("@article{canh05,abstract = {ups \tsala}}"),
- importFormatPreferences, fileMonitor);
+ ParserResult result = parser.parse(new StringReader("@article{canh05,abstract = {ups \tsala}}"));
Collection parsedEntries = result.getDatabase().getEntries();
BibEntry parsedEntry = parsedEntries.iterator().next();
@@ -1142,8 +1133,7 @@ public void parsePreservesTabsInAbstractField() throws IOException {
@Test
public void parsePreservesNewlineInAbstractField() throws IOException {
- ParserResult result = parser.parse(new StringReader("@article{canh05,abstract = {ups \nsala}}"),
- importFormatPreferences, fileMonitor);
+ ParserResult result = parser.parse(new StringReader("@article{canh05,abstract = {ups \nsala}}"));
Collection parsedEntries = result.getDatabase().getEntries();
BibEntry parsedEntry = parsedEntries.iterator().next();
@@ -1351,10 +1341,9 @@ public void integrationTestCustomEntryType() throws IOException {
@Test
public void integrationTestSaveOrderConfig() throws IOException {
- ParserResult result = BibtexParser.parse(
+ ParserResult result = parser.parse(
new StringReader(
- "@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"),
- importFormatPreferences, fileMonitor);
+ "@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"));
Optional saveOrderConfig = result.getMetaData().getSaveOrderConfig();
@@ -1367,7 +1356,7 @@ public void integrationTestSaveOrderConfig() throws IOException {
public void integrationTestCustomKeyPattern() throws IOException {
ParserResult result = parser
.parse(new StringReader("@comment{jabref-meta: keypattern_article:articleTest;}" + OS.NEWLINE
- + "@comment{jabref-meta: keypatterndefault:test;}"), importFormatPreferences, fileMonitor);
+ + "@comment{jabref-meta: keypatterndefault:test;}"));
GlobalBibtexKeyPattern pattern = mock(GlobalBibtexKeyPattern.class);
AbstractBibtexKeyPattern bibtexKeyPattern = result.getMetaData().getCiteKeyPattern(pattern);
@@ -1394,7 +1383,7 @@ public void integrationTestGroupTree() throws IOException, ParseException {
+ "@comment{jabref-meta: groupstree:" + OS.NEWLINE + "0 AllEntriesGroup:;" + OS.NEWLINE
+ "1 KeywordGroup:Fréchet\\;0\\;keywords\\;FrechetSpace\\;0\\;1\\;;" + OS.NEWLINE
+ "1 KeywordGroup:Invariant theory\\;0\\;keywords\\;GIT\\;0\\;0\\;;" + OS.NEWLINE
- + "1 ExplicitGroup:TestGroup\\;0\\;Key1\\;Key2\\;;" + "}"), importFormatPreferences, fileMonitor);
+ + "1 ExplicitGroup:TestGroup\\;0\\;Key1\\;Key2\\;;" + "}"));
GroupTreeNode root = result.getMetaData().getGroups().get();
@@ -1421,7 +1410,7 @@ public void integrationTestProtectedFlag() throws IOException {
@Test
public void integrationTestContentSelectors() throws IOException {
ParserResult result = parser.parse(
- new StringReader("@Comment{jabref-meta: selector_status:approved;captured;received;status;}"), importFormatPreferences, fileMonitor);
+ new StringReader("@Comment{jabref-meta: selector_status:approved;captured;received;status;}"));
List values = new ArrayList(4);
values.add("approved");
@@ -1495,8 +1484,7 @@ public void parseDoesNotRecognizeDatabaseIDasUserComment() throws Exception {
public void integrationTestFileDirectories() throws IOException {
ParserResult result = parser.parse(
new StringReader("@comment{jabref-meta: fileDirectory:\\\\Literature\\\\;}"
- + "@comment{jabref-meta: fileDirectory-defaultOwner-user:D:\\\\Documents;}"),
- importFormatPreferences, fileMonitor);
+ + "@comment{jabref-meta: fileDirectory-defaultOwner-user:D:\\\\Documents;}"));
assertEquals("\\Literature\\", result.getMetaData().getDefaultFileDirectory().get());
assertEquals("D:\\Documents", result.getMetaData().getUserFileDirectory("defaultOwner-user").get());
diff --git a/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java b/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java
index d8d60c5e671..3d934e5741f 100644
--- a/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java
+++ b/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java
@@ -79,9 +79,10 @@ public class XMPUtilTest {
private XMPPreferences xmpPreferences;
-
private ImportFormatPreferences importFormatPreferences;
+ private BibtexParser parser;
+
/**
* Wrap bibtex-data (...) into an rdf:Description.
*
@@ -248,6 +249,8 @@ public void setUp() throws IOException, COSVisitorException {
when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(false);
when(xmpPreferences.getKeywordSeparator()).thenReturn(',');
+
+ parser = new BibtexParser(importFormatPreferences, fileMonitor);
}
/**
@@ -446,13 +449,12 @@ public void testWriteReadManually() throws COSVisitorException, IOException {
*/
@Test
public void testReadWriteXMP() throws IOException, TransformerException {
- ParserResult result = BibtexParser.parse(new StringReader(
+ ParserResult result = parser.parse(new StringReader(
"@article{canh05," + " author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.}," + "\n"
+ " title = {Effective work practices for floss development: A model and propositions}," + "\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n"
+ " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29},"
- + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}"),
- importFormatPreferences, fileMonitor);
+ + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}"));
Collection c = result.getDatabase().getEntries();
Assert.assertEquals(1, c.size());
@@ -724,13 +726,12 @@ public void testSimpleUpdate() throws Exception {
*/
@Test
public void testXMLEscape() throws Exception {
- ParserResult result = BibtexParser.parse(new StringReader(
+ ParserResult result = parser.parse(new StringReader(
"@article{canh05," + " author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.}," + "\n"
+ " title = { \" bla \" '' '' && & for floss development: A model and propositions},"
+ "\n" + " booktitle = {}," + "\n" + " year = {2005}," + "\n"
+ " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29}," + "\n"
- + " url = {http://james.howison.name/publications.html}" + "\n" + "}"),
- importFormatPreferences, fileMonitor);
+ + " url = {http://james.howison.name/publications.html}" + "\n" + "}"));
Collection c = result.getDatabase().getEntries();
Assert.assertEquals(1, c.size());
@@ -774,10 +775,9 @@ public void assertEqualsBibtexEntry(BibEntry expected, BibEntry actual) {
@Test
public void testXMPreadString() throws Exception {
- ParserResult result = BibtexParser
+ ParserResult result = parser
.parse(new StringReader("@article{canh05," + " author = {Crowston, K. and Annabi, H.},\n"
- + " title = {Title A}}\n" + "@inProceedings{foo," + " author={Norton Bar}}"),
- importFormatPreferences, fileMonitor);
+ + " title = {Title A}}\n" + "@inProceedings{foo," + " author={Norton Bar}}"));
Collection c = result.getDatabase().getEntries();
Assert.assertEquals(2, c.size());
@@ -1045,13 +1045,12 @@ public void testWriteSingleUpdatesDCAndInfo() throws IOException, TransformerExc
@Test
public void testReadRawXMP() throws IOException, TransformerException {
- ParserResult result = BibtexParser.parse(new StringReader(
+ ParserResult result = parser.parse(new StringReader(
"@article{canh05," + " author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.},\n"
+ " title = {Effective work practices for floss development: A model and propositions},\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)},\n"
+ " year = {2005},\n" + " owner = {oezbek},\n" + " timestamp = {2006.05.29},\n"
- + " url = {http://james.howison.name/publications.html}}"),
- importFormatPreferences, fileMonitor);
+ + " url = {http://james.howison.name/publications.html}}"));
Collection c = result.getDatabase().getEntries();
Assert.assertEquals(1, c.size());
@@ -1285,15 +1284,14 @@ public void testCommandLineSeveral() throws IOException, TransformerException {
*/
@Test
public void testResolveStrings() throws IOException, TransformerException {
- ParserResult original = BibtexParser
+ ParserResult original = parser
.parse(new StringReader("@string{ crow = \"Crowston, K.\"}\n" + "@string{ anna = \"Annabi, H.\"}\n"
+ "@string{ howi = \"Howison, J.\"}\n" + "@string{ masa = \"Masango, C.\"}\n"
+ "@article{canh05," + " author = {#crow# and #anna# and #howi# and #masa#}," + "\n"
+ " title = {Effective work practices for floss development: A model and propositions}," + "\n"
+ " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n"
+ " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29},"
- + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}"),
- importFormatPreferences, fileMonitor);
+ + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}"));
Collection c = original.getDatabase().getEntries();
Assert.assertEquals(1, c.size());
diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml
index c447f41c6cc..8c6a336420a 100644
--- a/src/test/resources/log4j2.xml
+++ b/src/test/resources/log4j2.xml
@@ -2,7 +2,7 @@
-
+