View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
9    * for the specific language governing permissions and limitations under the License.
10   */
11  package org.apache.hadoop.hbase.regionserver;
12  
13  import static org.junit.Assert.*;
14  
15  import org.apache.hadoop.hbase.testclassification.SmallTests;
16  import org.apache.hadoop.hbase.regionserver.MemStoreFlusher.FlushRegionEntry;
17  import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
18  import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
19  import org.junit.After;
20  import org.junit.Before;
21  import org.junit.Test;
22  import org.junit.experimental.categories.Category;
23  import org.mockito.Mockito;
24  
25  @Category(SmallTests.class)
26  public class TestFlushRegionEntry {
27    @Before
28    public void setUp() throws Exception {
29      ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
30      edge.setValue(12345);
31      EnvironmentEdgeManager.injectEdge(edge);
32    }
33  
34    @Test
35    public void test() {
36      HRegion r = Mockito.mock(HRegion.class);
37      FlushRegionEntry entry = new FlushRegionEntry(r);
38      FlushRegionEntry other = new FlushRegionEntry(r);
39  
40      assertEquals(entry.hashCode(), other.hashCode());
41      assertEquals(entry, other);
42    }
43  
44    @After
45    public void teardown() {
46      EnvironmentEdgeManager.reset();
47    }
48  }