Search in sources :

Example 51 with CacheXmlException

use of org.apache.geode.cache.CacheXmlException in project geode by apache.

the class DiskRegionIllegalCacheXMLvaluesJUnitTest method createRegion.

public void createRegion(String path) {
    DistributedSystem ds = null;
    try {
        boolean exceptionOccurred = false;
        File dir = new File("testingDirectoryForXML");
        dir.mkdir();
        dir.deleteOnExit();
        Properties props = new Properties();
        props.setProperty(MCAST_PORT, "0");
        props.setProperty(CACHE_XML_FILE, TestUtil.getResourcePath(getClass(), path));
        ds = DistributedSystem.connect(props);
        try {
            CacheFactory.create(ds);
        } catch (IllegalArgumentException ex) {
            exceptionOccurred = true;
            System.out.println("ExpectedStrings: Received expected IllegalArgumentException:" + ex.getMessage());
        } catch (CacheXmlException ex) {
            exceptionOccurred = true;
            System.out.println("ExpectedStrings: Received expected CacheXmlException:" + ex.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            fail("test failed due to " + e);
        }
        if (!exceptionOccurred) {
            fail(" exception did not occur although was expected");
        }
    } finally {
        if (ds != null && ds.isConnected()) {
            ds.disconnect();
            ds = null;
        }
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) File(java.io.File) CacheXmlException(org.apache.geode.cache.CacheXmlException)

Aggregations

CacheXmlException (org.apache.geode.cache.CacheXmlException)51 Declarable (org.apache.geode.cache.Declarable)22 SAXException (org.xml.sax.SAXException)13 Test (org.junit.Test)12 IgnoredException (org.apache.geode.test.dunit.IgnoredException)11 IOException (java.io.IOException)10 RegionExistsException (org.apache.geode.cache.RegionExistsException)9 CacheException (org.apache.geode.cache.CacheException)8 SAXParseException (org.xml.sax.SAXParseException)8 File (java.io.File)7 EmptyStackException (java.util.EmptyStackException)7 InternalGemFireException (org.apache.geode.InternalGemFireException)7 CacheWriterException (org.apache.geode.cache.CacheWriterException)7 GatewayException (org.apache.geode.cache.GatewayException)7 TimeoutException (org.apache.geode.cache.TimeoutException)7 Properties (java.util.Properties)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2