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:06 UTC

[3/3] geode git commit: GEODE-2858: Add test for parsing of simple XML file w pool

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>
+