Search in sources :

Example 6 with AddResult

use of com.mysql.cj.xdevapi.AddResult in project aws-mysql-jdbc by awslabs.

the class CompressionTest method compressionThreshold.

/**
 * Tests the compression threshold applied to uplink data.
 */
@Test
public void compressionThreshold() {
    assumeTrue(this.compressionSettings.serverSupportsCompression(), "Server variable mysqlx_compression_algorithms must be configured to run this test.");
    dropCollection("compressionThreshold");
    this.schema.createCollection("compressionThreshold");
    Session testSession = this.fact.getSession(this.compressFreeBaseUrl + makeParam(PropertyKey.xdevapiCompression, Compression.REQUIRED));
    Collection col = testSession.getDefaultSchema().getCollection("compressionThreshold");
    assertTrue(this.counters.resetCounters());
    // Not enough bytes to trigger uplink compression.
    AddResult res = col.add(shortData).execute();
    assertEquals(1, res.getAffectedItemsCount());
    String docId = res.getGeneratedIds().get(0);
    assertTrue(this.counters.resetCounters());
    // Server compresses small messages anyway.
    assertTrue(this.counters.downlinkCompressionUsed());
    assertFalse(this.counters.uplinkCompressionUsed());
    DbDoc doc = col.getOne(docId);
    assertNotNull(doc);
    assertEquals(shortDataDoc.get("data").toString(), doc.get("data").toString());
    assertTrue(this.counters.resetCounters());
    // Server compresses small messages anyway.
    assertTrue(this.counters.downlinkCompressionUsed());
    assertFalse(this.counters.uplinkCompressionUsed());
    // Enough bytes to trigger uplink compression.
    res = col.add(longData).execute();
    assertEquals(1, res.getAffectedItemsCount());
    docId = res.getGeneratedIds().get(0);
    assertTrue(this.counters.resetCounters());
    assertTrue(this.counters.downlinkCompressionUsed());
    assertTrue(this.counters.uplinkCompressionUsed());
    doc = col.getOne(docId);
    assertNotNull(doc);
    assertEquals(longDataDoc.get("data").toString(), doc.get("data").toString());
    assertTrue(this.counters.resetCounters());
    assertTrue(this.counters.downlinkCompressionUsed());
    assertFalse(this.counters.uplinkCompressionUsed());
    dropCollection("compressionThreshold");
    testSession.close();
}
Also used : DbDoc(com.mysql.cj.xdevapi.DbDoc) Collection(com.mysql.cj.xdevapi.Collection) AddResult(com.mysql.cj.xdevapi.AddResult) JsonString(com.mysql.cj.xdevapi.JsonString) Session(com.mysql.cj.xdevapi.Session) Test(org.junit.jupiter.api.Test)

Example 7 with AddResult

use of com.mysql.cj.xdevapi.AddResult in project aws-mysql-jdbc by awslabs.

the class CollectionTest method testFetchOneFetchAllAsync.

