Debian Codegraph @

test/func/ArgsTest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2008 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: 11-Jan-2009
16 */
17 package func;
18
19 import java.io.FileNotFoundException;
20
21 import uk.me.parabola.imgfmt.app.trergn.TREFileReader;
22 import uk.me.parabola.imgfmt.app.trergn.TREHeader;
23 import uk.me.parabola.imgfmt.fs.FileSystem;
24 import uk.me.parabola.imgfmt.fs.ImgChannel;
25
26 import func.lib.Args;
27 import func.lib.Outputs;
28 import func.lib.TestUtils;
29 import org.junit.Test;
30
31 import static org.junit.Assert.*;
32
33 /**
34 * A basic check of various arguments that can be passed in.
35 *
36 * @author Steve Ratcliffe
37 */
38 public class ArgsTest extends Base {
39 @Test
40 public void testHelp() {
41 Outputs outputs = TestUtils.runAsProcess("--help");
42 outputs.checkOutput("--help=options", "--help=links");
43 outputs.checkNoError();
44 checkNoStdFile();
45 }
46
47 @Test
48 public void testHelpOptions() {
49 Outputs outputs = TestUtils.runAsProcess("--help=options");
50 outputs.checkNoError();
51 outputs.checkOutput("--mapname=name", "--latin1", "--list-styles");
52 checkNoStdFile();
53 }
54
55 @Test
56 public void testHelpUnknown() {
57 Outputs outputs = TestUtils.runAsProcess("--help=unknown-help-option");
58 outputs.checkNoError();
59 outputs.checkOutput("Could not find", "unknown-help-option");
60 checkNoStdFile();
61 }
62
63 @Test
64 public void testListStyles() {
65 Outputs op = TestUtils.runAsProcess("--style-file=test/resources/teststyles", "--list-styles");
66 op.checkNoError();
67 op.checkOutput("empty", "main", "simple", "derived", "2.2: A simple test style");
68 checkNoStdFile();
69 }
70
71 @Test
72 public void testListStylesVerbose() {
73 Outputs op = TestUtils.runAsProcess("--style-file=test/resources/teststyles",
74 "--verbose", "--list-styles");
75 op.checkNoError();
76 op.checkOutput("empty", "main", "simple", "derived",
77 "2.2: A simple test style", "Used for many functional tests");
78 checkNoStdFile();
79 }
80
81 @Test
82 public void testDisplayPriority() throws FileNotFoundException {
83 TestUtils.registerFile("osmmap.img");
84
85 int pri = 42;
86 Outputs op = TestUtils.runAsProcess("--draw-priority=" + pri,
87 Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz");
88 op.checkError("Number of ExitExceptions: 0");
89
90 FileSystem fs = openFs(Args.DEF_MAP_FILENAME);
91 ImgChannel chan = fs.open(Args.DEF_MAP_ID + ".TRE", "r");
92 TREFileReader treFile = new TREFileReader(chan);
93
94 assertEquals("display priority", pri, ((TREHeader) treFile.getHeader()).getDisplayPriority());
95 }
96
97 @Test
98 public void testNoDescription() {
99 Outputs op = TestUtils.runAsProcess("--description", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz");
100 op.checkError("Number of ExitExceptions: 0");
101 }
102 }