Skip to content

Commit b0acfdf

Browse files
author
a-brandt
committed
updates for ArangoDB 3.0.0
1 parent 5b6d9a6 commit b0acfdf

File tree

7 files changed

+24
-263
lines changed

7 files changed

+24
-263
lines changed

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,48 +3087,6 @@ public <T> ScalarExampleEntity<T> executeSimpleAny(String collectionName, Class<
30873087
return simpleDriver.executeSimpleAny(getDefaultDatabase(), collectionName, clazz);
30883088
}
30893089

3090-
/**
3091-
* This will find all documents within a given range. In order to execute a
3092-
* range query, a skip-list index on the queried attribute must be present.
3093-
*
3094-
* @param collectionName
3095-
* The collection name.
3096-
* @param attribute
3097-
* The attribute path to check.
3098-
* @param left
3099-
* The lower bound
3100-
* @param right
3101-
* The upper bound
3102-
* @param closed
3103-
* If true, use interval including left and right, otherwise
3104-
* exclude right, but include left.
3105-
* @param skip
3106-
* The number of documents to skip in the query.
3107-
* @param limit
3108-
* The maximal amount of documents to return. The skip is applied
3109-
* before the limit restriction.
3110-
* @param clazz
3111-
* the expected class, the result from the server request is
3112-
* deserialized to an instance of this class.
3113-
* @return a CursorEntity object
3114-
* @throws ArangoException
3115-
* @deprecated As of release 2.5.4, replaced by
3116-
* {@link #executeSimpleRangeWithDocuments(String, String, Object, Object, Boolean, int, int, Class)}
3117-
*/
3118-
@Deprecated
3119-
public <T> CursorEntity<T> executeSimpleRange(
3120-
String collectionName,
3121-
String attribute,
3122-
Object left,
3123-
Object right,
3124-
Boolean closed,
3125-
int skip,
3126-
int limit,
3127-
Class<T> clazz) throws ArangoException {
3128-
return simpleDriver.executeSimpleRange(getDefaultDatabase(), collectionName, attribute, left, right, closed,
3129-
skip, limit, clazz);
3130-
}
3131-
31323090
/**
31333091
* This will find all documents within a given range. In order to execute a
31343092
* range query, a skip-list index on the queried attribute must be present.

src/main/java/com/arangodb/entity/EntityDeserializers.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -749,15 +749,13 @@ public DocumentEntity<?> deserialize(JsonElement json, Type typeOfT, JsonDeseria
749749
Class<?> clazz = getParameterized();
750750
if (clazz != null) {
751751
entity.entity = context.deserialize(obj, clazz);
752-
// if
753-
// (clazz.getName().equalsIgnoreCase(BaseDocument.class.getName()))
754-
// {
755-
// // iterate all key/value pairs of the jsonObject and
756-
// // determine its class(String, Number, Boolean, HashMap,
757-
// // List)
758-
// ((BaseDocument)
759-
// entity.entity).setProperties(DeserializeSingleEntry.deserializeJsonObject(obj));
760-
// }
752+
753+
if (clazz.getName().equalsIgnoreCase(BaseDocument.class.getName())) {
754+
// iterate all key/value pairs of the jsonObject and
755+
// determine its class(String, Number, Boolean, HashMap,
756+
// List)
757+
((BaseDocument) entity.entity).setProperties(DeserializeSingleEntry.deserializeJsonObject(obj));
758+
}
761759
}
762760

763761
return entity;

src/main/java/com/arangodb/http/HttpManager.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import org.apache.http.config.Registry;
5353
import org.apache.http.config.RegistryBuilder;
5454
import org.apache.http.conn.ConnectionKeepAliveStrategy;
55-
import org.apache.http.conn.HttpClientConnectionManager;
5655
import org.apache.http.conn.socket.ConnectionSocketFactory;
5756
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
5857
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
@@ -62,8 +61,8 @@
6261
import org.apache.http.impl.client.CloseableHttpClient;
6362
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
6463
import org.apache.http.impl.client.HttpClientBuilder;
65-
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
6664
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
65+
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
6766
import org.apache.http.message.BasicHeaderElementIterator;
6867
import org.apache.http.message.BasicNameValuePair;
6968
import org.apache.http.protocol.HTTP;
@@ -88,7 +87,7 @@ public class HttpManager {
8887

8988
private static Logger logger = LoggerFactory.getLogger(HttpManager.class);
9089

91-
private HttpClientConnectionManager cm;
90+
private PoolingHttpClientConnectionManager cm;
9291
private CloseableHttpClient client;
9392

9493
private ArangoConfigure configure;
@@ -125,10 +124,9 @@ public void init() {
125124
.register("http", plainsf).register("https", sslsf).build();
126125

127126
// ConnectionManager
128-
// cm = new PoolingHttpClientConnectionManager(r);
129-
cm = new BasicHttpClientConnectionManager(r);
130-
// cm.setDefaultMaxPerRoute(configure.getMaxPerConnection());
131-
// cm.setMaxTotal(configure.getMaxTotalConnection());
127+
cm = new PoolingHttpClientConnectionManager(r);
128+
cm.setDefaultMaxPerRoute(configure.getMaxPerConnection());
129+
cm.setMaxTotal(configure.getMaxTotalConnection());
132130

133131
Builder custom = RequestConfig.custom();
134132

src/test/java/com/arangodb/ArangoDriverDocumentTest.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,7 @@ public void test_getDocuments() throws ArangoException {
401401
List<String> documents = driver.getDocuments(collectionName);
402402
assertEquals(3, documents.size());
403403

404-
String prefix;
405-
if (documents.get(0).startsWith("/_db/")) {
406-
// since ArangoDB 2.6
407-
prefix = "/_db/" + DATABASE_NAME + "/_api/document/";
408-
} else {
409-
prefix = "/_api/document/";
410-
}
411-
412-
List<String> list = Arrays.asList(prefix + doc1.getDocumentHandle(), prefix + doc2.getDocumentHandle(),
413-
prefix + doc3.getDocumentHandle());
404+
List<String> list = Arrays.asList(doc1.getDocumentHandle(), doc2.getDocumentHandle(), doc3.getDocumentHandle());
414405

415406
assertTrue(documents.containsAll(list));
416407
}

src/test/java/com/arangodb/ArangoDriverSimpleTest.java

Lines changed: 0 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public void setup() throws ArangoException {
7171
driver.createCollection(COLLECTION_NAME);
7272
} catch (ArangoException e) {
7373
}
74-
driver.truncateCollection(COLLECTION_NAME);
7574

7675
// add some test data
7776
for (int i = 0; i < 100; i++) {
@@ -105,52 +104,6 @@ public void test_simple_all() throws ArangoException {
105104
assertThat(count, is(100));
106105
}
107106

108-
@SuppressWarnings("deprecation")
109-
@Test
110-
public void test_simple_all_deprecated() throws ArangoException {
111-
112-
CursorResultSet<TestComplexEntity01> rs = driver.executeSimpleAllWithResultSet(COLLECTION_NAME, 0, 0,
113-
TestComplexEntity01.class);
114-
int count = 0;
115-
while (rs.hasNext()) {
116-
TestComplexEntity01 entity = rs.next();
117-
count++;
118-
119-
assertThat(entity, is(notNullValue()));
120-
}
121-
rs.close();
122-
123-
assertThat(count, is(100));
124-
}
125-
126-
@SuppressWarnings("deprecation")
127-
@Test
128-
public void test_simple_all_with_doc_deprecated() throws ArangoException {
129-
130-
CursorResultSet<DocumentEntity<TestComplexEntity01>> rs = driver
131-
.executeSimpleAllWithDocumentResultSet(COLLECTION_NAME, 0, 0, TestComplexEntity01.class);
132-
int count = 0;
133-
int ageCount = 0;
134-
while (rs.hasNext()) {
135-
DocumentEntity<TestComplexEntity01> doc = rs.next();
136-
count++;
137-
138-
assertThat(doc, is(notNullValue()));
139-
assertThat(doc.getDocumentHandle(), startsWith(COLLECTION_NAME));
140-
assertThat(doc.getDocumentKey(), is(notNullValue()));
141-
assertThat(doc.getDocumentRevision(), is(not(0L)));
142-
143-
if (doc.getEntity().getAge() != 0) {
144-
ageCount++;
145-
}
146-
}
147-
rs.close();
148-
149-
assertThat(count, is(100));
150-
assertThat(ageCount, is(99));
151-
152-
}
153-
154107
@Test
155108
public void test_example_by() throws ArangoException {
156109

@@ -168,48 +121,6 @@ public void test_example_by() throws ArangoException {
168121
assertThat(count, is(10));
169122
}
170123

171-
@SuppressWarnings("deprecation")
172-
@Test
173-
public void test_example_by_deprecated() throws ArangoException {
174-
175-
CursorResultSet<TestComplexEntity01> rs = driver.executeSimpleByExampleWithResusltSet(COLLECTION_NAME,
176-
new MapBuilder().put("user", "user_6").get(), 0, 0, TestComplexEntity01.class);
177-
int count = 0;
178-
while (rs.hasNext()) {
179-
TestComplexEntity01 entity = rs.next();
180-
count++;
181-
182-
assertThat(entity.getUser(), is("user_6"));
183-
}
184-
rs.close();
185-
186-
assertThat(count, is(10));
187-
188-
}
189-
190-
@SuppressWarnings("deprecation")
191-
@Test
192-
public void test_example_by_with_doc_deprecated() throws ArangoException {
193-
194-
CursorResultSet<DocumentEntity<TestComplexEntity01>> rs = driver.executeSimpleByExampleWithDocumentResusltSet(
195-
COLLECTION_NAME, new MapBuilder().put("user", "user_6").get(), 0, 0, TestComplexEntity01.class);
196-
int count = 0;
197-
while (rs.hasNext()) {
198-
DocumentEntity<TestComplexEntity01> doc = rs.next();
199-
count++;
200-
201-
assertThat(doc.getDocumentHandle(), startsWith(COLLECTION_NAME));
202-
assertThat(doc.getDocumentKey(), is(notNullValue()));
203-
assertThat(doc.getDocumentRevision(), is(not(0L)));
204-
205-
assertThat(doc.getEntity().getUser(), is("user_6"));
206-
}
207-
rs.close();
208-
209-
assertThat(count, is(10));
210-
211-
}
212-
213124
@Test
214125
public void test_first_example() throws ArangoException {
215126

@@ -263,22 +174,6 @@ public void test_range_no_skiplist() throws ArangoException {
263174

264175
}
265176

266-
@SuppressWarnings("deprecation")
267-
@Test
268-
public void test_range_no_skiplist_deprecated() throws ArangoException {
269-
270-
// no suitable index known
271-
try {
272-
driver.executeSimpleRangeWithResultSet(COLLECTION_NAME, "age", 5, 30, null, 0, 0,
273-
TestComplexEntity01.class);
274-
fail("request should fail");
275-
} catch (ArangoException e) {
276-
assertThat(e.getErrorNumber(), is(1209));
277-
assertThat(e.getCode(), is(404));
278-
}
279-
280-
}
281-
282177
@Test
283178
public void test_range() throws ArangoException {
284179

@@ -317,90 +212,6 @@ public void test_range() throws ArangoException {
317212

318213
}
319214

320-
@SuppressWarnings("deprecation")
321-
@Test
322-
public void test_range_deprecated() throws ArangoException {
323-
324-
// create skip-list
325-
driver.createIndex(COLLECTION_NAME, IndexType.SKIPLIST, false, "age");
326-
327-
{
328-
CursorResultSet<TestComplexEntity01> rs = driver.executeSimpleRangeWithResultSet(COLLECTION_NAME, "age", 5,
329-
30, null, 0, 0, TestComplexEntity01.class);
330-
331-
int count = 0;
332-
while (rs.hasNext()) {
333-
TestComplexEntity01 entity = rs.next();
334-
count++;
335-
assertThat(entity, is(notNullValue()));
336-
}
337-
rs.close();
338-
assertThat(count, is(25));
339-
}
340-
341-
{
342-
CursorResultSet<TestComplexEntity01> rs = driver.executeSimpleRangeWithResultSet(COLLECTION_NAME, "age", 5,
343-
30, true, 0, 0, TestComplexEntity01.class);
344-
345-
int count = 0;
346-
while (rs.hasNext()) {
347-
TestComplexEntity01 entity = rs.next();
348-
count++;
349-
assertThat(entity, is(notNullValue()));
350-
}
351-
rs.close();
352-
assertThat(count, is(26));
353-
}
354-
355-
}
356-
357-
@SuppressWarnings("deprecation")
358-
@Test
359-
public void test_range_with_doc_deprecated() throws ArangoException {
360-
361-
// create skip-list
362-
driver.createIndex(COLLECTION_NAME, IndexType.SKIPLIST, false, "age");
363-
364-
{
365-
CursorResultSet<DocumentEntity<TestComplexEntity01>> rs = driver.executeSimpleRangeWithDocumentResultSet(
366-
COLLECTION_NAME, "age", 5, 30, null, 0, 0, TestComplexEntity01.class);
367-
368-
int count = 0;
369-
while (rs.hasNext()) {
370-
DocumentEntity<TestComplexEntity01> doc = rs.next();
371-
count++;
372-
assertThat(doc, is(notNullValue()));
373-
assertThat(doc.getDocumentHandle(), startsWith(COLLECTION_NAME));
374-
assertThat(doc.getDocumentKey(), is(notNullValue()));
375-
assertThat(doc.getDocumentRevision(), is(not(0L)));
376-
assertThat(doc.getEntity(), is(notNullValue()));
377-
assertThat(doc.getEntity().getAge(), is(not(0)));
378-
}
379-
rs.close();
380-
assertThat(count, is(25));
381-
}
382-
383-
{
384-
CursorResultSet<DocumentEntity<TestComplexEntity01>> rs = driver.executeSimpleRangeWithDocumentResultSet(
385-
COLLECTION_NAME, "age", 5, 30, true, 0, 0, TestComplexEntity01.class);
386-
387-
int count = 0;
388-
while (rs.hasNext()) {
389-
DocumentEntity<TestComplexEntity01> doc = rs.next();
390-
count++;
391-
assertThat(doc, is(notNullValue()));
392-
assertThat(doc.getDocumentHandle(), startsWith(COLLECTION_NAME));
393-
assertThat(doc.getDocumentKey(), is(notNullValue()));
394-
assertThat(doc.getDocumentRevision(), is(not(0L)));
395-
assertThat(doc.getEntity(), is(notNullValue()));
396-
assertThat(doc.getEntity().getAge(), is(not(0)));
397-
}
398-
rs.close();
399-
assertThat(count, is(26));
400-
}
401-
402-
}
403-
404215
@Test
405216
public void test_remove_by_example() throws ArangoException {
406217

src/test/java/com/arangodb/ArangoDriverTransactionTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
public class ArangoDriverTransactionTest extends BaseTest {
3434

35+
private static final String SOME_COLLECTION = "someCollection";
36+
3537
public class ParamObject {
3638
private String a = "a";
3739

@@ -70,15 +72,13 @@ public ArangoDriverTransactionTest(ArangoConfigure configure, ArangoDriver drive
7072

7173
@Before
7274
public void setup() throws ArangoException {
73-
TestComplexEntity01 value = new TestComplexEntity01("user-" + 9999, "desc:" + 9999, 9999);
74-
driver.createDocument("someCollection", value, true, false);
7575
try {
76-
driver.deleteCollection("someCollection");
76+
driver.deleteCollection(SOME_COLLECTION);
7777
} catch (ArangoException e) {
7878

7979
}
8080
try {
81-
driver.createCollection("someCollection");
81+
driver.createCollection(SOME_COLLECTION);
8282
} catch (ArangoException e) {
8383

8484
}
@@ -87,7 +87,7 @@ public void setup() throws ArangoException {
8787
@After
8888
public void teardown() throws ArangoException {
8989
try {
90-
driver.deleteCollection("someCollection");
90+
driver.deleteCollection(SOME_COLLECTION);
9191
} catch (ArangoException e) {
9292

9393
}
@@ -107,7 +107,7 @@ public void test_Transaction() throws ArangoException {
107107

108108
transaction = driver.createTransaction("function (params) {" + "var db = require('internal').db;"
109109
+ "return db.someCollection.all().toArray()[0];" + "}");
110-
transaction.addReadCollection("someCollection");
110+
transaction.addReadCollection(SOME_COLLECTION);
111111
result = driver.executeTransaction(transaction);
112112

113113
assertThat(result.getStatusCode(), is(200));

0 commit comments

Comments
 (0)