Skip to content

Commit 1d2bbb7

Browse files
committed
Reworked example test due to new behaviour
1 parent 88e757e commit 1d2bbb7

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

examples/src/test/java/org/neo4j/docs/driver/ExamplesIT.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@
2121
import org.junit.Rule;
2222
import org.junit.Test;
2323
import org.junit.rules.ExpectedException;
24-
2524
import org.neo4j.driver.v1.Driver;
2625
import org.neo4j.driver.v1.GraphDatabase;
2726
import org.neo4j.driver.v1.Session;
27+
import org.neo4j.driver.v1.exceptions.ClientException;
2828
import org.neo4j.driver.v1.util.StdIOCapture;
2929
import org.neo4j.driver.v1.util.TestNeo4j;
3030

31-
import static java.util.Arrays.asList;
31+
import java.io.FileNotFoundException;
3232

33+
import static java.util.Arrays.asList;
3334
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.*;
3736
import static org.junit.Assert.assertNotNull;
3837
import static org.junit.Assert.assertThat;
3938

@@ -288,11 +287,22 @@ public void trustOnFirstUse() throws Throwable
288287
@Test
289288
public void trustSignedCertificates() throws Throwable
290289
{
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+
}
296306
}
297307

298308
@Test

0 commit comments

Comments
 (0)