You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/05/08 22:12:04 UTC
[1/3] geode git commit: GEODE-2887: exclude build-* output
directories from rat
Repository: geode
Updated Branches:
refs/heads/develop 65821d1ea -> b29e1bda4
GEODE-2887: exclude build-* output directories from rat
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b29e1bda
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b29e1bda
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b29e1bda
Branch: refs/heads/develop
Commit: b29e1bda431c55b4287582672c7f7c5d3e684386
Parents: 7482c00
Author: Kirk Lund <kl...@apache.org>
Authored: Fri May 5 15:33:27 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 8 15:06:32 2017 -0700
----------------------------------------------------------------------
.../cache/query/LocalQueryServiceJUnitTest.java | 102 ++++++++-----------
gradle/rat.gradle | 1 +
2 files changed, 45 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/b29e1bda/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
index d3df451..a474547 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
@@ -14,88 +14,74 @@
*/
package org.apache.geode.cache.query;
-import org.apache.geode.internal.net.SocketCreatorFactory;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
+import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
+import static org.junit.Assert.assertEquals;
+
import org.apache.geode.cache.CacheTransactionManager;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.cache.client.ClientRegionFactory;
import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.IOException;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
public class LocalQueryServiceJUnitTest {
- @Test
- public void testLocalQueryService() throws Exception {
- ClientCache c = null;
- try {
- c = new ClientCacheFactory().create();
- addExpectedException(c, IOException.class.getName());
- Region r = createRegion(c);
- int numEntries = 10;
- loadRegion(r, numEntries);
- SelectResults sR = executeLocalQuery(c, "SELECT * from /localRegion");
- assertEquals(numEntries, sR.size());
- } finally {
- if (c != null) {
- c.close();
- }
+ private IgnoredException ignoredException;
+ private ClientCache clientCache;
+ private int numEntries;
+
+ @Before
+ public void before() throws Exception {
+ this.ignoredException = addIgnoredException(IOException.class.getName());
+
+ this.clientCache = new ClientCacheFactory().create();
+ ClientRegionFactory factory =
+ this.clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL);
+ Region region = factory.create("localRegion");
+ this.numEntries = 10;
+ for (int i = 0; i < this.numEntries; i++) {
+ region.put(i, i);
}
}
- @Test
- public void testLocalQueryServiceWithTransaction() throws Exception {
- ClientCache c = null;
- try {
- SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
- c = new ClientCacheFactory().create();
- addExpectedException(c, IOException.class.getName());
- Region r = createRegion(c);
- int numEntries = 10;
- loadRegion(r, numEntries);
- CacheTransactionManager cacheTransactionManager = c.getCacheTransactionManager();
- cacheTransactionManager.begin();
- SelectResults sR = executeLocalQuery(c, "SELECT * from /localRegion");
- assertEquals(numEntries, sR.size());
- cacheTransactionManager.commit();
- } finally {
- if (c != null) {
- c.close();
- }
+ @After
+ public void after() throws Exception {
+ if (this.clientCache != null) {
+ this.clientCache.close();
}
+ this.ignoredException.remove();
}
- private Region createRegion(ClientCache c) {
- ClientRegionFactory factory = c.createClientRegionFactory(ClientRegionShortcut.LOCAL);
- return factory.create("localRegion");
- }
+ @Test
+ public void testLocalQueryService() throws Exception {
+ SelectResults sR = executeLocalQuery(this.clientCache, "SELECT * from /localRegion");
- private void loadRegion(Region r, int numEntries) {
- for (int i = 0; i < numEntries; i++) {
- r.put(i, i);
- }
+ assertEquals(this.numEntries, sR.size());
}
- private SelectResults executeLocalQuery(ClientCache c, String qS) throws QueryException {
- QueryService qs = c.getLocalQueryService();
- Query q = qs.newQuery("SELECT * from /localRegion");
- return (SelectResults) q.execute();
- }
+ @Test
+ public void testLocalQueryServiceWithTransaction() throws Exception {
+ CacheTransactionManager cacheTransactionManager = clientCache.getCacheTransactionManager();
+ cacheTransactionManager.begin();
+ SelectResults selectResults = executeLocalQuery(this.clientCache, "SELECT * from /localRegion");
+
+ assertEquals(this.numEntries, selectResults.size());
- private void addExpectedException(ClientCache c, String exception) {
- c.getLogger().info("<ExpectedException action=add>" + exception + "</ExpectedException>");
+ cacheTransactionManager.commit();
}
- private void removeExpectedException(ClientCache c, String exception) {
- c.getLogger().info("<ExpectedException action=remove>" + exception + "</ExpectedException>");
+ private SelectResults executeLocalQuery(ClientCache c, String query) throws QueryException {
+ QueryService qs = c.getLocalQueryService();
+ Query q = qs.newQuery(query);
+ return (SelectResults) q.execute();
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/b29e1bda/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index 440a7b7..f8018b6 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -37,6 +37,7 @@ rat {
'native/**',
'wrapper/**',
'**/build/**',
+ '**/build-*/**',
'.buildinfo',
// SBT
[3/3] geode git commit: GEODE-2858: Add test for parsing of simple
XML file w pool
Posted by kl...@apache.org.
GEODE-2858: Add test for parsing of simple XML file w pool
to detect/prevent regression to parsing exceptions that
was fixed in Geode 1.0
This closes #397
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/34deeabb
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/34deeabb
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/34deeabb
Branch: refs/heads/develop
Commit: 34deeabb9474a47052d06e8f25de018524f188e5
Parents: 65821d1
Author: Oleg Shvartsman <OS...@ford.com>
Authored: Mon Feb 13 15:52:01 2017 -0500
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 8 15:06:32 2017 -0700
----------------------------------------------------------------------
.../cache/query/LocalQueryServiceJUnitTest.java | 4 ++
.../cache/xmlcache/CacheXmlParserJUnitTest.java | 51 ++++++++++++++++----
...JUnitTest.testSimpleClientCacheXml.cache.xml | 28 +++++++++++
3 files changed, 73 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/34deeabb/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
index edd3f05..d3df451 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.cache.query;
+import org.apache.geode.internal.net.SocketCreatorFactory;
+import org.apache.geode.distributed.internal.DistributionConfigImpl;
import org.apache.geode.cache.CacheTransactionManager;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
@@ -25,6 +27,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.IOException;
+import java.util.Properties;
import static org.junit.Assert.assertEquals;
@@ -53,6 +56,7 @@ public class LocalQueryServiceJUnitTest {
public void testLocalQueryServiceWithTransaction() throws Exception {
ClientCache c = null;
try {
+ SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
c = new ClientCacheFactory().create();
addExpectedException(c, IOException.class.getName());
Region r = createRegion(c);
http://git-wip-us.apache.org/repos/asf/geode/blob/34deeabb/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
index 729dbfb..b0f5c8d 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
@@ -14,20 +14,29 @@
*/
package org.apache.geode.internal.cache.xmlcache;
-import static org.junit.Assert.*;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Locale;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import org.apache.geode.test.junit.categories.UnitTest;
+import java.util.Properties;
/**
* Test cases for {@link CacheXmlParser}.
@@ -79,6 +88,30 @@ public class CacheXmlParserJUnitTest {
}
/**
+ * Test that {@link CacheXmlParser} can parse the test cache.xml file.
+ *
+ * @since Geode 1.2
+ */
+ @Test
+ public void testCacheXmlParserWithSimplePool() {
+ assertNotNull("Did not find simple config.xml file", getClass()
+ .getResourceAsStream("CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml"));
+
+ DM dm = mock(DM.class);
+
+ Properties nonDefault = new Properties();
+ nonDefault.setProperty(MCAST_PORT, "0"); // loner
+
+ InternalDistributedSystem system =
+ InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
+ when(dm.getSystem()).thenReturn(system);
+ InternalDistributedSystem.connect(nonDefault);
+
+ CacheXmlParser.parse(getClass()
+ .getResourceAsStream("CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml"));
+ }
+
+ /**
* Test that {@link CacheXmlParser} falls back to DTD parsing when locale language is not English.
*
* @since Geode 1.0
@@ -164,7 +197,5 @@ public class CacheXmlParserJUnitTest {
public void endElement(String uri, String localName, String qName) throws SAXException {
throw new UnsupportedOperationException();
}
-
}
-
}
http://git-wip-us.apache.org/repos/asf/geode/blob/34deeabb/geode-core/src/test/resources/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml
new file mode 100644
index 0000000..0a76a77
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<client-cache
+ xmlns="http://geode.apache.org/schema/cache"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+ version="1.0">
+
+ <pool name="sessions" subscription-enabled="true">
+ <server host="1.2.3.4" port="11211" />
+ </pool>
+</client-cache>
+
[2/3] geode git commit: GEODE-2884: fix NPE when calling
getLatestAsClassLoader before getLatest
Posted by kl...@apache.org.
GEODE-2884: fix NPE when calling getLatestAsClassLoader before getLatest
Without this fix, CacheXmlParserJUnitTest.testGetDelegate() fails when
run in isolation but passes when run with all tests.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/7482c00b
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/7482c00b
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/7482c00b
Branch: refs/heads/develop
Commit: 7482c00bfe838414825cbd0d2a39b8c00fa476d5
Parents: 34deeab
Author: Kirk Lund <kl...@apache.org>
Authored: Fri May 5 15:05:07 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 8 15:06:32 2017 -0700
----------------------------------------------------------------------
.../apache/geode/internal/ClassPathLoader.java | 49 +++++++++-----------
1 file changed, 22 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/7482c00b/geode-core/src/main/java/org/apache/geode/internal/ClassPathLoader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/ClassPathLoader.java b/geode-core/src/main/java/org/apache/geode/internal/ClassPathLoader.java
index 39e9d62..b272f8a 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/ClassPathLoader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/ClassPathLoader.java
@@ -16,7 +16,6 @@ package org.apache.geode.internal;
import static java.util.stream.Collectors.joining;
-import org.apache.commons.io.FileUtils;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.util.CollectionUtils;
@@ -26,13 +25,13 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Proxy;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashSet;
+import java.util.List;
/**
* The delegating <tt>ClassLoader</tt> used by GemFire to load classes and other resources. This
@@ -57,30 +56,27 @@ import java.util.stream.Collectors;
* <li>4. <tt>ClassLoader.getSystemClassLoader()</tt> If the attempt to acquire any of the above
* class loaders results in either a {@link java.lang.SecurityException SecurityException} or a
* null, then that class loader is quietly skipped. Duplicate class loaders will be skipped.
- *
+ * <p>
+ * This class it not an extension of ClassLoader due to #43080. See also
+ * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html
+ *
* @since GemFire 6.5.1.4
*/
-public final class ClassPathLoader {
- /*
- * This class it not an extension of ClassLoader due to reasons outlined in
- * https://svn.gemstone.com/trac/gemfire/ticket/43080
- *
- * See also http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html
- */
+public class ClassPathLoader {
private static final Logger logger = LogService.getLogger();
- public static final String EXCLUDE_TCCL_PROPERTY =
+ static final String EXCLUDE_TCCL_PROPERTY =
DistributionConfig.GEMFIRE_PREFIX + "excludeThreadContextClassLoader";
- public static final boolean EXCLUDE_TCCL_DEFAULT_VALUE = false;
private static volatile ClassPathLoader latest;
private volatile URLClassLoader classLoaderForDeployedJars;
+
private final JarDeployer jarDeployer;
private boolean excludeTCCL;
- public void rebuildClassLoaderForDeployedJars() {
+ void rebuildClassLoaderForDeployedJars() {
ClassLoader parent = ClassPathLoader.class.getClassLoader();
this.classLoaderForDeployedJars = new URLClassLoader(jarDeployer.getDeployedJarURLs(), parent);
@@ -98,7 +94,7 @@ public final class ClassPathLoader {
rebuildClassLoaderForDeployedJars();
}
- public static ClassPathLoader setLatestToDefault() {
+ static ClassPathLoader setLatestToDefault() {
latest = new ClassPathLoader(Boolean.getBoolean(EXCLUDE_TCCL_PROPERTY));
return latest;
}
@@ -112,7 +108,9 @@ public final class ClassPathLoader {
return this.jarDeployer;
}
- // This is exposed for testing.
+ /**
+ * createWithDefaults is exposed for testing.
+ */
static ClassPathLoader createWithDefaults(final boolean excludeTCCL) {
return new ClassPathLoader(excludeTCCL);
}
@@ -174,7 +172,7 @@ public final class ClassPathLoader {
/**
* See {@link Proxy#getProxyClass(ClassLoader, Class...)}
*/
- public Class<?> getProxyClass(final Class<?>[] classObjs) {
+ Class<?> getProxyClass(final Class<?>... classObjs) {
IllegalArgumentException ex = null;
for (ClassLoader classLoader : this.getClassLoaders()) {
@@ -227,11 +225,9 @@ public final class ClassPathLoader {
/**
* Returns an input stream for reading the specified resource.
- *
* <p>
* The search order is described in the documentation for {@link #getResource(String)}.
- * </p>
- *
+ *
* @param name The resource name
* @return An input stream for reading the resource, or <tt>null</tt> if the resource could not be
* found
@@ -265,7 +261,6 @@ public final class ClassPathLoader {
return getResourceAsStream(name);
}
-
/**
* Finds all the resources with the given name. This method will first search the class loader of
* the context class for the resource before searching all other {@link ClassLoader}s.
@@ -278,7 +273,7 @@ public final class ClassPathLoader {
* @throws IOException If I/O errors occur
* @see ClassLoader#getResources(String)
*/
- public Enumeration<URL> getResources(final Class<?> contextClass, final String name)
+ private Enumeration<URL> getResources(final Class<?> contextClass, final String name)
throws IOException {
final LinkedHashSet<URL> urls = new LinkedHashSet<URL>();
@@ -369,8 +364,8 @@ public final class ClassPathLoader {
* @return {@link ClassLoader} for current {@link ClassPathLoader}.
* @since GemFire 8.1
*/
- public static final ClassLoader getLatestAsClassLoader() {
- return latest.asClassLoader();
+ public static ClassLoader getLatestAsClassLoader() {
+ return getLatest().asClassLoader();
}
}