use of org.apache.geode.test.dunit.IgnoredException 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();
}
}
use of org.apache.geode.test.dunit.IgnoredException 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();
}
}
use of org.apache.geode.test.dunit.IgnoredException 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();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class PRClientServerRegionFunctionExecutionDUnitTest method testServerExecution_NoLastResult.
/*
* Execution of the function on server with single key as the routing object and using the name of
* the function
*/
@Test
public void testServerExecution_NoLastResult() {
createScenario();
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_NO_LASTRESULT);
registerFunctionAtServer(function);
isByName = new Boolean(true);
toRegister = new Boolean(true);
final IgnoredException ex = IgnoredException.addIgnoredException("did not send last result");
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.serverSingleKeyExecution_NoLastResult(isByName, toRegister));
ex.remove();
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class OnGroupsFunctionExecutionDUnitTest method testClientServerException.
@Test
public void testClientServerException() {
Host host = Host.getHost(0);
VM server0 = host.getVM(0);
VM server1 = host.getVM(1);
VM server2 = host.getVM(2);
VM client = host.getVM(3);
VM locator = Host.getLocator();
final String regionName = getName();
initVM(server0, "mg,g0", regionName, true);
initVM(server1, "g1", regionName, true);
initVM(server2, "g0,g1,g2", regionName, true);
final int locatorPort = getLocatorPort(locator);
final String hostName = host.getHostName();
client.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
try {
Cache c = CacheFactory.getAnyInstance();
c.close();
} catch (CacheClosedException cce) {
}
disconnectFromDS();
LogWriterUtils.getLogWriter().fine("SWAP:creating client cache");
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.addPoolLocator(hostName, locatorPort);
ccf.setPoolServerGroup("mg");
ccf.set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
ClientCache c = ccf.create();
IgnoredException expected = IgnoredException.addIgnoredException("No member found");
try {
InternalFunctionService.onServers(c, "no such group").execute(new OnGroupsFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException e) {
} finally {
expected.remove();
}
IgnoredException.addIgnoredException("NullPointerException");
Execution e = InternalFunctionService.onServers(c, "mg");
ArrayList<String> args = new ArrayList<String>();
args.add("runtime");
e = e.setArguments(args);
try {
e.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
Execution e1 = InternalFunctionService.onServers(c, "g1");
e1 = e1.setArguments(args);
try {
e1.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
// only one member
Execution e2 = InternalFunctionService.onServers(c, "g1");
args.add("g2");
e2 = e2.setArguments(args);
try {
e2.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
return null;
}
});
}
Aggregations