You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2017/07/17 18:06:26 UTC
[17/58] [abbrv] geode git commit: Revert "GEODE-2632: use immutable
SecurityService impls to improve performance"
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 5a4a3d7..b3d9675 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -26,6 +26,8 @@ import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.execute.AbstractExecution;
import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.ConverterHint;
import org.apache.geode.management.cli.Result;
@@ -39,6 +41,7 @@ import org.apache.geode.management.internal.cli.functions.CreateIndexFunction;
import org.apache.geode.management.internal.cli.functions.DestroyIndexFunction;
import org.apache.geode.management.internal.cli.functions.ListIndexFunction;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResultException;
import org.apache.geode.management.internal.cli.result.ErrorResultData;
import org.apache.geode.management.internal.cli.result.InfoResultData;
import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -64,7 +67,8 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* The IndexCommands class encapsulates all GemFire shell (Gfsh) commands related to indexes defined
* in GemFire.
- *
+ * </p>
+ *
* @see GfshCommand
* @see org.apache.geode.management.internal.cli.domain.IndexDetails
* @see org.apache.geode.management.internal.cli.functions.ListIndexFunction
@@ -80,6 +84,8 @@ public class IndexCommands implements GfshCommand {
private static final Set<IndexInfo> indexDefinitions =
Collections.synchronizedSet(new HashSet<IndexInfo>());
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
+
@CliCommand(value = CliStrings.LIST_INDEX, help = CliStrings.LIST_INDEX__HELP)
@CliMetaData(shellOnly = false,
relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@@ -190,7 +196,7 @@ public class IndexCommands implements GfshCommand {
Result result = null;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
- getCache().getSecurityService().authorizeRegionManage(regionPath);
+ this.securityService.authorizeRegionManage(regionPath);
try {
final Cache cache = CacheFactory.getAnyInstance();
@@ -306,6 +312,7 @@ public class IndexCommands implements GfshCommand {
result = ResultBuilder.createGemFireErrorResult(e.getMessage());
}
+
if (xmlEntity.get() != null) {
persistClusterConfiguration(result,
() -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), group));
@@ -348,9 +355,9 @@ public class IndexCommands implements GfshCommand {
// requires data manage permission on all regions
if (StringUtils.isNotBlank(regionPath)) {
regionName = regionPath.startsWith("/") ? regionPath.substring(1) : regionPath;
- getCache().getSecurityService().authorizeRegionManage(regionName);
+ this.securityService.authorizeRegionManage(regionName);
} else {
- getCache().getSecurityService().authorizeDataManage();
+ this.securityService.authorizeDataManage();
}
IndexInfo indexInfo = new IndexInfo(indexName, regionName);
@@ -472,7 +479,7 @@ public class IndexCommands implements GfshCommand {
Result result = null;
XmlEntity xmlEntity = null;
- getCache().getSecurityService().authorizeRegionManage(regionPath);
+ this.securityService.authorizeRegionManage(regionPath);
int idxType = IndexInfo.RANGE_INDEX;
@@ -634,13 +641,14 @@ public class IndexCommands implements GfshCommand {
final InfoResultData infoResult = ResultBuilder.createInfoResultData();
infoResult.addLine(CliStrings.CLEAR_DEFINED_INDEX__SUCCESS__MSG);
return ResultBuilder.buildResult(infoResult);
+
}
@CliAvailabilityIndicator({CliStrings.LIST_INDEX, CliStrings.CREATE_INDEX,
CliStrings.DESTROY_INDEX, CliStrings.CREATE_DEFINED_INDEXES, CliStrings.CLEAR_DEFINED_INDEXES,
CliStrings.DEFINE_INDEX})
public boolean indexCommandsAvailable() {
- return !CliUtil.isGfshVM() || getGfsh() != null && getGfsh().isConnectedAndReady();
+ return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
}
protected static class IndexStatisticsDetailsAdapter {
@@ -656,28 +664,28 @@ public class IndexCommands implements GfshCommand {
}
public String getNumberOfKeys() {
- return getIndexStatisticsDetails() != null
- ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfKeys()) : "";
+ return (getIndexStatisticsDetails() != null
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfKeys()) : "");
}
public String getNumberOfUpdates() {
- return getIndexStatisticsDetails() != null
- ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfUpdates()) : "";
+ return (getIndexStatisticsDetails() != null
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfUpdates()) : "");
}
public String getNumberOfValues() {
- return getIndexStatisticsDetails() != null
- ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfValues()) : "";
+ return (getIndexStatisticsDetails() != null
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getNumberOfValues()) : "");
}
public String getTotalUpdateTime() {
- return getIndexStatisticsDetails() != null
- ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUpdateTime()) : "";
+ return (getIndexStatisticsDetails() != null
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUpdateTime()) : "");
}
public String getTotalUses() {
- return getIndexStatisticsDetails() != null
- ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUses()) : "";
+ return (getIndexStatisticsDetails() != null
+ ? StringUtils.defaultString(getIndexStatisticsDetails().getTotalUses()) : "");
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
index 20e2701..e2164a3 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
@@ -94,6 +94,9 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
protected static final String SELECT_STEP_EXEC = "SELECT_EXEC";
private static final int NESTED_JSON_LENGTH = 20;
+ // this needs to be static so that it won't get serialized
+ private static SecurityService securityService = SecurityService.getSecurityService();
+
@Override
public String getId() {
return DataCommandFunction.class.getName();
@@ -133,7 +136,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
}
DataCommandResult result = null;
if (request.isGet()) {
- result = get(request, cache.getSecurityService());
+ result = get(request);
} else if (request.isLocateEntry()) {
result = locateEntry(request);
} else if (request.isPut()) {
@@ -166,14 +169,13 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
return remove(key, keyClass, regionName, removeAllKeys);
}
- public DataCommandResult get(DataCommandRequest request, SecurityService securityService) {
+ public DataCommandResult get(DataCommandRequest request) {
String key = request.getKey();
String keyClass = request.getKeyClass();
String valueClass = request.getValueClass();
String regionName = request.getRegionName();
Boolean loadOnCacheMiss = request.isLoadOnCacheMiss();
- return get(request.getPrincipal(), key, keyClass, valueClass, regionName, loadOnCacheMiss,
- securityService);
+ return get(request.getPrincipal(), key, keyClass, valueClass, regionName, loadOnCacheMiss);
}
public DataCommandResult locateEntry(DataCommandRequest request) {
@@ -294,7 +296,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
List<SelectResultRow> list, AtomicInteger nestedObjectCount) throws GfJsonException {
for (Object object : selectResults) {
// Post processing
- object = getCache().getSecurityService().postProcess(principal, null, null, object, false);
+ object = securityService.postProcess(principal, null, null, object, false);
if (object instanceof Struct) {
StructImpl impl = (StructImpl) object;
@@ -432,7 +434,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
@SuppressWarnings({"rawtypes"})
public DataCommandResult get(Object principal, String key, String keyClass, String valueClass,
- String regionName, Boolean loadOnCacheMiss, SecurityService securityService) {
+ String regionName, Boolean loadOnCacheMiss) {
InternalCache cache = getCache();
@@ -834,7 +836,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
return list;
}
- static DataCommandResult cachedResult = null;
+ private static DataCommandResult cachedResult = null;
public static class SelectDisplayStep extends CLIMultiStepHelper.LocalStep {
@@ -914,12 +916,13 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
}
public static class SelectExecStep extends CLIMultiStepHelper.RemoteStep {
- private static final Logger logger = LogService.getLogger();
private static final long serialVersionUID = 1L;
+ private static SecurityService securityService = SecurityService.getSecurityService();
+
public SelectExecStep(Object[] arguments) {
- super(DataCommandFunction.SELECT_STEP_EXEC, arguments);
+ super(SELECT_STEP_EXEC, arguments);
}
@Override
@@ -928,19 +931,19 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
boolean interactive = (Boolean) commandArguments[2];
DataCommandResult result = _select(remainingQuery);
int endCount = 0;
- DataCommandFunction.cachedResult = result;
+ cachedResult = result;
if (interactive) {
- endCount = DataCommandFunction.getPageSize();
+ endCount = getPageSize();
} else {
if (result.getSelectResult() != null) {
endCount = result.getSelectResult().size();
}
}
if (interactive) {
- return result.pageResult(0, endCount, DataCommandFunction.SELECT_STEP_DISPLAY);
+ return result.pageResult(0, endCount, SELECT_STEP_DISPLAY);
} else {
return CLIMultiStepHelper.createBannerResult(new String[] {}, new Object[] {},
- DataCommandFunction.SELECT_STEP_END);
+ SELECT_STEP_END);
}
}
@@ -968,7 +971,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
// authorize data read on these regions
for (String region : regions) {
- cache.getSecurityService().authorizeRegionRead(region);
+ securityService.authorizeRegionRead(region);
}
regionsInQuery = Collections.unmodifiableSet(regions);
@@ -980,7 +983,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
DataCommandRequest request = new DataCommandRequest();
request.setCommand(CliStrings.QUERY);
request.setQuery(query);
- Subject subject = cache.getSecurityService().getSubject();
+ Subject subject = securityService.getSubject();
if (subject != null) {
request.setPrincipal(subject.getPrincipal());
}
@@ -1009,7 +1012,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
|| StringUtils.containsIgnoreCase(query, " count(")) {
return query;
}
- return query + " limit " + DataCommandFunction.getFetchSize();
+ return query + " limit " + getFetchSize();
}
}
@@ -1060,7 +1063,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti
return pageSize;
}
- static int getFetchSize() {
+ private static int getFetchSize() {
return CommandExecutionContext.getShellFetchSize();
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
index 7ec7699..c2c6e14 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.management.internal.cli.remote;
+import org.apache.geode.internal.security.IntegratedSecurityService;
import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.SecurityServiceFactory;
import org.apache.geode.management.cli.CommandProcessingException;
import org.apache.geode.management.cli.CommandStatement;
import org.apache.geode.management.cli.Result;
@@ -34,6 +34,8 @@ import java.util.Map;
import java.util.Properties;
/**
+ *
+ *
* @since GemFire 7.0
*/
public class CommandProcessor {
@@ -47,18 +49,16 @@ public class CommandProcessor {
private volatile boolean isStopped = false;
- private final SecurityService securityService;
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
public CommandProcessor() throws ClassNotFoundException, IOException {
- this(null, SecurityServiceFactory.create());
+ this(null);
}
- public CommandProcessor(Properties cacheProperties, SecurityService securityService)
- throws ClassNotFoundException, IOException {
+ public CommandProcessor(Properties cacheProperties) throws ClassNotFoundException, IOException {
this.gfshParser = new GfshParser(cacheProperties);
this.executionStrategy = new RemoteExecutionStrategy();
this.logWrapper = LogWrapper.getInstance();
- this.securityService = securityService;
}
protected RemoteExecutionStrategy getExecutionStrategy() {
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java
index 25ff549..a19c5cb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java
@@ -17,23 +17,24 @@ package org.apache.geode.management.internal.cli.remote;
import java.io.IOException;
import java.util.Map;
-import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.cache.Cache;
import org.apache.geode.management.cli.CommandService;
import org.apache.geode.management.cli.CommandServiceException;
import org.apache.geode.management.cli.CommandStatement;
import org.apache.geode.management.cli.Result;
+/**
+ */
public class MemberCommandService extends CommandService {
private final Object modLock = new Object();
- private InternalCache cache;
+ private Cache cache;
private CommandProcessor commandProcessor;
- public MemberCommandService(InternalCache cache) throws CommandServiceException {
+ public MemberCommandService(Cache cache) throws CommandServiceException {
this.cache = cache;
try {
- this.commandProcessor = new CommandProcessor(cache.getDistributedSystem().getProperties(),
- cache.getSecurityService());
+ this.commandProcessor = new CommandProcessor(cache.getDistributedSystem().getProperties());
} catch (ClassNotFoundException e) {
throw new CommandServiceException("Could not load commands.", e);
} catch (IOException e) {
@@ -69,4 +70,12 @@ public class MemberCommandService extends CommandService {
return (this.cache != null && !this.cache.isClosed());
}
+ // @Override
+ // public void stop() {
+ // cache = null;
+ // synchronized (modLock) {
+ // this.commandProcessor.stop();
+ // this.commandProcessor = null;
+ // }
+ // }
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
index f25d1af..a00a79e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.configuration.functions;
import org.apache.geode.cache.execute.Function;
import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.internal.InternalEntity;
import org.apache.geode.internal.cache.CacheConfig;
import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -28,7 +28,7 @@ public class RecreateCacheFunction implements Function, InternalEntity {
public void execute(FunctionContext context) {
CliFunctionResult result = null;
InternalCache cache = GemFireCacheImpl.getInstance();
- InternalDistributedSystem ds = cache.getInternalDistributedSystem();
+ DistributedSystem ds = cache.getDistributedSystem();
CacheConfig cacheConfig = cache.getCacheConfig();
try {
cache.close("Re-create Cache", true, true);
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java
index 365c6ae..6514a33 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.management.internal.security;
+import org.apache.geode.internal.security.IntegratedSecurityService;
import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.security.GemFireSecurityException;
@@ -25,11 +26,7 @@ import org.apache.geode.security.GemFireSecurityException;
*/
public class AccessControlMBean implements AccessControlMXBean {
- private final SecurityService securityService;
-
- public AccessControlMBean(SecurityService securityService) {
- this.securityService = securityService;
- }
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
@Override
public boolean authorize(String resource, String permission) {
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
index 345d688..fe79efb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
@@ -14,11 +14,6 @@
*/
package org.apache.geode.management.internal.security;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.management.internal.ManagementConstants;
-import org.apache.geode.security.GemFireSecurityException;
-import org.apache.geode.security.ResourcePermission;
-
import java.io.ObjectInputStream;
import java.util.Set;
import javax.management.Attribute;
@@ -47,22 +42,25 @@ import javax.management.ReflectionException;
import javax.management.loading.ClassLoaderRepository;
import javax.management.remote.MBeanServerForwarder;
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.management.internal.ManagementConstants;
+import org.apache.geode.security.GemFireSecurityException;
+import org.apache.geode.security.ResourcePermission;
+
/**
* This class intercepts all MBean requests for GemFire MBeans and passed it to
* ManagementInterceptor for authorization
*
* @since Geode 1.0
+ *
*/
public class MBeanServerWrapper implements MBeanServerForwarder {
-
- // TODO: make volatile or verify this is thread-safe
private MBeanServer mbs;
- private final SecurityService securityService;
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
- public MBeanServerWrapper(SecurityService securityService) {
- this.securityService = securityService;
- }
+ public MBeanServerWrapper() {}
private void checkDomain(ObjectName name) {
if (ManagementConstants.OBJECTNAME__DEFAULTDOMAIN.equals(name.getDomain()))
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
index 0a18ec5..54c29f8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java
@@ -12,6 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package org.apache.geode.management.internal.web.controllers;
import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -19,6 +20,8 @@ import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.logging.log4j.LogMarker;
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.internal.util.ArrayUtils;
import org.apache.geode.management.DistributedSystemMXBean;
import org.apache.geode.management.ManagementService;
@@ -82,6 +85,8 @@ public abstract class AbstractCommandsController {
private MemberMXBean managingMemberMXBeanProxy;
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
+
private Class accessControlKlass;
private InternalCache getCache() {
@@ -571,9 +576,10 @@ public abstract class AbstractCommandsController {
return new ResponseEntity<String>(result, HttpStatus.OK);
}
};
- return getCache().getSecurityService().associateWith(callable);
+ return this.securityService.associateWith(callable);
}
+
/**
* Executes the specified command as entered by the user using the GemFire Shell (Gfsh). Note,
* Gfsh performs validation of the command during parsing before sending the command to the
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java
index 5e502f5..56d9b9e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java
@@ -14,14 +14,11 @@
*/
package org.apache.geode.management.internal.web.controllers.support;
-import static org.apache.geode.internal.security.SecurityServiceFactory.findSecurityService;
-
+import org.apache.geode.cache.Cache;
import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.security.IntegratedSecurityService;
import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.SecurityServiceFactory;
import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper;
import org.apache.geode.management.internal.security.ResourceConstants;
import org.apache.geode.management.internal.web.util.UriUtils;
@@ -51,7 +48,9 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = LogService.getLogger();
- private final SecurityService securityService;
+ private Cache cache;
+
+ private SecurityService securityService = IntegratedSecurityService.getSecurityService();
private static final ThreadLocal<Map<String, String>> ENV =
new ThreadLocal<Map<String, String>>() {
@@ -66,14 +65,6 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {
protected static final String SECURITY_VARIABLE_REQUEST_HEADER_PREFIX =
DistributionConfig.SECURITY_PREFIX_NAME;
- public LoginHandlerInterceptor() {
- this(findSecurityService());
- }
-
- LoginHandlerInterceptor(SecurityService securityService) {
- this.securityService = securityService;
- }
-
public static Map<String, String> getEnvironment() {
return ENV.get();
}
@@ -113,6 +104,11 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {
return true;
}
+ public void setSecurityService(SecurityService securityService) {
+ this.securityService = securityService;
+ }
+
+
@Override
public void afterCompletion(final HttpServletRequest request, final HttpServletResponse response,
final Object handler, final Exception ex) throws Exception {
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java b/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java
index bad58d8..707e3cf 100644
--- a/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java
@@ -28,7 +28,7 @@ public interface PostProcessor {
* Given the security props of the server, properly initialize the post processor for the server.
* Initialized at cache creation
*
- * @param securityProps security properties
+ * @param securityProps
*/
default void init(Properties securityProps) {}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java b/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
index f68d4d7..dc73f04 100644
--- a/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
@@ -52,19 +52,9 @@ import java.util.Map;
@Category(IntegrationTest.class)
public class AnalyzeSerializablesJUnitTest {
- private static final String NEW_LINE = System.getProperty("line.separator");
-
- private static final String FAIL_MESSAGE = NEW_LINE + NEW_LINE
- + "If the class is not persisted or sent over the wire add it to the file " + NEW_LINE + "%s"
- + NEW_LINE + "Otherwise if this doesn't break backward compatibility, copy the file "
- + NEW_LINE + "%s to " + NEW_LINE + "%s.";
-
/** all loaded classes */
private Map<String, CompiledClass> classes;
- private File expectedDataSerializablesFile;
- private File expectedSerializablesFile;
-
private List<ClassAndMethodDetails> expectedDataSerializables;
private List<ClassAndVariableDetails> expectedSerializables;
@@ -86,18 +76,18 @@ public class AnalyzeSerializablesJUnitTest {
// setup expectedDataSerializables
- this.expectedDataSerializablesFile = getResourceAsFile("sanctionedDataSerializables.txt");
- assertThat(this.expectedDataSerializablesFile).exists().canRead();
+ File expectedDataSerializablesFile = getResourceAsFile("sanctionedDataSerializables.txt");
+ assertThat(expectedDataSerializablesFile).exists().canRead();
- this.expectedDataSerializables = loadClassesAndMethods(this.expectedDataSerializablesFile);
+ this.expectedDataSerializables = loadClassesAndMethods(expectedDataSerializablesFile);
Collections.sort(this.expectedDataSerializables);
// setup expectedSerializables
- this.expectedSerializablesFile = getResourceAsFile("sanctionedSerializables.txt");
- assertThat(this.expectedSerializablesFile).exists().canRead();
+ File expectedSerializablesFile = getResourceAsFile("sanctionedSerializables.txt");
+ assertThat(expectedSerializablesFile).exists().canRead();
- this.expectedSerializables = loadClassesAndVariables(this.expectedSerializablesFile);
+ this.expectedSerializables = loadClassesAndVariables(expectedSerializablesFile);
Collections.sort(this.expectedSerializables);
// setup empty actual files
@@ -122,13 +112,15 @@ public class AnalyzeSerializablesJUnitTest {
String diff =
diffSortedClassesAndMethods(this.expectedDataSerializables, actualDataSerializables);
- if (!diff.isEmpty()) {
+ if (diff.length() > 0) {
System.out.println(
"++++++++++++++++++++++++++++++testDataSerializables found discrepancies++++++++++++++++++++++++++++++++++++");
System.out.println(diff);
- fail(diff + FAIL_MESSAGE, getSrcPathFor(getResourceAsFile("excludedClasses.txt")),
- this.actualDataSerializablesFile.getAbsolutePath(),
- getSrcPathFor(this.expectedDataSerializablesFile));
+ fail(
+ diff + "\n\nIf the class is not persisted or sent over the wire add it to the excludedClasses.txt file in the "
+ + "\norg/apache/geode/codeAnalysis directory. Otherwise if this doesn't "
+ + "\nbreak backward compatibility move the file actualDataSerializables.dat to the codeAnalysis "
+ + "\ntest directory and rename to sanctionedDataSerializables.txt");
}
}
@@ -140,22 +132,18 @@ public class AnalyzeSerializablesJUnitTest {
storeClassesAndVariables(actualSerializables, this.actualSerializablesFile);
String diff = diffSortedClassesAndVariables(this.expectedSerializables, actualSerializables);
- if (!diff.isEmpty()) {
+ if (diff.length() > 0) {
System.out.println(
"++++++++++++++++++++++++++++++testSerializables found discrepancies++++++++++++++++++++++++++++++++++++");
System.out.println(diff);
- fail(diff + FAIL_MESSAGE, getSrcPathFor(getResourceAsFile("excludedClasses.txt")),
- this.actualSerializablesFile.getAbsolutePath(),
- getSrcPathFor(this.expectedSerializablesFile));
+ fail(
+ diff + "\n\nIf the class is not persisted or sent over the wire add it to the excludedClasses.txt file in the "
+ + "\n/org/apache/geode/codeAnalysis/ directory. Otherwise if this doesn't "
+ + "\nbreak backward compatibility move the file actualSerializables.dat to the "
+ + "\ncodeAnalysis test directory and rename to sanctionedSerializables.txt");
}
}
- private String getSrcPathFor(File file) {
- return file.getAbsolutePath().replace(
- "build" + File.separator + "resources" + File.separator + "test",
- "src" + File.separator + "test" + File.separator + "resources");
- }
-
private void loadClasses() throws IOException {
System.out.println("loadClasses starting");
@@ -186,7 +174,7 @@ public class AnalyzeSerializablesJUnitTest {
loadClassesFromBuild(new File(buildDir), excludedClasses);
long finish = System.currentTimeMillis();
- System.out.println("done loading " + this.classes.size() + " classes. elapsed time = "
+ System.out.println("done loading " + classes.size() + " classes. elapsed time = "
+ (finish - start) / 1000 + " seconds");
}
@@ -198,7 +186,7 @@ public class AnalyzeSerializablesJUnitTest {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
- if (!line.isEmpty() && !line.startsWith("#")) {
+ if (line.length() > 0 && !line.startsWith("#")) {
excludedClasses.add(line);
}
}
@@ -217,7 +205,7 @@ public class AnalyzeSerializablesJUnitTest {
// each line should have bug#,full-class-name
while ((line = br.readLine()) != null) {
line = line.trim();
- if (!line.isEmpty() && !line.startsWith("#")) {
+ if (line.length() > 0 && !line.startsWith("#")) {
String[] split = line.split(",");
if (split.length != 2) {
fail("unable to load classes due to malformed line in openBugs.txt: " + line);
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java
index a0c3cf3..f112d1a 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java
@@ -14,13 +14,6 @@
*/
package org.apache.geode.distributed.internal.membership;
-import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -29,48 +22,57 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.io.File;
+import java.net.InetAddress;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.logging.log4j.Level;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.GemFireConfigException;
import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.DMStats;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.SerialAckedMessage;
+import org.apache.geode.distributed.internal.*;
import org.apache.geode.distributed.internal.membership.gms.GMSUtil;
import org.apache.geode.distributed.internal.membership.gms.ServiceConfig;
import org.apache.geode.distributed.internal.membership.gms.Services;
import org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave;
import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave;
-import org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatRequestMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage;
-import org.apache.geode.distributed.internal.membership.gms.messages.ViewAckMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.*;
import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager;
import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.internal.security.SecurityServiceFactory;
+import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.logging.log4j.Level;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import java.io.File;
-import java.net.InetAddress;
-import java.util.List;
-import java.util.Properties;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
@Category({IntegrationTest.class, MembershipJUnitTest.class})
public class MembershipJUnitTest {
+ static Level baseLogLevel;
+
+ @BeforeClass
+ public static void setupClass() {
+ // baseLogLevel = LogService.getBaseLogLevel();
+ // LogService.setBaseLogLevel(Level.DEBUG);
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ // LogService.setBaseLogLevel(baseLogLevel);
+ }
+
+ // @Test
+ // public void testRepeat() throws Exception {
+ // for (int i=0; i<50; i++) {
+ // System.out.println("--------------------run #" + i);
+ // testMultipleManagersInSameProcess();
+ // }
+ // }
/**
* This test creates a locator with a colocated membership manager and then creates a second
@@ -150,8 +152,7 @@ public class MembershipJUnitTest {
DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
DMStats stats1 = mock(DMStats.class);
System.out.println("creating 1st membership manager");
- m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1,
- SecurityServiceFactory.create());
+ m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
m1.startEventProcessing();
} finally {
System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
@@ -161,8 +162,7 @@ public class MembershipJUnitTest {
DistributedMembershipListener listener2 = mock(DistributedMembershipListener.class);
DMStats stats2 = mock(DMStats.class);
System.out.println("creating 2nd membership manager");
- m2 = MemberFactory.newMembershipManager(listener2, config, transport, stats2,
- SecurityServiceFactory.create());
+ m2 = MemberFactory.newMembershipManager(listener2, config, transport, stats2);
m2.startEventProcessing();
// we have to check the views with JoinLeave because the membership
@@ -292,8 +292,7 @@ public class MembershipJUnitTest {
DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
DMStats stats1 = mock(DMStats.class);
System.out.println("creating 1st membership manager");
- m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1,
- SecurityServiceFactory.create());
+ m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
m1.startEventProcessing();
} finally {
System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
@@ -303,8 +302,7 @@ public class MembershipJUnitTest {
DistributedMembershipListener listener2 = mock(DistributedMembershipListener.class);
DMStats stats2 = mock(DMStats.class);
System.out.println("creating 2nd membership manager");
- m2 = MemberFactory.newMembershipManager(listener2, config, transport, stats2,
- SecurityServiceFactory.create());
+ m2 = MemberFactory.newMembershipManager(listener2, config, transport, stats2);
m2.startEventProcessing();
// we have to check the views with JoinLeave because the membership
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/AbstractGMSAuthenticatorTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/AbstractGMSAuthenticatorTestCase.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/AbstractGMSAuthenticatorTestCase.java
index e8c4e73..f17b40b 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/AbstractGMSAuthenticatorTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/AbstractGMSAuthenticatorTestCase.java
@@ -65,19 +65,18 @@ public abstract class AbstractGMSAuthenticatorTestCase {
clearStatics();
MockitoAnnotations.initMocks(this);
- this.props = new Properties();
- this.securityProps = new Properties();
-
- when(this.securityService.isIntegratedSecurity()).thenReturn(isIntegratedSecurity());
- when(this.securityService.isPeerSecurityRequired()).thenReturn(true);
- when(this.securityService.login(this.securityProps)).thenReturn(this.subject);
- when(this.distributionConfig.getSecurityProps()).thenReturn(this.securityProps);
- when(this.serviceConfig.getDistributionConfig()).thenReturn(this.distributionConfig);
- when(this.services.getSecurityLogWriter()).thenReturn(mock(InternalLogWriter.class));
- when(this.services.getConfig()).thenReturn(this.serviceConfig);
- when(this.services.getSecurityService()).thenReturn(this.securityService);
-
- this.authenticator.init(this.services);
+ props = new Properties();
+ securityProps = new Properties();
+
+ when(securityService.isIntegratedSecurity()).thenReturn(isIntegratedSecurity());
+ when(securityService.isPeerSecurityRequired()).thenReturn(true);
+ when(securityService.login(securityProps)).thenReturn(subject);
+ when(distributionConfig.getSecurityProps()).thenReturn(securityProps);
+ when(serviceConfig.getDistributionConfig()).thenReturn(distributionConfig);
+ when(services.getSecurityLogWriter()).thenReturn(mock(InternalLogWriter.class));
+ when(services.getConfig()).thenReturn(serviceConfig);
+
+ authenticator.init(services);
}
protected abstract boolean isIntegratedSecurity();
@@ -136,11 +135,11 @@ public abstract class AbstractGMSAuthenticatorTestCase {
@Override
public void close() {
- this.closed = true;
+ closed = true;
}
public boolean isClosed() {
- return this.closed;
+ return closed;
}
public static int getCreateCount() {
@@ -285,11 +284,11 @@ public abstract class AbstractGMSAuthenticatorTestCase {
@Override
public void close() {
- this.closed = true;
+ closed = true;
}
public boolean isClosed() {
- return this.closed;
+ return closed;
}
public static int getCreateCount() {
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithAuthenticatorTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithAuthenticatorTest.java
index 96a9a5f..b9f6429 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithAuthenticatorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithAuthenticatorTest.java
@@ -38,28 +38,26 @@ public class GMSAuthenticatorWithAuthenticatorTest extends AbstractGMSAuthentica
@Test
public void nullAuthenticatorShouldReturnNull() throws Exception {
- assertThat(this.securityProps).doesNotContainKey(SECURITY_PEER_AUTHENTICATOR);
- String result =
- this.authenticator.authenticate(this.member, this.securityProps, this.securityProps);
+ assertThat(securityProps).doesNotContainKey(SECURITY_PEER_AUTHENTICATOR);
+ String result = authenticator.authenticate(member, securityProps, securityProps);
// assertThat(result).isNull(); NOTE: old security used to return null
assertThat(result).contains("Security check failed");
}
@Test
public void emptyAuthenticatorShouldReturnNull() throws Exception {
- this.securityProps.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
- String result =
- this.authenticator.authenticate(this.member, this.securityProps, this.securityProps);
+ securityProps.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
+ String result = authenticator.authenticate(member, securityProps, securityProps);
// assertThat(result).isNull(); NOTE: old security used to return null
assertThat(result).contains("Security check failed");
}
@Test
public void shouldGetSecurityPropsFromDistributionConfig() throws Exception {
- this.securityProps.setProperty(SECURITY_PEER_AUTH_INIT, "dummy1");
- this.securityProps.setProperty(SECURITY_PEER_AUTHENTICATOR, "dummy2");
+ securityProps.setProperty(SECURITY_PEER_AUTH_INIT, "dummy1");
+ securityProps.setProperty(SECURITY_PEER_AUTHENTICATOR, "dummy2");
- Properties secProps = this.authenticator.getSecurityProps();
+ Properties secProps = authenticator.getSecurityProps();
assertThat(secProps.size()).isEqualTo(2);
assertThat(secProps.getProperty(SECURITY_PEER_AUTH_INIT)).isEqualTo("dummy1");
@@ -68,74 +66,73 @@ public class GMSAuthenticatorWithAuthenticatorTest extends AbstractGMSAuthentica
@Test
public void usesPeerAuthInitToGetCredentials() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, SpyAuthInit.class.getName() + ".create");
+ props.setProperty(SECURITY_PEER_AUTH_INIT, SpyAuthInit.class.getName() + ".create");
SpyAuthInit auth = new SpyAuthInit();
assertThat(auth.isClosed()).isFalse();
SpyAuthInit.setAuthInitialize(auth);
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ Properties credentials = authenticator.getCredentials(member, props);
- assertThat(credentials).isEqualTo(this.props);
+ assertThat(credentials).isEqualTo(props);
assertThat(auth.isClosed()).isTrue();
assertThat(SpyAuthInit.getCreateCount()).isEqualTo(1);
}
@Test
public void getCredentialsShouldReturnNullIfNoPeerAuthInit() throws Exception {
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ Properties credentials = authenticator.getCredentials(member, props);
assertThat(credentials).isNull();
}
@Test
public void getCredentialsShouldReturnNullIfEmptyPeerAuthInit() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, "");
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ props.setProperty(SECURITY_PEER_AUTH_INIT, "");
+ Properties credentials = authenticator.getCredentials(member, props);
assertThat(credentials).isNull();
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitDoesNotExist() throws Exception {
String authInit = getClass().getName() + "$NotExistAuth.create";
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, authInit);
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ props.setProperty(SECURITY_PEER_AUTH_INIT, authInit);
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("Instance could not be obtained from");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitCreateReturnsNull() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitCreateReturnsNull.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("Instance could not be obtained from");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitGetCredentialsAndInitThrow() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitGetCredentialsAndInitThrow.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("expected init error");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitGetCredentialsThrows() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitGetCredentialsThrows.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("expected get credential error");
}
@Test
public void authenticateShouldReturnNullIfSuccessful() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
- SpyAuthenticator.class.getName() + ".create");
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR, SpyAuthenticator.class.getName() + ".create");
SpyAuthenticator auth = new SpyAuthenticator();
assertThat(auth.isClosed()).isFalse();
SpyAuthenticator.setAuthenticator(auth);
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).isNull();
assertThat(auth.isClosed()).isTrue();
@@ -144,15 +141,15 @@ public class GMSAuthenticatorWithAuthenticatorTest extends AbstractGMSAuthentica
@Test
public void authenticateShouldReturnNullIfPeerAuthenticatorIsNull() throws Exception {
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
// assertThat(result).isNull(); // NOTE: old security used to return null
assertThat(result).contains("Security check failed. Instance could not be obtained from null");
}
@Test
public void authenticateShouldReturnNullIfPeerAuthenticatorIsEmpty() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
+ String result = authenticator.authenticate(member, props, props);
// assertThat(result).isNull(); // NOTE: old security used to return null
assertThat(result).contains("Security check failed. Instance could not be obtained from");
}
@@ -160,41 +157,40 @@ public class GMSAuthenticatorWithAuthenticatorTest extends AbstractGMSAuthentica
@Test
public void authenticateShouldReturnFailureMessageIfPeerAuthenticatorDoesNotExist()
throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
- getClass().getName() + "$NotExistAuth.create");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR, getClass().getName() + "$NotExistAuth.create");
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).startsWith("Security check failed. Instance could not be obtained from");
}
@Test
public void authenticateShouldReturnFailureMessageIfAuthenticateReturnsNull() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR,
AuthenticatorReturnsNulls.class.getName() + ".create");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).startsWith("Security check failed. Instance could not be obtained");
}
@Test
public void authenticateShouldReturnFailureMessageIfNullCredentials() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR,
AuthenticatorReturnsNulls.class.getName() + ".create");
- String result = this.authenticator.authenticate(this.member, null, this.props);
+ String result = authenticator.authenticate(member, null, props);
assertThat(result).startsWith("Failed to find credentials from");
}
@Test
public void authenticateShouldReturnFailureMessageIfAuthenticateInitThrows() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR,
AuthenticatorInitThrows.class.getName() + ".create");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).startsWith("Security check failed. expected init error");
}
@Test
public void authenticateShouldReturnFailureMessageIfAuthenticateThrows() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTHENTICATOR,
+ props.setProperty(SECURITY_PEER_AUTHENTICATOR,
AuthenticatorAuthenticateThrows.class.getName() + ".create");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).startsWith("Security check failed. expected authenticate error");
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithSecurityManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithSecurityManagerTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithSecurityManagerTest.java
index 01ebc81..0cb6994 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithSecurityManagerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticatorWithSecurityManagerTest.java
@@ -40,26 +40,24 @@ public class GMSAuthenticatorWithSecurityManagerTest extends AbstractGMSAuthenti
@Test
public void nullManagerShouldReturnNull() throws Exception {
- assertThat(this.securityProps).doesNotContainKey(SECURITY_MANAGER);
- String result =
- this.authenticator.authenticate(this.member, this.securityProps, this.securityProps);
+ assertThat(securityProps).doesNotContainKey(SECURITY_MANAGER);
+ String result = authenticator.authenticate(member, securityProps, securityProps);
assertThat(result).isNull();
}
@Test
public void emptyAuthenticatorShouldReturnNull() throws Exception {
- this.securityProps.setProperty(SECURITY_MANAGER, "");
- String result =
- this.authenticator.authenticate(this.member, this.securityProps, this.securityProps);
+ securityProps.setProperty(SECURITY_MANAGER, "");
+ String result = authenticator.authenticate(member, securityProps, securityProps);
assertThat(result).isNull();
}
@Test
public void shouldGetSecurityPropsFromDistributionConfig() throws Exception {
- this.securityProps.setProperty(SECURITY_PEER_AUTH_INIT, "dummy1");
- this.securityProps.setProperty(SECURITY_MANAGER, "dummy2");
+ securityProps.setProperty(SECURITY_PEER_AUTH_INIT, "dummy1");
+ securityProps.setProperty(SECURITY_MANAGER, "dummy2");
- Properties secProps = this.authenticator.getSecurityProps();
+ Properties secProps = authenticator.getSecurityProps();
assertThat(secProps.size()).isEqualTo(2);
assertThat(secProps.getProperty(SECURITY_PEER_AUTH_INIT)).isEqualTo("dummy1");
@@ -68,91 +66,91 @@ public class GMSAuthenticatorWithSecurityManagerTest extends AbstractGMSAuthenti
@Test
public void usesPeerAuthInitToGetCredentials() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, SpyAuthInit.class.getName() + ".create");
- this.props.setProperty(SECURITY_MANAGER, "dummy");
+ props.setProperty(SECURITY_PEER_AUTH_INIT, SpyAuthInit.class.getName() + ".create");
+ props.setProperty(SECURITY_MANAGER, "dummy");
SpyAuthInit auth = new SpyAuthInit();
assertThat(auth.isClosed()).isFalse();
SpyAuthInit.setAuthInitialize(auth);
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ Properties credentials = authenticator.getCredentials(member, props);
- assertThat(credentials).isEqualTo(this.props);
+ assertThat(credentials).isEqualTo(props);
assertThat(auth.isClosed()).isTrue();
assertThat(SpyAuthInit.getCreateCount() == 1).isTrue();
}
@Test
public void getCredentialsShouldReturnNullIfNoPeerAuthInit() throws Exception {
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ Properties credentials = authenticator.getCredentials(member, props);
assertThat(credentials).isNull();
}
@Test
public void getCredentialsShouldReturnNullIfEmptyPeerAuthInit() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, "");
- Properties credentials = this.authenticator.getCredentials(this.member, this.props);
+ props.setProperty(SECURITY_PEER_AUTH_INIT, "");
+ Properties credentials = authenticator.getCredentials(member, props);
assertThat(credentials).isNull();
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitDoesNotExist() throws Exception {
String authInit = getClass().getName() + "$NotExistAuth.create";
- this.props.setProperty(SECURITY_PEER_AUTH_INIT, authInit);
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ props.setProperty(SECURITY_PEER_AUTH_INIT, authInit);
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("Instance could not be obtained");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitCreateReturnsNull() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitCreateReturnsNull.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessageContaining("Instance could not be obtained from");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitGetCredentialsAndInitThrow() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitGetCredentialsAndInitThrow.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessage("expected init error");
}
@Test
public void getCredentialsShouldThrowIfPeerAuthInitGetCredentialsThrows() throws Exception {
- this.props.setProperty(SECURITY_PEER_AUTH_INIT,
+ props.setProperty(SECURITY_PEER_AUTH_INIT,
AuthInitGetCredentialsThrows.class.getName() + ".create");
- assertThatThrownBy(() -> this.authenticator.getCredentials(this.member, this.props))
+ assertThatThrownBy(() -> authenticator.getCredentials(member, props))
.hasMessage("expected get credential error");
}
@Test
public void authenticateShouldReturnNullIfSuccessful() throws Exception {
- this.props.setProperty(SECURITY_MANAGER, "dummy");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ props.setProperty(SECURITY_MANAGER, "dummy");
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).isNull();
}
@Test
public void authenticateShouldReturnNullIfNoSecurityManager() throws Exception {
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).isNull();
}
@Test
public void authenticateShouldReturnFailureMessageIfLoginThrows() throws Exception {
- when(this.securityService.login(any(Properties.class)))
+ when(securityService.login(any(Properties.class)))
.thenThrow(new GemFireSecurityException("dummy"));
- this.props.setProperty(SECURITY_MANAGER, "dummy");
- String result = this.authenticator.authenticate(this.member, this.props, this.props);
+ props.setProperty(SECURITY_MANAGER, "dummy");
+ String result = authenticator.authenticate(member, props, props);
assertThat(result).startsWith("Security check failed. dummy");
}
@Test
public void authenticateShouldReturnFailureMessageIfNullCredentials() throws Exception {
- this.props.setProperty(SECURITY_MANAGER, "dummy");
- String result = this.authenticator.authenticate(this.member, null, this.props);
+ props.setProperty(SECURITY_MANAGER, "dummy");
+ String result = authenticator.authenticate(member, null, props);
assertThat(result).startsWith("Failed to find credentials from");
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
index 40c058b..423d7e1 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
@@ -14,34 +14,18 @@
*/
package org.apache.geode.distributed.internal.membership.gms.locator;
-import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
import org.apache.geode.DataSerializer;
import org.apache.geode.InternalGemFireException;
import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.DMStats;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.distributed.internal.LocatorStats;
+import org.apache.geode.distributed.internal.*;
import org.apache.geode.distributed.internal.membership.DistributedMembershipListener;
import org.apache.geode.distributed.internal.membership.MemberFactory;
import org.apache.geode.distributed.internal.membership.MembershipManager;
import org.apache.geode.distributed.internal.membership.NetView;
import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
-import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.internal.security.SecurityServiceFactory;
import org.apache.geode.test.junit.categories.IntegrationTest;
import org.apache.geode.test.junit.categories.MembershipTest;
import org.junit.After;
@@ -55,27 +39,30 @@ import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.util.Properties;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
@Category({IntegrationTest.class, MembershipTest.class})
public class GMSLocatorRecoveryJUnitTest {
- private File tempStateFile;
- private GMSLocator locator;
+ File tempStateFile = null;
+ GMSLocator locator = null;
@Before
public void setUp() throws Exception {
- this.tempStateFile = new File("GMSLocatorJUnitTest_locator.dat");
- if (this.tempStateFile.exists()) {
- this.tempStateFile.delete();
+ tempStateFile = new File("GMSLocatorJUnitTest_locator.dat");
+ if (tempStateFile.exists()) {
+ tempStateFile.delete();
}
- this.locator =
- new GMSLocator(null, this.tempStateFile, null, false, false, new LocatorStats(), "");
+ locator = new GMSLocator(null, tempStateFile, null, false, false, new LocatorStats(), "");
// System.out.println("temp state file: " + tempStateFile);
}
@After
public void tearDown() throws Exception {
- if (this.tempStateFile.exists()) {
- this.tempStateFile.delete();
+ if (tempStateFile.exists()) {
+ tempStateFile.delete();
}
}
@@ -91,34 +78,31 @@ public class GMSLocatorRecoveryJUnitTest {
@Test
public void testRecoverFromFileWithNonExistFile() throws Exception {
- this.tempStateFile.delete();
- assertFalse(this.tempStateFile.exists());
- assertFalse(this.locator.recoverFromFile(this.tempStateFile));
+ tempStateFile.delete();
+ assertFalse(tempStateFile.exists());
+ assertFalse(locator.recoverFromFile(tempStateFile));
}
@Test
public void testRecoverFromFileWithNormalFile() throws Exception {
NetView view = new NetView();
- populateStateFile(this.tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL,
- view);
- assertTrue(this.locator.recoverFromFile(this.tempStateFile));
+ populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, view);
+ assertTrue(locator.recoverFromFile(tempStateFile));
}
@Test
public void testRecoverFromFileWithWrongFileStamp() throws Exception {
// add 1 to file stamp to make it invalid
- populateStateFile(this.tempStateFile, GMSLocator.LOCATOR_FILE_STAMP + 1,
- Version.CURRENT_ORDINAL, 1);
- assertFalse(this.locator.recoverFromFile(this.tempStateFile));
+ populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP + 1, Version.CURRENT_ORDINAL, 1);
+ assertFalse(locator.recoverFromFile(tempStateFile));
}
@Test
public void testRecoverFromFileWithWrongOrdinal() throws Exception {
// add 1 to ordinal to make it wrong
- populateStateFile(this.tempStateFile, GMSLocator.LOCATOR_FILE_STAMP,
- Version.CURRENT_ORDINAL + 1, 1);
+ populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL + 1, 1);
try {
- this.locator.recoverFromFile(this.tempStateFile);
+ locator.recoverFromFile(tempStateFile);
fail("expected an InternalGemFireException to be thrown");
} catch (InternalGemFireException e) {
// success
@@ -127,10 +111,9 @@ public class GMSLocatorRecoveryJUnitTest {
@Test
public void testRecoverFromFileWithInvalidViewObject() throws Exception {
- populateStateFile(this.tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL,
- 1);
+ populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, 1);
try {
- this.locator.recoverFromFile(this.tempStateFile);
+ locator.recoverFromFile(tempStateFile);
fail("should catch InternalGemFileException");
} catch (InternalGemFireException e) {
assertTrue(e.getMessage().startsWith("Unable to recover previous membership view from"));
@@ -170,8 +153,7 @@ public class GMSLocatorRecoveryJUnitTest {
// start the first membership manager
DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
DMStats stats1 = mock(DMStats.class);
- m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1,
- SecurityServiceFactory.create());
+ m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
// hook up the locator to the membership manager
((InternalLocator) l).getLocatorHandler().setMembershipManager(m1);
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java
index ee8b6fa..d0f5793 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java
@@ -390,8 +390,7 @@ public class BlockingHARegionJUnitTest {
}
} catch (Exception e) {
exceptionOccurred = true;
- exceptionString.append(" Exception occurred due to ").append(e);
- break;
+ exceptionString.append(" Exception occurred due to " + e);
}
}
}
@@ -415,13 +414,9 @@ public class BlockingHARegionJUnitTest {
for (int i = 0; i < numberOfTakes; i++) {
try {
assertNotNull(this.regionQueue.take());
- if (Thread.currentThread().isInterrupted()) {
- break;
- }
} catch (Exception e) {
exceptionOccurred = true;
- exceptionString.append(" Exception occurred due to ").append(e);
- break;
+ exceptionString.append(" Exception occurred due to " + e);
}
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java
index 7b7f4a7..98cb309 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java
@@ -14,14 +14,18 @@
*/
package org.apache.geode.internal.cache.tier.sockets;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
+import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.Cache;
@@ -49,17 +53,8 @@ import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.Wait;
import org.apache.geode.test.dunit.WaitCriterion;
import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.categories.FlakyTest;
-import org.awaitility.Awaitility;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
/**
* Test to verify Startup. and failover during startup.
@@ -339,7 +334,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
public void afterPrimaryIdentificationFromBackup(ServerLocation primaryEndpoint) {
synchronized (HAStartupAndFailoverDUnitTest.class) {
HAStartupAndFailoverDUnitTest.identifiedPrimary = true;
- HAStartupAndFailoverDUnitTest.class.notifyAll();
+ HAStartupAndFailoverDUnitTest.class.notify();
}
}
});
@@ -351,6 +346,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
HAStartupAndFailoverDUnitTest.identifiedPrimary = false;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter());
}
+
}
public static void stopServer() {
@@ -364,6 +360,17 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
}
}
+ // public static void processException() {
+ // assertIndexDetailsEquals(conn.getServer().getPort(), PORT1.intValue());
+ // try {
+ // pool.processException(new Exception("dummy"), conn);
+ // //Thread.sleep(10000); // why sleep?
+ // }
+ // catch (Exception e) {
+ // fail("While processException(): " + e, e);
+ // }
+ // }
+
public static void verifyPrimaryShouldNotBeNullAndEPListShouldNotBeEmpty() {
try {
assertNotNull(" Primary endpoint should not be null", pool.getPrimaryName());
@@ -379,7 +386,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
assertNull("Primary endpoint should be null as all server are dead", pool.getPrimaryName());
assertEquals("Endpoint List should be Empty as all server are dead", 0,
pool.getConnectedServerCount());
- fail("NoSubscriptionServersAvailableException is expected");
+ fail("NoSubscriptionServersAvailableException is expected"); // TODO:KIRK: added this line
} catch (NoSubscriptionServersAvailableException e) {
// pass
} catch (Exception e) {
@@ -399,7 +406,9 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
}
}
+
public static void waitForPrimaryIdentification() {
+
assertNotNull(cache);
if (!identifiedPrimary) {
synchronized (HAStartupAndFailoverDUnitTest.class) {
@@ -417,6 +426,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
}
}
}
+
}
public static void verifyDispatcherIsAlive() {
@@ -469,6 +479,9 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
}
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
+
+ // assertTrue("Dispatcher on primary should be alive",
+ // proxy._messageDispatcher.isAlive());
}
} catch (Exception ex) {
@@ -553,6 +566,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
pool = p;
conn = pool.acquireConnection();
assertNotNull(conn);
+
}
public static void createClientCacheWithLargeRetryInterval(String testName, String host)
@@ -577,6 +591,8 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
pool = p;
conn = pool.acquireConnection();
assertNotNull(conn);
+
+
}
public static void createClientCacheWithLargeRetryIntervalAndWithoutCallbackConnection(
@@ -637,6 +653,7 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
pool = p;
conn = pool.acquireConnection();
assertNotNull(conn);
+
}
public static Integer createServerCache() throws Exception {
@@ -656,8 +673,10 @@ public class HAStartupAndFailoverDUnitTest extends JUnit4DistributedTestCase {
server1.setMaximumTimeBetweenPings(180000);
server1.start();
return new Integer(server1.getPort());
+
}
+
@Override
public final void preTearDown() throws Exception {
// close the clients first
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
index 794c610..153e77b 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.when;
import org.apache.geode.cache.Cache;
import org.apache.geode.internal.Version;
-import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.tier.Acceptor;
-import org.apache.geode.internal.security.SecurityService;
import org.apache.geode.security.AuthenticationRequiredException;
import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.Before;
@@ -66,11 +64,10 @@ public class ServerConnectionTest {
Socket socket = mock(Socket.class);
when(socket.getInetAddress()).thenReturn(inetAddress);
- InternalCache cache = mock(InternalCache.class);
- SecurityService securityService = mock(SecurityService.class);
+ Cache cache = mock(Cache.class);
serverConnection = new ServerConnection(socket, cache, null, null, 0, 0, null,
- Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor, securityService);
+ Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor);
MockitoAnnotations.initMocks(this);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java
index 591aba9..3a6c2a3 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java
@@ -100,7 +100,7 @@ public class ContainsKey66Test {
public void noSecurityShouldSucceed() throws Exception {
when(this.securityService.isClientSecurityRequired()).thenReturn(false);
- this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ this.containsKey66.cmdExecute(this.message, this.serverConnection, 0);
verify(this.responseMessage).send(this.serverConnection);
}
@@ -110,7 +110,7 @@ public class ContainsKey66Test {
when(this.securityService.isClientSecurityRequired()).thenReturn(true);
when(this.securityService.isIntegratedSecurity()).thenReturn(true);
- this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ this.containsKey66.cmdExecute(this.message, this.serverConnection, 0);
verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY));
verify(this.responseMessage).send(this.serverConnection);
@@ -123,7 +123,7 @@ public class ContainsKey66Test {
doThrow(new NotAuthorizedException("")).when(this.securityService)
.authorizeRegionRead(eq(REGION_NAME), eq(KEY));
- this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ this.containsKey66.cmdExecute(this.message, this.serverConnection, 0);
verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY));
verify(this.errorResponseMessage).send(eq(this.serverConnection));
@@ -134,7 +134,7 @@ public class ContainsKey66Test {
when(this.securityService.isClientSecurityRequired()).thenReturn(true);
when(this.securityService.isIntegratedSecurity()).thenReturn(false);
- this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ this.containsKey66.cmdExecute(this.message, this.serverConnection, 0);
verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
verify(this.responseMessage).send(this.serverConnection);
@@ -147,7 +147,7 @@ public class ContainsKey66Test {
doThrow(new NotAuthorizedException("")).when(this.authzRequest)
.containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
- this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ this.containsKey66.cmdExecute(this.message, this.serverConnection, 0);
verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
verify(this.errorResponseMessage).send(eq(this.serverConnection));
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java
index 0492997..bc1be3e 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java
@@ -88,7 +88,7 @@ public class ContainsKeyTest {
public void noSecurityShouldSucceed() throws Exception {
when(this.securityService.isClientSecurityRequired()).thenReturn(false);
- containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ containsKey.cmdExecute(this.message, this.serverConnection, 0);
verify(this.replyMessage).send(this.serverConnection);
}
@@ -98,7 +98,7 @@ public class ContainsKeyTest {
when(this.securityService.isClientSecurityRequired()).thenReturn(true);
when(this.securityService.isIntegratedSecurity()).thenReturn(true);
- containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ containsKey.cmdExecute(this.message, this.serverConnection, 0);
verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY));
verify(this.replyMessage).send(this.serverConnection);
@@ -111,7 +111,7 @@ public class ContainsKeyTest {
doThrow(new NotAuthorizedException("")).when(this.securityService)
.authorizeRegionRead(eq(REGION_NAME), eq(KEY));
- containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ containsKey.cmdExecute(this.message, this.serverConnection, 0);
verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY));
verify(this.errorResponseMessage).send(eq(this.serverConnection));
@@ -123,7 +123,7 @@ public class ContainsKeyTest {
when(this.securityService.isIntegratedSecurity()).thenReturn(false);
- containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ containsKey.cmdExecute(this.message, this.serverConnection, 0);
verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
verify(this.replyMessage).send(this.serverConnection);
@@ -136,7 +136,7 @@ public class ContainsKeyTest {
doThrow(new NotAuthorizedException("")).when(this.authzRequest)
.containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
- containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
+ containsKey.cmdExecute(this.message, this.serverConnection, 0);
verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY));
verify(this.errorResponseMessage).send(eq(this.serverConnection));