// also tests TupleSerialKeyExtractor since
// TupleSerialMarshalledKeyExtractor extends it
public void testTupleSerialMarshalledKeyExtractor()
throws IOException {
TupleFormat keyFormat = new TupleFormat();
SerialFormat valueFormat = new SerialFormat(catalog,
MarshalledObject.class);
TupleFormat indexKeyFormat = new TupleFormat();
TupleSerialMarshalledBinding binding =
new TupleSerialMarshalledBinding(keyFormat, valueFormat);
KeyExtractor extractor =
new TupleSerialMarshalledKeyExtractor(binding, indexKeyFormat, "1",
false, true);
assertSame(valueFormat, extractor.getValueFormat());
assertNull(extractor.getPrimaryKeyFormat());
assertSame(indexKeyFormat, extractor.getIndexKeyFormat());
MarshalledObject val = new MarshalledObject("abc", "primary",
"index1", "index2");
binding.objectToValue(val, buffer);
binding.objectToKey(val, keyBuffer);
extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
TupleInput in = indexKeyFormat.dataToInput(indexKeyBuffer);
assertEquals("index1", in.readString());
extractor.clearIndexKey(buffer);
extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
assertEquals(0, indexKeyBuffer.getDataLength());