1 package net.trajano.commons.testing.test;
2
3 import java.net.URL;
4
5 import javax.net.ssl.SSLHandshakeException;
6
7 import net.trajano.commons.testing.DisableSslCertificateCheckUtil;
8
9 import org.junit.After;
10 import org.junit.Test;
11
12 public class DisableSslCertificateChecksIT {
13
14
15
16
17 @After
18 public void reenableCertificateChecks() {
19 DisableSslCertificateCheckUtil.reenableChecks();
20 }
21
22
23
24
25 @Test
26 public void testHttpsConnectionToGoogle() throws Exception {
27 DisableSslCertificateCheckUtil.disableChecks();
28 new URL("https://www.google.com/").getContent();
29 }
30
31
32
33
34
35
36
37 @Test
38 public void testInvalidCertificate() throws Exception {
39 DisableSslCertificateCheckUtil.disableChecks();
40 new URL("https://tv.eurosport.com/").openConnection().connect();
41 }
42
43
44
45
46
47
48
49 @Test(expected = SSLHandshakeException.class)
50 public void testInvalidCertificateFailure() throws Exception {
51 new URL("https://tv.eurosport.com/").openConnection().connect();
52 }
53 }