Skip to content

Commit 2f689db

Browse files
committed
updated tika version
1 parent e47aa1c commit 2f689db

6 files changed

Lines changed: 41 additions & 10 deletions

File tree

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@
9292
<dependency>
9393
<groupId>org.apache.tika</groupId>
9494
<artifactId>tika-core</artifactId>
95-
<version>2.4.0</version>
95+
<version>2.6.0</version>
9696
</dependency>
9797

98+
9899
<!-- Testing dependencies -->
99100
<dependency>
100101
<groupId>org.junit.jupiter</groupId>

src/test/java/base/BaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public AccountApiClient getDefaultAccountApiClient() {
6767
}
6868

6969
public String getDefaultFilePath() {
70-
return testResourcesPath.toString() + "/test.pdf";
70+
return testResourcesPath.toString();
7171
}
7272

7373
private void initConfingFromFile() {

src/test/java/integration/MessageStreamsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void edit() throws PostmarkException, IOException {
6363

6464
@Test
6565
void archive() throws PostmarkException, IOException {
66-
String streamId = "bulk-test-stream-100";
66+
String streamId = "bulk-test-stream-120";
6767
MessageStreams messages = client.getMessageStreams(Parameters.init().build("messageStreamType", "all")
6868
.build("includeArchivedStreams", "true"));
6969

src/test/java/unit/data/MessageTest.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,36 +187,65 @@ void attachmentException() throws IOException {
187187
}
188188

189189
@Test
190-
void addAttachment() throws IOException {
190+
void addPdfAttachment() throws IOException {
191191
Message message = new Message("from@example.com","to@example.com","Hello world", "Hello world");
192-
message.addAttachment(getDefaultFilePath());
192+
message.addAttachment(getDefaultFilePath() + "/test.pdf" );
193193

194194
HashMap<String,String> attachment = (HashMap<String, String>) message.getAttachments().get(0);
195195
assertEquals(attachment.get("ContentType"), "application/pdf");
196-
assertEquals(attachment.get("Name"), new File(getDefaultFilePath()).getName());
196+
assertEquals(attachment.get("Name"), new File(getDefaultFilePath() + "/test.pdf").getName());
197+
assertNotNull(attachment.get("Content"));
198+
assertEquals(attachment.get("ContentId"), null);
199+
}
200+
201+
@Test
202+
void addImageAttachment() throws IOException {
203+
String file = getDefaultFilePath() + "/test.jpg";
204+
Message message = new Message("from@example.com","to@example.com","Hello world", "Hello world");
205+
message.addAttachment(file);
206+
207+
HashMap<String,String> attachment = (HashMap<String, String>) message.getAttachments().get(0);
208+
assertEquals(attachment.get("ContentType"), "image/jpeg");
209+
assertEquals(attachment.get("Name"), new File(file).getName());
210+
assertNotNull(attachment.get("Content"));
211+
assertEquals(attachment.get("ContentId"), null);
212+
}
213+
214+
@Test
215+
void addTextAttachment() throws IOException {
216+
String file = getDefaultFilePath() + "/test.txt";
217+
Message message = new Message("from@example.com","to@example.com","Hello world", "Hello world");
218+
message.addAttachment(file);
219+
220+
HashMap<String,String> attachment = (HashMap<String, String>) message.getAttachments().get(0);
221+
assertEquals(attachment.get("ContentType"), "text/plain");
222+
assertEquals(attachment.get("Name"), new File(file).getName());
197223
assertNotNull(attachment.get("Content"));
198224
assertEquals(attachment.get("ContentId"), null);
199225
}
200226

201227
@Test
202228
void addAttachmentWithContentId() throws IOException {
203229
String contentId = "test-id";
230+
String file = getDefaultFilePath() + "/test.pdf";
204231
Message message = new Message("from@example.com","to@example.com","Hello world", "Hello world");
205-
message.addAttachment(getDefaultFilePath(), contentId);
232+
message.addAttachment(file, contentId);
206233

207234
HashMap<String,String> attachment = (HashMap<String, String>) message.getAttachments().get(0);
208235
assertEquals(attachment.get("ContentType"), "application/pdf");
209-
assertEquals(attachment.get("Name"), new File(getDefaultFilePath()).getName());
236+
assertEquals(attachment.get("Name"), new File(file).getName());
210237
assertNotNull(attachment.get("Content"));
211238
assertEquals(attachment.get("ContentId"), contentId);
212239
}
213240

214241
@Test
215242
void addMultipleAttachments() throws IOException {
216243
String contentId = "test-id";
244+
String file1 = getDefaultFilePath() + "/test.pdf";
245+
String file2 = getDefaultFilePath() + "/test.jpg";
217246
Message message = new Message("from@example.com","to@example.com","Hello world", "Hello world");
218-
message.addAttachment(getDefaultFilePath(), contentId);
219-
message.addAttachment(getDefaultFilePath());
247+
message.addAttachment(file1, contentId);
248+
message.addAttachment(file2);
220249
assertEquals(message.getAttachments().size(), 2);
221250
assertEquals(message.getAttachments().get(0).get("ContentId"), contentId);
222251
assertEquals(message.getAttachments().get(1).get("ContentId"), null);

src/test/resources/test.jpg

34.6 KB
Loading

src/test/resources/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

0 commit comments

Comments
 (0)