@Test
public void testFetchOneFetchAllAsync() throws Exception {
    int i = 0, maxrec = 10;
    CompletableFuture<DocResult> asyncDocs = null;
    List<DbDoc> rowDoc = null;
    DbDoc[] jsonlist = new DbDocImpl[maxrec];
    for (i = 0; i < maxrec; i++) {
        DbDoc newDoc2 = new DbDocImpl();
        newDoc2.add("_id", new JsonString().setValue(String.valueOf(i + 1000)));
        newDoc2.add("F1", new JsonString().setValue("Field-1-Data-" + i));
        newDoc2.add("F2", new JsonNumber().setValue(String.valueOf((100 + i) * 10)));
        newDoc2.add("F3", new JsonNumber().setValue(String.valueOf(100 + i)));
        newDoc2.add("F4", new JsonNumber().setValue(String.valueOf(1 + i)));
        jsonlist[i] = newDoc2;
        newDoc2 = null;
    }
    CompletableFuture<AddResult> asyncRes = this.collection.add(jsonlist).executeAsync();
    asyncRes.get();
    // fetchAll() after fetchOne (Error)
    asyncDocs = this.collection.find("F1 like :X and $.F3 <=:Y and  $.F3 !=:Z").bind("Y", 105).bind("Z", 105).bind("X", "Field-1-%").orderBy("F1 asc").executeAsync();
    DocResult docs1 = asyncDocs.get();
    DbDoc doc = docs1.fetchOne();
    assertThrows(WrongArgumentException.class, "Cannot fetchAll\\(\\) after starting iteration", () -> docs1.fetchAll());
    i = 0;
    while (doc != null) {
        assertEquals((long) (100 + i), (long) (((JsonNumber) doc.get("F3")).getInteger()));
        i = i + 1;
        doc = docs1.fetchOne();
    }
    assertThrows(WrongArgumentException.class, "Cannot fetchAll\\(\\) after starting iteration", () -> docs1.fetchAll());
    // fetchAll() after next (Error)
    asyncDocs = this.collection.find("F1 like :X and $.F3 <=:Y and  $.F3 !=:Z").bind("Y", 105).bind("Z", 105).bind("X", "Field-1-%").orderBy("F1 asc").executeAsync();
    DocResult docs2 = asyncDocs.get();
    doc = docs2.next();
    assertThrows(WrongArgumentException.class, "Cannot fetchAll\\(\\) after starting iteration", () -> docs2.fetchAll());
    i = 0;
    do {
        assertEquals((long) (100 + i), (long) (((JsonNumber) doc.get("F3")).getInteger()));
        i = i + 1;
        doc = docs2.next();
    } while (docs2.hasNext());
    assertThrows(WrongArgumentException.class, "Cannot fetchAll\\(\\) after starting iteration", () -> docs2.fetchAll());
    // fetchOne() and next(Success)
    asyncDocs = this.collection.find("F1 like :X and $.F3 <=:Y and  $.F3 !=:Z").bind("Y", 108).bind("Z", 108).bind("X", "Field-1-%").orderBy("F3 asc").executeAsync();
    DocResult docs3 = asyncDocs.get();
    i = 0;
    while (docs3.hasNext()) {
        if (i % 2 == 1) {
            doc = docs3.next();
        } else {
            doc = docs3.fetchOne();
        }
        assertEquals((long) (100 + i), (long) (((JsonNumber) doc.get("F3")).getInteger()));
        i = i + 1;
    }
    assertThrows(WrongArgumentException.class, "Cannot fetchAll\\(\\) after starting iteration", () -> docs3.fetchAll());
    // fetchAll (Success)
    asyncDocs = this.collection.find("F1 like :X and $.F3 <=:Y and  $.F3 !=:Z").bind("Y", 105).bind("Z", 105).bind("X", "Field-1-%").orderBy("F1 asc").executeAsync();
    DocResult docs = asyncDocs.get();
    rowDoc = docs.fetchAll();
    assertEquals((long) 5, (long) rowDoc.size());
    for (i = 0; i < rowDoc.size(); i++) {
        doc = rowDoc.get(i);
        assertEquals((long) (100 + i), (long) (((JsonNumber) doc.get("F3")).getInteger()));
    }
    doc = docs.fetchOne();
}
Also used : DbDoc(com.mysql.cj.xdevapi.DbDoc) DbDocImpl(com.mysql.cj.xdevapi.DbDocImpl) JsonNumber(com.mysql.cj.xdevapi.JsonNumber) AddResult(com.mysql.cj.xdevapi.AddResult) JsonString(com.mysql.cj.xdevapi.JsonString) DocResult(com.mysql.cj.xdevapi.DocResult) Test(org.junit.jupiter.api.Test)

Example 8 with AddResult

use of com.mysql.cj.xdevapi.AddResult in project aws-mysql-jdbc by awslabs.

the class CollectionTest method testCollectionAddModifyRemoveAsync.

