Giter Club home page Giter Club logo

embedded-jms-junit's Introduction

embedded-jms-junit

Build Status Maven Central Apache V2 License Libraries.io for GitHub Coverage Status DepShield Badge

JUnit extension that provides a ActiveMQ Embedded in-memory JMS Broker. It should be compatible with all the usual JMS integration tools such as Apache Camel and Spring JMS Template. Inspired by the Embedded DB JUnit Rule project.

Why?

  • because you want to test your JMS integration code without being dependent on a running external JMS Broker
  • setting up the broker manually for all your tests requires a lot of boilerplate code
  • I found myself repeating myself and decided that creating this library would make my life easier :-)

Status

This library is distributed through the Sonatype OSS repo and should thus be widely available. Java 8 or higher is required. Feedback is more than welcome. Feel free to create issues if you find bugs or have feature requests for future releases :-)

Changelog

  • version 0.2: rewritten core and added support for JUnit 5 Jupiter
  • version 0.1: initial release

Usage

JUnit 5 (v. 0.2+)

More information on JMS support is found in the project WIKI

Add dependency

<dependency>
    <groupId>org.zapodot</groupId>
    <artifactId>embedded-jms-junit5</artifactId>
    <version>0.2</version>
    <scope>test</scope>
</dependency>

Use ExtendWith to enable the extension and inject the connection factory using @EmbeddedJms

@ExtendWith(EmbeddedJmsBroker.class)
class EmbeddedJmsBrokerRequestReplySpringTest {

    private static final String TEST_MESSAGE = "Test message";

    private static final String DESTINATION = "queue:destination";

    /**
    *  The type of property must be either ConnectionFactory, ActiveMQFactory or URI.
    *  If it is a URI to the broker is injected
    */
    @EmbeddedJms 
    private ConnectionFactory connectionFactory;

    @DisplayName("My test")
    @Test
    void testJmsLogic() throws Exception {
       // make JMS magic
    }
    
    @DisplayName("parameterized test")
    @Test
    void connectionFactoryParameter(@EmbeddedJms ConnectionFactory connectionFactory) {
        // perform JMS magic
    }

}

JUnit 4

Add dependency

<dependency>
    <groupId>org.zapodot</groupId>
    <artifactId>embedded-jms-junit</artifactId>
    <version>0.2</version>
    <scope>test</scope>
</dependency>

Add to JUnit4 test

    @Rule
    public EmbeddedJmsRule embeddedJmsRule = EmbeddedJmsRule.builder().build();

    @Test
    public void jmsTest() throws Exception {
        final ConnectionFactory connectionFactory = embeddedJmsRule.connectionFactory();
        
        // work your JMS magic

    }

For more examples check the JUnit tests in this project

embedded-jms-junit's People

Contributors

dependabot-preview[bot] avatar zapodot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sterlp

embedded-jms-junit's Issues

[DepShield] (CVSS 9.8) Vulnerability due to usage of com.fasterxml.jackson.core:jackson-databind:2.9.8

Vulnerabilities

DepShield reports that this application's usage of com.fasterxml.jackson.core:jackson-databind:2.9.8 results in the following vulnerability(s):


Occurrences

com.fasterxml.jackson.core:jackson-databind:2.9.8 is a transitive dependency introduced by the following direct dependency(s):

org.apache.activemq:activemq-broker:5.15.9
        └─ com.fasterxml.jackson.core:jackson-databind:2.9.8

org.apache.activemq:activemq-broker:5.15.9
        └─ com.fasterxml.jackson.core:jackson-databind:2.9.8

org.apache.activemq:activemq-broker:5.15.9
        └─ com.fasterxml.jackson.core:jackson-databind:2.9.8

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

Support for JUnit 5

Full support for JUnit 5 Juniper by porting the functionality to a new ActiveMQExtension

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.