Added support for gateway conflict resolver and function service

This commit is contained in:
David Turanski
2012-07-23 17:30:13 -04:00
parent 94468bec9a
commit 57b33c007a
11 changed files with 390 additions and 6 deletions

View File

@@ -33,6 +33,11 @@ import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.springframework.test.util.ReflectionTestUtils;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.util.GatewayConflictHelper;
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
/**
* @author Costin Leau
*/
@@ -48,9 +53,8 @@ public class CacheNamespaceTest extends RecreatingContextTest {
testBasicCache();
testNamedCache();
testCacheWithXml();
// testBasicClientCache();
// testBasicClientCacheWithXml();
testHeapTunedCache();
testCacheWithGatewayConflictResolver();
}
private void testBasicCache() throws Exception {
@@ -79,6 +83,12 @@ public class CacheNamespaceTest extends RecreatingContextTest {
}
private void testCacheWithGatewayConflictResolver() {
Cache cache = ctx.getBean("cache-with-conflict-resolver", Cache.class);
assertNotNull(cache.getGatewayConflictResolver());
assertTrue(cache.getGatewayConflictResolver() instanceof TestConflictResolver);
}
@Test(expected = IllegalArgumentException.class)
public void testNoBeanFactory() throws Exception {
assertTrue(ctx.containsBean("no-bl"));
@@ -121,4 +131,12 @@ public class CacheNamespaceTest extends RecreatingContextTest {
assertEquals(70, chp, 0.0001);
assertEquals(60, ehp, 0.0001);
}
public static class TestConflictResolver implements GatewayConflictResolver {
@Override
public void onEvent(TimestampedEntryEvent arg0, GatewayConflictHelper arg1) {
// TODO Auto-generated method stub
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2010-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import com.gemstone.gemfire.cache.execute.FunctionAdapter;
import com.gemstone.gemfire.cache.execute.FunctionContext;
import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author Costin Leau
*/
public class FunctionServiceNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/function-service-ns.xml";
}
@Test
public void testFunctionsRegistered() throws Exception {
assertEquals(2, FunctionService.getRegisteredFunctions().size());
assertNotNull(FunctionService.getFunction("function1"));
assertNotNull(FunctionService.getFunction("function2"));
}
@SuppressWarnings("serial")
public static class Function1 extends FunctionAdapter {
@Override
public void execute(FunctionContext arg0) {
// TODO Auto-generated method stub
}
@Override
public String getId() {
return "function1";
}
}
@SuppressWarnings("serial")
public static class Function2 extends FunctionAdapter {
@Override
public void execute(FunctionContext arg0) {
// TODO Auto-generated method stub
}
@Override
public String getId() {
return "function2";
}
}
}