ignite-779
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/39823749 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/39823749 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/39823749 Branch: refs/heads/ignite-157-2 Commit: 39823749f374ac608e6ed98ef0f0a05a56938bfc Parents: 5718e8a Author: avinogradov <avinogra...@gridgain.com> Authored: Fri Apr 24 18:26:50 2015 +0300 Committer: avinogradov <avinogra...@gridgain.com> Committed: Fri Apr 24 18:26:50 2015 +0300 ---------------------------------------------------------------------- .../org/apache/ignite/internal/IgnitionEx.java | 15 +++--- .../util/spring/IgniteSpringHelper.java | 7 +-- .../util/spring/IgniteSpringHelperImpl.java | 31 ++++++------ .../spring/IgniteStartFromStreamCfgTest.java | 50 -------------------- .../IgniteStartFromStreamConfigurationTest.java | 50 ++++++++++++++++++++ .../testsuites/IgniteSpringTestSuite.java | 2 +- 6 files changed, 80 insertions(+), 75 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 469ba7b..c5145d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -560,8 +560,8 @@ public class IgnitionEx { * read. This exception will be thrown also if grid with given name has already * been started or Spring XML configuration file is invalid. */ - public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - URL springCfgUrl) throws IgniteCheckedException { + public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> + loadConfigurations(URL springCfgUrl) throws IgniteCheckedException { IgniteSpringHelper spring = SPRING.create(false); return spring.loadConfigurations(springCfgUrl); @@ -580,8 +580,8 @@ public class IgnitionEx { * read. This exception will be thrown also if grid with given name has already * been started or Spring XML configuration file is invalid. */ - public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - InputStream springCfgStream) throws IgniteCheckedException { + public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> + loadConfigurations(InputStream springCfgStream) throws IgniteCheckedException { IgniteSpringHelper spring = SPRING.create(false); return spring.loadConfigurations(springCfgStream); @@ -600,8 +600,8 @@ public class IgnitionEx { * read. This exception will be thrown also if grid with given name has already * been started or Spring XML configuration file is invalid. */ - public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - String springCfgPath) throws IgniteCheckedException { + public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> + loadConfigurations(String springCfgPath) throws IgniteCheckedException { A.notNull(springCfgPath, "springCfgPath"); URL url; @@ -636,7 +636,8 @@ public class IgnitionEx { */ public static IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> loadConfiguration(URL springCfgUrl) throws IgniteCheckedException { - IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> t = loadConfigurations(springCfgUrl); + IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> t = + loadConfigurations(springCfgUrl); return F.t(F.first(t.get1()), t.get2()); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java index 4b377f0..82ef421 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java @@ -75,7 +75,7 @@ public interface IgniteSpringHelper { * @throws IgniteCheckedException If configuration could not be read. */ public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException; + URL cfgUrl, Class<T> cls, String... excludedProps) throws IgniteCheckedException; /** * Loads all configurations with given type specified within given configuration input stream. @@ -87,7 +87,7 @@ public interface IgniteSpringHelper { * @throws IgniteCheckedException If configuration could not be read. */ public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - InputStream cfgStream, Class<T> cl, String... excludedProps) throws IgniteCheckedException; + InputStream cfgStream, Class<T> cls, String... excludedProps) throws IgniteCheckedException; /** * Loads bean instances that match the given types from given configuration file. @@ -119,7 +119,8 @@ public interface IgniteSpringHelper { * map value is {@code null}. * @throws IgniteCheckedException If failed to load configuration. */ - public Map<Class<?>, Object> loadBeans(InputStream cfgStream, Class<?>... beanClasses) throws IgniteCheckedException; + public Map<Class<?>, Object> loadBeans(InputStream cfgStream, Class<?>... beanClasses) + throws IgniteCheckedException; /** * Loads bean instance by name. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java index 17bc7a0..f05e991 100644 --- a/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java +++ b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java @@ -76,22 +76,22 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper { } /** {@inheritDoc} */ - @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, String... excludedProps) throws IgniteCheckedException { + @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> + loadConfigurations(URL cfgUrl, String... excludedProps) throws IgniteCheckedException { return loadConfigurations(cfgUrl, IgniteConfiguration.class, excludedProps); } /** {@inheritDoc} */ - @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException { + @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> + loadConfigurations(URL cfgUrl, Class<T> cls, String... excludedProps) throws IgniteCheckedException { ApplicationContext springCtx = applicationContext(cfgUrl, excludedProps); Map<String, T> cfgMap; try { - cfgMap = springCtx.getBeansOfType(cl); + cfgMap = springCtx.getBeansOfType(cls); } catch (BeansException e) { - throw new IgniteCheckedException("Failed to instantiate bean [type=" + cl + + throw new IgniteCheckedException("Failed to instantiate bean [type=" + cls + ", err=" + e.getMessage() + ']', e); } @@ -102,22 +102,22 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper { } /** {@inheritDoc} */ - @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - InputStream cfgStream, String... excludedProps) throws IgniteCheckedException { + @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> + loadConfigurations(InputStream cfgStream, String... excludedProps) throws IgniteCheckedException { return loadConfigurations(cfgStream, IgniteConfiguration.class, excludedProps); } /** {@inheritDoc} */ @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - InputStream cfgStream, Class<T> cl, String... excludedProps) throws IgniteCheckedException { + InputStream cfgStream, Class<T> cls, String... excludedProps) throws IgniteCheckedException { ApplicationContext springCtx = applicationContext(cfgStream, excludedProps); Map<String, T> cfgMap; try { - cfgMap = springCtx.getBeansOfType(cl); + cfgMap = springCtx.getBeansOfType(cls); } catch (BeansException e) { - throw new IgniteCheckedException("Failed to instantiate bean [type=" + cl + + throw new IgniteCheckedException("Failed to instantiate bean [type=" + cls + ", err=" + e.getMessage() + ']', e); } @@ -160,7 +160,8 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper { } /** {@inheritDoc} */ - @Override public Map<Class<?>, Object> loadBeans(InputStream cfgStream, Class<?>... beanClasses) throws IgniteCheckedException { + @Override public Map<Class<?>, Object> loadBeans(InputStream cfgStream, Class<?>... beanClasses) + throws IgniteCheckedException { assert beanClasses.length > 0; ApplicationContext springCtx = initContext(cfgStream); @@ -336,7 +337,8 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper { * @return Spring application context. * @throws IgniteCheckedException If configuration could not be read. */ - public static ApplicationContext applicationContext(URL cfgUrl, final String... excludedProps) throws IgniteCheckedException { + public static ApplicationContext applicationContext(URL cfgUrl, final String... excludedProps) + throws IgniteCheckedException { try { GenericApplicationContext springCtx = prepareSpringContext(excludedProps); @@ -368,7 +370,8 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper { * @return Spring application context. * @throws IgniteCheckedException If configuration could not be read. */ - public static ApplicationContext applicationContext(InputStream cfgStream, final String... excludedProps) throws IgniteCheckedException { + public static ApplicationContext applicationContext(InputStream cfgStream, final String... excludedProps) + throws IgniteCheckedException { try { GenericApplicationContext springCtx = prepareSpringContext(excludedProps); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamCfgTest.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamCfgTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamCfgTest.java deleted file mode 100644 index f47c6e0..0000000 --- a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamCfgTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.spring; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.net.*; - -/** - * Checks starts from Stream. - */ -public class IgniteStartFromStreamCfgTest extends GridCommonAbstractTest { - /** Tests starts from Stream. */ - public void testStartFromStream() throws Exception { - String cfg = "examples/config/example-cache.xml"; - - URL cfgLocation = U.resolveIgniteUrl(cfg); - - Ignite grid = Ignition.start(new FileInputStream(cfgLocation.getFile())); - - grid.cache(null).put("1", "1"); - - assert grid.cache(null).get("1").equals("1"); - - IgniteConfiguration icfg = Ignition.loadSpringBean(new FileInputStream(cfgLocation.getFile()), "ignite.cfg"); - - assert icfg.getCacheConfiguration()[0].getAtomicityMode() == CacheAtomicityMode.ATOMIC; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java new file mode 100644 index 0000000..4ebfcdc --- /dev/null +++ b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java @@ -0,0 +1,50 @@ +/* + * 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.spring; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.testframework.junits.common.*; + +import java.io.*; +import java.net.*; + +/** + * Checks starts from Stream. + */ +public class IgniteStartFromStreamConfigurationTest extends GridCommonAbstractTest { + /** Tests starts from Stream. */ + public void testStartFromStream() throws Exception { + String cfg = "examples/config/example-cache.xml"; + + URL cfgLocation = U.resolveIgniteUrl(cfg); + + Ignite grid = Ignition.start(new FileInputStream(cfgLocation.getFile())); + + grid.cache(null).put("1", "1"); + + assert grid.cache(null).get("1").equals("1"); + + IgniteConfiguration icfg = Ignition.loadSpringBean(new FileInputStream(cfgLocation.getFile()), "ignite.cfg"); + + assert icfg.getCacheConfiguration()[0].getAtomicityMode() == CacheAtomicityMode.ATOMIC; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39823749/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java index dd3bb79..8251c18 100644 --- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java +++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java @@ -45,7 +45,7 @@ public class IgniteSpringTestSuite extends TestSuite { suite.addTest(new TestSuite(IgniteDynamicCacheConfigTest.class)); - suite.addTest(new TestSuite(IgniteStartFromStreamCfgTest.class)); + suite.addTest(new TestSuite(IgniteStartFromStreamConfigurationTest.class)); return suite; }