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.io.IOException;
23 import java.io.StringReader;
24 import java.io.StringWriter;
25 import java.util.Iterator;
26
27 import javax.xml.bind.JAXBContext;
28 import javax.xml.bind.JAXBException;
29
30 import org.apache.hadoop.hbase.SmallTests;
31 import org.apache.hadoop.hbase.util.Base64;
32
33 import junit.framework.TestCase;
34 import org.junit.experimental.categories.Category;
35
36 @Category(SmallTests.class)
37 public class TestTableListModel extends TestModelBase<TableListModel> {
38 private static final String TABLE1 = "table1";
39 private static final String TABLE2 = "table2";
40 private static final String TABLE3 = "table3";
41
42 public TestTableListModel() throws Exception {
43 super(TableListModel.class);
44 AS_XML =
45 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TableList><table " +
46 "name=\"table1\"/><table name=\"table2\"/><table name=\"table3\"/></TableList>";
47
48 AS_PB = "CgZ0YWJsZTEKBnRhYmxlMgoGdGFibGUz";
49
50 AS_JSON =
51 "{\"table\":[{\"name\":\"table1\"},{\"name\":\"table2\"},{\"name\":\"table3\"}]}";
52 }
53
54 protected TableListModel buildTestModel() {
55 TableListModel model = new TableListModel();
56 model.add(new TableModel(TABLE1));
57 model.add(new TableModel(TABLE2));
58 model.add(new TableModel(TABLE3));
59 return model;
60 }
61
62 protected void checkModel(TableListModel model) {
63 Iterator<TableModel> tables = model.getTables().iterator();
64 TableModel table = tables.next();
65 assertEquals(table.getName(), TABLE1);
66 table = tables.next();
67 assertEquals(table.getName(), TABLE2);
68 table = tables.next();
69 assertEquals(table.getName(), TABLE3);
70 assertFalse(tables.hasNext());
71 }
72 }
73