@Override public <K, V> Region<K, V> getRegion(String path) { Region<K, V> result = delegate.getRegion(path); checkForInternalRegion(result); return result; }
@Override public Region getRegion(String path, boolean returnDestroyedRegion) { Region result = delegate.getRegion(path, returnDestroyedRegion); checkForInternalRegion(result); return result; }
private <K, V> Region<K, V> getRegion(String regionName) { Region<K, V> region = internalCache.getRegion(regionName); if (region == null) { throw new RegionDestroyedException("Region not found " + regionName, regionName); } return region; } }
@Override public LuceneIndex getIndex(String indexName, String regionPath) { Region region = cache.getRegion(regionPath); if (region == null) { return null; } return indexMap.get(getUniqueIndexName(indexName, region.getFullPath())); }
@Override public Object call() throws CqException, RegionNotFoundException, CqExistsException { getCache().getRegion("/" + regionName).registerInterestRegex(".*"); return true; } });
private static void prepareDeserializableDataForRegion(String regionPath) { InternalCache cache = ClusterStartupRule.getCache(); Region dataRegion = cache.getRegion(regionPath); for (int j = 0; j < 10; j++) { dataRegion.put(new Integer(j), new Value1(j)); } }
@Test public void getRegionWithSecretThrows() { when(delegate.getRegion("secret")).thenReturn(secretRegion); assertThatThrownBy(() -> { cache.getRegion("secret"); }).isInstanceOf(NotAuthorizedException.class); }
@Override public Object call() throws RegionNotFoundException, CqExistsException, IndexExistsException, IndexNameConflictException { Region region = getCache().getRegion("/" + regionName); CompactRangeIndex index = (CompactRangeIndex) getCache().getQueryService().getIndex(region, indexName); System.out.println(index.dump()); return true; } });
@Before public void setUp() throws Exception { regionMock = mock(Region.class); when(regionMock.put(TEST_KEY, TEST_VALUE)).thenReturn(1); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionMock); }
@Test public void getRegionBooleanWithSecretThrows() { when(delegate.getRegion("secret", false)).thenReturn(secretRegion); assertThatThrownBy(() -> { cache.getRegion("secret", false); }).isInstanceOf(NotAuthorizedException.class); }
@Before public void setUp() throws Exception { regionStub = mock(Region.class); when(regionStub.remove(TEST_KEY)).thenReturn(TEST_VALUE); when(regionStub.containsKey(TEST_KEY)).thenReturn(true); when(regionStub.containsKey(MISSING_KEY)).thenReturn(false); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null); operationHandler = new RemoveRequestOperationHandler(); }
@Before public void setUp() throws Exception { regionMock = mock(Region.class); when(regionMock.put(TEST_INVALID_KEY, TEST_INVALID_VALUE)) .thenThrow(new ClassCastException(EXCEPTION_TEXT)); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionMock); operationHandler = new PutAllRequestOperationHandler(); }
@Before public void setUp() throws Exception { Region regionStub = mock(Region.class); when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); when(regionStub.get(MISSING_KEY)).thenReturn(null); when(regionStub.get(NULLED_KEY)).thenReturn(null); when(regionStub.containsKey(MISSING_KEY)).thenReturn(false); when(regionStub.containsKey(NULLED_KEY)).thenReturn(true); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null); operationHandler = new GetRequestOperationHandler(); }
@Test public void getRegionBooleanWithApplicationWorks() { when(delegate.getRegion("application", true)).thenReturn(applicationRegion); Region result = cache.getRegion("application", true); assertThat(result).isSameAs(applicationRegion); }
@Before public void setUp() throws Exception { this.getClientPartitionAttributesCommand = new GetClientPartitionAttributesCommand(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(PartitionedRegion.class)); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); }
@Before public void setUp() throws Exception { this.getClientPartitionAttributesCommand66 = new GetClientPartitionAttributesCommand66(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); }
@Before public void setUp() throws Exception { regionStub = mock(Region.class); when(regionStub.get(TEST_KEY1)).thenReturn(TEST_VALUE1); when(regionStub.get(TEST_KEY2)).thenReturn(TEST_VALUE2); when(regionStub.get(TEST_KEY3)).thenReturn(TEST_VALUE3); when(regionStub.get(NO_VALUE_PRESENT_FOR_THIS_KEY)).thenReturn(null); when(regionStub.get(TEST_INVALID_KEY)) .thenThrow(new CacheLoaderException("Let's pretend that didn't work")); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); operationHandler = new GetAllRequestOperationHandler(); }
@Test public void nonexistingRegionReturnsServerError() throws Exception { when(cacheStub.getRegion(TEST_REGION)).thenReturn(null); expectedException.expect(RegionDestroyedException.class); Result<RegionAPI.PutIfAbsentResponse> result1 = operationHandler.process(serializationService, generateTestRequest(), TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
@Test public void test_RegionNotFound() throws Exception { when(cacheStub.getRegion(TEST_REGION)).thenReturn(null); PutRequestOperationHandler operationHandler = new PutRequestOperationHandler(); expectedException.expect(RegionDestroyedException.class); Result result = operationHandler.process(serializationService, generateTestRequest(), TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
@Test public void fileRegionExistsWhenFileRegionDoesNotExistShouldReturnFalse() { String name = "indexName"; String regionPath = "regionName"; InternalCache cache = Fakes.cache(); LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache); String fileRegionName = index.createFileRegionName(); when(cache.getRegion(fileRegionName)).thenReturn(null); assertFalse(index.fileRegionExists(fileRegionName)); }