@Before public void setUp() throws Exception { this.createRegion = new CreateRegion(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(eq(PARENT_REGION_NAME))).thenReturn(this.parentRegion); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.message.getPart(eq(0))).thenReturn(this.parentRegionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.regionNamePart); when(this.parentRegion.getAttributes()).thenReturn(new AttributesFactory().create()); when(this.parentRegionNamePart.getString()).thenReturn(PARENT_REGION_NAME); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCacheServerStats()).thenReturn(mock(CacheServerStats.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
protected static void writeException(Message origMsg, int msgType, Throwable e, boolean isSevere, ServerConnection serverConnection) throws IOException { Throwable theException = getClientException(serverConnection, e); Message errorMsg = serverConnection.getErrorResponseMessage(); errorMsg.setMessageType(msgType); errorMsg.setNumberOfParts(2); errorMsg.setTransactionId(origMsg.getTransactionId()); if (isSevere) { String msg = theException.getMessage(); if (msg == null) { msg = theException.toString(); } logger.fatal("Severe cache exception : {}", msg); } errorMsg.addObjPart(theException); errorMsg.addStringPart(getExceptionTrace(theException)); errorMsg.send(serverConnection); if (logger.isDebugEnabled()) { logger.debug("{}: Wrote exception: {}", serverConnection.getName(), e.getMessage(), e); } if (e instanceof MessageTooLargeException) { throw (IOException) e; } }
protected static void writeErrorResponse(Message origMsg, int messageType, ServerConnection serverConnection) throws IOException { Message errorMsg = serverConnection.getErrorResponseMessage(); errorMsg.setMessageType(messageType); errorMsg.setNumberOfParts(1); errorMsg.setTransactionId(origMsg.getTransactionId()); errorMsg.addStringPart( "Invalid data received. Please see the cache server log file for additional details."); errorMsg.send(serverConnection); }
@Before public void setUp() throws Exception { this.containsKey66 = new ContainsKey66(); MockitoAnnotations.initMocks(this); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.modePart.getInt()).thenReturn(0); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.modePart); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Region region = mock(LocalRegion.class); when(region.containsKey(isA(String.class))).thenReturn(true); InternalCache cache = mock(InternalCache.class); when(cache.getRegion(isA(String.class))).thenReturn(region); CacheServerStats cacheServerStats = mock(CacheServerStats.class); when(this.serverConnection.getCache()).thenReturn(cache); when(this.serverConnection.getCacheServerStats()).thenReturn(cacheServerStats); when(this.serverConnection.getResponseMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); Part regionNamePart = mock(Part.class); when(regionNamePart.getString()).thenReturn(REGION_NAME); Part keyPart = mock(Part.class); when(keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getPart(eq(0))).thenReturn(regionNamePart); when(this.message.getPart(eq(1))).thenReturn(keyPart); }
@Before public void setUp() throws Exception { this.invalidate = new Invalidate(); MockitoAnnotations.initMocks(this); when(this.authzRequest.invalidateAuthorize(any(), any(), any())) .thenReturn(mock(InvalidateOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY_STRING); when(this.message.getNumberOfParts()).thenReturn(4); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.eventPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(mock(CacheServerStats.class)); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
protected static void writeErrorResponse(Message origMsg, int messageType, String msg, ServerConnection serverConnection) throws IOException { Message errorMsg = serverConnection.getErrorResponseMessage(); errorMsg.setMessageType(messageType); errorMsg.setNumberOfParts(1); errorMsg.setTransactionId(origMsg.getTransactionId()); errorMsg.addStringPart(msg); errorMsg.send(serverConnection); }
@Before public void setUp() throws Exception { this.destroyRegion = new DestroyRegion(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyRegionAuthorize(eq(REGION_NAME), eq(CALLBACK_ARG))) .thenReturn(mock(RegionDestroyOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.message.getNumberOfParts()).thenReturn(3); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.eventPart); when(this.message.getPart(eq(2))).thenReturn(this.callbackArgPart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@Before public void setUp() throws Exception { this.get70 = new Get70(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())).thenReturn(this.getOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.getOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(3); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.valuePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.valuePart.getObject()).thenReturn(CALLBACK_ARG); }
@Before public void setUp() throws Exception { this.request = new Request(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())).thenReturn(this.getOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.getOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(3); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.valuePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.valuePart.getObject()).thenReturn(CALLBACK_ARG); }
@Before public void setUp() throws Exception { this.destroy65 = new Destroy65(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG))) .thenReturn(this.destroyOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(6); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(3))).thenReturn(mock(Part.class)); when(this.message.getPart(eq(4))).thenReturn(this.eventPart); when(this.message.getPart(eq(5))).thenReturn(this.callbackArgPart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getAcceptor()).thenReturn(this.acceptor); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT);
@Before public void setUp() throws Exception { this.destroy = new Destroy(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG))) .thenReturn(this.destroyOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.destroyOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(4); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.eventPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
private static void writeFatalException(Message origMsg, Throwable exception, ServerConnection servConn, int batchId) throws IOException { Message errorMsg = servConn.getErrorResponseMessage(); errorMsg.setMessageType(MessageType.EXCEPTION); errorMsg.setNumberOfParts(2); errorMsg.setTransactionId(origMsg.getTransactionId()); // For older gateway senders, we need to send back an exception // they can deserialize. if ((servConn.getClientVersion() == null || servConn.getClientVersion().compareTo(Version.GFE_80) < 0) && exception instanceof PdxRegistryMismatchException) { PdxConfigurationException newException = new PdxConfigurationException(exception.getMessage()); newException.setStackTrace(exception.getStackTrace()); exception = newException; } errorMsg.addObjPart(exception); // errorMsg.addStringPart(be.toString()); errorMsg.send(servConn); logger.warn(servConn.getName() + ": Wrote batch exception: ", exception); } }
when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT);
when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT);
when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT);
private static void writeBatchException(Message origMsg, List<BatchException70> exceptions, ServerConnection servConn, int batchId) throws IOException { Message errorMsg = servConn.getErrorResponseMessage(); errorMsg.setMessageType(MessageType.EXCEPTION); errorMsg.setNumberOfParts(2); errorMsg.setTransactionId(origMsg.getTransactionId()); errorMsg.addObjPart(exceptions); // errorMsg.addStringPart(be.toString()); errorMsg.send(servConn); for (Exception e : exceptions) { ((GatewayReceiverStats) servConn.getCacheServerStats()).incExceptionsOccurred(); } for (Exception be : exceptions) { if (logger.isWarnEnabled()) { logger.warn(servConn.getName() + ": Wrote batch exception: ", be); } } }
when(serverConnection.getCache()).thenReturn(cache); when(serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(serverConnection.getErrorResponseMessage()).thenReturn(errorResponseMessage); when(serverConnection.getFunctionResponseMessage()).thenReturn(functionResponseMessage); when(serverConnection.getHandshake()).thenReturn(mock(ServerSideHandshake.class));
InternalDistributedMember.class)); doReturn(mock(Message.class)).when(serverConnection).getErrorResponseMessage(); doReturn(handshake).when(serverConnection).getHandshake(); doReturn(1000).when(handshake).getClientReadTimeout();