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
7
7
## Debian/Ubuntu
8
8
9
9
``` 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
13
14
14
15
It can check is your Java installation can perform connection with given HTTPS address
15
16
@@ -18,8 +19,7 @@ positional arguments:
18
19
19
20
optional arguments:
20
21
-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)
23
23
-r MAX_REDIRECTS, --max_redirects MAX_REDIRECTS
24
24
Number of redirects to perform at maximum (default: 10)
25
25
```
Original file line number Diff line number Diff line change 24
24
import java .net .URLConnection ;
25
25
import java .util .List ;
26
26
import java .util .Map ;
27
+ import javax .net .ssl .SSLException ;
27
28
import pl .wavesoftware .utils .https .checker .cli .Application ;
28
29
import pl .wavesoftware .utils .https .checker .cli .Cli .Arguments ;
29
30
import pl .wavesoftware .utils .https .checker .cli .Cli .Retcodes ;
@@ -53,14 +54,14 @@ public Result perform(ProcessIO pio) {
53
54
io .out ("Response OK?: " + response .isSuccessful ());
54
55
io .out ("------" );
55
56
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
+
61
59
} catch (MalformedURLException ex ) {
62
60
io .exception (ex );
63
61
result = Result .result (Retcodes .INVALID_ARGS );
62
+ } catch (SSLException ex ) {
63
+ io .exception (ex );
64
+ result = Result .result (Retcodes .BAD_SSL );
64
65
} catch (IOException ex ) {
65
66
io .exception (ex );
66
67
result = Result .result (Retcodes .NO_CONNECTION );
Original file line number Diff line number Diff line change @@ -49,6 +49,26 @@ public void testDoMain() {
49
49
result = HttpsCheckerMain .doMain (args );
50
50
assertNotNull (args );
51
51
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 ());
52
72
}
53
73
54
74
}
You can’t perform that action at this time.
0 commit comments