| 1 |
/* |
| 2 |
* Created on Oct 12, 2011 |
| 3 |
* Copyright 2010 by Eduard Weissmann ([email protected]). |
| 4 |
* |
| 5 |
* This file is part of the Sejda source code |
| 6 |
* |
| 7 |
* This program is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Affero General Public License as |
| 9 |
* published by the Free Software Foundation, either version 3 of the |
| 10 |
* License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Affero General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Affero General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
package org.sejda.conversion; |
| 21 |
|
| 22 |
import static org.apache.commons.io.FilenameUtils.separatorsToSystem; |
| 23 |
import static org.hamcrest.CoreMatchers.hasItem; |
| 24 |
import static org.hamcrest.MatcherAssert.assertThat; |
| 25 |
|
| 26 |
import java.io.File; |
| 27 |
import java.util.List; |
| 28 |
|
| 29 |
import org.junit.Test; |
| 30 |
import org.sejda.conversion.exception.ConversionException; |
| 31 |
|
| 32 |
/** |
| 33 |
* Tests for {@link XmlFileSourceListParser} |
| 34 |
* |
| 35 |
* @author Eduard Weissmann |
| 36 |
* |
| 37 |
*/ |
| 38 |
public class XmlFileSourceListParserTest extends BaseFileSourceListParserTest { |
| 39 |
|
| 40 |
private final XmlFileSourceListParser victim = new XmlFileSourceListParser(); |
| 41 |
|
| 42 |
@Test |
| 43 |
public void parseFileNames() { |
| 44 |
List<String> result = victim.parseFileNames(xmlFile); |
| 45 |
assertThat(result, hasItem("/tmp/pdf/inputFile.pdf")); |
| 46 |
assertThat(result, hasItem("/tmp/pdf/inputFile2.pdf:test")); |
| 47 |
assertThat(result, hasItem(new File(xmlFile.getParent(), "inputFile1.pdf").getAbsolutePath())); |
| 48 |
assertThat(result, hasItem(new File(xmlFile.getParent(), "inputFile2.pdf").getAbsolutePath())); |
| 49 |
assertThat(result, hasItem(separatorsToSystem("/tmp/subdir/inputFile1.pdf"))); |
| 50 |
assertThat(result, hasItem(separatorsToSystem("/tmp/subdir3/inputFile2.pdf"))); // its defined in absolute path mode in the file |
| 51 |
assertThat(result, hasItem(separatorsToSystem("/tmp/subdir2/inputFile1.pdf"))); |
| 52 |
assertThat(result, hasItem(separatorsToSystem("/tmp/subdir2/inputFile2.pdf:secret2"))); |
| 53 |
assertThat(result, hasItem(separatorsToSystem("/tmp/subdir2/inputFile3.pdf"))); |
| 54 |
} |
| 55 |
|
| 56 |
@Test(expected = ConversionException.class) |
| 57 |
public void testNegative() { |
| 58 |
victim.parseFileNames(emptyFile); |
| 59 |
} |
| 60 |
} |