@Test public void testCopy() throws ConnectionException { String keyName = "A"; keyspace.prepareQuery(CF_STANDARD1).getKey(keyName).copyTo(CF_STANDARD2, keyName).execute(); ColumnList<String> list1 = keyspace.prepareQuery(CF_STANDARD1).getKey(keyName).execute().getResult(); ColumnList<String> list2 = keyspace.prepareQuery(CF_STANDARD2).getKey(keyName).execute().getResult(); Iterator<Column<String>> iter1 = list1.iterator(); Iterator<Column<String>> iter2 = list2.iterator(); while (iter1.hasNext()) { Column<String> column1 = iter1.next(); Column<String> column2 = iter2.next(); Assert.assertEquals(column1.getName(), column2.getName()); Assert.assertEquals(column1.getByteBufferValue(),column2.getByteBufferValue()); } Assert.assertFalse(iter2.hasNext()); }
@Test public void runRowCopyTest() throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); m.withRow(CF_ROW_COPY, 10).putColumn("c1", 1).putColumn("c2", 2); m.execute(); ColumnList<String> result = keyspace.prepareQuery(CF_ROW_COPY).getRow(10).execute().getResult(); Column<String> column = result.getColumnByIndex(0); Assert.assertEquals("c1", column.getName()); Assert.assertEquals(1, column.getIntegerValue()); column = result.getColumnByIndex(1); Assert.assertEquals("c2", column.getName()); Assert.assertEquals(2, column.getIntegerValue()); keyspace.prepareQuery(CF_ROW_COPY).getRow(10).copyTo(CF_ROW_COPY2, 11).execute(); ColumnList<String> result2 = keyspace.prepareQuery(CF_ROW_COPY2).getRow(11).execute().getResult(); column = result2.getColumnByIndex(0); Assert.assertEquals("c1", column.getName()); Assert.assertEquals(1, column.getIntegerValue()); column = result2.getColumnByIndex(1); Assert.assertEquals("c2", column.getName()); Assert.assertEquals(2, column.getIntegerValue()); } }