Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DE87718E77 for ; Wed, 3 Feb 2016 03:24:44 +0000 (UTC) Received: (qmail 40395 invoked by uid 500); 3 Feb 2016 03:24:44 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 40309 invoked by uid 500); 3 Feb 2016 03:24:44 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 39580 invoked by uid 99); 3 Feb 2016 03:24:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2016 03:24:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0DB42DFE60; Wed, 3 Feb 2016 03:24:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vkulichenko@apache.org To: commits@ignite.apache.org Date: Wed, 03 Feb 2016 03:25:00 -0000 Message-Id: <33f0ff0c3988435fb82aab702ce4cf0c@git.apache.org> In-Reply-To: <8ca2df1a43c5458f8c92d679a0115c73@git.apache.org> References: <8ca2df1a43c5458f8c92d679a0115c73@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [19/19] ignite git commit: IGNITE-2450 - Added test IGNITE-2450 - Added test Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7e936135 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7e936135 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7e936135 Branch: refs/heads/ignite-2450 Commit: 7e936135bdc1c4fca13e0ad70ca8781ec3e0037d Parents: d66e541 Author: Valentin Kulichenko Authored: Tue Feb 2 19:22:58 2016 -0800 Committer: Valentin Kulichenko Committed: Tue Feb 2 19:22:58 2016 -0800 ---------------------------------------------------------------------- ...namicProxySerializationMultiJvmSelfTest.java | 122 +++++++++++++++++++ .../ignite/testsuites/IgniteBasicTestSuite.java | 3 + 2 files changed, 125 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/7e936135/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java new file mode 100644 index 0000000..c5bd892 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java @@ -0,0 +1,122 @@ +/* + * 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.marshaller; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.lang.IgniteCallable; +import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * Multi-JVM test for dynamic proxy serialization. + */ +public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstractTest { + /** */ + private static boolean optMarsh; + + /** {@inheritDoc} */ + @Override protected boolean isMultiJvm() { + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + if (optMarsh) + cfg.setMarshaller(new OptimizedMarshaller(false)); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testOptimized() throws Exception { + optMarsh = true; + + doTest(); + } + + /** + * @throws Exception If failed. + */ + public void testBinary() throws Exception { + optMarsh = false; + + doTest(); + } + + /** + * @throws Exception If failed. + */ + private void doTest() throws Exception { + try { + Ignite ignite = startGrids(2); + + MyProxy p = (MyProxy)Proxy.newProxyInstance(getClass().getClassLoader(), + new Class[] { MyProxy.class }, new InvocationHandler() { + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("value".equals(method.getName())) + return 42; + + throw new IllegalStateException(); + } + }); + + int val = ignite.compute(ignite.cluster().forRemotes()).call(new MyCallable(p)); + + assertEquals(42, val); + } + finally { + stopAllGrids(); + } + } + + /** + */ + private static class MyCallable implements IgniteCallable { + /** */ + private final MyProxy p; + + /** + * @param p Proxy. + */ + public MyCallable(MyProxy p) { + this.p = p; + } + + /** {@inheritDoc} */ + @Override public Integer call() throws Exception { + return p.value(); + } + } + + /** + */ + private static interface MyProxy { + /** + * @return Value. + */ + public int value(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e936135/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index dece258..e26c5dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.service.ClosureServiceClientsNodesT import org.apache.ignite.internal.product.GridProductVersionSelfTest; import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.DynamicProxySerializationMultiJvmSelfTest; import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest; import org.apache.ignite.messaging.GridMessagingSelfTest; import org.apache.ignite.messaging.IgniteMessagingWithClientTest; @@ -116,6 +117,8 @@ public class IgniteBasicTestSuite extends TestSuite { suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class); + suite.addTestSuite(DynamicProxySerializationMultiJvmSelfTest.class); + return suite; } }