From d36cb3f26a90aec450a4d7bf625c38923c793c1c Mon Sep 17 00:00:00 2001 From: "Robert J. Moore" Date: Sat, 6 Jun 2015 00:23:38 -0400 Subject: [PATCH 1/2] Fix #277 - Switch from updateOne to replaceOne to match changed semantics in the MongoDB 3.0 driver. Created tests for the basic DB operations. Updated MongoDB Inc. Driver version to 3.0.2. --- mongodb/pom.xml | 171 +++++----- .../java/com/yahoo/ycsb/db/MongoDbClient.java | 10 +- .../yahoo/ycsb/db/AbstractDBTestCases.java | 299 ++++++++++++++++++ .../yahoo/ycsb/db/AsyncMongoDbClientTest.java | 77 +++++ .../com/yahoo/ycsb/db/MongoDbClientTest.java | 77 +++++ pom.xml | 2 +- 6 files changed, 549 insertions(+), 87 deletions(-) create mode 100644 mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java create mode 100644 mongodb/src/test/java/com/yahoo/ycsb/db/AsyncMongoDbClientTest.java create mode 100644 mongodb/src/test/java/com/yahoo/ycsb/db/MongoDbClientTest.java diff --git a/mongodb/pom.xml b/mongodb/pom.xml index 0a81b248b2..3038e17d4e 100644 --- a/mongodb/pom.xml +++ b/mongodb/pom.xml @@ -1,87 +1,94 @@ - - 4.0.0 - - com.yahoo.ycsb - root - 0.2.0-SNAPSHOT - + + 4.0.0 + + com.yahoo.ycsb + root + 0.2.0-SNAPSHOT + - mongodb-binding - MongoDB Binding - jar + mongodb-binding + MongoDB Binding + jar - - - org.mongodb - mongo-java-driver - ${mongodb.version} - - - com.allanbank - mongodb-async-driver - ${mongodb.async.version} - - - com.yahoo.ycsb - core - ${project.version} - - - ch.qos.logback - logback-classic - 1.1.2 - + + + org.mongodb + mongo-java-driver + ${mongodb.version} + + + com.allanbank + mongodb-async-driver + ${mongodb.async.version} + + + com.yahoo.ycsb + core + ${project.version} + + + ch.qos.logback + logback-classic + 1.1.2 + - - junit - junit - 4.12 - test - - + + junit + junit + 4.12 + test + + + de.flapdoodle.embed + de.flapdoodle.embed.mongo + 1.47.3 + test + + - - - - org.apache.maven.plugins - maven-assembly-plugin - ${maven.assembly.version} - - - jar-with-dependencies - - false - - - - package - - single - - - - - - - - - - - true - always - warn - - - false - never - fail - - allanbank - Allanbank Releases - http://www.allanbank.com/repo/ - default - - - + + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven.assembly.version} + + + jar-with-dependencies + + false + + + + package + + single + + + + + + + + + + true + always + warn + + + false + never + fail + + allanbank + Allanbank Releases + http://www.allanbank.com/repo/ + default + + + diff --git a/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java b/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java index 511efda264..5163f05c7a 100644 --- a/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java +++ b/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java @@ -20,6 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.bson.Document; +import org.bson.types.Binary; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; @@ -251,9 +252,10 @@ public int insert(String table, String key, // Do a single upsert. if (batchSize <= 1) { UpdateResult result = collection.withWriteConcern(writeConcern) - .updateOne(criteria, toInsert, UPSERT); + .replaceOne(criteria, toInsert, UPSERT); if (result.getMatchedCount() > 0 - || result.getModifiedCount() > 0) { + || result.getModifiedCount() > 0 + || result.getUpsertedId() != null) { return 0; } System.err.println("Nothing inserted for key " + key); @@ -465,9 +467,9 @@ public int update(String table, String key, */ protected void fillMap(HashMap resultMap, Document obj) { for (Map.Entry entry : obj.entrySet()) { - if (entry.getValue() instanceof byte[]) { + if (entry.getValue() instanceof Binary) { resultMap.put(entry.getKey(), new ByteArrayByteIterator( - (byte[]) entry.getValue())); + ((Binary) entry.getValue()).getData())); } } } diff --git a/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java b/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java new file mode 100644 index 0000000000..94d082b5eb --- /dev/null +++ b/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2014, Yahoo!, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you + * may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. See accompanying + * LICENSE file. + */ +package com.yahoo.ycsb.db; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeNoException; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Set; +import java.util.Vector; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.yahoo.ycsb.ByteArrayByteIterator; +import com.yahoo.ycsb.ByteIterator; +import com.yahoo.ycsb.DB; + +import de.flapdoodle.embed.mongo.Command; +import de.flapdoodle.embed.mongo.MongodExecutable; +import de.flapdoodle.embed.mongo.MongodProcess; +import de.flapdoodle.embed.mongo.MongodStarter; +import de.flapdoodle.embed.mongo.config.ArtifactStoreBuilder; +import de.flapdoodle.embed.mongo.config.IMongodConfig; +import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; +import de.flapdoodle.embed.mongo.config.Net; +import de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder; +import de.flapdoodle.embed.mongo.distribution.Version; +import de.flapdoodle.embed.process.io.directories.FixedPath; +import de.flapdoodle.embed.process.runtime.Network; + +/** + * MongoDbClientTest provides runs the basic DB test cases. + */ +@SuppressWarnings("boxing") +public abstract class AbstractDBTestCases { + + /** The handle to the running server. */ + private static MongodExecutable ourMongodExecutable = null; + + /** The running Mongodb process. */ + private static MongodProcess ourMongod = null; + + /** The directory to download the MongoDB executables to. */ + private static final File TMP_DIR = new File("target/mongodb"); + + /** + * Start a test mongd instance. + */ + @BeforeClass + public static void setUpBeforeClass() { + TMP_DIR.mkdirs(); + + MongodStarter starter = MongodStarter + .getInstance(new RuntimeConfigBuilder() + .defaults(Command.MongoD) + .artifactStore( + new ArtifactStoreBuilder() + .defaults(Command.MongoD) + .useCache(false) + .tempDir( + new FixedPath(TMP_DIR + .getAbsolutePath()))) + .build()); + int port = 27017; + + try { + IMongodConfig mongodConfig = new MongodConfigBuilder() + .version(Version.Main.PRODUCTION) + .net(new Net(port, Network.localhostIsIPv6())).build(); + + ourMongodExecutable = starter.prepare(mongodConfig); + ourMongod = ourMongodExecutable.start(); + } + catch (IOException error) { + assumeNoException(error); + } + } + + /** + * Stops the test server. + */ + @AfterClass + public static void tearDownAfterClass() { + if (ourMongod != null) { + ourMongod.stop(); + ourMongod = null; + } + if (ourMongodExecutable != null) { + ourMongodExecutable.stop(); + ourMongodExecutable = null; + } + } + + /** + * Test method for {@link MongoDbClient#insert}, {@link MongoDbClient#read}, + * {@link com.yahoo.ycsb.db.MongoDbClient#delete}. + */ + @Test + public void testInsertReadDelete() { + final DB client = getDB(); + + final String table = "test"; + final String id = "delete"; + + HashMap inserted = new HashMap(); + inserted.put("a", new ByteArrayByteIterator(new byte[] { 1, 2, 3, 4 })); + int result = client.insert(table, id, inserted); + assertThat("Insert did not return success (0).", result, is(0)); + + HashMap read = new HashMap(); + Set keys = Collections.singleton("a"); + result = client.read(table, id, keys, read); + assertThat("Read did not return success (0).", result, is(0)); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 1))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 2))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 3))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 4))); + assertFalse(iter.hasNext()); + } + + result = client.delete(table, id); + assertThat("Delete did not return success (0).", result, is(0)); + + read.clear(); + result = client.read(table, id, null, read); + assertThat("Read, after delete, did not return not found (1).", result, + is(1)); + assertThat("Found the deleted fields.", read.size(), is(0)); + + result = client.delete(table, id); + assertThat("Delete did not return not found (1).", result, is(1)); + } + + /** + * Test method for {@link MongoDbClient#scan} . + */ + @Test + public void testScan() { + final DB client = getDB(); + + final String table = "test"; + + // Insert a bunch of documents. + for (int i = 0; i < 100; ++i) { + HashMap inserted = new HashMap(); + inserted.put("a", new ByteArrayByteIterator(new byte[] { + (byte) (i & 0xFF), (byte) (i >> 8 & 0xFF), + (byte) (i >> 16 & 0xFF), (byte) (i >> 24 & 0xFF) })); + int result = client.insert(table, padded(i), inserted); + assertThat("Insert did not return success (0).", result, is(0)); + } + + Set keys = Collections.singleton("a"); + Vector> results = new Vector>(); + int result = client.scan(table, "00050", 5, null, results); + assertThat("Read did not return success (0).", result, is(0)); + assertThat(results.size(), is(5)); + for (int i = 0; i < 5; ++i) { + HashMap read = results.get(i); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), + is(Byte.valueOf((byte) ((i + 50) & 0xFF)))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), + is(Byte.valueOf((byte) ((i + 50) >> 8 & 0xFF)))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), + is(Byte.valueOf((byte) ((i + 50) >> 16 & 0xFF)))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), + is(Byte.valueOf((byte) ((i + 50) >> 24 & 0xFF)))); + assertFalse(iter.hasNext()); + } + } + } + + /** + * Creates a zero padded integer. + * + * @param i + * The integer to padd. + * @return The padded integer. + */ + private String padded(int i) { + String result = String.valueOf(i); + while (result.length() < 5) { + result = "0" + result; + } + return result; + } + + /** + * Gets the test DB. + * + * @return The test DB. + */ + protected abstract DB getDB(); + + /** + * Test method for + * {@link com.yahoo.ycsb.db.MongoDbClient#update(java.lang.String, java.lang.String, java.util.HashMap)} + * . + */ + @Test + public void testInsertReadUpdate() { + DB client = getDB(); + + final String table = "test"; + final String id = "update"; + + HashMap inserted = new HashMap(); + inserted.put("a", new ByteArrayByteIterator(new byte[] { 1, 2, 3, 4 })); + int result = client.insert(table, id, inserted); + assertThat("Insert did not return success (0).", result, is(0)); + + HashMap read = new HashMap(); + Set keys = Collections.singleton("a"); + result = client.read(table, id, keys, read); + assertThat("Read did not return success (0).", result, is(0)); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 1))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 2))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 3))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 4))); + assertFalse(iter.hasNext()); + } + + HashMap updated = new HashMap(); + updated.put("a", new ByteArrayByteIterator(new byte[] { 5, 6, 7, 8 })); + result = client.update(table, id, updated); + assertThat("Update did not return success (0).", result, is(0)); + + read.clear(); + result = client.read(table, id, null, read); + assertThat("Read, after update, did not return success (0).", result, + is(0)); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 5))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 6))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 7))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 8))); + assertFalse(iter.hasNext()); + } + } + +} \ No newline at end of file diff --git a/mongodb/src/test/java/com/yahoo/ycsb/db/AsyncMongoDbClientTest.java b/mongodb/src/test/java/com/yahoo/ycsb/db/AsyncMongoDbClientTest.java new file mode 100644 index 0000000000..f5ee7b658e --- /dev/null +++ b/mongodb/src/test/java/com/yahoo/ycsb/db/AsyncMongoDbClientTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014, Yahoo!, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you + * may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. See accompanying + * LICENSE file. + */ +package com.yahoo.ycsb.db; + +import static org.junit.Assume.assumeNoException; + +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; + +import com.yahoo.ycsb.DB; + +/** + * AsyncMongoDbClientTest provides runs the basic workload operations. + */ +public class AsyncMongoDbClientTest extends AbstractDBTestCases { + + /** The client to use. */ + private AsyncMongoDbClient myClient = null; + + /** + * Start a test client. + */ + @Before + public void setUp() { + myClient = new AsyncMongoDbClient(); + myClient.setProperties(new Properties()); + try { + myClient.init(); + } + catch (Exception error) { + assumeNoException(error); + } + } + + /** + * Stops the test client. + */ + @After + public void tearDown() { + try { + myClient.cleanup(); + } + catch (Exception error) { + // Ignore. + } + finally { + myClient = null; + } + } + + /** + * {@inheritDoc} + *

