23
23
import static org .junit .Assert .assertThat ;
24
24
import static org .junit .Assert .fail ;
25
25
26
+ import java .io .File ;
26
27
import java .io .IOException ;
27
28
import java .net .SocketTimeoutException ;
28
29
import java .net .URISyntaxException ;
29
30
import java .net .URL ;
30
- import java .nio .file .Paths ;
31
31
import java .security .KeyManagementException ;
32
32
import java .security .KeyStoreException ;
33
33
import java .security .NoSuchAlgorithmException ;
@@ -70,7 +70,7 @@ public void load_from_property_file() {
70
70
// validate file in classpath.
71
71
assertThat (getClass ().getResource ("/arangodb.properties" ), is (notNullValue ()));
72
72
73
- ArangoConfigure configure = new ArangoConfigure ();
73
+ final ArangoConfigure configure = new ArangoConfigure ();
74
74
assertThat (configure .getArangoHost ().getPort (), is (8529 ));
75
75
assertThat (configure .getArangoHost ().getHost (), is (notNullValue ()));
76
76
assertThat (configure .getDefaultDatabase (), is (nullValue ()));
@@ -80,13 +80,13 @@ public void load_from_property_file() {
80
80
@ Test
81
81
public void load_from_proerty_file2 () {
82
82
83
- ArangoConfigure configure = new ArangoConfigure ();
83
+ final ArangoConfigure configure = new ArangoConfigure ();
84
84
configure .loadProperties ("/arangodb-test.properties" );
85
85
86
86
assertThat (configure .getRetryCount (), is (10 ));
87
87
assertThat (configure .getDefaultDatabase (), is ("mydb2" ));
88
88
89
- ArangoHost arangoHost = configure .getArangoHost ();
89
+ final ArangoHost arangoHost = configure .getArangoHost ();
90
90
assertThat (arangoHost .getPort (), is (9999 ));
91
91
assertThat (arangoHost .getHost (), is (notNullValue ()));
92
92
@@ -96,17 +96,17 @@ public void load_from_proerty_file2() {
96
96
@ Test
97
97
public void connect_timeout () throws ArangoException {
98
98
99
- ArangoConfigure configure = new ArangoConfigure ();
99
+ final ArangoConfigure configure = new ArangoConfigure ();
100
100
configure .getArangoHost ().setHost ("1.0.0.200" );
101
101
configure .setConnectionTimeout (1 ); // 1ms
102
102
configure .init ();
103
103
104
- ArangoDriver driver = new ArangoDriver (configure );
104
+ final ArangoDriver driver = new ArangoDriver (configure );
105
105
106
106
try {
107
107
driver .getCollections ();
108
108
fail ("did no timeout" );
109
- } catch (ArangoException e ) {
109
+ } catch (final ArangoException e ) {
110
110
assertThat (e .getCause (), instanceOf (ConnectTimeoutException .class ));
111
111
}
112
112
@@ -118,17 +118,17 @@ public void connect_timeout() throws ArangoException {
118
118
@ Ignore (value = "this fails some times" )
119
119
public void so_connect_timeout () throws ArangoException {
120
120
121
- ArangoConfigure configure = new ArangoConfigure ();
121
+ final ArangoConfigure configure = new ArangoConfigure ();
122
122
configure .setConnectionTimeout (5000 );
123
123
configure .setTimeout (1 ); // 1ms
124
124
configure .init ();
125
125
126
- ArangoDriver driver = new ArangoDriver (configure );
126
+ final ArangoDriver driver = new ArangoDriver (configure );
127
127
128
128
try {
129
129
driver .getCollections ();
130
130
fail ("did no timeout" );
131
- } catch (ArangoException e ) {
131
+ } catch (final ArangoException e ) {
132
132
assertThat (e .getCause (), instanceOf (SocketTimeoutException .class ));
133
133
}
134
134
@@ -139,18 +139,18 @@ public void so_connect_timeout() throws ArangoException {
139
139
@ Test
140
140
public void reconnectFallbackArangoHost () throws ArangoException {
141
141
142
- ArangoConfigure configure = new ArangoConfigure ();
142
+ final ArangoConfigure configure = new ArangoConfigure ();
143
143
144
144
// copy default arango host to fallback
145
- ArangoHost arangoHost = configure .getArangoHost ();
146
- ArangoHost ah = new ArangoHost (arangoHost .getHost (), arangoHost .getPort ());
145
+ final ArangoHost arangoHost = configure .getArangoHost ();
146
+ final ArangoHost ah = new ArangoHost (arangoHost .getHost (), arangoHost .getPort ());
147
147
configure .addFallbackArangoHost (ah );
148
148
149
149
// change default port to wrong port
150
150
arangoHost .setPort (1025 );
151
151
configure .init ();
152
152
153
- ArangoDriver driver = new ArangoDriver (configure );
153
+ final ArangoDriver driver = new ArangoDriver (configure );
154
154
155
155
driver .getCollections ();
156
156
@@ -163,17 +163,17 @@ public void sslWithSelfSignedCertificateTest() throws ArangoException, KeyManage
163
163
NoSuchAlgorithmException , KeyStoreException , CertificateException , IOException , URISyntaxException {
164
164
165
165
// create a sslContext for the self signed certificate
166
- URL resource = this .getClass ().getResource (SSL_TRUSTSTORE );
167
- SSLContext sslContext = SSLContexts .custom ()
168
- .loadTrustMaterial (Paths . get (resource .toURI ()). toFile ( ), SSL_TRUSTSTORE_PASSWORD .toCharArray ()).build ();
166
+ final URL resource = this .getClass ().getResource (SSL_TRUSTSTORE );
167
+ final SSLContext sslContext = SSLContexts .custom ()
168
+ .loadTrustMaterial (new File (resource .toURI ()), SSL_TRUSTSTORE_PASSWORD .toCharArray ()).build ();
169
169
170
- ArangoConfigure configuration = new ArangoConfigure ("/ssl-arangodb.properties" );
170
+ final ArangoConfigure configuration = new ArangoConfigure ("/ssl-arangodb.properties" );
171
171
configuration .setSslContext (sslContext );
172
172
configuration .init ();
173
173
174
- ArangoDriver arangoDriver = new ArangoDriver (configuration );
174
+ final ArangoDriver arangoDriver = new ArangoDriver (configuration );
175
175
176
- ArangoVersion version = arangoDriver .getVersion ();
176
+ final ArangoVersion version = arangoDriver .getVersion ();
177
177
178
178
Assert .assertNotNull (version );
179
179
}
0 commit comments