diff --git a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java index 2242a73f4e6..b3c70b8f1ee 100644 --- a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java +++ b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java @@ -61,6 +61,44 @@ public void testSerialization() throws IOException { assertEquals(expected, actual); } + @Test + public void writeOtherTypeTest() throws Exception { + String expected = OS.NEWLINE + "@Other{test," + OS.NEWLINE + + " comment = {testentry}," + OS.NEWLINE + + "}"+ OS.NEWLINE; + + BibEntry entry = new BibEntry(); + entry.setType("other"); + entry.setField("Comment","testentry"); + entry.setCiteKey("test"); + + //write out bibtex string + StringWriter stringWriter = new StringWriter(); + writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX); + String actual = stringWriter.toString(); + + assertEquals(expected, actual); + } + + @Test + public void writeReallyunknownTypeTest() throws Exception { + String expected = OS.NEWLINE + "@Reallyunknowntype{test," + OS.NEWLINE + + " comment = {testentry}," + OS.NEWLINE + + "}"+ OS.NEWLINE; + + BibEntry entry = new BibEntry(); + entry.setType("ReallyUnknownType"); + entry.setField("Comment","testentry"); + entry.setCiteKey("test"); + + //write out bibtex string + StringWriter stringWriter = new StringWriter(); + writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX); + String actual = stringWriter.toString(); + + assertEquals(expected, actual); + } + @Test public void roundTripTest() throws IOException { // @formatter:off diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java index 66f705bf96f..62412dabe10 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -234,6 +234,38 @@ public void parseRecognizesEntryWithUnknownType() throws IOException { assertEquals(Optional.of("Ed von Test"), e.getField("author")); } + @Test + public void parseReallyUnknownType() throws Exception { + String bibtexEntry = "@ReallyUnknownType{test," + OS.NEWLINE + + " Comment = {testentry}" + OS.NEWLINE + + "}"; + + Collection entries = new BibtexParser(importFormatPreferences).parseEntries(bibtexEntry); + + BibEntry expectedEntry = new BibEntry(); + expectedEntry.setType("Reallyunknowntype"); + expectedEntry.setCiteKey("test"); + expectedEntry.setField("comment", "testentry"); + + assertEquals(Collections.singletonList(expectedEntry), entries); + } + + @Test + public void parseOtherTypeTest() throws Exception { + String bibtexEntry = "@Other{test," + OS.NEWLINE + + " Comment = {testentry}" + OS.NEWLINE + + "}"; + + Collection entries = new BibtexParser(importFormatPreferences).parseEntries(bibtexEntry); + + BibEntry expectedEntry = new BibEntry(); + expectedEntry.setType("Other"); + expectedEntry.setCiteKey("test"); + expectedEntry.setField("comment", "testentry"); + + assertEquals(Collections.singletonList(expectedEntry), entries); + } + @Test public void parseRecognizesEntryWithVeryLongType() throws IOException {