| 217 | // NOTE: The following are tests for HBase 0.96 and up |
| 218 | |
| 219 | @Test |
| 220 | public void serdesOrdering() throws Exception { |
| 221 | PutRequest put1 = new PutRequest(TABLE, concat(KEY, new byte[] { 2 }), |
| 222 | FAMILY, QUALIFIER, VALUE); |
| 223 | put1.region = region; |
| 224 | PutRequest put2 = new PutRequest(TABLE, KEY, FAMILY, "myqual".getBytes(), VALUE); |
| 225 | put2.region = region; |
| 226 | PutRequest put3 = new PutRequest(TABLE, concat(KEY, new byte[] { 2 }), |
| 227 | FAMILY, "myqual".getBytes(), VALUE); |
| 228 | put3.region = region2; |
| 229 | PutRequest put4 = new PutRequest(TABLE, KEY, FAMILY, "myqual".getBytes(), VALUE); |
| 230 | put4.region = region2; |
| 231 | MultiAction multi = new MultiAction(); |
| 232 | multi.add(put1); |
| 233 | multi.add(put2); |
| 234 | multi.add(put3); |
| 235 | multi.add(put4); |
| 236 | |
| 237 | ChannelBuffer buffer = multi.serialize(RegionClient.SERVER_VERSION_095_OR_ABOVE); |
| 238 | buffer.readerIndex(4 + 19 + MultiAction.MMULTI.length); |
| 239 | HBaseRpc.readProtoBufVarint(buffer); |
| 240 | byte[] bytes = new byte[buffer.writerIndex() - buffer.readerIndex()]; |
| 241 | buffer.readBytes(bytes); |
| 242 | MultiRequest parsed = MultiRequest.parseFrom(bytes); |
| 243 | assertEquals(2, parsed.getRegionActionCount()); |
| 244 | |
| 245 | RegionAction actions = parsed.getRegionAction(0); |
| 246 | assertEquals(2, actions.getActionCount()); |
| 247 | assertArrayEquals(region.name(), actions.getRegion().getValue().toByteArray()); |
| 248 | assertArrayEquals(KEY, actions.getAction(0).getMutation().getRow().toByteArray()); |
| 249 | assertArrayEquals(concat(KEY, new byte[] { 2 }), |
| 250 | actions.getAction(1).getMutation().getRow().toByteArray()); |
| 251 | |
| 252 | actions = parsed.getRegionAction(1); |
| 253 | assertEquals(2, actions.getActionCount()); |
| 254 | assertArrayEquals(region2.name(), actions.getRegion().getValue().toByteArray()); |
| 255 | assertArrayEquals(KEY, actions.getAction(0).getMutation().getRow().toByteArray()); |
| 256 | assertArrayEquals(concat(KEY, new byte[] { 2 }), |
| 257 | actions.getAction(1).getMutation().getRow().toByteArray()); |
| 258 | } |
| 259 | |
| 260 | @Test |
| 261 | public void deserializePuts() throws Exception { |