Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit a6f37ca9dc540253d4ea2acc9a6f06aca1f96ade @johndemic johndemic committed Dec 10, 2011
56 LICENSE.md
@@ -0,0 +1,56 @@
+Apache License
+==============
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+*TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION*
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
52 README.md
@@ -0,0 +1,52 @@
+
+WELCOME
+=======
+Congratulations you have just created a new Mule Cloud connector!
+
+Now you need to make sure that you update you pom.xml to use version
+${muleVersion} of Mule. This will ensure you are compiling against the correct
+version of Mule and you will avoid issues arising from not being about to find
+configuration schemas for this module.
+
+This wizard created a number of new classes and resources useful for Mule
+cloud connectors. Each of the created files contains documentation and TODO
+items where necessary. Here is an overview of what was created.
+
+./pom.xml:
+A maven project descriptor that describes how to build this module. It also
+contains additional information about how to share the connector on MuleForge.
+
+./assembly.xml:
+A maven assembly descriptor that defines how this module will be packaged
+when you make a release.
+
+./LICENSE.txt:
+The open source license text for this project.
+
+TESTING
+=======
+
+This project also contains test classes that can be run as part of a test
+suite.
+
+ADDITIONAL RESOURCES
+====================
+Everything you need to know about getting started with Mule can be found here:
+http://www.mulesoft.org/documentation/display/MULE3INTRO/Home
+
+There further useful information about extending Mule here:
+http://www.mulesoft.org/documentation/display/MULE3USER/Introduction+to+Extending+Mule
+
+For information about working with Mule inside and IDE with maven can be
+found here:
+http://www.mulesoft.org/documentation/display/MULE3INTRO/Setting+Up+Eclipse
+
+Remember if you get stuck you can try getting help on the Mule user list:
+http://www.mulesoft.org/email-lists
+
+Also, MuleSoft, the company behind Mule, offers 24x7 support options:
+http://www.mulesoft.com/enterprise-subscriptions-and-support
+
+Enjoy your Mule ride!
+
+The Mule Team
11 doc/Esper-connector.xml.sample
@@ -0,0 +1,11 @@
+<!-- BEGIN_INCLUDE(esper:send-event) -->
+ <esper:send event="#[payload:]" />
+<!-- END_INCLUDE(esper:send-event) -->
+
+<!-- BEGIN_INCLUDE(esper:listen) -->
+ <esper:listen statement="select count(*) from org.mule.api.MuleMessage.win:time_batch(10, 'FORCE_UPDATE, START_EAGER') having count(*) < 5" />
+<!-- END_INCLUDE(esper:listen) -->
+
+<!-- BEGIN_INCLUDE(esper:get-event-property) -->
+ <esper:get-event-property property="count(*)" />
+<!-- END_INCLUDE(esper:get-event-property) -->
249 pom.xml
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.mule.module.esper</groupId>
+ <artifactId>esper-connector</artifactId>
+ <version>1.0</version>
+ <packaging>mule-module</packaging>
+ <name>Mule Cloud Connector</name>
+
+ <properties>
+ <mule.version>3.2.0</mule.version>
+ <mule.devkit.version>3.0.1</mule.devkit.version>
+ <junit.version>4.8.2</junit.version>
+ <mockito.version>1.8.2</mockito.version>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.mule.tools.devkit</groupId>
+ <artifactId>mule-devkit-maven-plugin</artifactId>
+ <version>${mule.devkit.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.mule.tools.devkit</groupId>
+ <artifactId>mule-devkit-maven-plugin</artifactId>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>attach-test-resources</goal>
+ <goal>filter-resources</goal>
+ <goal>generate-sources</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.mule.tools.devkit</groupId>
+ <artifactId>mule-devkit-maven-plugin</artifactId>
+ <version>${mule.devkit.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <docletArtifact>
+ <groupId>org.mule.tools.devkit</groupId>
+ <artifactId>mule-devkit-doclet</artifactId>
+ <version>3.0.1</version>
+ </docletArtifact>
+ <doclet>org.mule.devkit.doclet.Doclava</doclet>
+ <bootclasspath>${sun.boot.class.path}</bootclasspath>
+ <additionalparam>
+ -quiet
+ -federate JDK http://download.oracle.com/javase/6/docs/api/index.html?
+ -federationxml JDK http://doclava.googlecode.com/svn/static/api/openjdk-6.xml
+ -hdf project.artifactId "${project.artifactId}"
+ -hdf project.groupId "${project.groupId}"
+ -hdf project.version "${project.version}"
+ -hdf project.name "${project.name}"
+ -hdf project.repo.name "${project.distributionManagement.repository.name}"
+ -hdf project.repo.id "${project.distributionManagement.repository.id}"
+ -hdf project.repo.url "${project.distributionManagement.repository.url}"
+ -hdf project.snapshotRepo.name "${project.distributionManagement.snapshotRepository.name}"
+ -hdf project.snapshotRepo.id "${project.distributionManagement.snapshotRepository.id}"
+ -hdf project.snapshotRepo.url "${project.distributionManagement.snapshotRepository.url}"
+ -d ${project.build.directory}/apidocs
+ </additionalparam>
+ <useStandardDocletOptions>false</useStandardDocletOptions>
+ <additionalJOption>-J-Xmx1024m</additionalJOption>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/test/resources</directory>
+ </resource>
+ </resources>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.mule.dsl</groupId>
+ <artifactId>dsl-api</artifactId>
+ <version>0.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mule</groupId>
+ <artifactId>core</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mule.modules</groupId>
+ <artifactId>mule-module-spring-config</artifactId>
+ <version>${mule.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mule.modules</groupId>
+ <artifactId>mule-module-client</artifactId>
+ <version>${mule.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mule.tools.devkit</groupId>
+ <artifactId>mule-devkit-annotations</artifactId>
+ <version>${mule.devkit.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.espertech</groupId>
+ <artifactId>esper</artifactId>
+ <version>4.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mule.tests</groupId>
+ <artifactId>mule-tests-functional</artifactId>
+ <version>${mule.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mule.transports</groupId>
+ <artifactId>mule-transport-vm</artifactId>
+ <version>${mule.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>muleforge-releases</id>
+ <name>MuleForge Releases Repository</name>
+ <url>http://repository.mulesoft.org/releases/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <id>muleforge-snapshots</id>
+ <name>MuleForge Snapshots Repository</name>
+ <url>http://repository.mulesoft.org/snapshots/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>muleforge-plugin-releases</id>
+ <name>Muleforge Release Repository</name>
+ <url>http://repository.mulesoft.org/releases/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>muleforge-plugin-snapshots</id>
+ <name>Muleforge Snapshot Repository</name>
+ <url>http://repository.mulesoft.org/snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
0 src/main/app/org/mule/module/esper/plugin.properties
No changes.
139 src/main/java/org/mule/module/esper/EsperConnector.java
@@ -0,0 +1,139 @@
+/**
+ * Mule Development Kit
+ * Copyright 2010-2011 (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file was automatically generated by the Mule Development Kit
+ */
+package org.mule.module.esper;
+
+import com.espertech.esper.client.*;
+import com.espertech.esper.event.map.MapEventBean;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mule.api.ConnectionException;
+import org.mule.api.MuleContext;
+import org.mule.api.MuleMessage;
+import org.mule.api.annotations.*;
+import org.mule.api.annotations.param.Optional;
+import org.mule.api.annotations.param.Payload;
+import org.mule.api.callback.SourceCallback;
+import org.mule.api.context.MuleContextAware;
+
+import java.net.URL;
+
+/**
+ * Cloud Connector for Esper.
+ *
+ * @author MuleSoft, Inc.
+ */
+@Connector(name = "esper", schemaVersion = "1.0")
+public class EsperConnector implements MuleContextAware {
+
+ protected transient Log logger = LogFactory.getLog(getClass());
+
+ private EPServiceProvider esperServiceProvider;
+
+ private MuleContext muleContext;
+ /**
+ * The optional location of an Esper config file.
+ */
+ @Configurable
+ @Optional
+ private String configuration;
+
+
+ public void setConfiguration(String configuration) {
+ this.configuration = configuration;
+ }
+
+
+ public void setMuleContext(MuleContext muleContext) {
+ this.muleContext = muleContext;
+ }
+
+
+ @Connect
+ public void connect() throws ConnectionException {
+ Configuration c = new Configuration();
+
+ if (StringUtils.isNotBlank(configuration)) {
+ logger.debug("Initializing EsperServiceProvider with configuration: " + configuration);
+ URL configURL = Thread.currentThread().getContextClassLoader().getResource(configuration);
+ c.configure(configURL);
+ }
+ esperServiceProvider = EPServiceProviderManager.getDefaultProvider(c);
+ }
+
+ @Disconnect
+ public void disconnect() {
+ logger.debug("Destroying EsperServiceProvider");
+ esperServiceProvider.destroy();
+ }
+
+ @ConnectionIdentifier
+ public String connectionId() {
+ return esperServiceProvider.getURI();
+ }
+
+ @ValidateConnection
+ public boolean isConnected() {
+ return esperServiceProvider != null;
+ }
+
+ /**
+ * Sends events to an Esper event stream.
+ * <p/>
+ * {@sample.xml ../../../doc/Esper-connector.xml.sample esper:send-event}
+ *
+ * @param eventPayload The event to be injected into the event stream.
+ */
+ @Processor
+ public void send(Object eventPayload) {
+ logger.debug(String.format("Sending event %s to stream", eventPayload));
+ esperServiceProvider.getEPRuntime().sendEvent(eventPayload);
+ }
+
+ /**
+ * Listens for events matching the specified query statement.
+ * <p/>
+ * {@sample.xml ../../../doc/Esper-connector.xml.sample esper:listen}
+ *
+ * @param statement The Esper statement to select events from a stream.
+ * @param callback The callback to be called when a message is received
+ */
+ @Source
+ public void listen(String statement, final SourceCallback callback) {
+ logger.debug("Listening for events with statement: " + statement);
+ EPStatement s = esperServiceProvider.getEPAdministrator().createEPL(statement);
+ s.addListener(new SourceCallbackUpdateListener(callback));
+ }
+
+ /**
+ * Utility transformer to extract a property from an <code>EventBean</code>.
+ * <p/>
+ * {@sample.xml ../../../doc/Esper-connector.xml.sample esper:get-event-property}
+ *
+ * @param event The <code>EventBean</code> to transform.
+ * @param key The property to extract
+ * @return The object corresponding to the parameter key
+ */
+ @Processor
+ public Object getEventProperty(@Payload EventBean event, String key) {
+ return event.get(key);
+ }
+}
35 src/main/java/org/mule/module/esper/SourceCallbackUpdateListener.java
@@ -0,0 +1,35 @@
+package org.mule.module.esper;
+
+import com.espertech.esper.client.EventBean;
+import com.espertech.esper.client.UpdateListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mule.api.callback.SourceCallback;
+
+
+/**
+ * <code>UpdateListener</code> implementation that invokes the <code>SourceCallback</code> facilitate the
+ * dispatch of events as they are read off the event stream.
+ */
+public class SourceCallbackUpdateListener implements UpdateListener {
+
+ protected transient Log logger = LogFactory.getLog(getClass());
+
+ SourceCallback sourceCallback;
+
+ public SourceCallbackUpdateListener(SourceCallback sourceCallback) {
+ this.sourceCallback = sourceCallback;
+ }
+
+ public void update(EventBean[] newEvents, EventBean[] oldEvents) {
+
+ for (EventBean event : newEvents) {
+ try {
+ sourceCallback.process(event);
+ } catch (Exception e) {
+ logger.error("Could not process event: " + event, e);
+ }
+ }
+
+ }
+}
5 src/test/java/org/mule/module/esper/DummyEvent.java
@@ -0,0 +1,5 @@
+package org.mule.module.esper;
+
+public class DummyEvent {
+
+}
51 src/test/java/org/mule/module/esper/EsperModuleTest.java
@@ -0,0 +1,51 @@
+/**
+ * Mule Development Kit
+ * Copyright 2010-2011 (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file was automatically generated by the Mule Development Kit
+ */
+package org.mule.module.esper;
+
+import org.mule.api.MuleMessage;
+import org.mule.module.client.MuleClient;
+import org.mule.tck.FunctionalTestCase;
+
+import org.junit.Test;
+
+public class EsperModuleTest extends FunctionalTestCase {
+ @Override
+ protected String getConfigResources() {
+ return "mule-config.xml";
+ }
+
+ @Test
+ public void testCanInsertAndListenForEvent() throws Exception {
+
+ MuleClient client = new MuleClient(muleContext);
+ DummyEvent dummyEvent = new DummyEvent();
+ client.dispatch("vm://in", dummyEvent, null);
+
+ MuleMessage response = client.request("vm://out", 15000);
+ assertNotNull(response);
+ assertEquals("The output payload does not match the input payload", dummyEvent, response.getPayload());
+
+ MuleMessage event = client.request("vm://events", 15000);
+ assertNotNull(event);
+ assertEquals(1L, event.getPayload());
+ }
+
+}
9 src/test/resources/esper-config.xml
@@ -0,0 +1,9 @@
+<esper-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.espertech.com/schema/esper"
+ xsi:schemaLocation="
+ http://www.espertech.com/schema/esper
+ http://www.espertech.com/schema/esper/esper-configuration-2.0.xsd">
+
+ <event-type name="TestEvent" class="org.mule.module.esper.DummyEvent"/>
+
+</esper-configuration>
16 src/test/resources/log4j.properties
@@ -0,0 +1,16 @@
+#Updated at Wed Oct 26 20:47:36 EDT 2011
+#Wed Oct 26 20:47:36 EDT 2011
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.R.File=application.log
+log4j.rootLogger=error, stdout
+log4j.appender.R.MaxFileSize=100KB
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.MaxBackupIndex=1
+log4j.logger.org.springframework=INFO
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.logger.org.mule=INFO
+log4j.logger.org.mule.module.esper=DEBUG
+log4j.logger.com.espertech.esper=INFO
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.R=org.apache.log4j.RollingFileAppender
48 src/test/resources/mule-config.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Mule Development Kit
+ Copyright 2010-2011 (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<mule xmlns="http://www.mulesoft.org/schema/mule/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:spring="http://www.springframework.org/schema/beans"
+ xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
+ xmlns:esper="http://www.mulesoft.org/schema/mule/esper"
+
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
+ http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd
+ http://www.mulesoft.org/schema/mule/esper http://www.mulesoft.org/schema/mule/esper/1.0/mule-esper.xsd">
+
+ <esper:config configuration="esper-config.xml"/>
+
+ <flow name="testFlow">
+ <vm:inbound-endpoint path="in"/>
+ <esper:send eventPayload-ref="#[payload:]"/>
+ <vm:outbound-endpoint path="out"/>
+ </flow>
+
+ <flow name="Event Listener Flow">
+ <esper:listen statement="select count(*) from TestEvent
+ .win:time_batch(5, 'FORCE_UPDATE, START_EAGER') having count(*) &gt; 0"/>
+ <esper:get-event-property key="count(*)"/>
+ <vm:outbound-endpoint path="events"/>
+ </flow>
+
+</mule>

0 comments on commit a6f37ca

Please sign in to comment.
Something went wrong with that request. Please try again.