Search in sources :

Example 6 with CacheXmlException

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

the class CacheXml66DUnitTest method testBadKeyConstraintClass.

/**
   * Tests parsing an XML file with a non-existent key constraint class.
   */
@Test
public void testBadKeyConstraintClass() throws Exception {
    setXmlFile(findFile("badKeyConstraintClass.xml"));
    IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
    try {
        getCache();
        fail("Should have thrown a CacheXmlException");
    } catch (CacheXmlException ex) {
        assertTrue(ex.getCause() instanceof ClassNotFoundException);
    } finally {
        expectedException.remove();
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test)

Example 7 with CacheXmlException

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

the class CacheXml66DUnitTest method testLoaderNotLoader.

/**
   * Tests parsing an XML file that specifies a cache listener that is not a {@code CacheLoader}.
   */
@Test
public void testLoaderNotLoader() throws Exception {
    setXmlFile(findFile("loaderNotLoader.xml"));
    IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
    try {
        getCache();
        fail("Should have thrown a CacheXmlException");
    } catch (CacheXmlException ex) {
        Throwable cause = ex.getCause();
        assertNull("Didn't expect a " + cause, cause);
    } finally {
        expectedException.remove();
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test)

Example 8 with CacheXmlException

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

the class CacheXml66DUnitTest method testXmlFileIsDirectory.

/**
   * Tests creating a cache with a XML file that is a directory
   */
@Test
public void testXmlFileIsDirectory() throws Exception {
    File dir = new File(this.getName() + "dir");
    dir.mkdirs();
    dir.deleteOnExit();
    setXmlFile(dir);
    IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.GemFireCache_DECLARATIVE_XML_FILE_0_IS_NOT_A_FILE.toLocalizedString(dir));
    try {
        getCache();
        fail("Should have thrown a CacheXmlException");
    } catch (CacheXmlException ex) {
    // pass...
    } finally {
        expectedException.remove();
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) Test(org.junit.Test)

Example 9 with CacheXmlException

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

the class CacheXml66DUnitTest method testBadScope.

/**
   * Tests parsing an XML file with a bad scope. This error should be caught by the XML parser.
   */
@Test
public void testBadScope() throws Exception {
    setXmlFile(findFile("badScope.xml"));
    IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
    try {
        getCache();
        fail("Should have thrown a CacheXmlException");
    } catch (CacheXmlException ex) {
        assertTrue(ex.getCause() instanceof SAXException);
    } finally {
        expectedException.remove();
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Example 10 with CacheXmlException

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

the class CacheXmlParser method endAsyncEventListener.

private void endAsyncEventListener() {
    Declarable d = createDeclarable();
    if (!(d instanceof AsyncEventListener)) {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_ASYNCEVENTLISTENER.toLocalizedString(d.getClass().getName()));
    }
    AsyncEventQueueCreation eventChannel = peekAsyncEventQueueContext(ASYNC_EVENT_LISTENER);
    eventChannel.setAsyncEventListener((AsyncEventListener) d);
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

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