Repository: incubator-geode Updated Branches: refs/heads/develop 8fcd9c0e6 -> aca7b288f
GEODE-625: Adding tests for exception handling of functions Testing how functions propagate exceptions from within the function to the caller or the result collector. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/aca7b288 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/aca7b288 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/aca7b288 Branch: refs/heads/develop Commit: aca7b288f378ec05e00ec3a9277265d1a9679b4a Parents: 15a2a29 Author: Dan Smith <upthewatersp...@apache.org> Authored: Thu Apr 28 14:13:36 2016 -0700 Committer: Dan Smith <upthewatersp...@apache.org> Committed: Thu May 5 17:17:01 2016 -0700 ---------------------------------------------------------------------- .../cache/execute/FunctionServiceBase.java | 287 +++++++++++++++++++ .../FunctionServiceLocalPRDUnitTest.java | 54 ++++ .../FunctionServiceLocalRRDUnitTest.java | 52 ++++ ...unctionServiceMultipleOnMemberDUnitTest.java | 57 ++++ .../FunctionServicePeerAccessorPRDUnitTest.java | 73 +++++ .../FunctionServicePeerAccessorRRDUnitTest.java | 63 ++++ .../FunctionServiceSingleOnMemberDUnitTest.java | 49 ++++ 7 files changed, 635 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceBase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceBase.java new file mode 100644 index 0000000..eeb7d8d --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceBase.java @@ -0,0 +1,287 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import static org.hamcrest.Matchers.isA; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; + +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionException; +import com.gemstone.gemfire.cache.execute.ResultCollector; +import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/* + * Base class for tests of FunctionService that are agnostic to the + * type of Execution that they are running on. The goal is to completely + * cover all common behavior of sending results and sending exceptions + * here. + */ +public abstract class FunctionServiceBase extends JUnit4CacheTestCase { + + @Rule + public transient ExpectedException thrown = ExpectedException.none(); + + private transient CustomCollector customCollector; + + @Before + public void createCollector() { + this.customCollector = new CustomCollector(); + } + + /** + * Return the execution used to execute functions for this + * test. Subclasses should override this to provide a specific + * execution, for example onMember. + */ + public abstract Execution getExecution(); + + /** + * Return the number of members the function is expected + * to execute on + */ + public abstract int numberOfExecutions(); + + @Test + public void defaultCollectorReturnsSingleResult() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {context.getResultSender().lastResult("done");}); + List<String> results = (List<String>) rc.getResult(); + assertEquals(numberOfExecutions(), results.size()); + results.stream().forEach(element -> assertEquals("done", element)); + } + + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionThrowsIllegalState() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {throw new IllegalStateException();}); + thrown.expect(FunctionException.class); + thrown.expectCause(isA(IllegalStateException.class)); + final Object result = rc.getResult(); + } + + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionThrowsFunctionException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {throw new FunctionException();}); + + thrown.expect(FunctionException.class); + final Object result = rc.getResult(); + } + + /** + * Tests what happens if a function returns an exception as a result. This + * is kind a weird, but it seems that the default collector will just throw it + * as an exception + */ + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {context.getResultSender().lastResult(new IllegalStateException());}); + + thrown.expect(FunctionException.class); + thrown.expectCause(isA(IllegalStateException.class)); + final Object result = rc.getResult(); + } + + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionReturnsFunctionException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {context.getResultSender().lastResult(new FunctionException());}); + thrown.expect(FunctionException.class); + thrown.expectCause(is((Throwable) null)); + final Object result = rc.getResult(); + } + + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateExceptionAsIntermediateResult() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> { + context.getResultSender().sendResult(new IllegalStateException()); + context.getResultSender().lastResult("done"); + }); + thrown.expect(FunctionException.class); + thrown.expectCause(isA(IllegalStateException.class)); + final Object result = rc.getResult(); + } + + @Test() + public void defaultCollectorThrowsExceptionAfterFunctionReturnsFunctionExceptionAsIntermediateResult() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> { + context.getResultSender().sendResult(new FunctionException()); + context.getResultSender().lastResult("done"); + }); + thrown.expect(FunctionException.class); + thrown.expectCause(is((Throwable) null)); + final Object result = rc.getResult(); + } + + @Test + public void defaultCollectorReturnsResultOfSendException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> { + context.getResultSender().sendException(new IllegalStateException()); + }); + final List<Object> result = (List<Object>) rc.getResult(); + assertEquals(numberOfExecutions(), result.size()); + result.stream().forEach(element -> assertEquals(IllegalStateException.class, element.getClass())); + } + + @Test + public void defaultCollectorReturnsResultOfSendFunctionException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> { + context.getResultSender().sendException(new FunctionException()); + }); + final List<Object> result = (List<Object>) rc.getResult(); + assertEquals(numberOfExecutions(), result.size()); + result.stream().forEach(element -> assertEquals(FunctionException.class, element.getClass())); + } + + @Test + public void customCollectorDoesNotSeeExceptionFunctionThrowsIllegalState() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {throw new IllegalStateException();}); + try { + rc.getResult(); + fail("should have received an exception"); + } catch (FunctionException expected) {} + + Assert.assertEquals(0, customCollector.getResult().size()); + } + + @Test + public void customCollectorDoesNotSeeExceptionFunctionThrowsFunctionException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {throw new FunctionException();}); + try { + rc.getResult(); + fail("should have received an exception"); + } catch (FunctionException expected) {} + + Assert.assertEquals(0, customCollector.getResult().size()); + } + + @Test + public void customCollectorDoesNotSeeExceptionAfterFunctionReturnsIllegalStateException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> {context.getResultSender().lastResult(new IllegalStateException());}); + try { + rc.getResult(); + fail("should have received an exception"); + } catch (FunctionException expected) {} + Assert.assertEquals(0, customCollector.getResult().size()); + } + + @Test + public void customCollectorDoesNotSeeExceptionAfterFunctionReturnsIllegalStateExceptionAsIntermediateResult() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().execute((context) -> { + context.getResultSender().sendResult(new IllegalStateException()); + context.getResultSender().lastResult("done"); + }); + try { + rc.getResult(); + fail("should have received an exception"); + } catch (FunctionException expected) {} + Assert.assertEquals(0, customCollector.getResult().size()); + } + + @Test + public void customCollectorReturnsResultOfSendException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> { + context.getResultSender().sendException(new IllegalStateException()); + }); + final List<Object> result = (List<Object>) rc.getResult(); + assertEquals(numberOfExecutions(), result.size()); + result.stream().forEach(element -> assertEquals(IllegalStateException.class, element.getClass())); + assertEquals(result, customCollector.getResult()); + } + + @Test + public void customCollectorReturnsResultOfSendFunctionException() { + final Host host = Host.getHost(0); + + ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> { + context.getResultSender().sendException(new FunctionException()); + }); + final List<Object> result = (List<Object>) rc.getResult(); + assertEquals(numberOfExecutions(), result.size()); + result.stream().forEach(element -> assertEquals(FunctionException.class, element.getClass())); + assertEquals(result, customCollector.getResult()); + } + + private static class CustomCollector implements ResultCollector<Object, List<Object>> { + private ArrayList<Object> results = new ArrayList<Object>(); + + @Override + public List<Object> getResult() throws FunctionException { + return results; + } + + @Override + public List<Object> getResult(final long timeout, final TimeUnit unit) + throws FunctionException, InterruptedException + { + return results; + } + + @Override + public void addResult(final DistributedMember memberID, final Object resultOfSingleExecution) { + results.add(resultOfSingleExecution); + } + + @Override + public void endResults() { + } + + @Override + public void clearResults() { + results.clear(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalPRDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalPRDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalPRDUnitTest.java new file mode 100644 index 0000000..5617ee6 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalPRDUnitTest.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionShortcut; +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServiceLocalPRDUnitTest extends FunctionServiceBase { + + public static final String REGION = "region"; + + private transient Region<Object, Object> region; + + @Before + public void createRegions() { + region = getCache().createRegionFactory(RegionShortcut.PARTITION) + .create(REGION); + PartitionRegionHelper.assignBucketsToPartitions(region); + } + + @Override public Execution getExecution() { + return FunctionService.onRegion(region); + } + + @Override public int numberOfExecutions() { + return 1; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalRRDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalRRDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalRRDUnitTest.java new file mode 100644 index 0000000..085e709 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceLocalRRDUnitTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionShortcut; +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServiceLocalRRDUnitTest extends FunctionServiceBase { + + public static final String REGION = "region"; + + private transient Region<Object, Object> region; + + @Before + public void createRegions() { + region = getCache().createRegionFactory(RegionShortcut.REPLICATE) + .create(REGION); + } + + @Override public Execution getExecution() { + return FunctionService.onRegion(region); + } + + @Override public int numberOfExecutions() { + return 1; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java new file mode 100644 index 0000000..cc67830 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceMultipleOnMemberDUnitTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import java.util.HashSet; +import java.util.Set; + +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServiceMultipleOnMemberDUnitTest extends FunctionServiceBase { + + private Set<DistributedMember> members = new HashSet<DistributedMember>(); + + @Before + public void createDistributedSystems() { + getSystem(); + Host host = Host.getHost(0); + VM vm0 = host.getVM(0); + VM vm1 = host.getVM(1); + members.add(vm0.invoke(() -> getSystem().getDistributedMember())); + members.add(vm1.invoke(() -> getSystem().getDistributedMember())); + } + + @Override public Execution getExecution() { + return FunctionService.onMembers(members); + } + + @Override public int numberOfExecutions() { + return 2; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorPRDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorPRDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorPRDUnitTest.java new file mode 100644 index 0000000..e5bf2d2 --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorPRDUnitTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionShortcut; +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServicePeerAccessorPRDUnitTest extends FunctionServiceBase { + + public static final String REGION = "region"; + + private transient Region<Object, Object> region; + + @Before + public void createRegions() { + region = getCache().createRegionFactory(RegionShortcut.PARTITION_PROXY) + .create(REGION); + Host host = Host.getHost(0); + VM vm0 = host.getVM(0); + vm0.invoke(() -> { + + getCache().createRegionFactory(RegionShortcut.PARTITION) + .create(REGION); + + }); + + PartitionRegionHelper.assignBucketsToPartitions(region); + } + + @Override public Execution getExecution() { + return FunctionService.onRegion(region); + } + + @Override public int numberOfExecutions() { + return 1; + } + + @Ignore("GEODE-1348 - With this topology, the exception is not wrapped in FunctionException") + @Override public void defaultCollectorThrowsExceptionAfterFunctionThrowsIllegalState() { + } + + @Ignore("GEODE-1348 - With this topology, the exception is not wrapped in FunctionException") + @Override public void customCollectorDoesNotSeeExceptionFunctionThrowsIllegalState() { + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorRRDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorRRDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorRRDUnitTest.java new file mode 100644 index 0000000..439e04f --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServicePeerAccessorRRDUnitTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionShortcut; +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServicePeerAccessorRRDUnitTest extends FunctionServiceBase { + + public static final String REGION = "region"; + + private transient Region<Object, Object> region; + + @Before + public void createRegions() { + region = getCache().createRegionFactory(RegionShortcut.REPLICATE_PROXY) + .create(REGION); + Host host = Host.getHost(0); + VM vm0 = host.getVM(0); + vm0.invoke(() -> { + + getCache().createRegionFactory(RegionShortcut.REPLICATE) + .create(REGION); + + }); + } + + @Override public Execution getExecution() { + return FunctionService.onRegion(region); + } + + @Override public int numberOfExecutions() { + return 1; + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/aca7b288/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java new file mode 100644 index 0000000..29dd3ee --- /dev/null +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/FunctionServiceSingleOnMemberDUnitTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 com.gemstone.gemfire.internal.cache.execute; + +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; + +import org.junit.Before; +import org.junit.experimental.categories.Category; + +/** + * Test of the behavior of a custom ResultCollector when handling exceptions + */ +@Category(DistributedTest.class) +public class FunctionServiceSingleOnMemberDUnitTest extends FunctionServiceBase { + + private InternalDistributedMember memberId; + + @Before + public void createDistributedSystem() { + memberId = getSystem().getDistributedMember(); + } + + @Override public Execution getExecution() { + return FunctionService.onMember(memberId); + } + + @Override public int numberOfExecutions() { + return 1; + } + + +}