Skip to content

Commit 92291b0

Browse files
committed
Coverage and readme updates
1 parent e87db50 commit 92291b0

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ HTTP/S Java Checker - It can check is your Java installation can perform connect
77
## Debian/Ubuntu
88

99
```bash
10-
dpkg -i jhttps-checker_0.8.0.deb
11-
jhttps-checker --help
12-
usage: jhttps-checker [-h] [-q QUIET] [-r MAX_REDIRECTS] address
10+
$ wget -O jhttps-checker_0.8.0.deb http://search.maven.org/remotecontent?filepath=pl/wavesoftware/jhttps-checker/0.8.0/jhttps-checker-0.8.0.deb
11+
$ sudo dpkg -i jhttps-checker-0.8.0.deb
12+
$ jhttps-checker --help
13+
usage: jhttps-checker [-h] [-q] [-r MAX_REDIRECTS] address
1314

1415
It can check is your Java installation can perform connection with given HTTPS address
1516

@@ -18,8 +19,7 @@ positional arguments:
1819

1920
optional arguments:
2021
-h, --help show this help message and exit
21-
-q QUIET, --quiet QUIET
22-
Do not display anything, only retcodes (default: false)
22+
-q, --quiet Do not display anything, only retcodes (default: false)
2323
-r MAX_REDIRECTS, --max_redirects MAX_REDIRECTS
2424
Number of redirects to perform at maximum (default: 10)
2525
```

src/main/java/pl/wavesoftware/utils/https/checker/logic/MainApplication.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.net.URLConnection;
2525
import java.util.List;
2626
import java.util.Map;
27+
import javax.net.ssl.SSLException;
2728
import pl.wavesoftware.utils.https.checker.cli.Application;
2829
import pl.wavesoftware.utils.https.checker.cli.Cli.Arguments;
2930
import pl.wavesoftware.utils.https.checker.cli.Cli.Retcodes;
@@ -53,14 +54,14 @@ public Result perform(ProcessIO pio) {
5354
io.out("Response OK?: " + response.isSuccessful());
5455
io.out("------");
5556
printHeaders(io, response);
56-
if (response.isSuccessful()) {
57-
result = Result.result(Retcodes.OK);
58-
} else {
59-
result = Result.result(Retcodes.BAD_SSL);
60-
}
57+
result = Result.result(Retcodes.OK);
58+
6159
} catch (MalformedURLException ex) {
6260
io.exception(ex);
6361
result = Result.result(Retcodes.INVALID_ARGS);
62+
} catch (SSLException ex) {
63+
io.exception(ex);
64+
result = Result.result(Retcodes.BAD_SSL);
6465
} catch (IOException ex) {
6566
io.exception(ex);
6667
result = Result.result(Retcodes.NO_CONNECTION);

src/test/java/pl/wavesoftware/utils/https/checker/HttpsCheckerMainTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ public void testDoMain() {
4949
result = HttpsCheckerMain.doMain(args);
5050
assertNotNull(args);
5151
assertEquals(Result.result(Cli.Retcodes.INVALID_ARGS).retcode(), result.retcode());
52+
53+
args = new String[]{"httttp://invalid.addres.com/quoa"};
54+
result = HttpsCheckerMain.doMain(args);
55+
assertNotNull(args);
56+
assertEquals(Result.result(Cli.Retcodes.INVALID_ARGS).retcode(), result.retcode());
57+
58+
args = new String[]{"https://invalid.addres.org/quoa"};
59+
result = HttpsCheckerMain.doMain(args);
60+
assertNotNull(args);
61+
assertEquals(Result.result(Cli.Retcodes.NO_CONNECTION).retcode(), result.retcode());
62+
63+
args = new String[]{"https://www.google.pl/no-a-file-to-download.txt"};
64+
result = HttpsCheckerMain.doMain(args);
65+
assertNotNull(args);
66+
assertEquals(Result.result(Cli.Retcodes.NO_CONNECTION).retcode(), result.retcode());
67+
68+
args = new String[]{"https://tv.eurosport.com/"};
69+
result = HttpsCheckerMain.doMain(args);
70+
assertNotNull(args);
71+
assertEquals(Result.result(Cli.Retcodes.BAD_SSL).retcode(), result.retcode());
5272
}
5373

5474
}

0 commit comments

Comments
 (0)