kgeisz commented on code in PR #7464:
URL: https://github.com/apache/hbase/pull/7464#discussion_r2589851348


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyControllerMasterObserver.java:
##########
@@ -0,0 +1,748 @@
+/*
+ * 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.security.access;
+
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.BalanceRequest;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.SnapshotDescription;
+import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.net.Address;
+import org.apache.hadoop.hbase.quotas.GlobalQuotaSettings;
+import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
+import org.apache.hadoop.hbase.replication.SyncReplicationState;
+import org.apache.hadoop.hbase.testclassification.SecurityTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+// Tests methods of Master Observer which are implemented in 
ReadOnlyController,
+// by mocking the coprocessor environment and dependencies
+
+@Category({ SecurityTests.class, SmallTests.class })
+public class TestReadOnlyControllerMasterObserver {
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+    HBaseClassTestRule.forClass(TestReadOnlyControllerMasterObserver.class);
+
+  ReadOnlyController readOnlyController;
+
+  // Master Coprocessor mocking variables
+  ObserverContext<MasterCoprocessorEnvironment> c, ctx;
+  TableDescriptor desc;
+  RegionInfo[] regions;
+  TableName tableName;
+  TableDescriptor currentDescriptor, newDescriptor;
+  String dstSFT;
+  byte[] family;
+  byte[] splitRow;
+  byte[] splitKey;
+  List<Mutation> metaEntries;
+  RegionInfo[] regionsToMerge;
+  SnapshotDescription snapshot;
+  TableDescriptor tableDescriptor;
+  NamespaceDescriptor ns;
+  NamespaceDescriptor currentNsDescriptor, newNsDescriptor;
+  String namespace;
+  String userName;
+  GlobalQuotaSettings quotas;
+  String regionServer;
+  Set<Address> servers;
+  Set<TableName> tables;
+  String targetGroup;
+  String name;
+  String groupName;
+  BalanceRequest request;
+  String oldName, newName;
+  Map<String, String> configuration;
+  String peerId;
+  ReplicationPeerConfig peerConfig;
+  SyncReplicationState state;
+  UserPermission userPermission;
+  boolean mergeExistingPermissions;
+
+  @Before
+  public void setup() throws Exception {
+    readOnlyController = new ReadOnlyController();
+
+    // mocking variables initialization
+    c = mock(ObserverContext.class);
+    // ctx is created to make naming variable in sync with the Observer 
interface
+    // methods where 'ctx' is used as the ObserverContext variable name 
instead of 'c'.
+    // otherwise both are one and the same
+    ctx = c;

Review Comment:
   Ah ok, that makes sense.  I think it's fine to leave your change as is for 
now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to