ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [23/45] ignite git commit: ignite-3392 Added test. (cherry picked from commit a056954)
Date Wed, 20 Jul 2016 09:29:34 GMT
ignite-3392 Added test.
(cherry picked from commit a056954)


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e1195296
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e1195296
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e1195296

Branch: refs/heads/ignite-1232-1
Commit: e1195296ddc883c0a980f64bf0d80c26ef78b233
Parents: 4f97444
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jul 13 12:29:33 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Jul 18 16:38:00 2016 +0300

----------------------------------------------------------------------
 ...rviceDeploymentExceptionPropagationTest.java | 80 ++++++++++++++++++++
 1 file changed, 80 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e1195296/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
new file mode 100644
index 0000000..811594f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.ignite.internal.processors.service;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.GridStringLogger;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/** */
+public class GridServiceDeploymentExceptionPropagationTest extends GridCommonAbstractTest
{
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /** */
+    @SuppressWarnings("unused")
+    public void testExceptionPropagation() throws Exception {
+        try (Ignite srv = startGrid("server")) {
+
+            GridStringLogger log = new GridStringLogger();
+
+            try (Ignite client = startGrid("client", getConfiguration("client").setGridLogger(log).setClientMode(true)))
{
+
+                try {
+                    client.services().deployClusterSingleton("my-service", new ServiceImpl());
+                }
+                catch (IgniteException e) {
+                    assertTrue(log.toString().contains("ServiceImpl init exception"));
+
+                    return; // Exception is what we expect.
+                }
+
+                // Fail explicitly if we've managed to get here though we shouldn't have.
+                fail("https://issues.apache.org/jira/browse/IGNITE-3392");
+            }
+        }
+    }
+
+    /**
+     * Simple service implementation throwing an exception on init.
+     * Doesn't even try to do anything useful because what we're testing here is failure.
+     */
+    private static class ServiceImpl implements Service {
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) throws Exception {
+            throw new RuntimeException("ServiceImpl init exception");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+    }
+}


Mime
View raw message