renaming classes, etc

This commit is contained in:
David Turanski
2012-12-22 09:55:40 -05:00
parent e18e603000
commit 074eee56fd
40 changed files with 237 additions and 176 deletions

View File

@@ -43,21 +43,21 @@ public class AnnotationDrivenFunctionsTest {
@Test
public void testAnnotatedFunctions() {
assertTrue(FunctionService.isRegistered(FooFunction.class.getName()+".foo"));
assertTrue(FunctionService.isRegistered("foo"));
Function function = FunctionService.getFunction(FooFunction.class.getName()+".foo");
Function function = FunctionService.getFunction("foo");
assertFalse(function.isHA());
assertFalse(function.optimizeForWrite());
assertFalse(function.hasResult());
assertTrue(FunctionService.isRegistered(FooFunction.class.getName()+".bar"));
function = FunctionService.getFunction(FooFunction.class.getName()+".bar");
assertTrue(FunctionService.isRegistered("bar"));
function = FunctionService.getFunction("bar");
assertTrue(function.isHA());
assertFalse(function.optimizeForWrite());
assertTrue(function.hasResult());
assertTrue(FunctionService.isRegistered("foo"));
function = FunctionService.getFunction("foo");
assertTrue(FunctionService.isRegistered("foo2"));
function = FunctionService.getFunction("foo2");
assertTrue(function.isHA());
assertTrue(function.optimizeForWrite());
assertTrue(function.hasResult());
@@ -84,7 +84,7 @@ public class AnnotationDrivenFunctionsTest {
@Component
public static class Foo2Function {
@GemfireFunction(id="foo", HA=true,optimizeForWrite=true)
@GemfireFunction(id="foo2", HA=true,optimizeForWrite=true)
public List<String> foo (Object someVal, @RegionData Map<?,?> region, Object someOtherValue) {
return null;
}

View File

@@ -13,19 +13,27 @@
package org.springframework.data.gemfire.function.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.gemfire.function.execution.GemfireOnServerFunctionTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.execute.FunctionException;
import com.gemstone.gemfire.cache.execute.ResultCollector;
import com.gemstone.gemfire.distributed.DistributedMember;
/**
* @author David Turanski
@@ -47,6 +55,9 @@ public class FunctionExecutionClientCacheTests {
assertEquals(pool.getServers().get(0), cache.getDefaultPool().getServers().get(0));
context.getBean("r1",Region.class);
GemfireOnServerFunctionTemplate template = context.getBean(GemfireOnServerFunctionTemplate.class);
assertTrue(template.getResultCollector() instanceof MyResultCollector);
}
}
@@ -61,8 +72,60 @@ public class FunctionExecutionClientCacheTests {
)
@Configuration
class TestClientCacheConfig {
@Bean
MyResultCollector myResultCollector() {
return new MyResultCollector();
}
}
@SuppressWarnings("rawtypes")
class MyResultCollector implements ResultCollector {
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.ResultCollector#addResult(com.gemstone.gemfire.distributed.DistributedMember, java.lang.Object)
*/
@Override
public void addResult(DistributedMember arg0, Object arg1) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.ResultCollector#clearResults()
*/
@Override
public void clearResults() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.ResultCollector#endResults()
*/
@Override
public void endResults() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.ResultCollector#getResult()
*/
@Override
public Object getResult() throws FunctionException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.ResultCollector#getResult(long, java.util.concurrent.TimeUnit)
*/
@Override
public Object getResult(long arg0, TimeUnit arg1) throws FunctionException, InterruptedException {
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -31,41 +31,43 @@ import org.springframework.data.gemfire.function.config.one.TestFunctionExecutio
*
*/
public class FunctionExecutionComponentProviderTest {
@Test
public void testDiscovery() throws ClassNotFoundException {
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()+".one");
ScannedGenericBeanDefinition bd = null;
for (BeanDefinition candidate: candidates) {
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
bd = (ScannedGenericBeanDefinition)candidate;
}
}
assertNotNull(bd);
}
@Test
public void testExcludeFilter() throws ClassNotFoundException {
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
provider.addExcludeFilter(new AssignableTypeFilter(TestFunctionExecution.class));
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()+".one");
for (BeanDefinition candidate: candidates) {
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
fail(TestFunctionExecution.class.getName() + " not excluded");
}
}
}
@Test
public void testDiscovery() throws ClassNotFoundException {
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,
AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()
+ ".one");
ScannedGenericBeanDefinition bd = null;
for (BeanDefinition candidate : candidates) {
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
bd = (ScannedGenericBeanDefinition) candidate;
}
}
assertNotNull(bd);
}
@Test
public void testExcludeFilter() throws ClassNotFoundException {
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,
AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
provider.addExcludeFilter(new AssignableTypeFilter(TestFunctionExecution.class));
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()
+ ".one");
for (BeanDefinition candidate : candidates) {
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
fail(TestFunctionExecution.class.getName() + " not excluded");
}
}
}
}

View File

@@ -22,7 +22,7 @@ import org.springframework.data.gemfire.function.config.OnServer;
* @author David Turanski
*
*/
@OnServer(id="testClientOnServerFunction",pool="gemfirePool")
@OnServer(id="testClientOnServerFunction",pool="gemfirePool",resultCollector="myResultCollector")
public interface TestClientOnServerFunction {
@FunctionId("f1")
public String getString(Object arg1, @Filter Set<Object> keys) ;

View File

@@ -95,7 +95,7 @@ public class FunctionExecutionTests {
private void verifyfunctionExecution(FunctionExecution functionExecution) {
private void verifyfunctionExecution(AbstractFunctionExecution functionExecution) {
Iterable<String> results = functionExecution
.setArgs("1","2","3")
.setFunctionId("echoFunction")

View File

@@ -55,7 +55,6 @@ public class GemfireFunctionProxyFactoryBeanTests {
GemfireFunctionProxyFactoryBean proxy = new GemfireFunctionProxyFactoryBean(IFoo.class,functionOperations);
proxy.setFunctionId(IFoo.class.getName());
MethodInvocation invocation = new TestInvocation(IFoo.class).withMethodNameAndArgTypes("oneArg",String.class);
@@ -75,13 +74,12 @@ public class GemfireFunctionProxyFactoryBeanTests {
GemfireFunctionProxyFactoryBean proxy = new GemfireFunctionProxyFactoryBean(IFoo.class, functionOperations);
proxy.setFunctionId(IFoo.class.getName());
MethodInvocation invocation = new TestInvocation(IFoo.class).withMethodNameAndArgTypes("collections",List.class);
List results = Arrays.asList(new Integer[]{1,2,3});
when(functionOperations.execute(IFoo.class.getName() + ".collections",invocation.getArguments())).thenReturn(results);
when(functionOperations.execute("collections",invocation.getArguments())).thenReturn(results);
Object result = proxy.invoke(invocation);
assertTrue(result instanceof List);