You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2014/05/14 02:27:04 UTC
svn commit: r1594423 [16/17] - in /hbase/branches/0.89-fb: ./ bin/
src/main/java/org/apache/hadoop/hbase/rest/
src/main/java/org/apache/hadoop/hbase/rest/client/
src/main/java/org/apache/hadoop/hbase/rest/metrics/
src/main/java/org/apache/hadoop/hbase/...
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java Wed May 14 00:26:57 2014
@@ -1,158 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.rest.client.Client;
-import org.apache.hadoop.hbase.rest.client.Cluster;
-import org.apache.hadoop.hbase.rest.client.Response;
-import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;
-import org.apache.hadoop.hbase.rest.model.VersionModel;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-public class TestVersionResource extends HBaseRESTClusterTestBase {
- static final Log LOG = LogFactory.getLog(TestVersionResource.class);
-
- Client client;
- JAXBContext context;
-
- public TestVersionResource() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- VersionModel.class,
- StorageClusterVersionModel.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- client = new Client(new Cluster().add("localhost", testServletPort));
- }
-
- @Override
- protected void tearDown() throws Exception {
- client.shutdown();
- super.tearDown();
- }
-
- void validate(VersionModel model) {
- assertNotNull(model);
- assertNotNull(model.getRESTVersion());
- assertEquals(model.getRESTVersion(), RESTServlet.VERSION_STRING);
- String osVersion = model.getOSVersion();
- assertNotNull(osVersion);
- assertTrue(osVersion.contains(System.getProperty("os.name")));
- assertTrue(osVersion.contains(System.getProperty("os.version")));
- assertTrue(osVersion.contains(System.getProperty("os.arch")));
- String jvmVersion = model.getJVMVersion();
- assertNotNull(jvmVersion);
- assertTrue(jvmVersion.contains(System.getProperty("java.vm.vendor")));
- assertTrue(jvmVersion.contains(System.getProperty("java.version")));
- assertTrue(jvmVersion.contains(System.getProperty("java.vm.version")));
- assertNotNull(model.getServerVersion());
- String jerseyVersion = model.getJerseyVersion();
- assertNotNull(jerseyVersion);
- assertEquals(jerseyVersion, ServletContainer.class.getPackage()
- .getImplementationVersion());
- }
-
- void doTestGetStargateVersionText() throws IOException {
- Response response = client.get("/version", MIMETYPE_TEXT);
- assertTrue(response.getCode() == 200);
- String body = Bytes.toString(response.getBody());
- assertTrue(body.length() > 0);
- assertTrue(body.contains(RESTServlet.VERSION_STRING));
- assertTrue(body.contains(System.getProperty("java.vm.vendor")));
- assertTrue(body.contains(System.getProperty("java.version")));
- assertTrue(body.contains(System.getProperty("java.vm.version")));
- assertTrue(body.contains(System.getProperty("os.name")));
- assertTrue(body.contains(System.getProperty("os.version")));
- assertTrue(body.contains(System.getProperty("os.arch")));
- assertTrue(body.contains(ServletContainer.class.getPackage()
- .getImplementationVersion()));
- }
-
- void doTestGetStargateVersionXML() throws IOException, JAXBException {
- Response response = client.get("/version", MIMETYPE_XML);
- assertTrue(response.getCode() == 200);
- VersionModel model = (VersionModel)
- context.createUnmarshaller().unmarshal(
- new ByteArrayInputStream(response.getBody()));
- validate(model);
- LOG.info("success retrieving Stargate version as XML");
- }
-
- void doTestGetStargateVersionJSON() throws IOException {
- Response response = client.get("/version", MIMETYPE_JSON);
- assertTrue(response.getCode() == 200);
- }
-
- void doTestGetStargateVersionPB() throws IOException {
- Response response = client.get("/version", MIMETYPE_PROTOBUF);
- assertTrue(response.getCode() == 200);
- VersionModel model = new VersionModel();
- model.getObjectFromMessage(response.getBody());
- validate(model);
- LOG.info("success retrieving Stargate version as protobuf");
- }
-
- void doTestGetStorageClusterVersionText() throws IOException {
- Response response = client.get("/version/cluster", MIMETYPE_TEXT);
- assertTrue(response.getCode() == 200);
- }
-
- void doTestGetStorageClusterVersionXML() throws IOException,
- JAXBException {
- Response response = client.get("/version/cluster", MIMETYPE_XML);
- assertTrue(response.getCode() == 200);
- StorageClusterVersionModel clusterVersionModel =
- (StorageClusterVersionModel)
- context.createUnmarshaller().unmarshal(
- new ByteArrayInputStream(response.getBody()));
- assertNotNull(clusterVersionModel);
- assertNotNull(clusterVersionModel.getVersion());
- LOG.info("success retrieving storage cluster version as XML");
- }
-
- void doTestGetStorageClusterVersionJSON() throws IOException {
- Response response = client.get("/version/cluster", MIMETYPE_JSON);
- assertTrue(response.getCode() == 200);
- }
-
- public void testVersionResource() throws Exception {
- doTestGetStargateVersionText();
- doTestGetStargateVersionXML();
- doTestGetStargateVersionJSON();
- doTestGetStargateVersionPB();
- doTestGetStorageClusterVersionText();
- doTestGetStorageClusterVersionXML();
- doTestGetStorageClusterVersionJSON();
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteAdmin.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteAdmin.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteAdmin.java Wed May 14 00:26:57 2014
@@ -1,83 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.client;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.rest.HBaseRESTClusterTestBase;
-import org.apache.hadoop.hbase.rest.client.Client;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class TestRemoteAdmin extends HBaseRESTClusterTestBase {
-
- static final String TABLE_1 = "TestRemoteAdmin_Table_1";
- static final String TABLE_2 = "TestRemoteAdmin_Table_2";
- static final byte[] COLUMN_1 = Bytes.toBytes("a");
-
- static final HTableDescriptor DESC_1;
- static {
- DESC_1 = new HTableDescriptor(TABLE_1);
- DESC_1.addFamily(new HColumnDescriptor(COLUMN_1));
- }
- static final HTableDescriptor DESC_2;
- static {
- DESC_2 = new HTableDescriptor(TABLE_2);
- DESC_2.addFamily(new HColumnDescriptor(COLUMN_1));
- }
-
- Client client;
- HBaseAdmin localAdmin;
- RemoteAdmin remoteAdmin;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- localAdmin = new HBaseAdmin(conf);
- remoteAdmin = new RemoteAdmin(new Client(
- new Cluster().add("localhost", testServletPort)),
- conf);
- if (localAdmin.tableExists(TABLE_1)) {
- localAdmin.disableTable(TABLE_1);
- localAdmin.deleteTable(TABLE_1);
- }
- if (!localAdmin.tableExists(TABLE_2)) {
- localAdmin.createTable(DESC_2);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCreateTable() throws Exception {
- assertFalse(remoteAdmin.isTableAvailable(TABLE_1));
- remoteAdmin.createTable(DESC_1);
- assertTrue(remoteAdmin.isTableAvailable(TABLE_1));
- }
-
- public void testDeleteTable() throws Exception {
- assertTrue(remoteAdmin.isTableAvailable(TABLE_2));
- remoteAdmin.deleteTable(TABLE_2);
- assertFalse(remoteAdmin.isTableAvailable(TABLE_2));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java Wed May 14 00:26:57 2014
@@ -1,330 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.client;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.rest.HBaseRESTClusterTestBase;
-import org.apache.hadoop.hbase.rest.client.Client;
-import org.apache.hadoop.hbase.rest.client.Cluster;
-import org.apache.hadoop.hbase.rest.client.RemoteHTable;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class TestRemoteTable extends HBaseRESTClusterTestBase {
-
- static final String TABLE = "TestRemoteTable";
- static final byte[] ROW_1 = Bytes.toBytes("testrow1");
- static final byte[] ROW_2 = Bytes.toBytes("testrow2");
- static final byte[] ROW_3 = Bytes.toBytes("testrow3");
- static final byte[] ROW_4 = Bytes.toBytes("testrow4");
- static final byte[] COLUMN_1 = Bytes.toBytes("a");
- static final byte[] COLUMN_2 = Bytes.toBytes("b");
- static final byte[] COLUMN_3 = Bytes.toBytes("c");
- static final byte[] QUALIFIER_1 = Bytes.toBytes("1");
- static final byte[] QUALIFIER_2 = Bytes.toBytes("2");
- static final byte[] QUALIFIER_3 = Bytes.toBytes("3");
- static final byte[] VALUE_1 = Bytes.toBytes("testvalue1");
- static final byte[] VALUE_2 = Bytes.toBytes("testvalue2");
- static final byte[] VALUE_3 = Bytes.toBytes("testvalue3");
-
- static final long ONE_HOUR = 60 * 60 * 1000;
- static final long TS_2 = System.currentTimeMillis();
- static final long TS_1 = TS_2 - ONE_HOUR;
-
- Client client;
- HBaseAdmin admin;
- RemoteHTable remoteTable;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- admin = new HBaseAdmin(conf);
- if (!admin.tableExists(TABLE)) {
- HTableDescriptor htd = new HTableDescriptor(TABLE);
- htd.addFamily(new HColumnDescriptor(COLUMN_1));
- htd.addFamily(new HColumnDescriptor(COLUMN_2));
- htd.addFamily(new HColumnDescriptor(COLUMN_3));
- admin.createTable(htd);
- HTable table = new HTable(conf, TABLE);
- Put put = new Put(ROW_1);
- put.add(COLUMN_1, QUALIFIER_1, TS_2, VALUE_1);
- table.put(put);
- put = new Put(ROW_2);
- put.add(COLUMN_1, QUALIFIER_1, TS_1, VALUE_1);
- put.add(COLUMN_1, QUALIFIER_1, TS_2, VALUE_2);
- put.add(COLUMN_2, QUALIFIER_2, TS_2, VALUE_2);
- table.put(put);
- table.flushCommits();
- }
- remoteTable = new RemoteHTable(
- new Client(new Cluster().add("localhost", testServletPort)),
- conf, TABLE, null);
- }
-
- @Override
- protected void tearDown() throws Exception {
- remoteTable.close();
- super.tearDown();
- }
-
- public void testGetTableDescriptor() throws IOException {
- HTableDescriptor local = new HTable(conf, TABLE).getTableDescriptor();
- assertEquals(remoteTable.getTableDescriptor(), local);
- }
-
- public void testGet() throws IOException {
- Get get = new Get(ROW_1);
- Result result = remoteTable.get(get);
- byte[] value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- byte[] value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1));
- assertNull(value2);
-
- get = new Get(ROW_1);
- get.addFamily(COLUMN_3);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNull(value1);
- assertNull(value2);
-
- get = new Get(ROW_1);
- get.addColumn(COLUMN_1, QUALIFIER_1);
- get.addColumn(COLUMN_2, QUALIFIER_2);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1));
- assertNull(value2);
-
- get = new Get(ROW_2);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_2, value1)); // @TS_2
- assertNotNull(value2);
- assertTrue(Bytes.equals(VALUE_2, value2));
-
- get = new Get(ROW_2);
- get.addFamily(COLUMN_1);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_2, value1)); // @TS_2
- assertNull(value2);
-
- get = new Get(ROW_2);
- get.addColumn(COLUMN_1, QUALIFIER_1);
- get.addColumn(COLUMN_2, QUALIFIER_2);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_2, value1)); // @TS_2
- assertNotNull(value2);
- assertTrue(Bytes.equals(VALUE_2, value2));
-
- // test timestamp
-
- get = new Get(ROW_2);
- get.addFamily(COLUMN_1);
- get.addFamily(COLUMN_2);
- get.setTimeStamp(TS_1);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1)); // @TS_1
- assertNull(value2);
-
- // test timerange
-
- get = new Get(ROW_2);
- get.addFamily(COLUMN_1);
- get.addFamily(COLUMN_2);
- get.setTimeRange(0, TS_1 + 1);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1)); // @TS_1
- assertNull(value2);
-
- // test maxVersions
-
- get = new Get(ROW_2);
- get.addFamily(COLUMN_1);
- get.setMaxVersions(2);
- result = remoteTable.get(get);
- int count = 0;
- for (KeyValue kv: result.list()) {
- if (Bytes.equals(COLUMN_1, kv.getFamily()) && TS_1 == kv.getTimestamp()) {
- assertTrue(Bytes.equals(VALUE_1, kv.getValue())); // @TS_1
- count++;
- }
- if (Bytes.equals(COLUMN_1, kv.getFamily()) && TS_2 == kv.getTimestamp()) {
- assertTrue(Bytes.equals(VALUE_2, kv.getValue())); // @TS_2
- count++;
- }
- }
- assertEquals(2, count);
- }
-
- public void testPut() throws IOException {
- Put put = new Put(ROW_3);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- remoteTable.put(put);
-
- Get get = new Get(ROW_3);
- get.addFamily(COLUMN_1);
- Result result = remoteTable.get(get);
- byte[] value = result.getValue(COLUMN_1, QUALIFIER_1);
- assertNotNull(value);
- assertTrue(Bytes.equals(VALUE_1, value));
-
- // multiput
-
- List<Put> puts = new ArrayList<Put>();
- put = new Put(ROW_3);
- put.add(COLUMN_2, QUALIFIER_2, VALUE_2);
- puts.add(put);
- put = new Put(ROW_4);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- puts.add(put);
- put = new Put(ROW_4);
- put.add(COLUMN_2, QUALIFIER_2, VALUE_2);
- puts.add(put);
- remoteTable.put(puts);
-
- get = new Get(ROW_3);
- get.addFamily(COLUMN_2);
- result = remoteTable.get(get);
- value = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value);
- assertTrue(Bytes.equals(VALUE_2, value));
- get = new Get(ROW_4);
- result = remoteTable.get(get);
- value = result.getValue(COLUMN_1, QUALIFIER_1);
- assertNotNull(value);
- assertTrue(Bytes.equals(VALUE_1, value));
- value = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value);
- assertTrue(Bytes.equals(VALUE_2, value));
- }
-
- public void testDelete() throws IOException {
- Put put = new Put(ROW_3);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- put.add(COLUMN_2, QUALIFIER_2, VALUE_2);
- remoteTable.put(put);
-
- Get get = new Get(ROW_3);
- get.addFamily(COLUMN_1);
- get.addFamily(COLUMN_2);
- Result result = remoteTable.get(get);
- byte[] value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- byte[] value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1));
- assertNotNull(value2);
- assertTrue(Bytes.equals(VALUE_2, value2));
-
- Delete delete = new Delete(ROW_3);
- delete.deleteColumn(COLUMN_2, QUALIFIER_2);
- remoteTable.delete(delete);
-
- get = new Get(ROW_3);
- get.addFamily(COLUMN_1);
- get.addFamily(COLUMN_2);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNotNull(value1);
- assertTrue(Bytes.equals(VALUE_1, value1));
- assertNull(value2);
-
- delete = new Delete(ROW_3);
- remoteTable.delete(delete);
-
- get = new Get(ROW_3);
- get.addFamily(COLUMN_1);
- get.addFamily(COLUMN_2);
- result = remoteTable.get(get);
- value1 = result.getValue(COLUMN_1, QUALIFIER_1);
- value2 = result.getValue(COLUMN_2, QUALIFIER_2);
- assertNull(value1);
- assertNull(value2);
- }
-
- public void testScanner() throws IOException {
- List<Put> puts = new ArrayList<Put>();
- Put put = new Put(ROW_1);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- puts.add(put);
- put = new Put(ROW_2);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- puts.add(put);
- put = new Put(ROW_3);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- puts.add(put);
- put = new Put(ROW_4);
- put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
- puts.add(put);
- remoteTable.put(puts);
-
- ResultScanner scanner = remoteTable.getScanner(new Scan());
-
- Result[] results = scanner.next(1);
- assertNotNull(results);
- assertEquals(1, results.length);
- assertTrue(Bytes.equals(ROW_1, results[0].getRow()));
-
- results = scanner.next(3);
- assertNotNull(results);
- assertEquals(3, results.length);
- assertTrue(Bytes.equals(ROW_2, results[0].getRow()));
- assertTrue(Bytes.equals(ROW_3, results[1].getRow()));
- assertTrue(Bytes.equals(ROW_4, results[2].getRow()));
-
- results = scanner.next(1);
- assertNull(results);
-
- scanner.close();
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java Wed May 14 00:26:57 2014
@@ -1,104 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestCellModel extends TestCase {
-
- private static final long TIMESTAMP = 1245219839331L;
- private static final byte[] COLUMN = Bytes.toBytes("testcolumn");
- private static final byte[] VALUE = Bytes.toBytes("testvalue");
-
- private static final String AS_XML =
- "<Cell timestamp=\"1245219839331\"" +
- " column=\"dGVzdGNvbHVtbg==\">" +
- "dGVzdHZhbHVl</Cell>";
-
- private static final String AS_PB =
- "Egp0ZXN0Y29sdW1uGOO6i+eeJCIJdGVzdHZhbHVl";
-
- private JAXBContext context;
-
- public TestCellModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(CellModel.class);
- }
-
- private CellModel buildTestModel() {
- CellModel model = new CellModel();
- model.setColumn(COLUMN);
- model.setTimestamp(TIMESTAMP);
- model.setValue(VALUE);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(CellModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private CellModel fromXML(String xml) throws JAXBException {
- return (CellModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(CellModel model) {
- return model.createProtobufOutput();
- }
-
- private CellModel fromPB(String pb) throws IOException {
- return (CellModel)
- new CellModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(CellModel model) {
- assertTrue(Bytes.equals(model.getColumn(), COLUMN));
- assertTrue(Bytes.equals(model.getValue(), VALUE));
- assertTrue(model.hasUserTimestamp());
- assertEquals(model.getTimestamp(), TIMESTAMP);
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java Wed May 14 00:26:57 2014
@@ -1,154 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestCellSetModel extends TestCase {
-
- private static final byte[] ROW1 = Bytes.toBytes("testrow1");
- private static final byte[] COLUMN1 = Bytes.toBytes("testcolumn1");
- private static final byte[] VALUE1 = Bytes.toBytes("testvalue1");
- private static final long TIMESTAMP1 = 1245219839331L;
- private static final byte[] ROW2 = Bytes.toBytes("testrow1");
- private static final byte[] COLUMN2 = Bytes.toBytes("testcolumn2");
- private static final byte[] VALUE2 = Bytes.toBytes("testvalue2");
- private static final long TIMESTAMP2 = 1245239813319L;
- private static final byte[] COLUMN3 = Bytes.toBytes("testcolumn3");
- private static final byte[] VALUE3 = Bytes.toBytes("testvalue3");
- private static final long TIMESTAMP3 = 1245393318192L;
-
- private static final String AS_XML =
- "<CellSet>" +
- "<Row key=\"dGVzdHJvdzE=\">" +
- "<Cell timestamp=\"1245219839331\" column=\"dGVzdGNvbHVtbjE=\">" +
- "dGVzdHZhbHVlMQ==</Cell>" +
- "</Row>" +
- "<Row key=\"dGVzdHJvdzE=\">" +
- "<Cell timestamp=\"1245239813319\" column=\"dGVzdGNvbHVtbjI=\">" +
- "dGVzdHZhbHVlMg==</Cell>" +
- "<Cell timestamp=\"1245393318192\" column=\"dGVzdGNvbHVtbjM=\">" +
- "dGVzdHZhbHVlMw==</Cell>" +
- "</Row>" +
- "</CellSet>";
-
- private static final String AS_PB =
- "CiwKCHRlc3Ryb3cxEiASC3Rlc3Rjb2x1bW4xGOO6i+eeJCIKdGVzdHZhbHVlMQpOCgh0ZXN0cm93" +
- "MRIgEgt0ZXN0Y29sdW1uMhjHyc7wniQiCnRlc3R2YWx1ZTISIBILdGVzdGNvbHVtbjMYsOLnuZ8k" +
- "Igp0ZXN0dmFsdWUz";
-
- private JAXBContext context;
-
- public TestCellSetModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- CellModel.class,
- CellSetModel.class,
- RowModel.class);
- }
-
- private CellSetModel buildTestModel() {
- CellSetModel model = new CellSetModel();
- RowModel row;
- row = new RowModel();
- row.setKey(ROW1);
- row.addCell(new CellModel(COLUMN1, TIMESTAMP1, VALUE1));
- model.addRow(row);
- row = new RowModel();
- row.setKey(ROW2);
- row.addCell(new CellModel(COLUMN2, TIMESTAMP2, VALUE2));
- row.addCell(new CellModel(COLUMN3, TIMESTAMP3, VALUE3));
- model.addRow(row);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(CellSetModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private CellSetModel fromXML(String xml) throws JAXBException {
- return (CellSetModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(CellSetModel model) {
- return model.createProtobufOutput();
- }
-
- private CellSetModel fromPB(String pb) throws IOException {
- return (CellSetModel)
- new CellSetModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(CellSetModel model) {
- Iterator<RowModel> rows = model.getRows().iterator();
- RowModel row = rows.next();
- assertTrue(Bytes.equals(ROW1, row.getKey()));
- Iterator<CellModel> cells = row.getCells().iterator();
- CellModel cell = cells.next();
- assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
- assertTrue(Bytes.equals(VALUE1, cell.getValue()));
- assertTrue(cell.hasUserTimestamp());
- assertEquals(cell.getTimestamp(), TIMESTAMP1);
- assertFalse(cells.hasNext());
- row = rows.next();
- assertTrue(Bytes.equals(ROW2, row.getKey()));
- cells = row.getCells().iterator();
- cell = cells.next();
- assertTrue(Bytes.equals(COLUMN2, cell.getColumn()));
- assertTrue(Bytes.equals(VALUE2, cell.getValue()));
- assertTrue(cell.hasUserTimestamp());
- assertEquals(cell.getTimestamp(), TIMESTAMP2);
- cell = cells.next();
- assertTrue(Bytes.equals(COLUMN3, cell.getColumn()));
- assertTrue(Bytes.equals(VALUE3, cell.getValue()));
- assertTrue(cell.hasUserTimestamp());
- assertEquals(cell.getTimestamp(), TIMESTAMP3);
- assertFalse(cells.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java Wed May 14 00:26:57 2014
@@ -1,102 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import junit.framework.TestCase;
-
-public class TestColumnSchemaModel extends TestCase {
-
- protected static final String COLUMN_NAME = "testcolumn";
- protected static final boolean BLOCKCACHE = true;
- protected static final int BLOCKSIZE = 16384;
- protected static final String BLOOMFILTER = "NONE";
- protected static final String COMPRESSION = "GZ";
- protected static final boolean IN_MEMORY = false;
- protected static final int TTL = 86400;
- protected static final int VERSIONS = 1;
-
- protected static final String AS_XML =
- "<ColumnSchema name=\"testcolumn\"" +
- " BLOCKSIZE=\"16384\"" +
- " BLOOMFILTER=\"NONE\"" +
- " BLOCKCACHE=\"true\"" +
- " COMPRESSION=\"GZ\"" +
- " VERSIONS=\"1\"" +
- " TTL=\"86400\"" +
- " IN_MEMORY=\"false\"/>";
-
- private JAXBContext context;
-
- public TestColumnSchemaModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(ColumnSchemaModel.class);
- }
-
- protected static ColumnSchemaModel buildTestModel() {
- ColumnSchemaModel model = new ColumnSchemaModel();
- model.setName(COLUMN_NAME);
- model.__setBlockcache(BLOCKCACHE);
- model.__setBlocksize(BLOCKSIZE);
- model.__setBloomfilter(BLOOMFILTER);
- model.__setCompression(COMPRESSION);
- model.__setInMemory(IN_MEMORY);
- model.__setTTL(TTL);
- model.__setVersions(VERSIONS);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(ColumnSchemaModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private ColumnSchemaModel fromXML(String xml) throws JAXBException {
- return (ColumnSchemaModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- protected static void checkModel(ColumnSchemaModel model) {
- assertEquals(model.getName(), COLUMN_NAME);
- assertEquals(model.__getBlockcache(), BLOCKCACHE);
- assertEquals(model.__getBlocksize(), BLOCKSIZE);
- assertEquals(model.__getBloomfilter(), BLOOMFILTER);
- assertTrue(model.__getCompression().equalsIgnoreCase(COMPRESSION));
- assertEquals(model.__getInMemory(), IN_MEMORY);
- assertEquals(model.__getTTL(), TTL);
- assertEquals(model.__getVersions(), VERSIONS);
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestRowModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestRowModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestRowModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestRowModel.java Wed May 14 00:26:57 2014
@@ -1,93 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestRowModel extends TestCase {
-
- private static final byte[] ROW1 = Bytes.toBytes("testrow1");
- private static final byte[] COLUMN1 = Bytes.toBytes("testcolumn1");
- private static final byte[] VALUE1 = Bytes.toBytes("testvalue1");
- private static final long TIMESTAMP1 = 1245219839331L;
-
- private static final String AS_XML =
- "<Row key=\"dGVzdHJvdzE=\">" +
- "<Cell timestamp=\"1245219839331\" column=\"dGVzdGNvbHVtbjE=\">" +
- "dGVzdHZhbHVlMQ==</Cell>" +
- "</Row>";
-
- private JAXBContext context;
-
- public TestRowModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- CellModel.class,
- RowModel.class);
- }
-
- private RowModel buildTestModel() {
- RowModel model = new RowModel();
- model.setKey(ROW1);
- model.addCell(new CellModel(COLUMN1, TIMESTAMP1, VALUE1));
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(RowModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private RowModel fromXML(String xml) throws JAXBException {
- return (RowModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- private void checkModel(RowModel model) {
- assertTrue(Bytes.equals(ROW1, model.getKey()));
- Iterator<CellModel> cells = model.getCells().iterator();
- CellModel cell = cells.next();
- assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
- assertTrue(Bytes.equals(VALUE1, cell.getValue()));
- assertTrue(cell.hasUserTimestamp());
- assertEquals(cell.getTimestamp(), TIMESTAMP1);
- assertFalse(cells.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java Wed May 14 00:26:57 2014
@@ -1,128 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestScannerModel extends TestCase {
- private static final byte[] START_ROW = Bytes.toBytes("abracadabra");
- private static final byte[] END_ROW = Bytes.toBytes("zzyzx");
- private static final byte[] COLUMN1 = Bytes.toBytes("column1");
- private static final byte[] COLUMN2 = Bytes.toBytes("column2:foo");
- private static final long START_TIME = 1245219839331L;
- private static final long END_TIME = 1245393318192L;
- private static final int BATCH = 100;
-
- private static final String AS_XML =
- "<Scanner startTime=\"1245219839331\"" +
- " startRow=\"YWJyYWNhZGFicmE=\"" +
- " endTime=\"1245393318192\"" +
- " endRow=\"enp5eng=\"" +
- " batch=\"100\">" +
- "<column>Y29sdW1uMQ==</column>" +
- "<column>Y29sdW1uMjpmb28=</column>" +
- "</Scanner>";
-
- private static final String AS_PB =
- "CgthYnJhY2FkYWJyYRIFenp5engaB2NvbHVtbjEaC2NvbHVtbjI6Zm9vIGQo47qL554kMLDi57mf" +
- "JA==";
-
- private JAXBContext context;
-
- public TestScannerModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(ScannerModel.class);
- }
-
- private ScannerModel buildTestModel() {
- ScannerModel model = new ScannerModel();
- model.setStartRow(START_ROW);
- model.setEndRow(END_ROW);
- model.addColumn(COLUMN1);
- model.addColumn(COLUMN2);
- model.setStartTime(START_TIME);
- model.setEndTime(END_TIME);
- model.setBatch(BATCH);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(ScannerModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private ScannerModel fromXML(String xml) throws JAXBException {
- return (ScannerModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(ScannerModel model) {
- return model.createProtobufOutput();
- }
-
- private ScannerModel fromPB(String pb) throws IOException {
- return (ScannerModel)
- new ScannerModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(ScannerModel model) {
- assertTrue(Bytes.equals(model.getStartRow(), START_ROW));
- assertTrue(Bytes.equals(model.getEndRow(), END_ROW));
- boolean foundCol1 = false, foundCol2 = false;
- for (byte[] column: model.getColumns()) {
- if (Bytes.equals(column, COLUMN1)) {
- foundCol1 = true;
- } else if (Bytes.equals(column, COLUMN2)) {
- foundCol2 = true;
- }
- }
- assertTrue(foundCol1);
- assertTrue(foundCol2);
- assertEquals(model.getStartTime(), START_TIME);
- assertEquals(model.getEndTime(), END_TIME);
- assertEquals(model.getBatch(), BATCH);
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java Wed May 14 00:26:57 2014
@@ -1,148 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestStorageClusterStatusModel extends TestCase {
-
- private static final String AS_XML =
- "<ClusterStatus requests=\"0\" regions=\"2\" averageLoad=\"1.0\">" +
- "<DeadNodes/>" +
- "<LiveNodes><Node startCode=\"1245219839331\" requests=\"0\"" +
- " name=\"test1\" maxHeapSizeMB=\"1024\" heapSizeMB=\"128\">" +
- "<Region stores=\"1\" storefiles=\"1\" storefileSizeMB=\"0\"" +
- " storefileIndexSizeMB=\"0\" name=\"LVJPT1QtLCww\"" +
- " memstoreSizeMB=\"0\"/></Node>" +
- "<Node startCode=\"1245239331198\" requests=\"0\" name=\"test2\"" +
- " maxHeapSizeMB=\"1024\" heapSizeMB=\"512\">" +
- "<Region stores=\"1\" storefiles=\"1\" storefileSizeMB=\"0\"" +
- " storefileIndexSizeMB=\"0\" name=\"Lk1FVEEuLCwxMjQ2MDAwMDQzNzI0\"" +
- " memstoreSizeMB=\"0\"/></Node>"+
- "</LiveNodes></ClusterStatus>";
-
- private static final String AS_PB =
-"Ci0KBXRlc3QxEOO6i+eeJBgAIIABKIAIMhUKCS1ST09ULSwsMBABGAEgACgAMAAKOQoFdGVzdDIQ"+
-"/pKx8J4kGAAggAQogAgyIQoVLk1FVEEuLCwxMjQ2MDAwMDQzNzI0EAEYASAAKAAwABgCIAApAAAA"+
-"AAAA8D8=";
-
- private JAXBContext context;
-
- public TestStorageClusterStatusModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(StorageClusterStatusModel.class);
- }
-
- private StorageClusterStatusModel buildTestModel() {
- StorageClusterStatusModel model = new StorageClusterStatusModel();
- model.setRegions(2);
- model.setRequests(0);
- model.setAverageLoad(1.0);
- model.addLiveNode("test1", 1245219839331L, 128, 1024)
- .addRegion(Bytes.toBytes("-ROOT-,,0"), 1, 1, 0, 0, 0);
- model.addLiveNode("test2", 1245239331198L, 512, 1024)
- .addRegion(Bytes.toBytes(".META.,,1246000043724"),1, 1, 0, 0, 0);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(StorageClusterStatusModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private StorageClusterStatusModel fromXML(String xml) throws JAXBException {
- return (StorageClusterStatusModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(StorageClusterStatusModel model) {
- return model.createProtobufOutput();
- }
-
- private StorageClusterStatusModel fromPB(String pb) throws IOException {
- return (StorageClusterStatusModel)
- new StorageClusterStatusModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(StorageClusterStatusModel model) {
- assertEquals(model.getRegions(), 2);
- assertEquals(model.getRequests(), 0);
- assertEquals(model.getAverageLoad(), 1.0);
- Iterator<StorageClusterStatusModel.Node> nodes =
- model.getLiveNodes().iterator();
- StorageClusterStatusModel.Node node = nodes.next();
- assertEquals(node.getName(), "test1");
- assertEquals(node.getStartCode(), 1245219839331L);
- assertEquals(node.getHeapSizeMB(), 128);
- assertEquals(node.getMaxHeapSizeMB(), 1024);
- Iterator<StorageClusterStatusModel.Node.Region> regions =
- node.getRegions().iterator();
- StorageClusterStatusModel.Node.Region region = regions.next();
- assertTrue(Bytes.toString(region.getName()).equals("-ROOT-,,0"));
- assertEquals(region.getStores(), 1);
- assertEquals(region.getStorefiles(), 1);
- assertEquals(region.getStorefileSizeMB(), 0);
- assertEquals(region.getMemstoreSizeMB(), 0);
- assertEquals(region.getStorefileIndexSizeMB(), 0);
- assertFalse(regions.hasNext());
- node = nodes.next();
- assertEquals(node.getName(), "test2");
- assertEquals(node.getStartCode(), 1245239331198L);
- assertEquals(node.getHeapSizeMB(), 512);
- assertEquals(node.getMaxHeapSizeMB(), 1024);
- regions = node.getRegions().iterator();
- region = regions.next();
- assertEquals(Bytes.toString(region.getName()), ".META.,,1246000043724");
- assertEquals(region.getStores(), 1);
- assertEquals(region.getStorefiles(), 1);
- assertEquals(region.getStorefileSizeMB(), 0);
- assertEquals(region.getMemstoreSizeMB(), 0);
- assertEquals(region.getStorefileIndexSizeMB(), 0);
- assertFalse(regions.hasNext());
- assertFalse(nodes.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java Wed May 14 00:26:57 2014
@@ -1,73 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import junit.framework.TestCase;
-
-public class TestStorageClusterVersionModel extends TestCase {
- private static final String VERSION = "0.0.1-testing";
-
- private static final String AS_XML =
- "<ClusterVersion>" + VERSION + "</ClusterVersion>";
-
- private JAXBContext context;
-
- public TestStorageClusterVersionModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(StorageClusterVersionModel.class);
- }
-
- private StorageClusterVersionModel buildTestModel() {
- StorageClusterVersionModel model = new StorageClusterVersionModel();
- model.setVersion(VERSION);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(StorageClusterVersionModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private StorageClusterVersionModel fromXML(String xml) throws JAXBException {
- return (StorageClusterVersionModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- private void checkModel(StorageClusterVersionModel model) {
- assertEquals(model.getVersion(), VERSION);
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableInfoModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableInfoModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableInfoModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableInfoModel.java Wed May 14 00:26:57 2014
@@ -1,116 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestTableInfoModel extends TestCase {
- private static final String TABLE = "testtable";
- private static final byte[] START_KEY = Bytes.toBytes("abracadbra");
- private static final byte[] END_KEY = Bytes.toBytes("zzyzx");
- private static final long ID = 8731042424L;
- private static final String LOCATION = "testhost:9876";
-
- private static final String AS_XML =
- "<TableInfo name=\"testtable\">" +
- "<Region location=\"testhost:9876\"" +
- " endKey=\"enp5eng=\"" +
- " startKey=\"YWJyYWNhZGJyYQ==\"" +
- " id=\"8731042424\"" +
- " name=\"testtable,abracadbra,8731042424\"/>" +
- "</TableInfo>";
-
- private static final String AS_PB =
- "Cgl0ZXN0dGFibGUSSQofdGVzdHRhYmxlLGFicmFjYWRicmEsODczMTA0MjQyNBIKYWJyYWNhZGJy" +
- "YRoFenp5engg+MSkwyAqDXRlc3Rob3N0Ojk4NzY=";
-
- private JAXBContext context;
-
- public TestTableInfoModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- TableInfoModel.class,
- TableRegionModel.class);
- }
-
- private TableInfoModel buildTestModel() {
- TableInfoModel model = new TableInfoModel();
- model.setName(TABLE);
- model.add(new TableRegionModel(TABLE, ID, START_KEY, END_KEY, LOCATION));
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(TableInfoModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private TableInfoModel fromXML(String xml) throws JAXBException {
- return (TableInfoModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(TableInfoModel model) {
- return model.createProtobufOutput();
- }
-
- private TableInfoModel fromPB(String pb) throws IOException {
- return (TableInfoModel)
- new TableInfoModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(TableInfoModel model) {
- assertEquals(model.getName(), TABLE);
- Iterator<TableRegionModel> regions = model.getRegions().iterator();
- TableRegionModel region = regions.next();
- assertTrue(Bytes.equals(region.getStartKey(), START_KEY));
- assertTrue(Bytes.equals(region.getEndKey(), END_KEY));
- assertEquals(region.getId(), ID);
- assertEquals(region.getLocation(), LOCATION);
- assertFalse(regions.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableListModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableListModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableListModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableListModel.java Wed May 14 00:26:57 2014
@@ -1,107 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-
-import junit.framework.TestCase;
-
-public class TestTableListModel extends TestCase {
- private static final String TABLE1 = "table1";
- private static final String TABLE2 = "table2";
- private static final String TABLE3 = "table3";
-
- private static final String AS_XML =
- "<TableList><table name=\"table1\"/><table name=\"table2\"/>" +
- "<table name=\"table3\"/></TableList>";
-
- private static final String AS_PB = "CgZ0YWJsZTEKBnRhYmxlMgoGdGFibGUz";
-
- private JAXBContext context;
-
- public TestTableListModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- TableListModel.class,
- TableModel.class);
- }
-
- private TableListModel buildTestModel() {
- TableListModel model = new TableListModel();
- model.add(new TableModel(TABLE1));
- model.add(new TableModel(TABLE2));
- model.add(new TableModel(TABLE3));
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(TableListModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private TableListModel fromXML(String xml) throws JAXBException {
- return (TableListModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(TableListModel model) {
- return model.createProtobufOutput();
- }
-
- private TableListModel fromPB(String pb) throws IOException {
- return (TableListModel)
- new TableListModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(TableListModel model) {
- Iterator<TableModel> tables = model.getTables().iterator();
- TableModel table = tables.next();
- assertEquals(table.getName(), TABLE1);
- table = tables.next();
- assertEquals(table.getName(), TABLE2);
- table = tables.next();
- assertEquals(table.getName(), TABLE3);
- assertFalse(tables.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableRegionModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableRegionModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableRegionModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableRegionModel.java Wed May 14 00:26:57 2014
@@ -1,88 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
-
-public class TestTableRegionModel extends TestCase {
- private static final String TABLE = "testtable";
- private static final byte[] START_KEY = Bytes.toBytes("abracadbra");
- private static final byte[] END_KEY = Bytes.toBytes("zzyzx");
- private static final long ID = 8731042424L;
- private static final String LOCATION = "testhost:9876";
-
- private static final String AS_XML =
- "<Region location=\"testhost:9876\"" +
- " endKey=\"enp5eng=\"" +
- " startKey=\"YWJyYWNhZGJyYQ==\"" +
- " id=\"8731042424\"" +
- " name=\"testtable,abracadbra,8731042424\"/>";
-
- private JAXBContext context;
-
- public TestTableRegionModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(TableRegionModel.class);
- }
-
- private TableRegionModel buildTestModel() {
- TableRegionModel model =
- new TableRegionModel(TABLE, ID, START_KEY, END_KEY, LOCATION);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(TableRegionModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private TableRegionModel fromXML(String xml) throws JAXBException {
- return (TableRegionModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- private void checkModel(TableRegionModel model) {
- assertTrue(Bytes.equals(model.getStartKey(), START_KEY));
- assertTrue(Bytes.equals(model.getEndKey(), END_KEY));
- assertEquals(model.getId(), ID);
- assertEquals(model.getLocation(), LOCATION);
- assertEquals(model.getName(),
- TABLE + "," + Bytes.toString(START_KEY) + "," + Long.toString(ID));
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java Wed May 14 00:26:57 2014
@@ -1,128 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-
-import junit.framework.TestCase;
-
-public class TestTableSchemaModel extends TestCase {
-
- public static final String TABLE_NAME = "testTable";
- private static final boolean IS_META = false;
- private static final boolean IS_ROOT = false;
- private static final boolean READONLY = false;
-
- private static final String AS_XML =
- "<TableSchema name=\"testTable\"" +
- " IS_META=\"false\"" +
- " IS_ROOT=\"false\"" +
- " READONLY=\"false\">" +
- TestColumnSchemaModel.AS_XML +
- "</TableSchema>";
-
- private static final String AS_PB =
- "Cgl0ZXN0VGFibGUSEAoHSVNfTUVUQRIFZmFsc2USEAoHSVNfUk9PVBIFZmFsc2USEQoIUkVBRE9O" +
- "TFkSBWZhbHNlGpcBCgp0ZXN0Y29sdW1uEhIKCUJMT0NLU0laRRIFMTYzODQSEwoLQkxPT01GSUxU" +
- "RVISBE5PTkUSEgoKQkxPQ0tDQUNIRRIEdHJ1ZRIRCgtDT01QUkVTU0lPThICR1oSDQoIVkVSU0lP" +
- "TlMSATESDAoDVFRMEgU4NjQwMBISCglJTl9NRU1PUlkSBWZhbHNlGICjBSABKgJHWigA";
-
- private JAXBContext context;
-
- public TestTableSchemaModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(
- ColumnSchemaModel.class,
- TableSchemaModel.class);
- }
-
- public static TableSchemaModel buildTestModel() {
- return buildTestModel(TABLE_NAME);
- }
-
- public static TableSchemaModel buildTestModel(String name) {
- TableSchemaModel model = new TableSchemaModel();
- model.setName(name);
- model.__setIsMeta(IS_META);
- model.__setIsRoot(IS_ROOT);
- model.__setReadOnly(READONLY);
- model.addColumnFamily(TestColumnSchemaModel.buildTestModel());
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(TableSchemaModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private TableSchemaModel fromXML(String xml) throws JAXBException {
- return (TableSchemaModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(TableSchemaModel model) {
- return model.createProtobufOutput();
- }
-
- private TableSchemaModel fromPB(String pb) throws IOException {
- return (TableSchemaModel)
- new TableSchemaModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- public static void checkModel(TableSchemaModel model) {
- checkModel(model, TABLE_NAME);
- }
-
- public static void checkModel(TableSchemaModel model, String tableName) {
- assertEquals(model.getName(), tableName);
- assertEquals(model.__getIsMeta(), IS_META);
- assertEquals(model.__getIsRoot(), IS_ROOT);
- assertEquals(model.__getReadOnly(), READONLY);
- Iterator<ColumnSchemaModel> families = model.getColumns().iterator();
- assertTrue(families.hasNext());
- ColumnSchemaModel family = families.next();
- TestColumnSchemaModel.checkModel(family);
- assertFalse(families.hasNext());
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestVersionModel.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestVersionModel.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestVersionModel.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/rest/model/TestVersionModel.java Wed May 14 00:26:57 2014
@@ -1,112 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest.model;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.apache.hadoop.hbase.util.Base64;
-
-import junit.framework.TestCase;
-
-public class TestVersionModel extends TestCase {
- private static final String REST_VERSION = "0.0.1";
- private static final String OS_VERSION =
- "Linux 2.6.18-128.1.6.el5.centos.plusxen amd64";
- private static final String JVM_VERSION =
- "Sun Microsystems Inc. 1.6.0_13-11.3-b02";
- private static final String JETTY_VERSION = "6.1.14";
- private static final String JERSEY_VERSION = "1.1.0-ea";
-
- private static final String AS_XML =
- "<Version REST=\"" + REST_VERSION + "\"" +
- " OS=\"" + OS_VERSION + "\"" +
- " JVM=\"" + JVM_VERSION + "\"" +
- " Server=\"" + JETTY_VERSION + "\"" +
- " Jersey=\"" + JERSEY_VERSION + "\"/>";
-
- private static final String AS_PB =
- "CgUwLjAuMRInU3VuIE1pY3Jvc3lzdGVtcyBJbmMuIDEuNi4wXzEzLTExLjMtYjAyGi1MaW51eCAy" +
- "LjYuMTgtMTI4LjEuNi5lbDUuY2VudG9zLnBsdXN4ZW4gYW1kNjQiBjYuMS4xNCoIMS4xLjAtZWE=";
-
- private JAXBContext context;
-
- public TestVersionModel() throws JAXBException {
- super();
- context = JAXBContext.newInstance(VersionModel.class);
- }
-
- private VersionModel buildTestModel() {
- VersionModel model = new VersionModel();
- model.setRESTVersion(REST_VERSION);
- model.setOSVersion(OS_VERSION);
- model.setJVMVersion(JVM_VERSION);
- model.setServerVersion(JETTY_VERSION);
- model.setJerseyVersion(JERSEY_VERSION);
- return model;
- }
-
- @SuppressWarnings("unused")
- private String toXML(VersionModel model) throws JAXBException {
- StringWriter writer = new StringWriter();
- context.createMarshaller().marshal(model, writer);
- return writer.toString();
- }
-
- private VersionModel fromXML(String xml) throws JAXBException {
- return (VersionModel)
- context.createUnmarshaller().unmarshal(new StringReader(xml));
- }
-
- @SuppressWarnings("unused")
- private byte[] toPB(VersionModel model) {
- return model.createProtobufOutput();
- }
-
- private VersionModel fromPB(String pb) throws IOException {
- return (VersionModel)
- new VersionModel().getObjectFromMessage(Base64.decode(AS_PB));
- }
-
- private void checkModel(VersionModel model) {
- assertEquals(model.getRESTVersion(), REST_VERSION);
- assertEquals(model.getOSVersion(), OS_VERSION);
- assertEquals(model.getJVMVersion(), JVM_VERSION);
- assertEquals(model.getServerVersion(), JETTY_VERSION);
- assertEquals(model.getJerseyVersion(), JERSEY_VERSION);
- }
-
- public void testBuildModel() throws Exception {
- checkModel(buildTestModel());
- }
-
- public void testFromXML() throws Exception {
- checkModel(fromXML(AS_XML));
- }
-
- public void testFromPB() throws Exception {
- checkModel(fromPB(AS_PB));
- }
-}
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java Wed May 14 00:26:57 2014
@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFac
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.CallQueue.Call;
import org.apache.hadoop.hbase.thrift.generated.Hbase;
import org.apache.hadoop.metrics.ContextFactory;
@@ -37,6 +38,7 @@ import org.apache.hadoop.metrics.Metrics
import org.apache.hadoop.metrics.spi.NoEmitMetricsContext;
import org.apache.hadoop.metrics.spi.OutputRecord;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@@ -45,6 +47,7 @@ import org.junit.runners.Parameterized.P
* Unit testing for CallQueue, a part of the
* org.apache.hadoop.hbase.thrift package.
*/
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestCallQueue {
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHBCpp.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHBCpp.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHBCpp.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHBCpp.java Wed May 14 00:26:57 2014
@@ -28,11 +28,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
/**
* This class defines testcases for HBCpp client. It spawns an executable binary
@@ -49,6 +51,7 @@ import org.junit.Test;
* family of "f1" is created. Then the address(and port) of zookeeper is passed
* to the binary using --hbase flag.
*/
+@Category(MediumTests.class)
public class TestHBCpp {
final Log LOG = LogFactory.getLog(getClass());
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHeaderSendReceive.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHeaderSendReceive.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHeaderSendReceive.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHeaderSendReceive.java Wed May 14 00:26:57 2014
@@ -27,6 +27,7 @@ import junit.framework.Assert;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
@@ -39,12 +40,14 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
/**
* Check whether we correctly receive profiling data with the header protocol
* enabled
*
*/
+@Category(MediumTests.class)
public class TestHeaderSendReceive {
private static HBaseTestingUtility TEST_UTIL;
private static final int SLAVES = 1;
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHsHaServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHsHaServerCmdLine.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHsHaServerCmdLine.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestHsHaServerCmdLine.java Wed May 14 00:26:57 2014
@@ -18,12 +18,15 @@ package org.apache.hadoop.hbase.thrift;
import java.util.Collection;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType;
import org.apache.thrift.server.THsHaServer;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Parameterized;
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestHsHaServerCmdLine extends ThriftServerCmdLineTestBase {
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestMutationWriteToWAL.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestMutationWriteToWAL.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestMutationWriteToWAL.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestMutationWriteToWAL.java Wed May 14 00:26:57 2014
@@ -37,6 +37,8 @@ import org.apache.hadoop.hbase.HBaseTest
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTestConst;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.LargeTests;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
import org.apache.hadoop.hbase.thrift.generated.BatchMutation;
import org.apache.hadoop.hbase.thrift.generated.Hbase;
@@ -45,8 +47,10 @@ import org.apache.hadoop.hbase.thrift.ge
import org.apache.hadoop.hbase.thrift.generated.TRowResult;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
/** Tests switching writing to WAL on and off in the Thrift Mutation API */
+@Category(LargeTests.class)
public class TestMutationWriteToWAL extends ThriftServerTestBase {
private static Log LOG = LogFactory.getLog(TestMutationWriteToWAL.class);
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNativeThriftClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNativeThriftClient.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNativeThriftClient.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNativeThriftClient.java Wed May 14 00:26:57 2014
@@ -9,11 +9,14 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MediumTests;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
+@Category(MediumTests.class)
public class TestNativeThriftClient {
final Log LOG = LogFactory.getLog(getClass());
private final static HBaseTestingUtility TEST_UTIL =
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNonblockingServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNonblockingServerCmdLine.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNonblockingServerCmdLine.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestNonblockingServerCmdLine.java Wed May 14 00:26:57 2014
@@ -18,12 +18,15 @@ package org.apache.hadoop.hbase.thrift;
import java.util.Collection;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType;
import org.apache.thrift.server.TNonblockingServer;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestNonblockingServerCmdLine extends ThriftServerCmdLineTestBase {
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerFramedCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerFramedCmdLine.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerFramedCmdLine.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerFramedCmdLine.java Wed May 14 00:26:57 2014
@@ -18,11 +18,14 @@ package org.apache.hadoop.hbase.thrift;
import java.util.Collection;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestThreadPoolServerFramedCmdLine extends ThriftServerCmdLineTestBase {
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerUnframedCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerUnframedCmdLine.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerUnframedCmdLine.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadPoolServerUnframedCmdLine.java Wed May 14 00:26:57 2014
@@ -18,11 +18,14 @@ package org.apache.hadoop.hbase.thrift;
import java.util.Collection;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestThreadPoolServerUnframedCmdLine extends ThriftServerCmdLineTestBase {
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadedSelectorServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadedSelectorServerCmdLine.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadedSelectorServerCmdLine.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThreadedSelectorServerCmdLine.java Wed May 14 00:26:57 2014
@@ -18,12 +18,15 @@ package org.apache.hadoop.hbase.thrift;
import java.util.Collection;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType;
import org.apache.thrift.server.TThreadedSelectorServer;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+@Category(MediumTests.class)
@RunWith(Parameterized.class)
public class TestThreadedSelectorServerCmdLine extends ThriftServerCmdLineTestBase {