Search in sources :

Example 1 with DBReportMediatorFactory

use of org.apache.synapse.config.xml.DBReportMediatorFactory in project wso2-synapse by wso2.

the class DBReportMediatorTest method suite.

public static Test suite() {
    return new TestSetup(new TestSuite(DBReportMediatorTest.class)) {

        @Override
        protected void setUp() throws Exception {
            String baseDir = System.getProperty("basedir");
            if (baseDir == null) {
                baseDir = ".";
            }
            report = (DBReportMediator) new DBReportMediatorFactory().createMediator(createOMElement("<dblookup xmlns=\"http://ws.apache.org/ns/synapse\">\n" + "  <connection>\n" + "    <pool>\n" + "      <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>\n" + "      <url>jdbc:derby:" + baseDir + "/target/derbyDB;create=true</url>\n" + "      <user>user</user>\n" + "      <password>pass</password>\n" + "      <property name=\"initialsize\" value=\"2\"/>\n" + "      <property name=\"isolation\" value=\"Connection.TRANSACTION_SERIALIZABLE\"/>\n" + "    </pool>\n" + "  </connection>\n" + "  <statement>\n" + "    <sql>insert into audit values(?, ?, ?, ?)</sql>\n" + "    <parameter expression=\"//from\" type=\"VARCHAR\"/>\n" + "    <parameter expression=\"//count\" type=\"INTEGER\"/>\n" + "    <parameter expression=\"//to\" type=\"VARCHAR\"/>\n" + "    <parameter value=\"GOLD\" type=\"VARCHAR\"/>\n" + "  </statement>\n" + "</dblookup>"), new Properties());
            report.init(new Axis2SynapseEnvironment(new SynapseConfiguration()));
            java.sql.Statement s = report.getDataSource().getConnection().createStatement();
            try {
                s.execute("drop table audit");
            } catch (SQLException ignore) {
            }
            s.execute("create table audit(fromepr varchar(10), cnt int, toepr varchar(10), category varchar(10))");
            s.close();
        }

        @Override
        protected void tearDown() throws Exception {
        }
    };
}
Also used : TestSetup(junit.extensions.TestSetup) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestSuite(junit.framework.TestSuite) SQLException(java.sql.SQLException) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) DBReportMediatorFactory(org.apache.synapse.config.xml.DBReportMediatorFactory)

Aggregations

SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1 TestSetup (junit.extensions.TestSetup)1 TestSuite (junit.framework.TestSuite)1 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)1 DBReportMediatorFactory (org.apache.synapse.config.xml.DBReportMediatorFactory)1 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)1