|
21 | 21 | import org.junit.Rule; |
22 | 22 | import org.junit.Test; |
23 | 23 | import org.junit.rules.ExpectedException; |
24 | | - |
25 | 24 | import org.neo4j.driver.v1.Driver; |
26 | 25 | import org.neo4j.driver.v1.GraphDatabase; |
27 | 26 | import org.neo4j.driver.v1.Session; |
| 27 | +import org.neo4j.driver.v1.exceptions.ClientException; |
28 | 28 | import org.neo4j.driver.v1.util.StdIOCapture; |
29 | 29 | import org.neo4j.driver.v1.util.TestNeo4j; |
30 | 30 |
|
31 | | -import static java.util.Arrays.asList; |
| 31 | +import java.io.FileNotFoundException; |
32 | 32 |
|
| 33 | +import static java.util.Arrays.asList; |
33 | 34 | import static junit.framework.TestCase.assertEquals; |
34 | | -import static org.hamcrest.Matchers.contains; |
35 | | -import static org.hamcrest.Matchers.containsString; |
36 | | -import static org.hamcrest.Matchers.equalTo; |
| 35 | +import static org.hamcrest.Matchers.*; |
37 | 36 | import static org.junit.Assert.assertNotNull; |
38 | 37 | import static org.junit.Assert.assertThat; |
39 | 38 |
|
@@ -288,11 +287,22 @@ public void trustOnFirstUse() throws Throwable |
288 | 287 | @Test |
289 | 288 | public void trustSignedCertificates() throws Throwable |
290 | 289 | { |
291 | | - Driver driver = Examples.trustSignedCertificates(); |
292 | | - |
293 | | - // Then |
294 | | - assertNotNull( driver ); |
295 | | - driver.close(); |
| 290 | + try |
| 291 | + { |
| 292 | + Driver driver = Examples.trustSignedCertificates(); |
| 293 | + } |
| 294 | + catch ( ClientException ex ) |
| 295 | + { |
| 296 | + // This will ultimately fail as it can't find "/path/to/ca-certificate.pem" |
| 297 | + // We'll check for that error specifically and OK it, but die for everything |
| 298 | + // else. Previously, this was not evaluated on driver construction so never |
| 299 | + // occurred. |
| 300 | + // TODO: find a way to mock this properly |
| 301 | + assertThat( ex.getMessage(), equalTo( "Unable to establish SSL parameters" ) ); |
| 302 | + Throwable cause = ex.getCause(); |
| 303 | + assertThat( cause, instanceOf( FileNotFoundException.class ) ); |
| 304 | + assertThat( cause.getMessage(), equalTo( "/path/to/ca-certificate.pem (No such file or directory)" ) ); |
| 305 | + } |
296 | 306 | } |
297 | 307 |
|
298 | 308 | @Test |
|
0 commit comments