You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jc...@apache.org on 2020/02/07 00:43:17 UTC
[geode] branch feature/GEODE-7746 updated: WIP: add a DUnit
This is an automated email from the ASF dual-hosted git repository.
jchen21 pushed a commit to branch feature/GEODE-7746
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-7746 by this push:
new 8400ce4 WIP: add a DUnit
8400ce4 is described below
commit 8400ce4d05523a7032ad02d7183803520b794b63
Author: Jianxia Chen <jc...@apache.org>
AuthorDate: Thu Feb 6 16:42:22 2020 -0800
WIP: add a DUnit
---
.../cache/execute/FunctionExecutionDUnit.java | 52 ++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionDUnit.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionDUnit.java
new file mode 100644
index 0000000..f97812f
--- /dev/null
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionDUnit.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 org.apache.geode.internal.cache.execute;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.internal.cache.functions.TestFunction;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+
+public class FunctionExecutionDUnit {
+
+ @Rule
+ public ClusterStartupRule cluster = new ClusterStartupRule();
+
+ @Test
+ public void test() throws Exception {
+ MemberVM locator = cluster.startLocatorVM(0);
+ MemberVM server = cluster.startServerVM(1, locator.getPort());
+ ClientVM client = cluster.startClientVM(2, c -> c.withLocatorConnection(locator.getPort()));
+
+ server.invoke( () -> {
+ Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1);
+ FunctionService.registerFunction(function);
+ });
+ client.invokeAsync(() -> {
+ ClientCache clientCache = ClusterStartupRule.getClientCache();
+ while (true) {
+ FunctionService.onServers(clientCache).execute(TestFunction.TEST_FUNCTION1).getResult();
+ }
+ });
+ cluster.stop(1);
+ cluster.stop(0);
+ }
+}