+ * Overriden to return the {@link AsyncMongoDbClient}. + *

+ */ + @Override + protected DB getDB() { + return myClient; + } +} diff --git a/mongodb/src/test/java/com/yahoo/ycsb/db/MongoDbClientTest.java b/mongodb/src/test/java/com/yahoo/ycsb/db/MongoDbClientTest.java new file mode 100644 index 0000000000..515fb80263 --- /dev/null +++ b/mongodb/src/test/java/com/yahoo/ycsb/db/MongoDbClientTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014, Yahoo!, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you + * may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. See accompanying + * LICENSE file. + */ +package com.yahoo.ycsb.db; + +import static org.junit.Assume.assumeNoException; + +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; + +import com.yahoo.ycsb.DB; + +/** + * MongoDbClientTest provides runs the basic workload operations. + */ +public class MongoDbClientTest extends AbstractDBTestCases { + + /** The client to use. */ + private MongoDbClient myClient = null; + + /** + * Start a test client. + */ + @Before + public void setUp() { + myClient = new MongoDbClient(); + myClient.setProperties(new Properties()); + try { + myClient.init(); + } + catch (Exception error) { + assumeNoException(error); + } + } + + /** + * Stops the test client. + */ + @After + public void tearDown() { + try { + myClient.cleanup(); + } + catch (Exception error) { + // Ignore. + } + finally { + myClient = null; + } + } + + /** + * {@inheritDoc} + *

+ * Overriden to return the {@link MongoDbClient}. + *

+ */ + @Override + protected DB getDB() { + return myClient; + } +} diff --git a/pom.xml b/pom.xml index 9d430b7ab9..1b9f12cc27 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 7.1.0.CR1 2.1.1 - 3.0.1 + 3.0.2 2.0.1 1.0.1 2.0.0 From b88aea2046a0f49d2851e7a34c302357b9f8f168 Mon Sep 17 00:00:00 2001 From: "Robert J. Moore" Date: Sat, 6 Jun 2015 08:24:13 -0400 Subject: [PATCH 2/2] Javadoc updates for the test cases. #277. --- .../yahoo/ycsb/db/AbstractDBTestCases.java | 151 +++++++++--------- 1 file changed, 75 insertions(+), 76 deletions(-) diff --git a/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java b/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java index 94d082b5eb..503a83f347 100644 --- a/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java +++ b/mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java @@ -57,12 +57,12 @@ @SuppressWarnings("boxing") public abstract class AbstractDBTestCases { - /** The handle to the running server. */ - private static MongodExecutable ourMongodExecutable = null; - /** The running Mongodb process. */ private static MongodProcess ourMongod = null; + /** The handle to the running server. */ + private static MongodExecutable ourMongodExecutable = null; + /** The directory to download the MongoDB executables to. */ private static final File TMP_DIR = new File("target/mongodb"); @@ -115,8 +115,8 @@ public static void tearDownAfterClass() { } /** - * Test method for {@link MongoDbClient#insert}, {@link MongoDbClient#read}, - * {@link com.yahoo.ycsb.db.MongoDbClient#delete}. + * Test method for {@link DB#insert}, {@link DB#read}, and {@link DB#delete} + * . */ @Test public void testInsertReadDelete() { @@ -164,7 +164,69 @@ public void testInsertReadDelete() { } /** - * Test method for {@link MongoDbClient#scan} . + * Test method for {@link DB#insert}, {@link DB#read}, and {@link DB#update} + * . + */ + @Test + public void testInsertReadUpdate() { + DB client = getDB(); + + final String table = "test"; + final String id = "update"; + + HashMap inserted = new HashMap(); + inserted.put("a", new ByteArrayByteIterator(new byte[] { 1, 2, 3, 4 })); + int result = client.insert(table, id, inserted); + assertThat("Insert did not return success (0).", result, is(0)); + + HashMap read = new HashMap(); + Set keys = Collections.singleton("a"); + result = client.read(table, id, keys, read); + assertThat("Read did not return success (0).", result, is(0)); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 1))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 2))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 3))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 4))); + assertFalse(iter.hasNext()); + } + + HashMap updated = new HashMap(); + updated.put("a", new ByteArrayByteIterator(new byte[] { 5, 6, 7, 8 })); + result = client.update(table, id, updated); + assertThat("Update did not return success (0).", result, is(0)); + + read.clear(); + result = client.read(table, id, null, read); + assertThat("Read, after update, did not return success (0).", result, + is(0)); + for (String key : keys) { + ByteIterator iter = read.get(key); + + assertThat("Did not read the inserted field: " + key, iter, + notNullValue()); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 5))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 6))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 7))); + assertTrue(iter.hasNext()); + assertThat(iter.nextByte(), is(Byte.valueOf((byte) 8))); + assertFalse(iter.hasNext()); + } + } + + /** + * Test method for {@link DB#scan}. */ @Test public void testScan() { @@ -211,6 +273,13 @@ public void testScan() { } } + /** + * Gets the test DB. + * + * @return The test DB. + */ + protected abstract DB getDB(); + /** * Creates a zero padded integer. * @@ -226,74 +295,4 @@ private String padded(int i) { return result; } - /** - * Gets the test DB. - * - * @return The test DB. - */ - protected abstract DB getDB(); - - /** - * Test method for - * {@link com.yahoo.ycsb.db.MongoDbClient#update(java.lang.String, java.lang.String, java.util.HashMap)} - * . - */ - @Test - public void testInsertReadUpdate() { - DB client = getDB(); - - final String table = "test"; - final String id = "update"; - - HashMap inserted = new HashMap(); - inserted.put("a", new ByteArrayByteIterator(new byte[] { 1, 2, 3, 4 })); - int result = client.insert(table, id, inserted); - assertThat("Insert did not return success (0).", result, is(0)); - - HashMap read = new HashMap(); - Set keys = Collections.singleton("a"); - result = client.read(table, id, keys, read); - assertThat("Read did not return success (0).", result, is(0)); - for (String key : keys) { - ByteIterator iter = read.get(key); - - assertThat("Did not read the inserted field: " + key, iter, - notNullValue()); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 1))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 2))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 3))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 4))); - assertFalse(iter.hasNext()); - } - - HashMap updated = new HashMap(); - updated.put("a", new ByteArrayByteIterator(new byte[] { 5, 6, 7, 8 })); - result = client.update(table, id, updated); - assertThat("Update did not return success (0).", result, is(0)); - - read.clear(); - result = client.read(table, id, null, read); - assertThat("Read, after update, did not return success (0).", result, - is(0)); - for (String key : keys) { - ByteIterator iter = read.get(key); - - assertThat("Did not read the inserted field: " + key, iter, - notNullValue()); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 5))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 6))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 7))); - assertTrue(iter.hasNext()); - assertThat(iter.nextByte(), is(Byte.valueOf((byte) 8))); - assertFalse(iter.hasNext()); - } - } - } \ No newline at end of file