use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class SpaceLogListener method setConfiguration.
/**
* @param cfg Configuration object
* @throws ConfigurationException
*/
@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
this.cfg = cfg;
queueName = cfg.get("queue", null);
if (queueName == null)
throw new ConfigurationException("'queue' property not configured");
timeout = cfg.getLong("timeout", timeout);
frozen = cfg.getBoolean("frozen", true);
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class FilterLogListenerTest method testSetConfigurationThrowsConfigurationException.
@Test
public void testSetConfigurationThrowsConfigurationException() throws Throwable {
FilterLogListener filterLogListener = new FilterLogListener(new PrintStream(new ByteArrayOutputStream()));
Configuration cfg = new SubConfiguration();
try {
filterLogListener.setConfiguration(cfg);
fail("Expected ConfigurationException to be thrown");
} catch (ConfigurationException ex) {
assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage());
assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
assertEquals("filterLogListener.getPriority()", "info", filterLogListener.getPriority());
}
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class SimpleKeyFileTest method testSetConfigurationThrowsConfigurationException.
@Test
public void testSetConfigurationThrowsConfigurationException() throws Throwable {
SimpleKeyFile simpleKeyFile = new SimpleKeyFile();
Configuration cfg = new SimpleConfiguration(new Properties());
try {
simpleKeyFile.setConfiguration(cfg);
fail("Expected ConfigurationException to be thrown");
} catch (ConfigurationException ex) {
assertEquals("simpleKeyFile.file.getName()", "", simpleKeyFile.file.getName());
assertEquals("simpleKeyFile.header", "Key File", simpleKeyFile.header);
assertEquals("simpleKeyFile.props.size()", 0, simpleKeyFile.props.size());
}
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class GenericPackager method setConfiguration.
/**
* Packager Configuration.
*
* <ul>
* <li>packager-config
* <li>packager-logger
* <li>packager-realm
* </ul>
*
* @param cfg Configuration
*/
public void setConfiguration(Configuration cfg) throws ConfigurationException {
filename = cfg.get("packager-config", null);
if (filename == null)
throw new ConfigurationException("packager-config property cannot be null");
try {
String loggerName = cfg.get("packager-logger");
if (loggerName != null)
setLogger(Logger.getLogger(loggerName), cfg.get("packager-realm"));
readFile(filename);
} catch (ISOException e) {
throw new ConfigurationException(e.getMessage(), e.fillInStackTrace());
}
}
use of org.jpos.core.ConfigurationException in project jPOS by jpos.
the class QFactory method invoke.
/**
* Try to invoke a method (usually a setter) on the given object
* silently ignoring if method does not exist
* @param obj the object
* @param m method to invoke
* @param p parameter
* @param pc parameter class
* @throws ConfigurationException if method happens to throw an exception
*/
@SuppressWarnings("PMD.EmptyCatchBlock")
public static void invoke(Object obj, String m, Object p, Class pc) throws ConfigurationException {
try {
if (p != null) {
Class[] paramTemplate = { pc };
Method method = obj.getClass().getMethod(m, paramTemplate);
Object[] param = new Object[1];
param[0] = p;
method.invoke(obj, param);
} else {
Method method = obj.getClass().getMethod(m);
method.invoke(obj);
}
} catch (NoSuchMethodException ignored) {
} catch (NullPointerException ignored) {
} catch (IllegalAccessException ignored) {
} catch (InvocationTargetException e) {
throw new ConfigurationException(obj.getClass().getName() + "." + m + "(" + p + ")", e.getTargetException());
}
}
Aggregations