01: package liquibase.commandline;
02:
03: import liquibase.FileOpener;
04: import liquibase.AbstractFileOpenerTest;
05: import static org.junit.Assert.*;
06: import org.junit.Test;
07:
08: import java.io.IOException;
09: import java.io.InputStream;
10: import java.net.URL;
11: import java.util.Enumeration;
12:
13: /**
14: * Tests for {@link CommandLineFileOpener}
15: */
16: public class CommandLineFileOpenerTest extends AbstractFileOpenerTest {
17:
18: /**
19: * @see liquibase.AbstractFileOpenerTest#createFileOpener()
20: */
21: @Override
22: protected FileOpener createFileOpener() {
23: return new CommandLineFileOpener(Thread.currentThread()
24: .getContextClassLoader());
25: }
26:
27: @Test
28: public void getResourceAsStream() throws Exception {
29: InputStream inputStream = fileOpener
30: .getResourceAsStream("liquibase/ant/AntFileOpenerTest.class");
31: assertNotNull(inputStream);
32: }
33:
34: @Test(expected=IOException.class)
35: public void getResourceAsStreamNonExistantFile() throws Exception {
36: fileOpener.getResourceAsStream("non/existant/file.txt");
37: }
38:
39: @Test
40: public void getResources() throws Exception {
41: Enumeration<URL> resources = fileOpener
42: .getResources("liquibase/ant");
43: assertNotNull(resources);
44: }
45: }
|