1   /**
2    * Copyright 2007 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package org.apache.hadoop.hbase.io;
21  
22  import java.io.ByteArrayInputStream;
23  import java.io.ByteArrayOutputStream;
24  import java.io.DataInput;
25  import java.io.DataInputStream;
26  import java.io.DataOutput;
27  import java.io.DataOutputStream;
28  import java.io.IOException;
29  import java.io.Serializable;
30  import java.lang.reflect.Array;
31  import java.util.ArrayList;
32  import java.util.List;
33  import java.util.NavigableSet;
34  
35  import junit.framework.TestCase;
36  
37  import org.apache.hadoop.conf.Configuration;
38  import org.apache.hadoop.hbase.ClusterStatus;
39  import org.apache.hadoop.hbase.HBaseConfiguration;
40  import org.apache.hadoop.hbase.HColumnDescriptor;
41  import org.apache.hadoop.hbase.HConstants;
42  import org.apache.hadoop.hbase.HRegionInfo;
43  import org.apache.hadoop.hbase.HServerAddress;
44  import org.apache.hadoop.hbase.HServerInfo;
45  import org.apache.hadoop.hbase.HServerLoad;
46  import org.apache.hadoop.hbase.HTableDescriptor;
47  import org.apache.hadoop.hbase.KeyValue;
48  import org.apache.hadoop.hbase.SmallTests;
49  import org.apache.hadoop.hbase.client.Action;
50  import org.apache.hadoop.hbase.client.Append;
51  import org.apache.hadoop.hbase.client.Delete;
52  import org.apache.hadoop.hbase.client.Get;
53  import org.apache.hadoop.hbase.client.Increment;
54  import org.apache.hadoop.hbase.client.MultiAction;
55  import org.apache.hadoop.hbase.client.MultiResponse;
56  import org.apache.hadoop.hbase.client.Put;
57  import org.apache.hadoop.hbase.client.Result;
58  import org.apache.hadoop.hbase.client.Row;
59  import org.apache.hadoop.hbase.client.RowMutations;
60  import org.apache.hadoop.hbase.client.Scan;
61  import org.apache.hadoop.hbase.client.coprocessor.Exec;
62  import org.apache.hadoop.hbase.filter.BinaryComparator;
63  import org.apache.hadoop.hbase.filter.BitComparator;
64  import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;
65  import org.apache.hadoop.hbase.filter.ColumnPrefixFilter;
66  import org.apache.hadoop.hbase.filter.ColumnRangeFilter;
67  import org.apache.hadoop.hbase.filter.CompareFilter;
68  import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
69  import org.apache.hadoop.hbase.filter.DependentColumnFilter;
70  import org.apache.hadoop.hbase.filter.Filter;
71  import org.apache.hadoop.hbase.filter.FilterBase;
72  import org.apache.hadoop.hbase.filter.FilterList;
73  import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
74  import org.apache.hadoop.hbase.filter.InclusiveStopFilter;
75  import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
76  import org.apache.hadoop.hbase.filter.PageFilter;
77  import org.apache.hadoop.hbase.filter.PrefixFilter;
78  import org.apache.hadoop.hbase.filter.QualifierFilter;
79  import org.apache.hadoop.hbase.filter.RandomRowFilter;
80  import org.apache.hadoop.hbase.filter.RowFilter;
81  import org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter;
82  import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
83  import org.apache.hadoop.hbase.filter.SkipFilter;
84  import org.apache.hadoop.hbase.filter.ValueFilter;
85  import org.apache.hadoop.hbase.filter.WhileMatchFilter;
86  import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
87  import org.apache.hadoop.hbase.regionserver.HRegion;
88  import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
89  import org.apache.hadoop.hbase.regionserver.wal.HLog;
90  import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
91  import org.apache.hadoop.hbase.util.Bytes;
92  import org.apache.hadoop.io.IntWritable;
93  import org.apache.hadoop.io.MapWritable;
94  import org.apache.hadoop.io.Text;
95  import org.apache.hadoop.io.Writable;
96  import org.apache.hadoop.io.WritableComparator;
97  import org.junit.Assert;
98  import org.junit.experimental.categories.Category;
99  
100 import com.google.common.collect.Lists;
101 import com.google.protobuf.Message;
102 
103 @Category(SmallTests.class)
104 public class TestHbaseObjectWritable extends TestCase {
105 
106   @Override
107   protected void setUp() throws Exception {
108     super.setUp();
109   }
110 
111   @Override
112   protected void tearDown() throws Exception {
113     super.tearDown();
114   }
115 
116   @SuppressWarnings("boxing")
117   public void testReadOldObjectDataInput() throws IOException {
118     Configuration conf = HBaseConfiguration.create();
119     /*
120      * This is the code used to generate byte[] where
121      *  HbaseObjectWritable used byte for code
122      *
123     ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
124     DataOutputStream out = new DataOutputStream(byteStream);
125     HbaseObjectWritable.writeObject(out, bytes, byte[].class, conf);
126     byte[] ba = byteStream.toByteArray();
127     out.close();
128     */
129 
130     /*
131      * byte array generated by the folowing call
132      *  HbaseObjectWritable.writeObject(out, new Text("Old"), Text.class, conf);
133      */
134     byte[] baForText = {13, 13, 3, 79, 108, 100};
135     Text txt = (Text)readByteArray(conf, baForText);
136     Text oldTxt = new Text("Old");
137     assertEquals(txt, oldTxt);
138 
139     final byte A = 'A';
140     byte [] bytes = new byte[1];
141     bytes[0] = A;
142     /*
143      * byte array generated by the folowing call
144      *  HbaseObjectWritable.writeObject(out, bytes, byte[].class, conf);
145      */
146     byte[] baForByteArray = { 11, 1, 65 };
147     byte[] baOut = (byte[])readByteArray(conf, baForByteArray);
148     assertTrue(Bytes.equals(baOut, bytes));
149   }
150 
151   /*
152    * helper method which reads byte array using HbaseObjectWritable.readObject()
153    */
154   private Object readByteArray(final Configuration conf, final byte[] ba)
155   throws IOException {
156     ByteArrayInputStream bais =
157       new ByteArrayInputStream(ba);
158     DataInputStream dis = new DataInputStream(bais);
159     Object product = HbaseObjectWritable.readObject(dis, conf);
160     dis.close();
161     return product;
162   }
163 
164   @SuppressWarnings("boxing")
165   public void testReadObjectDataInputConfiguration() throws IOException {
166     Configuration conf = HBaseConfiguration.create();
167     // Do primitive type
168     final int COUNT = 101;
169     assertTrue(doType(conf, COUNT, int.class).equals(COUNT));
170     // Do array
171     final byte [] testing = "testing".getBytes();
172     byte [] result = (byte [])doType(conf, testing, testing.getClass());
173     assertTrue(WritableComparator.compareBytes(testing, 0, testing.length,
174        result, 0, result.length) == 0);
175     // Do unsupported type.
176     boolean exception = false;
177     try {
178       doType(conf, new Object(), Object.class);
179     } catch (UnsupportedOperationException uoe) {
180       exception = true;
181     }
182     assertTrue(exception);
183     // Try odd types
184     final byte A = 'A';
185     byte [] bytes = new byte[1];
186     bytes[0] = A;
187     Object obj = doType(conf, bytes, byte [].class);
188     assertTrue(((byte [])obj)[0] == A);
189     // Do 'known' Writable type.
190     obj = doType(conf, new Text(""), Text.class);
191     assertTrue(obj instanceof Text);
192     //List.class
193     List<String> list = new ArrayList<String>();
194     list.add("hello");
195     list.add("world");
196     list.add("universe");
197     obj = doType(conf, list, List.class);
198     assertTrue(obj instanceof List);
199     Assert.assertArrayEquals(list.toArray(), ((List)obj).toArray() );
200     //List.class with null values
201     List<String> listWithNulls = new ArrayList<String>();
202     listWithNulls.add("hello");
203     listWithNulls.add("world");
204     listWithNulls.add(null);
205     obj = doType(conf, listWithNulls, List.class);
206     assertTrue(obj instanceof List);
207     Assert.assertArrayEquals(listWithNulls.toArray(), ((List)obj).toArray() );
208     //ArrayList.class
209     ArrayList<String> arr = new ArrayList<String>();
210     arr.add("hello");
211     arr.add("world");
212     arr.add("universe");
213     obj = doType(conf,  arr, ArrayList.class);
214     assertTrue(obj instanceof ArrayList);
215     Assert.assertArrayEquals(list.toArray(), ((ArrayList)obj).toArray() );
216     // Check that filters can be serialized
217     obj = doType(conf, new PrefixFilter(HConstants.EMPTY_BYTE_ARRAY),
218       PrefixFilter.class);
219     assertTrue(obj instanceof PrefixFilter);
220   }
221 
222   public void testCustomWritable() throws Exception {
223     Configuration conf = HBaseConfiguration.create();
224 
225     // test proper serialization of un-encoded custom writables
226     CustomWritable custom = new CustomWritable("test phrase");
227     Object obj = doType(conf, custom, CustomWritable.class);
228     assertTrue(obj instanceof Writable);
229     assertTrue(obj instanceof CustomWritable);
230     assertEquals("test phrase", ((CustomWritable)obj).getValue());
231 
232     // test proper serialization of a custom filter
233     CustomFilter filt = new CustomFilter("mykey");
234     FilterList filtlist = new FilterList(FilterList.Operator.MUST_PASS_ALL);
235     filtlist.addFilter(filt);
236     obj = doType(conf, filtlist, FilterList.class);
237     assertTrue(obj instanceof FilterList);
238     assertNotNull(((FilterList)obj).getFilters());
239     assertEquals(1, ((FilterList)obj).getFilters().size());
240     Filter child = ((FilterList)obj).getFilters().get(0);
241     assertTrue(child instanceof CustomFilter);
242     assertEquals("mykey", ((CustomFilter)child).getKey());
243   }
244 
245   public void testCustomSerializable() throws Exception {
246     Configuration conf = HBaseConfiguration.create();
247 
248     // test proper serialization of un-encoded serialized java objects
249     CustomSerializable custom = new CustomSerializable("test phrase");
250     Object obj = doType(conf, custom, CustomSerializable.class);
251     assertTrue(obj instanceof Serializable);
252     assertTrue(obj instanceof CustomSerializable);
253     assertEquals("test phrase", ((CustomSerializable)obj).getValue());
254   }
255 
256   private Object doType(final Configuration conf, final Object value,
257       final Class<?> clazz)
258   throws IOException {
259     ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
260     DataOutputStream out = new DataOutputStream(byteStream);
261     HbaseObjectWritable.writeObject(out, value, clazz, conf);
262     out.close();
263     ByteArrayInputStream bais =
264       new ByteArrayInputStream(byteStream.toByteArray());
265     DataInputStream dis = new DataInputStream(bais);
266     Object product = HbaseObjectWritable.readObject(dis, conf);
267     dis.close();
268     return product;
269   }
270 
271   public static class A extends IntWritable {
272     public A() {}
273     public A(int a) {super(a);}
274   }
275 
276   public static class B extends A {
277     int b;
278     public B() { }
279     public B(int a, int b) {
280       super(a);
281       this.b = b;
282     }
283     @Override
284     public void write(DataOutput out) throws IOException {
285       super.write(out);
286       out.writeInt(b);
287     }
288 
289     @Override
290     public void readFields(DataInput in) throws IOException {
291       super.readFields(in);
292       this.b = in.readInt();
293     }
294     @Override
295     public boolean equals(Object o) {
296       if (o instanceof B) {
297         return this.get() == ((B) o).get() && this.b == ((B) o).b;
298       }
299       return false;
300     }
301   }
302 
303   /** Tests for serialization of List and Arrays */
304   @SuppressWarnings({ "unchecked", "rawtypes" })
305   public void testPolymorphismInSequences() throws Exception {
306     Configuration conf = HBaseConfiguration.create();
307     Object ret;
308 
309     //test with lists
310     List<A> list = Lists.newArrayList(new A(42), new B(10, 100));
311     ret = doType(conf, list, list.getClass());
312     assertEquals(ret, list);
313 
314     //test with Writable[]
315     Writable[] warr = new Writable[] {new A(42), new B(10, 100)};
316     ret = doType(conf, warr, warr.getClass());
317     Assert.assertArrayEquals((Writable[])ret, warr);
318 
319     //test with arrays
320     A[] arr = new A[] {new A(42), new B(10, 100)};
321     ret = doType(conf, arr, arr.getClass());
322     Assert.assertArrayEquals((A[])ret, arr);
323 
324     //test with double array
325     A[][] darr = new A[][] {new A[] { new A(42), new B(10, 100)}, new A[] {new A(12)}};
326     ret = doType(conf, darr, darr.getClass());
327     Assert.assertArrayEquals((A[][])ret, darr);
328 
329     //test with List of arrays
330     List<A[]> larr = Lists.newArrayList(arr, new A[] {new A(99)});
331     ret = doType(conf, larr, larr.getClass());
332     List<A[]> lret = (List<A[]>) ret;
333     assertEquals(larr.size(), lret.size());
334     for (int i=0; i<lret.size(); i++) {
335       Assert.assertArrayEquals(larr.get(i), lret.get(i));
336     }
337 
338     //test with array of lists
339     List[] alarr = new List[] {Lists.newArrayList(new A(1), new A(2)),
340         Lists.newArrayList(new B(4,5))};
341     ret = doType(conf, alarr, alarr.getClass());
342     List[] alret = (List[]) ret;
343     Assert.assertArrayEquals(alarr, alret);
344 
345     //test with array of Text, note that Text[] is not pre-defined
346     Text[] tarr = new Text[] {new Text("foo"), new Text("bar")};
347     ret = doType(conf, tarr, tarr.getClass());
348     Assert.assertArrayEquals(tarr, (Text[])ret);
349 
350     //test with byte[][]
351     byte[][] barr = new byte[][] {"foo".getBytes(), "baz".getBytes()};
352     ret = doType(conf, barr, barr.getClass());
353     Assert.assertArrayEquals(barr, (byte[][])ret);
354   }
355 
356   public static class CustomSerializable implements Serializable {
357     private static final long serialVersionUID = 1048445561865740632L;
358     private String value = null;
359 
360     public CustomSerializable() {
361     }
362 
363     public CustomSerializable(String value) {
364       this.value = value;
365     }
366 
367     public String getValue() {
368       return value;
369     }
370 
371     public void setValue(String value) {
372       this.value = value;
373     }
374 
375   }
376 
377   public static class CustomWritable implements Writable {
378     private String value = null;
379 
380     public CustomWritable() {
381     }
382 
383     public CustomWritable(String val) {
384       this.value = val;
385     }
386 
387     public String getValue() { return value; }
388 
389     @Override
390     public void write(DataOutput out) throws IOException {
391       Text.writeString(out, this.value);
392     }
393 
394     @Override
395     public void readFields(DataInput in) throws IOException {
396       this.value = Text.readString(in);
397     }
398   }
399 
400   public static class CustomFilter extends FilterBase {
401     private String key = null;
402 
403     public CustomFilter() {
404     }
405 
406     public CustomFilter(String key) {
407       this.key = key;
408     }
409 
410     public String getKey() { return key; }
411 
412     public void write(DataOutput out) throws IOException {
413       Text.writeString(out, this.key);
414     }
415 
416     public void readFields(DataInput in) throws IOException {
417       this.key = Text.readString(in);
418     }
419   }
420 
421   /**
422    * Test case to ensure ordering of CODE_TO_CLASS and CLASS_TO_CODE. In the
423    * past, and item was added in the middle of the static initializer, and that
424    * threw off all of the codes after the addition. This unintentionally broke
425    * the wire protocol for clients. The idea behind this test case is that if
426    * you unintentionally change the order, you will get a test failure. If you
427    * are actually intentionally change the order, just update the test case.
428    * This should be a clue to the reviewer that you are doing something to
429    * change the wire protocol.
430    */
431   public void testGetClassCode() throws IOException{
432     // Primitive types
433     assertEquals(1,HbaseObjectWritable.getClassCode(Boolean.TYPE).intValue());
434     assertEquals(2,HbaseObjectWritable.getClassCode(Byte.TYPE).intValue());
435     assertEquals(3,HbaseObjectWritable.getClassCode(Character.TYPE).intValue());
436     assertEquals(4,HbaseObjectWritable.getClassCode(Short.TYPE).intValue());
437     assertEquals(5,HbaseObjectWritable.getClassCode(Integer.TYPE).intValue());
438     assertEquals(6,HbaseObjectWritable.getClassCode(Long.TYPE).intValue());
439     assertEquals(7,HbaseObjectWritable.getClassCode(Float.TYPE).intValue());
440     assertEquals(8,HbaseObjectWritable.getClassCode(Double.TYPE).intValue());
441     assertEquals(9,HbaseObjectWritable.getClassCode(Void.TYPE).intValue());
442 
443     // Other java types
444     assertEquals(10,HbaseObjectWritable.getClassCode(String.class).intValue());
445     assertEquals(11,HbaseObjectWritable.getClassCode(byte [].class).intValue());
446     assertEquals(12,HbaseObjectWritable.getClassCode(byte [][].class).intValue());
447 
448     // Hadoop types
449     assertEquals(13,HbaseObjectWritable.getClassCode(Text.class).intValue());
450     assertEquals(14,HbaseObjectWritable.getClassCode(Writable.class).intValue());
451     assertEquals(15,HbaseObjectWritable.getClassCode(Writable [].class).intValue());
452     assertEquals(16,HbaseObjectWritable.getClassCode(HbaseMapWritable.class).intValue());
453     // 17 is NullInstance which isn't visible from here
454 
455     // Hbase types
456     assertEquals(18,HbaseObjectWritable.getClassCode(HColumnDescriptor.class).intValue());
457     assertEquals(19,HbaseObjectWritable.getClassCode(HConstants.Modify.class).intValue());
458     // 20 and 21 are place holders for HMsg
459     assertEquals(22,HbaseObjectWritable.getClassCode(HRegion.class).intValue());
460     assertEquals(23,HbaseObjectWritable.getClassCode(HRegion[].class).intValue());
461     assertEquals(24,HbaseObjectWritable.getClassCode(HRegionInfo.class).intValue());
462     assertEquals(25,HbaseObjectWritable.getClassCode(HRegionInfo[].class).intValue());
463     assertEquals(26,HbaseObjectWritable.getClassCode(HServerAddress.class).intValue());
464     assertEquals(27,HbaseObjectWritable.getClassCode(HServerInfo.class).intValue());
465     assertEquals(28,HbaseObjectWritable.getClassCode(HTableDescriptor.class).intValue());
466     assertEquals(29,HbaseObjectWritable.getClassCode(MapWritable.class).intValue());
467 
468     // HBASE-880
469     assertEquals(30,HbaseObjectWritable.getClassCode(ClusterStatus.class).intValue());
470     assertEquals(31,HbaseObjectWritable.getClassCode(Delete.class).intValue());
471     assertEquals(32,HbaseObjectWritable.getClassCode(Get.class).intValue());
472     assertEquals(33,HbaseObjectWritable.getClassCode(KeyValue.class).intValue());
473     assertEquals(34,HbaseObjectWritable.getClassCode(KeyValue[].class).intValue());
474     assertEquals(35,HbaseObjectWritable.getClassCode(Put.class).intValue());
475     assertEquals(36,HbaseObjectWritable.getClassCode(Put[].class).intValue());
476     assertEquals(37,HbaseObjectWritable.getClassCode(Result.class).intValue());
477     assertEquals(38,HbaseObjectWritable.getClassCode(Result[].class).intValue());
478     assertEquals(39,HbaseObjectWritable.getClassCode(Scan.class).intValue());
479 
480     assertEquals(40,HbaseObjectWritable.getClassCode(WhileMatchFilter.class).intValue());
481     assertEquals(41,HbaseObjectWritable.getClassCode(PrefixFilter.class).intValue());
482     assertEquals(42,HbaseObjectWritable.getClassCode(PageFilter.class).intValue());
483     assertEquals(43,HbaseObjectWritable.getClassCode(InclusiveStopFilter.class).intValue());
484     assertEquals(44,HbaseObjectWritable.getClassCode(ColumnCountGetFilter.class).intValue());
485     assertEquals(45,HbaseObjectWritable.getClassCode(SingleColumnValueFilter.class).intValue());
486     assertEquals(46,HbaseObjectWritable.getClassCode(SingleColumnValueExcludeFilter.class).intValue());
487     assertEquals(47,HbaseObjectWritable.getClassCode(BinaryComparator.class).intValue());
488     assertEquals(48,HbaseObjectWritable.getClassCode(BitComparator.class).intValue());
489     assertEquals(49,HbaseObjectWritable.getClassCode(CompareFilter.class).intValue());
490     assertEquals(50,HbaseObjectWritable.getClassCode(RowFilter.class).intValue());
491     assertEquals(51,HbaseObjectWritable.getClassCode(ValueFilter.class).intValue());
492     assertEquals(52,HbaseObjectWritable.getClassCode(QualifierFilter.class).intValue());
493     assertEquals(53,HbaseObjectWritable.getClassCode(SkipFilter.class).intValue());
494     assertEquals(54,HbaseObjectWritable.getClassCode(WritableByteArrayComparable.class).intValue());
495     assertEquals(55,HbaseObjectWritable.getClassCode(FirstKeyOnlyFilter.class).intValue());
496     assertEquals(56,HbaseObjectWritable.getClassCode(DependentColumnFilter.class).intValue());
497 
498     assertEquals(57,HbaseObjectWritable.getClassCode(Delete [].class).intValue());
499 
500     assertEquals(58,HbaseObjectWritable.getClassCode(HLog.Entry.class).intValue());
501     assertEquals(59,HbaseObjectWritable.getClassCode(HLog.Entry[].class).intValue());
502     assertEquals(60,HbaseObjectWritable.getClassCode(HLogKey.class).intValue());
503 
504     assertEquals(61,HbaseObjectWritable.getClassCode(List.class).intValue());
505 
506     assertEquals(62,HbaseObjectWritable.getClassCode(NavigableSet.class).intValue());
507     assertEquals(63,HbaseObjectWritable.getClassCode(ColumnPrefixFilter.class).intValue());
508 
509     // Multi
510     assertEquals(64,HbaseObjectWritable.getClassCode(Row.class).intValue());
511     assertEquals(65,HbaseObjectWritable.getClassCode(Action.class).intValue());
512     assertEquals(66,HbaseObjectWritable.getClassCode(MultiAction.class).intValue());
513     assertEquals(67,HbaseObjectWritable.getClassCode(MultiResponse.class).intValue());
514 
515     // coprocessor execution
516     assertEquals(68,HbaseObjectWritable.getClassCode(Exec.class).intValue());
517     assertEquals(69,HbaseObjectWritable.getClassCode(Increment.class).intValue());
518 
519     assertEquals(70,HbaseObjectWritable.getClassCode(KeyOnlyFilter.class).intValue());
520 
521     // serializable
522     assertEquals(71,HbaseObjectWritable.getClassCode(Serializable.class).intValue());
523     assertEquals(72,HbaseObjectWritable.getClassCode(RandomRowFilter.class).intValue());
524     assertEquals(73,HbaseObjectWritable.getClassCode(CompareOp.class).intValue());
525     assertEquals(74,HbaseObjectWritable.getClassCode(ColumnRangeFilter.class).intValue());
526     assertEquals(75,HbaseObjectWritable.getClassCode(HServerLoad.class).intValue());
527     assertEquals(76,HbaseObjectWritable.getClassCode(RegionOpeningState.class).intValue());
528     assertEquals(77,HbaseObjectWritable.getClassCode(HTableDescriptor[].class).intValue());
529     assertEquals(78,HbaseObjectWritable.getClassCode(Append.class).intValue());
530     assertEquals(79,HbaseObjectWritable.getClassCode(RowMutations.class).intValue());
531     assertEquals(80,HbaseObjectWritable.getClassCode(Message.class).intValue());
532 
533     assertEquals(81,HbaseObjectWritable.getClassCode(Array.class).intValue());
534   }
535 
536   /**
537    * This test verifies that additional objects have not been added to the end of the list.
538    * If you are legitimately adding objects, this test will need to be updated, but see the
539    * note on the test above. 
540    */
541   public void testGetNextObjectCode(){
542     assertEquals(83,HbaseObjectWritable.getNextClassCode());
543   }
544 
545   @org.junit.Rule
546   public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
547     new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
548 }
549