@SuppressWarnings({ "deprecation", "unchecked" })
@Test
public void testCollectionAddModifyRemoveAsync() throws Exception {
    int i = 0;
    int NUMBER_OF_QUERIES = 5000;
    DbDoc doc = null;
    AddResult res = null;
    SqlResult res1 = null;
    CompletableFuture<DocResult> asyncDocs = null;
    DocResult docs = null;
    DbDoc newDoc1 = new DbDocImpl();
    newDoc1.add("_id", new JsonString().setValue(String.valueOf(1000)));
    newDoc1.add("F1", new JsonString().setValue("Field-1-Data-1"));
    newDoc1.add("F2", new JsonNumber().setValue(String.valueOf(1000)));
    newDoc1.add("T", new JsonNumber().setValue(String.valueOf(10)));
    DbDoc newDoc2 = new DbDocImpl();
    newDoc2.add("_id", new JsonString().setValue(String.valueOf(1000)));
    // add(), modify(),find(),  remove() Success And Failure
    List<Object> futures = new ArrayList<>();
    for (i = 0; i < NUMBER_OF_QUERIES; ++i) {
        if (i % 10 == 0) {
            futures.add(this.collection.add(newDoc1).executeAsync());
        } else if (i % 10 == 1) {
            // Error
            futures.add(this.collection.find("NON_EXISTING_FUNCTION1()").fields("$._id as _id, $.F1 as F1, $.F2 as F2, $.F3 as F3").executeAsync());
        } else if (i % 10 == 2) {
            futures.add(this.collection.find("$.F2 = 1000").fields("$._id as _id, $.F1 as F1, $.F2 as F2, $.T as T").executeAsync());
        } else if (i % 10 == 3) {
            // Error
            futures.add(this.collection.add(newDoc2).executeAsync());
        } else if (i % 10 == 4) {
            futures.add(this.collection.modify("$.F2 = 1000").change("$.T", expr("$.T+1")).sort("$.F3 desc").executeAsync());
        } else if (i % 10 == 5) {
            // Error
            futures.add(this.collection.modify("$.F2 = 1000").change("$.T", expr("NON_EXISTING_FUNCTION2()")).sort("$.F3 desc").executeAsync());
        } else if (i % 10 == 6) {
            // Error
            futures.add(this.collection.remove("NON_EXISTING_FUNCTION3()=:PARAM").bind("PARAM", 1000).orderBy("$.F3 desc").executeAsync());
        } else if (i % 10 == 7) {
            futures.add(this.session.sql("SELECT JSON_OBJECT('_id', JSON_EXTRACT(doc,'$._id'),'F1', JSON_EXTRACT(doc,'$.F1'),'F2', JSON_EXTRACT(doc,'$.F2'),'T', JSON_EXTRACT(doc,'$.T')) AS doc FROM `" + this.collectionName + "` WHERE (JSON_EXTRACT(doc,'$.F2') = 1000) ").executeAsync());
        } else if (i % 10 == 8) {
            // Error
            futures.add(this.session.sql("select non_existingfun() /* loop : " + i + "*/").executeAsync());
        } else {
            futures.add(this.collection.remove("$.F2 = :PARAM").bind("PARAM", 1000).orderBy("$.F3 desc").executeAsync());
        }
    }
    for (i = 0; i < NUMBER_OF_QUERIES; ++i) {
        int i1 = i;
        if (i % 10 == 0) {
            res = ((CompletableFuture<AddResult>) futures.get(i)).get();
            assertEquals(1, res.getAffectedItemsCount());
        } else if (i % 10 == 1) {
            assertThrows(ExecutionException.class, ".*FUNCTION " + this.schema.getName() + ".NON_EXISTING_FUNCTION1 does not exist.*", () -> ((CompletableFuture<DocResult>) futures.get(i1)).get());
        } else if (i % 10 == 2) {
            docs = ((CompletableFuture<DocResult>) futures.get(i)).get();
            assertTrue(docs.hasNext());
            doc = docs.next();
            assertEquals((long) (10), (long) (((JsonNumber) doc.get("T")).getInteger()));
            assertFalse(docs.hasNext());
        } else if (i % 10 == 3) {
            assertThrows(ExecutionException.class, ".*Document contains a field value that is not unique but required to be.*", () -> ((CompletableFuture<AddResult>) futures.get(i1)).get());
        } else if (i % 10 == 4) {
            Result res2 = ((CompletableFuture<AddResult>) futures.get(i)).get();
            assertEquals(1, res2.getAffectedItemsCount());
        } else if (i % 10 == 5) {
            assertThrows(ExecutionException.class, ".*FUNCTION " + this.schema.getName() + ".NON_EXISTING_FUNCTION2 does not exist.*", () -> ((CompletableFuture<Result>) futures.get(i1)).get());
        } else if (i % 10 == 6) {
            assertThrows(ExecutionException.class, ".*FUNCTION " + this.schema.getName() + ".NON_EXISTING_FUNCTION3 does not exist.*", () -> ((CompletableFuture<Result>) futures.get(i1)).get());
        } else if (i % 10 == 7) {
            res1 = ((CompletableFuture<SqlResult>) futures.get(i)).get();
            res1.next();
            assertFalse(res1.hasNext());
        } else if (i % 10 == 8) {
            assertThrows(ExecutionException.class, ".*FUNCTION " + this.schema.getName() + ".non_existingfun does not exist.*", () -> ((CompletableFuture<SqlResult>) futures.get(i1)).get());
        } else {
            Result res2 = ((CompletableFuture<AddResult>) futures.get(i)).get();
            assertEquals(1, res2.getAffectedItemsCount());
        }
    }
    if ((NUMBER_OF_QUERIES - 1) % 10 < 9) {
        assertEquals((1), this.collection.count());
        asyncDocs = this.collection.find("$.T = :X ").bind("X", 10).fields(expr("{'cnt':count($.T)}")).executeAsync();
        docs = asyncDocs.get();
        doc = docs.next();
        assertEquals((long) (1), (long) (((JsonNumber) doc.get("cnt")).getInteger()));
    } else {
        assertEquals((0), this.collection.count());
    }
}
Also used : SqlResult(com.mysql.cj.xdevapi.SqlResult) ArrayList(java.util.ArrayList) AddResult(com.mysql.cj.xdevapi.AddResult) RowResult(com.mysql.cj.xdevapi.RowResult) Result(com.mysql.cj.xdevapi.Result) AddResult(com.mysql.cj.xdevapi.AddResult) DocResult(com.mysql.cj.xdevapi.DocResult) SqlResult(com.mysql.cj.xdevapi.SqlResult) DbDoc(com.mysql.cj.xdevapi.DbDoc) DbDocImpl(com.mysql.cj.xdevapi.DbDocImpl) CompletableFuture(java.util.concurrent.CompletableFuture) JsonNumber(com.mysql.cj.xdevapi.JsonNumber) JsonString(com.mysql.cj.xdevapi.JsonString) ExecutionException(java.util.concurrent.ExecutionException) DocResult(com.mysql.cj.xdevapi.DocResult) Test(org.junit.jupiter.api.Test)

