http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/DisabledSecurityServiceTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/DisabledSecurityServiceTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/DisabledSecurityServiceTest.java
new file mode 100644
index 0000000..cacbeed
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/DisabledSecurityServiceTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.geode.internal.security;
+
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+import org.apache.geode.security.PostProcessor;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.support.SubjectThreadState;
+import org.apache.shiro.util.ThreadState;
+import org.apache.geode.security.SecurityManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+@Category(UnitTest.class)
+public class DisabledSecurityServiceTest {
+
+  private DisabledSecurityService disabledSecurityService;
+  private Subject mockSubject;
+
+  @Before
+  public void before() throws Exception {
+    this.disabledSecurityService = new DisabledSecurityService();
+    this.mockSubject = mock(Subject.class);
+  }
+
+  @Test
+  public void bindSubject_null() throws Exception {
+    ThreadState threadState = this.disabledSecurityService.bindSubject(null);
+    assertThat(threadState).isNull();
+  }
+
+  @Test
+  public void bindSubject_subject_shouldReturnThreadState() throws Exception {
+    ThreadState threadState = 
this.disabledSecurityService.bindSubject(this.mockSubject);
+    assertThat(threadState).isNotNull().isInstanceOf(SubjectThreadState.class);
+  }
+
+  @Test
+  public void getSubject_beforeLogin_shouldReturnNull() throws Exception {
+    Subject subject = this.disabledSecurityService.getSubject();
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void login_null_shouldReturnNull() throws Exception {
+    Subject subject = this.disabledSecurityService.login(null);
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void login_properties_shouldReturnNull() throws Exception {
+    Subject subject = this.disabledSecurityService.login(new Properties());
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void getSubject_afterLogin_shouldReturnNull() throws Exception {
+    this.disabledSecurityService.login(new Properties());
+    Subject subject = this.disabledSecurityService.getSubject();
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void getSubject_afterLogout_shouldReturnNull() throws Exception {
+    this.disabledSecurityService.login(new Properties());
+    this.disabledSecurityService.logout();
+    Subject subject = this.disabledSecurityService.getSubject();
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void associateWith_callable_shouldReturnSameCallable() throws 
Exception {
+    Callable mockCallable = mock(Callable.class);
+    Callable callable = 
this.disabledSecurityService.associateWith(mockCallable);
+    assertThat(callable).isNotNull().isSameAs(mockCallable);
+  }
+
+  @Test
+  public void associateWith_null_should() throws Exception {
+    Callable callable = this.disabledSecurityService.associateWith(null);
+    assertThat(callable).isNull();
+  }
+
+  @Test
+  public void needPostProcess_returnsFalse() throws Exception {
+    boolean needPostProcess = this.disabledSecurityService.needPostProcess();
+    assertThat(needPostProcess).isFalse();
+  }
+
+  @Test
+  public void postProcess1_value_shouldReturnSameValue() throws Exception {
+    Object value = new Object();
+    Object result = this.disabledSecurityService.postProcess(null, null, 
value, false);
+    assertThat(result).isNotNull().isSameAs(value);
+  }
+
+  @Test
+  public void postProcess1_null_returnsNull() throws Exception {
+    Object result = this.disabledSecurityService.postProcess(null, null, null, 
false);
+    assertThat(result).isNull();
+  }
+
+  @Test
+  public void postProcess2_value_shouldReturnSameValue() throws Exception {
+    Object value = new Object();
+    Object result = this.disabledSecurityService.postProcess(null, null, null, 
value, false);
+    assertThat(result).isNotNull().isSameAs(value);
+  }
+
+  @Test
+  public void postProcess2_null_returnsNull() throws Exception {
+    Object result = this.disabledSecurityService.postProcess(null, null, null, 
null, false);
+    assertThat(result).isNull();
+  }
+
+  @Test
+  public void isClientSecurityRequired_returnsFalse() throws Exception {
+    boolean result = this.disabledSecurityService.isClientSecurityRequired();
+    assertThat(result).isFalse();
+  }
+
+  @Test
+  public void isIntegratedSecurity_returnsFalse() throws Exception {
+    boolean result = this.disabledSecurityService.isIntegratedSecurity();
+    assertThat(result).isFalse();
+  }
+
+  @Test
+  public void isPeerSecurityRequired_returnsFalse() throws Exception {
+    boolean result = this.disabledSecurityService.isPeerSecurityRequired();
+    assertThat(result).isFalse();
+  }
+
+  @Test
+  public void getSecurityManager_returnsNull() throws Exception {
+    SecurityManager securityManager = 
this.disabledSecurityService.getSecurityManager();
+    assertThat(securityManager).isNull();
+  }
+
+  @Test
+  public void getPostProcessor_returnsNull() throws Exception {
+    PostProcessor postProcessor = 
this.disabledSecurityService.getPostProcessor();
+    assertThat(postProcessor).isNull();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/EnabledSecurityServiceTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/EnabledSecurityServiceTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/EnabledSecurityServiceTest.java
new file mode 100644
index 0000000..fca7eae
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/EnabledSecurityServiceTest.java
@@ -0,0 +1,184 @@
+/*
+ * 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.geode.internal.security;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.*;
+
+import org.apache.geode.internal.security.shiro.RealmInitializer;
+import org.apache.geode.security.AuthenticationFailedException;
+import org.apache.geode.security.GemFireSecurityException;
+import org.apache.geode.security.PostProcessor;
+import org.apache.geode.security.SecurityManager;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.support.SubjectThreadState;
+import org.apache.shiro.util.ThreadState;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+@Category(UnitTest.class)
+public class EnabledSecurityServiceTest {
+
+  private SecurityManager mockSecurityManager;
+  private PostProcessor mockPostProcessor;
+  private RealmInitializer spyRealmInitializer;
+  private Subject mockSubject;
+
+  private EnabledSecurityService securityService;
+  private EnabledSecurityService securityServiceWithPostProcessor;
+
+  @Before
+  public void before() throws Exception {
+    this.mockSecurityManager = mock(SecurityManager.class);
+    this.mockPostProcessor = mock(PostProcessor.class);
+    this.spyRealmInitializer = spy(RealmInitializer.class);
+    this.mockSubject = mock(Subject.class);
+
+    this.securityService =
+        new EnabledSecurityService(this.mockSecurityManager, null, 
this.spyRealmInitializer);
+    this.securityServiceWithPostProcessor = new 
EnabledSecurityService(this.mockSecurityManager,
+        this.mockPostProcessor, this.spyRealmInitializer);
+  }
+
+  @Test
+  public void bindSubject_nullSubject_shouldReturn_null() throws Exception {
+    ThreadState threadState = this.securityService.bindSubject(null);
+    assertThat(threadState).isNull();
+  }
+
+  @Test
+  public void bindSubject_subject_shouldReturn_ThreadState() throws Exception {
+    ThreadState threadState = 
this.securityService.bindSubject(this.mockSubject);
+    assertThat(threadState).isNotNull().isInstanceOf(SubjectThreadState.class);
+  }
+
+  @Test
+  public void getSubject_beforeLogin_shouldThrow_GemFireSecurityException() 
throws Exception {
+    assertThatThrownBy(() -> this.securityService.getSubject())
+        
.isInstanceOf(GemFireSecurityException.class).hasMessageContaining("Anonymous 
User");
+  }
+
+  @Test
+  public void login_nullProperties_shouldReturn_null() throws Exception {
+    Subject subject = this.securityService.login(null);
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void 
login_emptyProperties_shouldThrow_AuthenticationFailedException() throws 
Exception {
+    assertThatThrownBy(() -> this.securityService.login(new Properties()))
+        .isInstanceOf(AuthenticationFailedException.class)
+        .hasMessageContaining("Please check your credentials");
+  }
+
+  @Ignore("Extract all shiro integration code out of EnabledSecurityService 
for mocking")
+  @Test
+  public void getSubject_afterLogin_shouldReturnNull() throws Exception {
+    this.securityService.login(new Properties());
+    Subject subject = this.securityService.getSubject();
+    assertThat(subject).isNull();
+  }
+
+  @Ignore("Extract all shiro integration code out of EnabledSecurityService 
for mocking")
+  @Test
+  public void getSubject_afterLogout_shouldReturnNull() throws Exception {
+    this.securityService.login(new Properties());
+    this.securityService.logout();
+    Subject subject = this.securityService.getSubject();
+    assertThat(subject).isNull();
+  }
+
+  @Test
+  public void 
associateWith_callable_beforeLogin_shouldThrow_GemFireSecurityException()
+      throws Exception {
+    assertThatThrownBy(() -> 
this.securityService.associateWith(mock(Callable.class)))
+        
.isInstanceOf(GemFireSecurityException.class).hasMessageContaining("Anonymous 
User");
+  }
+
+  @Test
+  public void associateWith_null_should() throws Exception {
+    assertThatThrownBy(() -> this.securityService.associateWith(null))
+        
.isInstanceOf(GemFireSecurityException.class).hasMessageContaining("Anonymous 
User");
+  }
+
+  @Test
+  public void needPostProcess_returnsFalse() throws Exception {
+    boolean needPostProcess = this.securityService.needPostProcess();
+    assertThat(needPostProcess).isFalse();
+  }
+
+  @Test
+  public void postProcess1_value_shouldReturnSameValue() throws Exception {
+    Object value = new Object();
+    Object result = this.securityService.postProcess(null, null, value, false);
+    assertThat(result).isNotNull().isSameAs(value);
+  }
+
+  @Test
+  public void postProcess1_null_returnsNull() throws Exception {
+    Object result = this.securityService.postProcess(null, null, null, false);
+    assertThat(result).isNull();
+  }
+
+  @Test
+  public void postProcess2_value_shouldReturnSameValue() throws Exception {
+    Object value = new Object();
+    Object result = this.securityService.postProcess(null, null, null, value, 
false);
+    assertThat(result).isNotNull().isSameAs(value);
+  }
+
+  @Test
+  public void postProcess2_null_returnsNull() throws Exception {
+    Object result = this.securityService.postProcess(null, null, null, null, 
false);
+    assertThat(result).isNull();
+  }
+
+  @Test
+  public void isClientSecurityRequired_returnsTrue() throws Exception {
+    boolean result = this.securityService.isClientSecurityRequired();
+    assertThat(result).isTrue();
+  }
+
+  @Test
+  public void isIntegratedSecurity_returnsTrue() throws Exception {
+    boolean result = this.securityService.isIntegratedSecurity();
+    assertThat(result).isTrue();
+  }
+
+  @Test
+  public void isPeerSecurityRequired_returnsTrue() throws Exception {
+    boolean result = this.securityService.isPeerSecurityRequired();
+    assertThat(result).isTrue();
+  }
+
+  @Test
+  public void getSecurityManager_returnsSecurityManager() throws Exception {
+    SecurityManager securityManager = 
this.securityService.getSecurityManager();
+    assertThat(securityManager).isNotNull().isSameAs(this.mockSecurityManager);
+  }
+
+  @Test
+  public void getPostProcessor_returnsNull() throws Exception {
+    PostProcessor postProcessor = this.securityService.getPostProcessor();
+    assertThat(postProcessor).isNull();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/FakePostProcessor.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/FakePostProcessor.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/FakePostProcessor.java
new file mode 100644
index 0000000..7082344
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/FakePostProcessor.java
@@ -0,0 +1,103 @@
+/*
+ * 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.geode.internal.security;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.geode.security.PostProcessor;
+
+public class FakePostProcessor implements PostProcessor {
+
+  private final AtomicInteger initInvocations = new AtomicInteger(0);
+  private final AtomicInteger processRegionValueInvocations = new 
AtomicInteger(0);
+  private final AtomicInteger closeInvocations = new AtomicInteger(0);
+
+  private final AtomicReference<Properties> securityPropsRef = new 
AtomicReference<>();
+  private final AtomicReference<ProcessRegionValueArguments> 
processRegionValueArgumentsRef =
+      new AtomicReference<>();
+
+  @Override
+  public void init(Properties securityProps) {
+    this.initInvocations.incrementAndGet();
+    this.securityPropsRef.set(securityProps);
+  }
+
+  @Override
+  public Object processRegionValue(final Object principal, final String 
regionName,
+      final Object key, final Object value) {
+    this.processRegionValueInvocations.incrementAndGet();
+    this.processRegionValueArgumentsRef
+        .set(new ProcessRegionValueArguments(principal, regionName, key, 
value));
+    return this.processRegionValueArgumentsRef.get();
+  }
+
+  @Override
+  public void close() {
+    this.closeInvocations.incrementAndGet();
+  }
+
+  public int getInitInvocations() {
+    return this.initInvocations.get();
+  }
+
+  public int getProcessRegionValueInvocations() {
+    return this.processRegionValueInvocations.get();
+  }
+
+  public int getCloseInvocations() {
+    return this.closeInvocations.get();
+  }
+
+  public Properties getSecurityProps() {
+    return this.securityPropsRef.get();
+  }
+
+  public ProcessRegionValueArguments getProcessRegionValueArguments() {
+    return this.processRegionValueArgumentsRef.get();
+  }
+
+  public static class ProcessRegionValueArguments {
+    private final Object principal;
+    private final String regionName;
+    private final Object key;
+    private final Object value;
+
+    public ProcessRegionValueArguments(final Object principal, final String 
regionName,
+        final Object key, final Object value) {
+      this.principal = principal;
+      this.regionName = regionName;
+      this.key = key;
+      this.value = value;
+    }
+
+    public Object getPrincipal() {
+      return this.principal;
+    }
+
+    public String getRegionName() {
+      return this.regionName;
+    }
+
+    public Object getKey() {
+      return this.key;
+    }
+
+    public Object getValue() {
+      return this.value;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/FakeSecurityManager.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/FakeSecurityManager.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/FakeSecurityManager.java
new file mode 100644
index 0000000..ca4e6b7
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/FakeSecurityManager.java
@@ -0,0 +1,103 @@
+/*
+ * 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.geode.internal.security;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.geode.security.AuthenticationFailedException;
+import org.apache.geode.security.ResourcePermission;
+import org.apache.geode.security.SecurityManager;
+
+public class FakeSecurityManager implements SecurityManager {
+
+  private final AtomicInteger initInvocations = new AtomicInteger(0);
+  private final AtomicInteger authenticateInvocations = new AtomicInteger(0);
+  private final AtomicInteger authorizeInvocations = new AtomicInteger(0);
+  private final AtomicInteger closeInvocations = new AtomicInteger(0);
+
+  private final AtomicReference<Properties> securityPropsRef = new 
AtomicReference<>();
+  private final AtomicReference<Properties> credentialsRef = new 
AtomicReference<>();
+  private final AtomicReference<AuthorizeArguments> 
processAuthorizeArgumentsRef =
+      new AtomicReference<>();
+
+  @Override
+  public void init(final Properties securityProps) {
+    this.initInvocations.incrementAndGet();
+    this.securityPropsRef.set(securityProps);
+  }
+
+  @Override
+  public Object authenticate(final Properties credentials) throws 
AuthenticationFailedException {
+    this.authenticateInvocations.incrementAndGet();
+    this.credentialsRef.set(credentials);
+    return credentials;
+  }
+
+  @Override
+  public boolean authorize(final Object principal, final ResourcePermission 
permission) {
+    this.authorizeInvocations.incrementAndGet();
+    this.processAuthorizeArgumentsRef.set(new AuthorizeArguments(principal, 
permission));
+    return true;
+  }
+
+  @Override
+  public void close() {
+    this.closeInvocations.incrementAndGet();
+  }
+
+  public int getInitInvocations() {
+    return this.initInvocations.get();
+  }
+
+  public int getAuthenticateInvocations() {
+    return this.authenticateInvocations.get();
+  }
+
+  public int getAuthorizeInvocations() {
+    return this.authorizeInvocations.get();
+  }
+
+  public int getCloseInvocations() {
+    return this.closeInvocations.get();
+  }
+
+  public Properties getSecurityProps() {
+    return this.securityPropsRef.get();
+  }
+
+  public AuthorizeArguments getAuthorizeArguments() {
+    return this.processAuthorizeArgumentsRef.get();
+  }
+
+  public static class AuthorizeArguments {
+    private final Object principal;
+    private final ResourcePermission permission;
+
+    public AuthorizeArguments(final Object principal, final ResourcePermission 
permission) {
+      this.principal = principal;
+      this.permission = permission;
+    }
+
+    public Object getPrincipal() {
+      return this.principal;
+    }
+
+    public ResourcePermission getPermission() {
+      return this.permission;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/IntegratedSecurityServiceTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/IntegratedSecurityServiceTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/IntegratedSecurityServiceTest.java
deleted file mode 100644
index 01782cf..0000000
--- 
a/geode-core/src/test/java/org/apache/geode/internal/security/IntegratedSecurityServiceTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.geode.internal.security;
-
-import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
-import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
-import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.geode.security.GemFireSecurityException;
-import org.apache.geode.security.TestPostProcessor;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
-
-@Category(UnitTest.class)
-public class IntegratedSecurityServiceTest {
-
-  private Properties properties;
-  private SecurityService securityService;
-
-  @Before
-  public void before() {
-    properties = new Properties();
-    securityService = SecurityService.getSecurityService();
-    securityService.initSecurity(properties);
-  }
-
-  @Test
-  public void testGetObjectFromConstructor() {
-    String string = SecurityService.getObjectOfType(String.class.getName(), 
String.class);
-    assertNotNull(string);
-
-    CharSequence charSequence =
-        SecurityService.getObjectOfType(String.class.getName(), 
CharSequence.class);
-    assertNotNull(charSequence);
-
-    assertThatThrownBy(() -> 
SecurityService.getObjectOfType("com.abc.testString", String.class))
-        .isInstanceOf(GemFireSecurityException.class);
-
-    assertThatThrownBy(() -> 
SecurityService.getObjectOfType(String.class.getName(), Boolean.class))
-        .isInstanceOf(GemFireSecurityException.class);
-
-    assertThatThrownBy(() -> SecurityService.getObjectOfType("", String.class))
-        .isInstanceOf(GemFireSecurityException.class);
-
-    assertThatThrownBy(() -> SecurityService.getObjectOfType(null, 
String.class))
-        .isInstanceOf(GemFireSecurityException.class);
-
-    assertThatThrownBy(() -> SecurityService.getObjectOfType("  ", 
String.class))
-        .isInstanceOf(GemFireSecurityException.class);
-  }
-
-  @Test
-  public void testGetObjectFromFactoryMethod() {
-    String string =
-        SecurityService.getObjectOfType(Factories.class.getName() + 
".getString", String.class);
-    assertNotNull(string);
-
-    CharSequence charSequence =
-        SecurityService.getObjectOfType(Factories.class.getName() + 
".getString", String.class);
-    assertNotNull(charSequence);
-
-    assertThatThrownBy(() -> SecurityService
-        .getObjectOfType(Factories.class.getName() + ".getStringNonStatic", 
String.class))
-            .isInstanceOf(GemFireSecurityException.class);
-
-    assertThatThrownBy(() -> SecurityService
-        .getObjectOfType(Factories.class.getName() + ".getNullString", 
String.class))
-            .isInstanceOf(GemFireSecurityException.class);
-  }
-
-  @Test
-  public void testInitialSecurityFlags() {
-    // initial state of IntegratedSecurityService
-    assertFalse(securityService.isIntegratedSecurity());
-    assertFalse(securityService.isClientSecurityRequired());
-    assertFalse(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testInitWithSecurityManager() {
-    properties.setProperty(SECURITY_MANAGER, 
"org.apache.geode.security.TestSecurityManager");
-    properties.setProperty(TestSecurityManager.SECURITY_JSON,
-        "org/apache/geode/security/templates/security.json");
-
-    securityService.initSecurity(properties);
-
-    assertTrue(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertTrue(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testInitWithClientAuthenticator() {
-    properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
-
-    securityService.initSecurity(properties);
-    assertFalse(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertFalse(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testInitWithPeerAuthenticator() {
-    properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
-
-    securityService.initSecurity(properties);
-
-    assertFalse(securityService.isIntegratedSecurity());
-    assertFalse(securityService.isClientSecurityRequired());
-    assertTrue(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testInitWithAuthenticators() {
-    properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
-    properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
-
-    securityService.initSecurity(properties);
-
-    assertFalse(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertTrue(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testInitWithShiroAuthenticator() {
-    properties.setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
-
-    securityService.initSecurity(properties);
-
-    assertTrue(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertTrue(securityService.isPeerSecurityRequired());
-  }
-
-  @Test
-  public void testNoInit() {
-    assertFalse(securityService.isIntegratedSecurity());
-  }
-
-  @Test
-  public void testInitWithOutsideShiroSecurityManager() {
-    SecurityUtils.setSecurityManager(new DefaultSecurityManager());
-    securityService.initSecurity(properties);
-    assertTrue(securityService.isIntegratedSecurity());
-  }
-
-  @Test
-  public void testSetSecurityManager() {
-    // initially
-    assertFalse(securityService.isIntegratedSecurity());
-
-    // init with client authenticator
-    properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
-    securityService.initSecurity(properties);
-    assertFalse(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertFalse(securityService.isPeerSecurityRequired());
-
-    // set a security manager
-    securityService.setSecurityManager(new SimpleTestSecurityManager());
-    assertTrue(securityService.isIntegratedSecurity());
-    assertTrue(securityService.isClientSecurityRequired());
-    assertTrue(securityService.isPeerSecurityRequired());
-    assertFalse(securityService.needPostProcess());
-
-    // set a post processor
-    securityService.setPostProcessor(new TestPostProcessor());
-    assertTrue(securityService.isIntegratedSecurity());
-    assertTrue(securityService.needPostProcess());
-  }
-
-  @After
-  public void after() {
-    securityService.close();
-  }
-
-  private static class Factories {
-
-    public static String getString() {
-      return new String();
-    }
-
-    public static String getNullString() {
-      return null;
-    }
-
-    public String getStringNonStatic() {
-      return new String();
-    }
-
-    public static Boolean getBoolean() {
-      return Boolean.TRUE;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.java
new file mode 100644
index 0000000..8907012
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.geode.internal.security;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+import org.apache.geode.security.PostProcessor;
+import org.apache.geode.security.SecurityManager;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.util.ThreadContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import java.util.Properties;
+
+@Category({IntegrationTest.class, SecurityTest.class})
+public class SecurityServiceFactoryShiroIntegrationTest {
+
+  private static final String SHIRO_INI_FILE = 
"SecurityServiceFactoryShiroIntegrationTest.ini";
+
+  private String shiroIniInClasspath;
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public void before() throws Exception {
+    assertThat(getClass().getResource(SHIRO_INI_FILE)).isNotNull();
+    this.shiroIniInClasspath = getResourcePackage(getClass()) + SHIRO_INI_FILE;
+  }
+
+  @After
+  public void after() throws Exception {
+    ThreadContext.remove();
+    SecurityUtils.setSecurityManager(null);
+  }
+
+  @Test
+  public void getResourcePackage_shouldReturnPackageWithSlashes() throws 
Exception {
+    String expected = "org/apache/geode/internal/security/";
+    assertThat(getResourcePackage(getClass())).isEqualTo(expected);
+  }
+
+  @Test
+  public void create_shiro_createsCustomSecurityService() throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_SHIRO_INIT, this.shiroIniInClasspath);
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, null))
+        .isInstanceOf(CustomSecurityService.class);
+  }
+
+  @Test
+  public void create_all_createsCustomSecurityService() throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_SHIRO_INIT, this.shiroIniInClasspath);
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(
+        SecurityServiceFactory.create(securityConfig, mockSecurityManager, 
mockPostProcessor))
+            .isInstanceOf(CustomSecurityService.class);
+  }
+
+  private String getResourcePackage(Class classInPackage) {
+    return classInPackage.getName().replace(classInPackage.getSimpleName(), 
"").replace(".", "/");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryTest.java
new file mode 100644
index 0000000..f027a43
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceFactoryTest.java
@@ -0,0 +1,280 @@
+/*
+ * 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.geode.internal.security;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+import org.apache.geode.security.PostProcessor;
+import org.apache.geode.security.SecurityManager;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.util.ThreadContext;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
+
+@Category({UnitTest.class, SecurityTest.class})
+public class SecurityServiceFactoryTest {
+
+  @After
+  public void after() throws Exception {
+    ThreadContext.remove();
+    SecurityUtils.setSecurityManager(null);
+  }
+
+  @Test
+  public void getPostProcessor_null_returnsNull() throws Exception {
+    assertThat(SecurityServiceFactory.getPostProcessor(null, null)).isNull();
+  }
+
+  @Test
+  public void getPostProcessor_returnsPostProcessor() throws Exception {
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(SecurityServiceFactory.getPostProcessor(mockPostProcessor, 
null))
+        .isSameAs(mockPostProcessor);
+  }
+
+  @Test
+  public void getPostProcessor_SecurityConfig_createsPostProcessor() throws 
Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_POST_PROCESSOR, 
FakePostProcessor.class.getName());
+
+    PostProcessor postProcessor = 
SecurityServiceFactory.getPostProcessor(null, securityConfig);
+
+    assertThat(postProcessor).isInstanceOf(FakePostProcessor.class);
+
+    FakePostProcessor fakePostProcessor = (FakePostProcessor) postProcessor;
+
+    assertThat(fakePostProcessor.getInitInvocations()).isEqualTo(0);
+    assertThat(fakePostProcessor.getSecurityProps()).isNull();
+  }
+
+  @Test
+  public void getPostProcessor_prefersPostProcessorOverSecurityConfig() throws 
Exception {
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_POST_PROCESSOR, 
FakePostProcessor.class.getName());
+
+    assertThat(SecurityServiceFactory.getPostProcessor(mockPostProcessor, 
securityConfig))
+        .isSameAs(mockPostProcessor);
+  }
+
+  @Test
+  public void getSecurityManager_null_returnsNull() throws Exception {
+    assertThat(SecurityServiceFactory.getSecurityManager(null, null)).isNull();
+  }
+
+  @Test
+  public void getSecurityManager_returnsSecurityManager() throws Exception {
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+
+    assertThat(SecurityServiceFactory.getSecurityManager(mockSecurityManager, 
null))
+        .isSameAs(mockSecurityManager);
+  }
+
+  @Test
+  public void getSecurityManager_SecurityConfig_createsSecurityManager() 
throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_MANAGER, 
FakeSecurityManager.class.getName());
+
+    SecurityManager securityManager =
+        SecurityServiceFactory.getSecurityManager(null, securityConfig);
+
+    assertThat(securityManager).isInstanceOf(FakeSecurityManager.class);
+
+    FakeSecurityManager fakeSecurityManager = (FakeSecurityManager) 
securityManager;
+
+    assertThat(fakeSecurityManager.getInitInvocations()).isEqualTo(0);
+    assertThat(fakeSecurityManager.getSecurityProps()).isNull();
+  }
+
+  @Test
+  public void getSecurityManager_prefersSecurityManagerOverSecurityConfig() 
throws Exception {
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_MANAGER, 
FakePostProcessor.class.getName());
+
+    assertThat(SecurityServiceFactory.getSecurityManager(mockSecurityManager, 
securityConfig))
+        .isSameAs(mockSecurityManager);
+  }
+
+  @Test
+  public void determineType_null_returnsDISABLED() throws Exception {
+    assertThat(SecurityServiceFactory.determineType(null, null, null))
+        .isSameAs(SecurityServiceType.DISABLED);
+  }
+
+  @Test
+  public void determineType_shiro_returnsCUSTOM() throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_SHIRO_INIT, "value");
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
null))
+        .isSameAs(SecurityServiceType.CUSTOM);
+  }
+
+  @Test
+  public void determineType_securityManager_returnsENABLED() throws Exception {
+    Properties securityConfig = new Properties();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, 
mockSecurityManager, null))
+        .isSameAs(SecurityServiceType.ENABLED);
+  }
+
+  @Test
+  public void determineType_postProcessor_returnsDISABLED() throws Exception {
+    Properties securityConfig = new Properties();
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
mockPostProcessor))
+        .isSameAs(SecurityServiceType.DISABLED);
+  }
+
+  @Test
+  public void determineType_both_returnsENABLED() throws Exception {
+    Properties securityConfig = new Properties();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, 
mockSecurityManager,
+        mockPostProcessor)).isSameAs(SecurityServiceType.ENABLED);
+  }
+
+  @Test
+  public void determineType_prefersCUSTOM() throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_SHIRO_INIT, "value");
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, 
mockSecurityManager, null))
+        .isSameAs(SecurityServiceType.CUSTOM);
+  }
+
+  @Test
+  public void determineType_clientAuthenticator_returnsLEGACY() throws 
Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
null))
+        .isSameAs(SecurityServiceType.LEGACY);
+  }
+
+  @Test
+  public void determineType_peerAuthenticator_returnsLEGACY() throws Exception 
{
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
null))
+        .isSameAs(SecurityServiceType.LEGACY);
+  }
+
+  @Test
+  public void determineType_authenticators_returnsLEGACY() throws Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
null))
+        .isSameAs(SecurityServiceType.LEGACY);
+  }
+
+  @Test
+  public void determineType_empty_returnsDISABLED() throws Exception {
+    Properties securityConfig = new Properties();
+
+    assertThat(SecurityServiceFactory.determineType(securityConfig, null, 
null))
+        .isSameAs(SecurityServiceType.DISABLED);
+  }
+
+  @Test
+  public void create_clientAuthenticator_createsLegacySecurityService() throws 
Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, null))
+        .isInstanceOf(LegacySecurityService.class);
+  }
+
+  @Test
+  public void create_peerAuthenticator_createsLegacySecurityService() throws 
Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, null))
+        .isInstanceOf(LegacySecurityService.class);
+  }
+
+  @Test
+  public void create_authenticators_createsLegacySecurityService() throws 
Exception {
+    Properties securityConfig = new Properties();
+    securityConfig.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "value");
+    securityConfig.setProperty(SECURITY_PEER_AUTHENTICATOR, "value");
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, null))
+        .isInstanceOf(LegacySecurityService.class);
+  }
+
+  @Test
+  public void create_none_createsDisabledSecurityService() throws Exception {
+    Properties securityConfig = new Properties();
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, null))
+        .isInstanceOf(DisabledSecurityService.class);
+  }
+
+  @Test
+  public void create_postProcessor_createsDisabledSecurityService() throws 
Exception {
+    Properties securityConfig = new Properties();
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(SecurityServiceFactory.create(securityConfig, null, 
mockPostProcessor))
+        .isInstanceOf(DisabledSecurityService.class);
+  }
+
+  @Test
+  public void create_securityManager_createsEnabledSecurityService() throws 
Exception {
+    Properties securityConfig = new Properties();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+
+    assertThat(SecurityServiceFactory.create(securityConfig, 
mockSecurityManager, null))
+        .isInstanceOf(EnabledSecurityService.class);
+  }
+
+  @Test
+  public void 
create_securityManagerAndPostProcessor_createsEnabledSecurityService()
+      throws Exception {
+    Properties securityConfig = new Properties();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
+    PostProcessor mockPostProcessor = mock(PostProcessor.class);
+
+    assertThat(
+        SecurityServiceFactory.create(securityConfig, mockSecurityManager, 
mockPostProcessor))
+            .isInstanceOf(EnabledSecurityService.class);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceTest.java
new file mode 100644
index 0000000..4489352
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/SecurityServiceTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.geode.internal.security;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
+
+@Category({UnitTest.class, SecurityTest.class})
+public class SecurityServiceTest {
+
+  private Properties properties;
+  private DistributionConfig distributionConfig;
+  private SecurityService securityService;
+
+  @Before
+  public void before() {
+    this.properties = new Properties();
+    this.distributionConfig = mock(DistributionConfig.class);
+    
when(this.distributionConfig.getSecurityProps()).thenReturn(this.properties);
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+  }
+
+  @After
+  public void after() throws Exception {
+    this.securityService.close();
+    SecurityUtils.setSecurityManager(null);
+  }
+
+  @Test
+  public void testInitialSecurityFlags() {
+    // initial state of SecurityService
+    assertThat(this.securityService.isIntegratedSecurity()).isFalse();
+    assertThat(this.securityService.isClientSecurityRequired()).isFalse();
+    assertThat(this.securityService.isPeerSecurityRequired()).isFalse();
+  }
+
+  @Test
+  public void testInitWithSecurityManager() {
+    this.properties.setProperty(SECURITY_MANAGER, 
"org.apache.geode.security.TestSecurityManager");
+    this.properties.setProperty(TestSecurityManager.SECURITY_JSON,
+        "org/apache/geode/security/templates/security.json");
+
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isTrue();
+    assertThat(this.securityService.isClientSecurityRequired()).isTrue();
+    assertThat(this.securityService.isPeerSecurityRequired()).isTrue();
+  }
+
+  @Test
+  public void testInitWithClientAuthenticator() {
+    this.properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isFalse();
+    assertThat(this.securityService.isClientSecurityRequired()).isTrue();
+    assertThat(this.securityService.isPeerSecurityRequired()).isFalse();
+  }
+
+  @Test
+  public void testInitWithPeerAuthenticator() {
+    this.properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isFalse();
+    assertThat(this.securityService.isClientSecurityRequired()).isFalse();
+    assertThat(this.securityService.isPeerSecurityRequired()).isTrue();
+  }
+
+  @Test
+  public void testInitWithAuthenticators() {
+    this.properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
+    this.properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
+
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isFalse();
+    assertThat(this.securityService.isClientSecurityRequired()).isTrue();
+    assertThat(this.securityService.isPeerSecurityRequired()).isTrue();
+  }
+
+  @Test
+  public void testInitWithShiroAuthenticator() {
+    this.properties.setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
+
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isTrue();
+    assertThat(this.securityService.isClientSecurityRequired()).isTrue();
+    assertThat(this.securityService.isPeerSecurityRequired()).isTrue();
+  }
+
+  @Test
+  public void testNoInit() {
+    assertThat(this.securityService.isIntegratedSecurity()).isFalse();
+  }
+
+  @Test
+  public void testInitWithOutsideShiroSecurityManager() {
+    SecurityUtils.setSecurityManager(new DefaultSecurityManager());
+    this.securityService = SecurityServiceFactory.create(null, 
this.distributionConfig);
+
+    assertThat(this.securityService.isIntegratedSecurity()).isTrue();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.java
new file mode 100644
index 0000000..857c0be
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.geode.internal.security.shiro;
+
+import static org.assertj.core.api.Assertions.*;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.config.ConfigurationException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+
+@Category(UnitTest.class)
+public class ConfigInitializerIntegrationTest {
+
+  private static final String SHIRO_INI_FILE = 
"ConfigInitializerIntegrationTest.ini";
+
+  private String shiroIniInClasspath;
+  private ConfigInitializer configInitializer;
+  private String shiroIniInFilesystem;
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public void before() throws Exception {
+    assertThat(getClass().getResource(SHIRO_INI_FILE)).isNotNull();
+
+    this.configInitializer = new ConfigInitializer();
+
+    this.shiroIniInClasspath = getResourcePackage(getClass()) + SHIRO_INI_FILE;
+
+    File shiroIniFile = this.temporaryFolder.newFile(SHIRO_INI_FILE);
+    FileUtils.copyURLToFile(getClass().getResource(SHIRO_INI_FILE), 
shiroIniFile);
+    this.shiroIniInFilesystem = shiroIniFile.getAbsolutePath();
+
+    assertThatThrownBy(() -> SecurityUtils.getSecurityManager())
+        .isInstanceOf(UnavailableSecurityManagerException.class);
+  }
+
+  @After
+  public void after() throws Exception {
+    ThreadContext.remove();
+    SecurityUtils.setSecurityManager(null);
+  }
+
+  @Test
+  public void initialize_fileInClasspath() throws Exception {
+    this.configInitializer.initialize(this.shiroIniInClasspath);
+    assertThat(SecurityUtils.getSecurityManager()).isNotNull();
+  }
+
+  @Test
+  public void initialize_null_throws_ConfigurationException() throws Exception 
{
+    assertThatThrownBy(() -> this.configInitializer.initialize(null))
+        .isInstanceOf(ConfigurationException.class)
+        .hasMessageContaining("Resource [classpath:null] could not be found");
+  }
+
+  @Test
+  public void initialize_fileInFilesystem() throws Exception {
+    assertThatThrownBy(() -> 
this.configInitializer.initialize(this.shiroIniInFilesystem))
+        
.isInstanceOf(ConfigurationException.class).hasMessageContaining("Resource 
[classpath:")
+        .hasMessageContaining("ConfigInitializerIntegrationTest.ini] could not 
be found");
+  }
+
+  private String getResourcePackage(Class classInPackage) {
+    return classInPackage.getName().replace(classInPackage.getSimpleName(), 
"").replace(".", "/");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
index b582e52..bd5083c 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
@@ -20,11 +20,8 @@ import static 
org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_B
 import static 
org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static 
org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertFalse;
-import static org.apache.geode.test.dunit.Assert.assertNotNull;
-import static org.apache.geode.test.dunit.Assert.assertTrue;
 import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.internal.AvailablePortHelper;
@@ -41,12 +38,14 @@ import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import 
org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 import org.junit.Rule;
 import org.junit.rules.TemporaryFolder;
 import org.springframework.shell.core.CommandMarker;
 
 import java.io.IOException;
 import java.io.PrintStream;
+import java.io.Serializable;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.List;
@@ -60,20 +59,26 @@ import java.util.regex.Pattern;
  *
  * @deprecated use LocatorServerStartupRule and GfshShellConnectorRule instead.
  */
+@Deprecated
 public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
 
   public static final String USE_HTTP_SYSTEM_PROPERTY = "useHTTP";
+
   @Rule
-  public transient DistributedRestoreSystemProperties restoreSystemProperties =
+  public DistributedRestoreSystemProperties restoreSystemProperties =
       new DistributedRestoreSystemProperties();
+
   @Rule
-  public transient TemporaryFolder temporaryFolder = new TemporaryFolder();
-  protected transient int httpPort;
-  protected transient int jmxPort;
-  protected transient String jmxHost;
-  protected transient String gfshDir;
-  private boolean useHttpOnConnect = 
Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
-  private ManagementService managementService;
+  public SerializableTemporaryFolder temporaryFolder = new 
SerializableTemporaryFolder();
+
+  protected int httpPort;
+  protected int jmxPort;
+  protected String jmxHost;
+  protected String gfshDir;
+
+  private final boolean useHttpOnConnect = 
Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
+
+  private transient ManagementService managementService;
   private transient HeadlessGfsh shell;
 
   public static boolean checkIfCommandsAreLoadedOrNot() {
@@ -84,7 +89,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
   }
 
   protected static String commandResultToString(final CommandResult 
commandResult) {
-    assertNotNull(commandResult);
+    assertThat(commandResult).isNotNull();
 
     commandResult.resetToFirstLine();
 
@@ -109,7 +114,9 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
     this.gfshDir = 
this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath();
   }
 
-  protected void postSetUpCliCommandTestBase() throws Exception {}
+  protected void postSetUpCliCommandTestBase() throws Exception {
+    // nothing
+  }
 
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
@@ -118,7 +125,9 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
     destroyDefaultSetup();
   }
 
-  protected void preTearDownCliCommandTestBase() throws Exception {}
+  protected void preTearDownCliCommandTestBase() throws Exception {
+    // nothing
+  }
 
   /**
    * Create all of the components necessary for the default setup. The 
provided properties will be
@@ -131,14 +140,13 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @param props the Properties used when creating the cache for this default 
setup.
    * @return the default testable GemFire shell.
    */
-  @SuppressWarnings("serial")
   protected HeadlessGfsh setUpJmxManagerOnVm0ThenConnect(final Properties 
props) {
     Object[] result = setUpJMXManagerOnVM(0, props);
     this.jmxHost = (String) result[0];
     this.jmxPort = (Integer) result[1];
     this.httpPort = (Integer) result[2];
     connect(this.jmxHost, this.jmxPort, this.httpPort, getDefaultShell());
-    return shell;
+    return this.shell;
   }
 
   protected Object[] setUpJMXManagerOnVM(int vm, final Properties props) {
@@ -155,9 +163,9 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
       final Properties localProps = (props != null ? props : new Properties());
 
       try {
-        jmxHost = InetAddress.getLocalHost().getHostName();
+        this.jmxHost = InetAddress.getLocalHost().getHostName();
       } catch (UnknownHostException ignore) {
-        jmxHost = "localhost";
+        this.jmxHost = "localhost";
       }
 
       if (!localProps.containsKey(NAME)) {
@@ -170,14 +178,14 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
 
       final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
-      jmxPort = ports[0];
-      httpPort = ports[1];
+      this.jmxPort = ports[0];
+      this.httpPort = ports[1];
 
       localProps.setProperty(JMX_MANAGER, "true");
       localProps.setProperty(JMX_MANAGER_START, "true");
-      localProps.setProperty(JMX_MANAGER_BIND_ADDRESS, 
String.valueOf(jmxHost));
-      localProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
-      localProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
+      localProps.setProperty(JMX_MANAGER_BIND_ADDRESS, 
String.valueOf(this.jmxHost));
+      localProps.setProperty(JMX_MANAGER_PORT, String.valueOf(this.jmxPort));
+      localProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(this.httpPort));
 
       getSystem(localProps);
       verifyManagementServiceStarted(getCache());
@@ -185,9 +193,9 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
       
IgnoredException.addIgnoredException("org.eclipse.jetty.io.EofException");
       
IgnoredException.addIgnoredException("java.nio.channels.ClosedChannelException");
 
-      results[0] = jmxHost;
-      results[1] = jmxPort;
-      results[2] = httpPort;
+      results[0] = this.jmxHost;
+      results[1] = this.jmxPort;
+      results[2] = this.httpPort;
       return results;
     });
 
@@ -199,7 +207,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    */
   protected void destroyDefaultSetup() {
     if (this.shell != null) {
-      executeCommand(shell, "exit");
+      executeCommand(this.shell, "exit");
       this.shell.terminate();
       this.shell = null;
     }
@@ -216,12 +224,12 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @param cache Cache to use when creating the management service
    */
   private void verifyManagementServiceStarted(Cache cache) {
-    assertTrue(cache != null);
+    assertThat(cache).isNotNull();
 
     this.managementService = 
ManagementService.getExistingManagementService(cache);
-    assertNotNull(this.managementService);
-    assertTrue(this.managementService.isManager());
-    assertTrue(checkIfCommandsAreLoadedOrNot());
+    assertThat(this.managementService).isNotNull();
+    assertThat(this.managementService.isManager()).isTrue();
+    assertThat(checkIfCommandsAreLoadedOrNot()).isTrue();
   }
 
   /**
@@ -229,7 +237,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    */
   private void verifyManagementServiceStopped() {
     if (this.managementService != null) {
-      assertFalse(this.managementService.isManager());
+      assertThat(this.managementService.isManager()).isFalse();
       this.managementService = null;
     }
   }
@@ -244,7 +252,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
     final CommandStringBuilder command = new 
CommandStringBuilder(CliStrings.CONNECT);
 
     String endpoint;
-    if (useHttpOnConnect) {
+    if (this.useHttpOnConnect) {
       endpoint = "http://"; + host + ":" + httpPort + "/gemfire/v1";
       command.addOption(CliStrings.CONNECT__USE_HTTP, Boolean.TRUE.toString());
       command.addOption(CliStrings.CONNECT__URL, endpoint);
@@ -263,12 +271,13 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
     CommandResult result = executeCommand(shell, command.toString());
 
     if (!shell.isConnectedAndReady()) {
-      throw new AssertionError("Connect command failed to connect to manager " 
+ endpoint
-          + " result=" + commandResultToString(result));
+      throw new AssertionError("Execution of " + command + " failed to connect 
to manager "
+          + endpoint + " result=" + commandResultToString(result));
     }
 
-    info("Successfully connected to managing node using " + (useHttpOnConnect 
? "HTTP" : "JMX"));
-    assertEquals(true, shell.isConnectedAndReady());
+    info("Successfully connected to managing node using "
+        + (this.useHttpOnConnect ? "HTTP" : "JMX"));
+    assertThat(shell.isConnectedAndReady()).isTrue();
   }
 
   /**
@@ -289,7 +298,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    *
    * @return The created shell.
    */
-  protected HeadlessGfsh createShell() {
+  private HeadlessGfsh createShell() {
     try {
       Gfsh.SUPPORT_MUTLIPLESHELL = true;
       String shellId = getClass().getSimpleName() + "_" + getName();
@@ -297,9 +306,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
       // Added to avoid trimming of the columns
       info("Started testable shell: " + shell);
       return shell;
-    } catch (ClassNotFoundException e) {
-      throw new AssertionError(e);
-    } catch (IOException e) {
+    } catch (ClassNotFoundException | IOException e) {
       throw new AssertionError(e);
     }
   }
@@ -311,7 +318,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The result of the command execution
    */
   protected CommandResult executeCommand(String command) {
-    assert (command != null);
+    assertThat(command).isNotNull();
 
     return executeCommand(getDefaultShell(), command);
   }
@@ -324,8 +331,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The result of the command execution
    */
   protected CommandResult executeCommand(HeadlessGfsh shell, String command) {
-    assert (shell != null);
-    assert (command != null);
+    assertThat(shell).isNotNull();
+    assertThat(command).isNotNull();
 
     CommandResult commandResult = executeCommandWithoutClear(shell, command);
     shell.clearEvents();
@@ -340,9 +347,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @param command Command to execute
    * @return The result of the command execution
    */
-  @SuppressWarnings("unused")
   protected CommandResult executeCommandWithoutClear(String command) {
-    assert (command != null);
+    assertThat(command).isNotNull();
 
     return executeCommandWithoutClear(getDefaultShell(), command);
   }
@@ -357,19 +363,20 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The result of the command execution
    */
   protected CommandResult executeCommandWithoutClear(HeadlessGfsh shell, 
String command) {
-    assert (shell != null);
-    assert (command != null);
+    assertThat(shell).isNotNull();
+    assertThat(command).isNotNull();
+
     shell.executeCommand(command);
     if (shell.hasError()) {
-      error("executeCommand completed with error : " + shell.getError());
+      throw new AssertionError(shell.getError());
     }
 
     CommandResult result = null;
     try {
-      result = (CommandResult) shell.getResult(); // TODO: this can result in 
ClassCastException if
-                                                  // command resulted in error
+      // TODO: this can result in ClassCastException if command resulted in 
error
+      result = (CommandResult) shell.getResult();
     } catch (InterruptedException ex) {
-      error("shell received InterruptedException");
+      throw new AssertionError(ex);
     }
 
     if (result != null) {
@@ -386,8 +393,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @param printStream Stream to dump the results to
    */
   protected void printResult(final CommandResult commandResult, PrintStream 
printStream) {
-    assert (commandResult != null);
-    assert (printStream != null);
+    assertThat(commandResult).isNotNull();
+    assertThat(printStream).isNotNull();
 
     commandResult.resetToFirstLine();
     printStream.print(commandResultToString(commandResult));
@@ -400,7 +407,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The CommandResult object or null if not found.
    */
   protected CommandResult extractCommandResult(Map<String, Object> 
commandOutput) {
-    assert (commandOutput != null);
+    assertThat(commandOutput).isNotNull();
 
     for (Object resultObject : commandOutput.values()) {
       if (resultObject instanceof CommandResult) {
@@ -422,8 +429,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The number of matches.
    */
   protected int countMatchesInString(final String stringToSearch, final String 
stringToCount) {
-    assert (stringToSearch != null);
-    assert (stringToCount != null);
+    assertThat(stringToSearch).isNotNull();
+    assertThat(stringToCount).isNotNull();
 
     int length = stringToSearch.length();
     int count = 0;
@@ -445,8 +452,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return True if a match is found, false otherwise
    */
   protected boolean stringContainsLine(final String stringToSearch, final 
String stringPattern) {
-    assert (stringToSearch != null);
-    assert (stringPattern != null);
+    assertThat(stringToSearch).isNotNull();
+    assertThat(stringPattern).isNotNull();
 
     Pattern pattern = Pattern.compile("^\\s*" + stringPattern + "\\s*$", 
Pattern.MULTILINE);
     Matcher matcher = pattern.matcher(stringToSearch);
@@ -461,7 +468,7 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The number of lines found.
    */
   protected int countLinesInString(final String stringToSearch, final boolean 
countBlankLines) {
-    assert (stringToSearch != null);
+    assertThat(stringToSearch).isNotNull();
 
     int length = stringToSearch.length();
     int count = 0;
@@ -503,8 +510,8 @@ public abstract class CliCommandTestBase extends 
JUnit4CacheTestCase {
    * @return The line
    */
   protected String getLineFromString(final String stringToSearch, final int 
lineNumber) {
-    assert (stringToSearch != null);
-    assert (lineNumber > 0);
+    assertThat(stringToSearch != null).isNotNull();
+    assertThat(lineNumber).isGreaterThan(0);
 
     int length = stringToSearch.length();
     int count = 0;

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
index 4b7ba9c..1aad49c 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
@@ -58,7 +58,6 @@ import 
org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.DiskStoreImpl;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.PartitionedRegion;
@@ -107,7 +106,7 @@ import java.util.concurrent.TimeUnit;
 @SuppressWarnings("serial")
 public class DiskStoreCommandsDUnitTest extends CliCommandTestBase {
 
-  final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
+  private final List<String> filesToBeDeleted = new CopyOnWriteArrayList<>();
 
   @Category(FlakyTest.class) // GEODE-2102
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
index 30ece5a..22502c3 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MemberCommandsDUnitTest.java
@@ -52,7 +52,9 @@ import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.ClassRule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.ProvideSystemProperty;
 import org.junit.experimental.categories.Category;
 
 import java.io.File;
@@ -78,6 +80,10 @@ public class MemberCommandsDUnitTest extends 
JUnit4CacheTestCase {
   private static final String PR1 = "PartitionedRegion1";
   private static final String PR2 = "ParitionedRegion2";
 
+  @ClassRule
+  public static ProvideSystemProperty provideSystemProperty =
+      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, 
"true");
+
   @Override
   public final void postSetUp() throws Exception {
     // This test does not require an actual Gfsh connection to work, however 
when run as part of a

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
index 04a8c13..a56febe 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueueCommandsDUnitTest.java
@@ -77,7 +77,7 @@ public class QueueCommandsDUnitTest extends 
CliCommandTestBase {
 
   private static final long serialVersionUID = 1L;
 
-  final List<String> filesToBeDeleted = new CopyOnWriteArrayList<String>();
+  private final List<String> filesToBeDeleted = new CopyOnWriteArrayList<>();
 
   @Override
   public final void preSetUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
new file mode 100644
index 0000000..d8c3095
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.apache.geode.test.dunit.Wait.waitForCriterion;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.DistributedRegionMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.SerializableRunnable;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.WaitCriterion;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.ProvideSystemProperty;
+import org.junit.experimental.categories.Category;
+
+@Category(DistributedTest.class)
+public class RebalanceCommandDistributedTest extends CliCommandTestBase {
+
+  private static final String REBALANCE_REGION_NAME =
+      RebalanceCommandDistributedTest.class.getSimpleName() + "Region";
+
+  @ClassRule
+  public static ProvideSystemProperty provideSystemProperty =
+      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, 
"false");
+
+  @Before
+  public void before() throws Exception {
+    setUpJmxManagerOnVm0ThenConnect(null);
+    setupTestRebalanceForEntireDS();
+  }
+
+  @Test
+  public void testSimulateForEntireDSWithTimeout() {
+    // check if DistributedRegionMXBean is available so that command will not 
fail
+    final VM manager = Host.getHost(0).getVM(0);
+    manager.invoke(() -> checkRegionMBeans());
+
+    getLogWriter().info("testSimulateForEntireDS verified MBean and executing 
command");
+
+    String command = "rebalance --simulate=true --time-out=-1";
+
+    CommandResult cmdResult = executeCommand(command);
+
+    getLogWriter().info("testSimulateForEntireDS just after executing " + 
cmdResult);
+
+    assertThat(cmdResult).isNotNull();
+
+    String stringResult = commandResultToString(cmdResult);
+    getLogWriter().info("testSimulateForEntireDS stringResult : " + 
stringResult);
+    assertThat(cmdResult.getStatus()).isEqualTo(Result.Status.OK);
+  }
+
+  private void checkRegionMBeans() {
+    WaitCriterion waitForManagerMBean = new WaitCriterion() {
+      @Override
+      public boolean done() {
+        final ManagementService service = 
ManagementService.getManagementService(getCache());
+        final DistributedRegionMXBean bean =
+            service.getDistributedRegionMXBean(Region.SEPARATOR + 
REBALANCE_REGION_NAME);
+        if (bean == null) {
+          getLogWriter().info("Still probing for checkRegionMBeans 
ManagerMBean");
+          return false;
+        } else {
+          // verify that bean is proper before executing tests
+          return bean.getMembers() != null && bean.getMembers().length > 1
+              && bean.getMemberCount() > 0
+              && service.getDistributedSystemMXBean().listRegions().length >= 
2;
+        }
+      }
+
+      @Override
+      public String description() {
+        return "Probing for testRebalanceCommandForSimulateWithNoMember 
ManagerMBean";
+      }
+    };
+
+    waitForCriterion(waitForManagerMBean, 2 * 60 * 1000, 2000, true);
+
+    DistributedRegionMXBean bean = 
ManagementService.getManagementService(getCache())
+        .getDistributedRegionMXBean("/" + REBALANCE_REGION_NAME);
+    assertThat(bean).isNotNull();
+  }
+
+  private void setupTestRebalanceForEntireDS() {
+    VM vm1 = Host.getHost(0).getVM(1);
+    VM vm2 = Host.getHost(0).getVM(2);
+
+    vm1.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+
+        // no need to close cache as it will be closed as part of teardown2
+        Cache cache = getCache();
+
+        RegionFactory<Integer, Integer> dataRegionFactory =
+            cache.createRegionFactory(RegionShortcut.PARTITION);
+        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
+        for (int i = 0; i < 10; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another1");
+        for (int i = 0; i < 100; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+      }
+    });
+
+    vm2.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+
+        // no need to close cache as it will be closed as part of teardown2
+        Cache cache = getCache();
+
+        RegionFactory<Integer, Integer> dataRegionFactory =
+            cache.createRegionFactory(RegionShortcut.PARTITION);
+        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
+        for (int i = 0; i < 100; i++) {
+          region.put("key" + (i + 400), "value" + (i + 400));
+        }
+        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another2");
+        for (int i = 0; i < 10; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+      }
+    });
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
index 626ca45..49b8347 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
@@ -31,6 +31,7 @@ import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class AccessControlMBeanJUnitTest {
+
   private AccessControlMXBean bean;
 
   @ClassRule

Reply via email to