1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.rest.model;
21
22 import java.util.Iterator;
23
24 import org.apache.hadoop.hbase.testclassification.SmallTests;
25 import org.apache.hadoop.hbase.util.Bytes;
26
27 import org.junit.experimental.categories.Category;
28
29 @Category(SmallTests.class)
30 public class TestRowModel extends TestModelBase<RowModel> {
31
32 private static final byte[] ROW1 = Bytes.toBytes("testrow1");
33 private static final byte[] COLUMN1 = Bytes.toBytes("testcolumn1");
34 private static final byte[] VALUE1 = Bytes.toBytes("testvalue1");
35 private static final long TIMESTAMP1 = 1245219839331L;
36
37 public TestRowModel() throws Exception {
38 super(RowModel.class);
39 AS_XML =
40 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Row key=\"dGVzdHJvdzE=\">" +
41 "<Cell column=\"dGVzdGNvbHVtbjE=\" timestamp=\"1245219839331\">dGVzdHZhbHVlMQ==</Cell></Row>";
42
43 AS_JSON =
44 "{\"key\":\"dGVzdHJvdzE=\",\"Cell\":[{\"column\":\"dGVzdGNvbHVtbjE=\"," +
45 "\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVlMQ==\"}]}";
46 }
47
48 @Override
49 protected RowModel buildTestModel() {
50 RowModel model = new RowModel();
51 model.setKey(ROW1);
52 model.addCell(new CellModel(COLUMN1, TIMESTAMP1, VALUE1));
53 return model;
54 }
55
56 @Override
57 protected void checkModel(RowModel model) {
58 assertTrue(Bytes.equals(ROW1, model.getKey()));
59 Iterator<CellModel> cells = model.getCells().iterator();
60 CellModel cell = cells.next();
61 assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
62 assertTrue(Bytes.equals(VALUE1, cell.getValue()));
63 assertTrue(cell.hasUserTimestamp());
64 assertEquals(TIMESTAMP1, cell.getTimestamp());
65 assertFalse(cells.hasNext());
66 }
67
68 @Override
69 public void testFromPB() throws Exception {
70
71 }
72 }
73