Example 9 with AddResult

use of com.mysql.cj.xdevapi.AddResult in project aws-mysql-jdbc by awslabs.

the class CollectionTest method testAsyncBind.

@Test
public void testAsyncBind() throws Exception {
    int i = 0, maxrec = 10;
    DbDoc[] jsonlist = new DbDocImpl[maxrec];
    for (i = 0; i < maxrec; i++) {
        DbDoc newDoc2 = new DbDocImpl();
        newDoc2.add("_id", new JsonString().setValue(String.valueOf(i + 1000)));
        newDoc2.add("F1", new JsonString().setValue("Field-1-Data-" + i));
        newDoc2.add("F2", new JsonNumber().setValue(String.valueOf((100 + i) * 10)));
        newDoc2.add("F3", new JsonNumber().setValue(String.valueOf(100 + i)));
        newDoc2.add("F4", new JsonNumber().setValue(String.valueOf(1 + i)));
        jsonlist[i] = newDoc2;
        newDoc2 = null;
    }
    CompletableFuture<AddResult> asyncRes = this.collection.add(jsonlist).executeAsync();
    asyncRes.get();
    // 1. Incorrect PlaceHolder Name in bind
    assertThrows(WrongArgumentException.class, "Unknown placeholder: F", () -> this.collection.find("F1 like :X").bind("F", "Field-1-%-3").executeAsync());
    // 2. PlaceHolder Name in small letter
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.find("F1 like :X").bind("x", "Field-1-%-3").executeAsync());
    // 3. No bind
    assertThrows(WrongArgumentException.class, "Placeholder 'X' is not bound", () -> this.collection.find("F1 like :X").executeAsync());
    // 4. bind 2 times
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.find("F1 like :X").bind("X", "Field-1-%-4").bind("x", "Field-1-%-3").bind("X", "Field-1-%-3").executeAsync());
    // 5. bind same variable 2 times (Success)
    CompletableFuture<DocResult> asyncDocs = this.collection.find("F1 like :X").bind("X", "Field-1-%-4").bind("X", "Field-1-%-3").executeAsync();
    DocResult docs = asyncDocs.get();
    DbDoc doc = docs.next();
    assertEquals((long) 103, (long) (((JsonNumber) doc.get("F3")).getInteger()));
    assertFalse(docs.hasNext());
    // 6. bind In different order (Success)
    asyncDocs = this.collection.find("F1 like :X and $.F3 =:Y and  $.F3 !=:Z").bind("Y", 103).bind("Z", 104).bind("X", "Field-1-%-3").executeAsync();
    docs = asyncDocs.get();
    doc = docs.next();
    assertEquals((long) 103, (long) (((JsonNumber) doc.get("F3")).getInteger()));
    assertFalse(docs.hasNext());
    // 7. Using same Bind Variables many times(Success)
    asyncDocs = this.collection.find("F1 like :F1 and $.F3 in (:F3,:F2,:F3) and  $.F2 =(:F3*10)").bind("F3", 103).bind("F2", 102).bind("F1", "Field-1-%-3").executeAsync();
    docs = asyncDocs.get();
    doc = docs.next();
    assertEquals((long) 103, (long) (((JsonNumber) doc.get("F3")).getInteger()));
    assertFalse(docs.hasNext());
    // 1. Incorrect PlaceHolder Name in bind
    assertThrows(WrongArgumentException.class, "Unknown placeholder: F", () -> this.collection.modify("F1 like :X").set("$.F4", 1).bind("F", "Field-1-%-3").executeAsync());
    // 2. PlaceHolder Name in small letter
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.modify("F1 like :X").set("$.F4", 1).bind("x", "Field-1-%-3").executeAsync());
    // 3. No bind
    assertThrows(WrongArgumentException.class, "Placeholder 'X' is not bound", () -> this.collection.modify("F1 like :X").set("$.F4", 1).executeAsync());
    // 4. bind 2 times
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.modify("F1 like :X").set("$.F4", 1).bind("X", "Field-1-%-4").bind("x", "Field-1-%-3").bind("X", "Field-1-%-3").executeAsync());
    // 5. bind same variable 2 times (Success)
    CompletableFuture<Result> asyncRes2 = this.collection.modify("F1 like :X").set("$.F4", -1).bind("X", "Field-1-%-4").bind("X", "Field-1-%-3").executeAsync();
    Result res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    // 6. bind In different order (Success)
    asyncRes2 = this.collection.modify("F1 like :X and $.F3 =:Y and  $.F3 !=:Z").set("$.F4", -2).bind("Y", 103).bind("Z", 104).bind("X", "Field-1-%-3").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    // 7. Using same Bind Variables many times(Success)
    asyncRes2 = this.collection.modify("F1 like :F1 and $.F3 in (:F3,:F2,:F3) and  $.F2 =(:F3*10)").set("$.F4", -3).bind("F3", 103).bind("F2", 102).bind("F1", "Field-1-%-3").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    asyncRes2 = this.collection.modify("$.F3 = :X").set("$.F4", 1).bind("X", 101).sort("$.F1 asc").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    asyncRes2 = this.collection.modify("$.F3 = :X+:Y+:X+:Y").set("$.F4", -4).bind("X", 50).bind("Y", 2).sort("$.F1 asc").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    // 1. Incorrect PlaceHolder Name in bind
    assertThrows(WrongArgumentException.class, "Unknown placeholder: F", () -> this.collection.remove("F1 like :X").bind("F", "Field-1-%-3").executeAsync());
    // 2. PlaceHolder Name in small letter
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.remove("F1 like :X").bind("x", "Field-1-%-3").executeAsync());
    // 3. No bind
    assertThrows(WrongArgumentException.class, "Placeholder 'X' is not bound", () -> this.collection.remove("F1 like :X").executeAsync());
    // 4. bind 2 times
    assertThrows(WrongArgumentException.class, "Unknown placeholder: x", () -> this.collection.remove("F1 like :X").bind("X", "Field-1-%-4").bind("x", "Field-1-%-3").bind("X", "Field-1-%-3").executeAsync());
    // 5. bind same variable 2 times (Success)
    asyncRes2 = this.collection.remove("F1 like :X").bind("X", "Field-1-%-4").bind("X", "Field-1-%-0").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    // 6. bind In different order (Success)
    asyncRes2 = this.collection.remove("F1 like :X and $.F3 =:Y and  $.F3 !=:Z").bind("Y", 101).bind("Z", 104).bind("X", "Field-1-%-1").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
    // 7. Using same Bind Variables many times(Success)
    asyncRes2 = this.collection.remove("F1 like :F1 and $.F3 in (:F3,:F2,:F3) and  $.F2 =(:F3*10)").bind("F3", 102).bind("F2", 107).bind("F1", "Field-1-%-2").executeAsync();
    res2 = asyncRes2.get();
    assertEquals(1, res2.getAffectedItemsCount());
}
Also used : DbDoc(com.mysql.cj.xdevapi.DbDoc) DbDocImpl(com.mysql.cj.xdevapi.DbDocImpl) JsonNumber(com.mysql.cj.xdevapi.JsonNumber) AddResult(com.mysql.cj.xdevapi.AddResult) JsonString(com.mysql.cj.xdevapi.JsonString) DocResult(com.mysql.cj.xdevapi.DocResult) RowResult(com.mysql.cj.xdevapi.RowResult) Result(com.mysql.cj.xdevapi.Result) AddResult(com.mysql.cj.xdevapi.AddResult) DocResult(com.mysql.cj.xdevapi.DocResult) SqlResult(com.mysql.cj.xdevapi.SqlResult) Test(org.junit.jupiter.api.Test)

