1
2
3
4 package org.sourceforge.xradar;
5
6 import org.junit.After;
7 import static org.junit.Assert.assertTrue;
8 import org.junit.Before;
9
10 import java.io.File;
11 import java.io.IOException;
12 import java.net.MalformedURLException;
13
14
15
16
17
18
19 public abstract class AbstractTestForCommandLine {
20
21 protected final String targetDirectory = "target";
22 protected String testProductsDirectory;
23 protected String target;
24
25
26 @Before
27 public void createResultDirectory() {
28 File targetDirectoryFile = new File(targetDirectory);
29 if ( ! targetDirectoryFile.exists() )
30 assertTrue(targetDirectoryFile.mkdir());
31 File targetFile = new File(target);
32 if ( ! targetFile.exists() )
33 assertTrue(targetFile.mkdir());
34
35 }
36
37 @After
38 public void deleteResultDirectory() {
39 File targetFile = new File(targetDirectory);
40 if ( targetFile.exists() )
41 targetFile.delete();
42 }
43
44
45
46
47
48
49
50
51
52
53
54
55 protected boolean runRadar(String arg[], String expectedMessage) throws MalformedURLException, IOException, XRadarException {
56
57 try {
58 XRadarExecute.main(arg);
59 } catch (IllegalArgumentException e) {
60
61
62 return e.getMessage().replace(File.separator, "/").equals(expectedMessage);
63 }
64 return true;
65 }
66 }