Search in sources :

Example 31 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class GenericPackagerTest method testSetConfigurationThrowsConfigurationException.

@Ignore("test failing")
@Test
public void testSetConfigurationThrowsConfigurationException() throws Throwable {
    GenericPackager genericPackager = new GenericPackager();
    Configuration cfg = new SimpleConfiguration();
    try {
        genericPackager.setConfiguration(cfg);
        fail("Expected ConfigurationException to be thrown");
    } catch (ConfigurationException ex) {
        assertEquals("ex.getMessage()", "org.jpos.iso.ISOException: java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl (java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl)", ex.getMessage());
        assertEquals("ex.getNested().getMessage()", "java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl", ex.getNested().getMessage());
        assertEquals("(GenericValidatingPackager) genericValidatingPackager.getLogger().getName()", "", genericPackager.getLogger().getName());
        assertEquals("(GenericValidatingPackager) genericValidatingPackager.getRealm()", "", genericPackager.getRealm());
    }
}
Also used : SubConfiguration(org.jpos.core.SubConfiguration) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Configuration(org.jpos.core.Configuration) ConfigurationException(org.jpos.core.ConfigurationException) SimpleConfiguration(org.jpos.core.SimpleConfiguration) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 32 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class TransactionManager method initService.

@Override
public void initService() throws ConfigurationException {
    queue = cfg.get("queue", null);
    if (queue == null)
        throw new ConfigurationException("queue property not specified");
    sp = SpaceFactory.getSpace(cfg.get("space"));
    isp = SpaceFactory.getSpace(cfg.get("input-space", cfg.get("space")));
    if (isp == sp)
        iisp = isp;
    else {
        iisp = sp;
    }
    psp = SpaceFactory.getSpace(cfg.get("persistent-space", this.toString()));
    tail = initCounter(TAIL, cfg.getLong("initial-tail", 1));
    head = Math.max(initCounter(HEAD, tail), tail);
    initTailLock();
    groups = new HashMap<>();
    initParticipants(getPersist());
    initStatusListeners(getPersist());
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException)

Example 33 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class BSHTransactionParticipant method setConfiguration.

public void setConfiguration(Element e) throws ConfigurationException {
    try {
        prepareMethod = BSHMethod.createBshMethod(e.getChild("prepare"));
        prepareForAbortMethod = BSHMethod.createBshMethod(e.getChild("prepare-for-abort"));
        commitMethod = BSHMethod.createBshMethod(e.getChild("commit"));
        abortMethod = BSHMethod.createBshMethod(e.getChild("abort"));
        trace = "yes".equals(e.getAttributeValue("trace"));
    } catch (Exception ex) {
        throw new ConfigurationException(ex.getMessage(), ex);
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) ConfigurationException(org.jpos.core.ConfigurationException) IOException(java.io.IOException)

Example 34 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class Forward method setConfiguration.

public void setConfiguration(Configuration cfg) throws ConfigurationException {
    sp = SpaceFactory.getSpace(cfg.get("space", ""));
    queue = cfg.get("queue", null);
    if (queue == null)
        throw new ConfigurationException("Unspecified queue");
    timeout = cfg.getLong("timeout", 60000L);
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException)

Example 35 with ConfigurationException

use of org.jpos.core.ConfigurationException in project jPOS by jpos.

the class JSParticipant method setConfiguration.

public void setConfiguration(Element e) throws ConfigurationException {
    try (FileReader src = new FileReader(e.getAttributeValue("src"))) {
        trace = "yes".equals(e.getAttributeValue("trace"));
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
        engine.eval(src);
        js = (Invocable) engine;
        hasPrepare = hasFunction("prepare");
        hasPrepareForAbort = hasFunction("prepareForAbort");
        hasCommit = hasFunction("commit");
        hasAbort = hasFunction("abort");
    } catch (Exception ex) {
        throw new ConfigurationException(ex.getMessage(), ex);
    }
}
Also used : ConfigurationException(org.jpos.core.ConfigurationException) ScriptEngineManager(javax.script.ScriptEngineManager) FileReader(java.io.FileReader) ScriptEngine(javax.script.ScriptEngine) ConfigurationException(org.jpos.core.ConfigurationException) ScriptException(javax.script.ScriptException)

Aggregations

ConfigurationException (org.jpos.core.ConfigurationException)52 Element (org.jdom2.Element)10 SimpleConfiguration (org.jpos.core.SimpleConfiguration)10 Test (org.junit.Test)9 Configuration (org.jpos.core.Configuration)8 Configurable (org.jpos.core.Configurable)5 SubConfiguration (org.jpos.core.SubConfiguration)5 NameRegistrar (org.jpos.util.NameRegistrar)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Properties (java.util.Properties)3 LogSource (org.jpos.util.LogSource)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 StringTokenizer (java.util.StringTokenizer)2 Timer (java.util.Timer)2 ISOException (org.jpos.iso.ISOException)2 Logger (org.jpos.util.Logger)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1