Example 10 with AddResult

use of com.mysql.cj.xdevapi.AddResult in project aws-mysql-jdbc by awslabs.

the class CompressionTest method compressionDisabled.

/**
 * Tests compression disabled by connection option.
 */
@Test
public void compressionDisabled() {
    assumeTrue(this.compressionSettings.serverSupportsCompression(), "Server variable mysqlx_compression_algorithms must be configured to run this test.");
    dropCollection("compressionDisabled");
    this.schema.createCollection("compressionDisabled");
    Session testSession = this.fact.getSession(this.compressFreeBaseUrl + makeParam(PropertyKey.xdevapiCompression, Compression.DISABLED));
    Collection col = testSession.getDefaultSchema().getCollection("compressionDisabled");
    assertFalse(isCompressionEnabled(testSession));
    assertTrue(this.counters.resetCounters());
    AddResult res = col.add("{\"foo\": \"bar\"}", "{\"baz\": \"[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]" + "[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]" + "[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]" + "[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]\"}").execute();
    assertEquals(2, res.getAffectedItemsCount());
    assertTrue(this.counters.resetCounters());
    assertFalse(this.counters.usedCompression());
    DocResult docs = col.find().execute();
    assertEquals(2, docs.count());
    assertTrue(this.counters.resetCounters());
    assertFalse(this.counters.usedCompression());
    dropCollection("compressionDisabled");
    testSession.close();
}
Also used : Collection(com.mysql.cj.xdevapi.Collection) AddResult(com.mysql.cj.xdevapi.AddResult) DocResult(com.mysql.cj.xdevapi.DocResult) Session(com.mysql.cj.xdevapi.Session) Test(org.junit.jupiter.api.Test)

Aggregations

AddResult (com.mysql.cj.xdevapi.AddResult)25 Test (org.junit.jupiter.api.Test)25 JsonString (com.mysql.cj.xdevapi.JsonString)23 DbDoc (com.mysql.cj.xdevapi.DbDoc)22 DocResult (com.mysql.cj.xdevapi.DocResult)22 DbDocImpl (com.mysql.cj.xdevapi.DbDocImpl)8 Collection (com.mysql.cj.xdevapi.Collection)7 JsonNumber (com.mysql.cj.xdevapi.JsonNumber)7 Session (com.mysql.cj.xdevapi.Session)7 Result (com.mysql.cj.xdevapi.Result)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 ArrayList (java.util.ArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)4 Compression (com.mysql.cj.conf.PropertyDefinitions.Compression)2 RowResult (com.mysql.cj.xdevapi.RowResult)2 SqlResult (com.mysql.cj.xdevapi.SqlResult)2 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 JsonArray (com.mysql.cj.xdevapi.JsonArray)1 SessionFactory (com.mysql.cj.xdevapi.SessionFactory)1