geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject geode git commit: GEODE-2858: Add test for parsing of simple XML file w pool
Date Fri, 05 May 2017 20:40:18 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2858 [created] 15c87b79a


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/15c87b79
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/15c87b79
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/15c87b79

Branch: refs/heads/feature/GEODE-2858
Commit: 15c87b79ac524423a27fa94616962792dd1d465c
Parents: 149e06d
Author: Oleg Shvartsman <OSHVARTS@ford.com>
Authored: Mon Feb 13 15:52:01 2017 -0500
Committer: Kirk Lund <klund@apache.org>
Committed: Fri May 5 13:39:24 2017 -0700

----------------------------------------------------------------------
 .../cache/query/LocalQueryServiceJUnitTest.java |  4 +++
 .../cache/xmlcache/CacheXmlParserJUnitTest.java | 35 ++++++++++++++++++++
 ...JUnitTest.testSimpleClientCacheXml.cache.xml | 28 ++++++++++++++++
 3 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/15c87b79/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/15c87b79/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..c2023a7 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
@@ -15,12 +15,15 @@
 package org.apache.geode.internal.cache.xmlcache;
 
 import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Locale;
+import java.util.Properties;
 
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -28,6 +31,10 @@ import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+
 
 /**
  * Test cases for {@link CacheXmlParser}.
@@ -79,6 +86,32 @@ 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", this.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(this.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
@@ -145,6 +178,8 @@ public class CacheXmlParserJUnitTest {
         throw new IllegalStateException(e);
       }
     }
+
+
   }
 
   public static class MockXmlParser extends AbstractXmlParser {

http://git-wip-us.apache.org/repos/asf/geode/blob/15c87b79/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>
+


Mime
View raw message