File tree Expand file tree Collapse file tree 3 files changed +31
-10
lines changed
main/java/pl/wavesoftware/utils/https/checker/logic
test/java/pl/wavesoftware/utils/https/checker Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Original file line number Diff line number Diff 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
1415It can check is your Java installation can perform connection with given HTTPS address
1516
@@ -18,8 +19,7 @@ positional arguments:
1819
1920optional 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```
Original file line number Diff line number Diff line change 2424import java .net .URLConnection ;
2525import java .util .List ;
2626import java .util .Map ;
27+ import javax .net .ssl .SSLException ;
2728import pl .wavesoftware .utils .https .checker .cli .Application ;
2829import pl .wavesoftware .utils .https .checker .cli .Cli .Arguments ;
2930import 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 );
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments