2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.regionserver
;
20 import static org
.junit
.Assert
.assertEquals
;
21 import static org
.mockito
.Mockito
.doReturn
;
22 import static org
.mockito
.Mockito
.mock
;
23 import org
.apache
.hadoop
.hbase
.HBaseClassTestRule
;
24 import org
.apache
.hadoop
.hbase
.TableName
;
25 import org
.apache
.hadoop
.hbase
.client
.RegionInfo
;
26 import org
.apache
.hadoop
.hbase
.client
.RegionInfoBuilder
;
27 import org
.apache
.hadoop
.hbase
.regionserver
.MemStoreFlusher
.FlushRegionEntry
;
28 import org
.apache
.hadoop
.hbase
.testclassification
.RegionServerTests
;
29 import org
.apache
.hadoop
.hbase
.testclassification
.SmallTests
;
30 import org
.apache
.hadoop
.hbase
.util
.EnvironmentEdgeManager
;
31 import org
.apache
.hadoop
.hbase
.util
.ManualEnvironmentEdge
;
32 import org
.junit
.AfterClass
;
33 import org
.junit
.BeforeClass
;
34 import org
.junit
.ClassRule
;
35 import org
.junit
.Rule
;
36 import org
.junit
.Test
;
37 import org
.junit
.experimental
.categories
.Category
;
38 import org
.junit
.rules
.TestName
;
40 @Category({ RegionServerTests
.class, SmallTests
.class })
41 public class TestFlushRegionEntry
{
44 public static final HBaseClassTestRule CLASS_RULE
=
45 HBaseClassTestRule
.forClass(TestFlushRegionEntry
.class);
48 public TestName name
= new TestName();
51 public static void setUp() throws Exception
{
52 ManualEnvironmentEdge edge
= new ManualEnvironmentEdge();
54 EnvironmentEdgeManager
.injectEdge(edge
);
58 public static void teardown() {
59 EnvironmentEdgeManager
.reset();
63 public void testFlushRegionEntryEquality() {
64 RegionInfo hri
= RegionInfoBuilder
.newBuilder(TableName
.valueOf(name
.getMethodName()))
65 .setRegionId(1).setReplicaId(0).build();
66 HRegion r
= mock(HRegion
.class);
67 doReturn(hri
).when(r
).getRegionInfo();
69 FlushRegionEntry entry
= new FlushRegionEntry(r
, true, FlushLifeCycleTracker
.DUMMY
);
70 FlushRegionEntry other
= new FlushRegionEntry(r
, true, FlushLifeCycleTracker
.DUMMY
);
72 assertEquals(entry
.hashCode(), other
.hashCode());
73 assertEquals(entry
, other
);