Skip to content

Commit

Permalink
Fixed compilation problems of some unit test using jdk 5 and 6
Browse files Browse the repository at this point in the history
  • Loading branch information
torakiki committed Feb 2, 2014
1 parent bdb9dc9 commit db48126
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sejda-console/src/test/java/org/sejda/cli/MergeTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.sejda.cli;

import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -34,6 +33,7 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.Matcher;
import org.hamcrest.core.CombinableMatcher;
import org.junit.Before;
import org.junit.Test;
import org.sejda.model.input.PdfFileSource;
Expand Down Expand Up @@ -164,7 +164,7 @@ private static List<Matcher<Iterable<? super File>>> filesList(String... filenam
for (String current : filenames) {
String filename = current.toString();
if (FilenameUtils.getPrefixLength(filename) > 0) {
result.add(either(hasItem(new File(filename))).or(
result.add(CombinableMatcher.<Iterable<? super File>> either(hasItem(new File(filename))).or(
hasItem(new File(FilenameUtils.separatorsToWindows("C:" + filename)))));
}
result.add(hasItem(new File(filename)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.sejda.conversion;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
Expand All @@ -27,6 +26,7 @@
import java.io.InputStream;

import org.apache.commons.io.FileUtils;
import org.hamcrest.core.CombinableMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -67,23 +67,26 @@ public void windowsFileWithPassword() {
PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf:secret123").getPdfFileSource();
assertThat(result.getPassword(), is("secret123"));
assertThat(result.getSource(),
either(is(new File("/tmp/inputFile1.pdf"))).or(is(new File("c:\\tmp\\inputFile1.pdf"))));
CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
is(new File("c:\\tmp\\inputFile1.pdf"))));
}

@Test
public void windowsFileNoPassword() {
PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf").getPdfFileSource();
assertNull(result.getPassword());
assertThat(result.getSource(),
either(is(new File("/tmp/inputFile1.pdf"))).or(is(new File("c:\\tmp\\inputFile1.pdf"))));
CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
is(new File("c:\\tmp\\inputFile1.pdf"))));
}

@Test
public void protectedFileWithPasswordContainingSeparator() {
PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf:secret.pdf:password").getPdfFileSource();
assertThat(result.getPassword(), is("secret.pdf:password"));
assertThat(result.getSource(),
either(is(new File("/tmp/inputFile1.pdf"))).or(is(new File("c:\\tmp\\inputFile1.pdf"))));
CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
is(new File("c:\\tmp\\inputFile1.pdf"))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package org.sejda.conversion;

import static org.hamcrest.CoreMatchers.either;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.apache.commons.io.FilenameUtils;
import org.hamcrest.core.CombinableMatcher;
import org.junit.Test;
import org.sejda.conversion.exception.ConversionException;

Expand All @@ -41,8 +41,13 @@ public void parseFileNames() {
List<String> result = victim.parseFileNames(xmlFile);
assertThat(result, hasItem("/tmp/pdf/inputFile.pdf"));
assertThat(result, hasItem("/tmp/pdf/inputFile2.pdf:test"));
assertThat(result, either(hasItem("/tmp/inputFile1.pdf")).or(hasItem("C:\\tmp\\inputFile1.pdf")));
assertThat(result, either(hasItem("/tmp/inputFile2.pdf")).or(hasItem("C:\\tmp\\inputFile2.pdf")));
assertThat(result,
org.hamcrest.core.CombinableMatcher.<Iterable<? super String>> either(hasItem("/tmp/inputFile1.pdf"))
.or(hasItem("C:\\tmp\\inputFile1.pdf")));
assertThat(
result,
CombinableMatcher.<Iterable<? super String>> either(hasItem("/tmp/inputFile2.pdf")).or(
hasItem("C:\\tmp\\inputFile2.pdf")));
assertThat(result, hasItem(FilenameUtils.separatorsToSystem("/tmp/subdir/inputFile1.pdf")));
assertThat(result, hasItem(FilenameUtils.separatorsToSystem("/tmp/subdir3/inputFile2.pdf"))); // its defined in absolute path mode in the file
assertThat(result, hasItem(FilenameUtils.separatorsToSystem("/tmp/subdir2/inputFile1.pdf")));
Expand Down

0 comments on commit db48126

Please sign in to comment.