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