Skip to content

Commit

Permalink
GEODE-3306: Add unit tests
Browse files Browse the repository at this point in the history
Modified existing `testCacheXmlParserWithSimplePool()` to be able to
close the created cache, otherwise there will be an
IllegalStateException thrown about an "incomplete shutdown of a previous
cache".
  • Loading branch information
darrenfoong committed Aug 3, 2017
1 parent 6849c21 commit 6dd702c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions geode-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ dependencies {
testCompile 'com.pholser:junit-quickcheck-core:' + project.'junit-quickcheck.version'
testCompile 'com.pholser:junit-quickcheck-generators:' + project.'junit-quickcheck.version'
testCompile 'com.pholser:junit-quickcheck-guava:' + project.'junit-quickcheck.version'

testRuntime 'xerces:xercesImpl:' + project.'xercesImpl.version'
}

def generatedResources = "$buildDir/generated-resources/main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.distributed.internal.DM;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.test.junit.categories.UnitTest;
Expand Down Expand Up @@ -113,8 +115,23 @@ public void testCacheXmlParserWithSimplePool() {
when(dm.getSystem()).thenReturn(system);
InternalDistributedSystem.connect(nonDefault);

CacheXmlParser.parse(getClass()
.getResourceAsStream("CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml"));
Cache cache = new CacheFactory()
.set("cache-xml-file", "CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml")
.create(InternalDistributedSystem.connect(nonDefault));
cache.close();
}

/**
* Test that {@link CacheXmlParser} can parse the test cache.xml file, using the Apache Xerces XML
* parser.
*
* @since Geode 1.3
*/
@Test
public void testCacheXmlParserWithSimplePoolXerces() {
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
testCacheXmlParserWithSimplePool();
}

/**
Expand All @@ -137,6 +154,19 @@ public void testDTDFallbackWithNonEnglishLocal() {
}
}

/**
* Test that {@link CacheXmlParser} falls back to DTD parsing when locale language is not English,
* using the Apache Xerces XML parser.
*
* @since Geode 1.3
*/
@Test
public void testDTDFallbackWithNonEnglishLocalXerces() {
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
testDTDFallbackWithNonEnglishLocal();
}

/**
* Get access to {@link CacheXmlParser} protected methods and fields.
*
Expand Down
1 change: 1 addition & 0 deletions gradle/dependency-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ tomcat6.version = 6.0.37
tomcat7.version = 7.0.73
tomcat8.version = 8.5.9
commons-validator.version = 1.6
xercesImpl.version = 2.11.0

0 comments on commit 6dd702c

Please sign in to comment.