Skip to content

Commit

Permalink
test and fix get_column regression. patch by Jun Rao; reviewed by jbe…
Browse files Browse the repository at this point in the history
…llis for #90
  • Loading branch information
Jonathan Ellis committed Apr 21, 2009
1 parent 4cda995 commit 0155291
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/org/apache/cassandra/db/ReadCommand.java
Expand Up @@ -128,7 +128,7 @@ public ReadCommand copy()

public Row getRow(Table table) throws IOException, ColumnFamilyNotDefinedException
{
if (columnNames != EMPTY_COLUMNS)
if (!columnNames.isEmpty())
{
return table.getRow(key, columnFamilyColumn, columnNames);
}
Expand Down
21 changes: 21 additions & 0 deletions test/org/apache/cassandra/db/ReadMessageTest.java
@@ -1,7 +1,10 @@
package org.apache.cassandra.db;

import static org.testng.Assert.assertNull;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

import org.apache.cassandra.io.DataInputBuffer;
import org.apache.cassandra.io.DataOutputBuffer;
Expand Down Expand Up @@ -41,4 +44,22 @@ private ReadCommand serializeAndDeserializeReadMessage(ReadCommand rm)
}
return rm2;
}

@Test
public void testGetColumn() throws IOException, ColumnFamilyNotDefinedException
{
Table table = Table.open("Table1");
RowMutation rm;

// add data
rm = new RowMutation("Table1", "key1");
rm.add("Standard1:Column1", "abcd".getBytes(), 0);
rm.apply();

ReadCommand command = new ReadCommand("Table1", "key1", "Standard1:Column1", -1, Integer.MAX_VALUE);
Row row = command.getRow(table);
ColumnFamily cf = row.getColumnFamily("Standard1");
IColumn col = cf.getColumn("Column1");
assert Arrays.equals(((Column)col).value(), "abcd".getBytes());
}
}

0 comments on commit 0155291

Please sign in to comment.