com.github.fridujo:spring-automocker-starter-jms

Reactor for Spring-Automocker projects.

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

com.github.fridujo
ArtifactId

ArtifactId

spring-automocker-starter-jms
Last Version

Last Version

1.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Reactor for Spring-Automocker projects.

Download spring-automocker-starter-jms

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.fridujo/spring-automocker-starter-jms/ -->
<dependency>
    <groupId>com.github.fridujo</groupId>
    <artifactId>spring-automocker-starter-jms</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.fridujo/spring-automocker-starter-jms/
implementation 'com.github.fridujo:spring-automocker-starter-jms:1.2.1'
// https://jarcasting.com/artifacts/com.github.fridujo/spring-automocker-starter-jms/
implementation ("com.github.fridujo:spring-automocker-starter-jms:1.2.1")
'com.github.fridujo:spring-automocker-starter-jms:jar:1.2.1'
<dependency org="com.github.fridujo" name="spring-automocker-starter-jms" rev="1.2.1">
  <artifact name="spring-automocker-starter-jms" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.fridujo', module='spring-automocker-starter-jms', version='1.2.1')
)
libraryDependencies += "com.github.fridujo" % "spring-automocker-starter-jms" % "1.2.1"
[com.github.fridujo/spring-automocker-starter-jms "1.2.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.github.fridujo : spring-automocker-starter jar 1.2.1
com.mockrunner : mockrunner-jms jar 2.0.1

test (5)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.12.1
org.mockito : mockito-core jar 2.25.0
org.junit.jupiter : junit-jupiter-api jar 5.4.0
org.junit.jupiter : junit-jupiter-engine jar 5.4.0
org.junit.jupiter : junit-jupiter-params jar 5.4.0

Project Modules

There are no modules declared in this project.

Spring-Automocker

Build Status codecov Maven Central License

Automatic detection and mocking of Spring IO components.

Motivation

Writing integration tests for Spring application is often writing the same glue code over and over again. Spring-Automocker was created to avoid re-writing the same boilerplate code and focus on test added value.

Mocking strategies

Property sources

The extension @MockPropertySources adds a ProtocolResolver to Spring context resolving properties file as empty ones.

MVC controllers

The extension @MockWebMvc sets up a MockMvc. This MockMvc instance is either wired on :

  • the org.springframework.web.context.WebApplicationContext if the current context is of such type
  • the @Controller annotated beans otherwise
JDBC Data Sources

The extension @MockJdbc

  • modifies javax.sql.DataSource beans by making them point to a dedicated H2 in-memory database.
  • adds a DataSourceResetter to truncate all tables after each test
JMS Connection Factories

The extension @MockJms

  • replace all javax.jms.ConnectionFactory beans by mockrunner-jms MockConnectionFactory ones
  • for each javax.jms.ConnectionFactory beans adds a JmsMock with the same qualifiers for simplified JMS operations usage
  • adds a DestinationManagerResetter to remove messages from all queues after each test
  • if available, wraps the ErrorHandler of JmsListenerContainerFactory to access errors from matching JmsMock
Micrometer Graphite Meter Registry

The extension @MockMicrometerGraphite replaces the default GraphiteReporter by one baked by GraphiteMock which can be injected like any other bean.

RabbitMQ Connection Factories

The extension @MockAmqp replaces all org.springframework.amqp.rabbit.connection.ConnectionFactory beans by rabbitmq-mock ones.

Utilities

The extension @RegisterTools registers a BeanLocator to easily access beans by partial name.

Example Use

As Spring-Automocker uses spring-test org.springframework.test.context.ContextCustomizerFactory extension mechanism, it is compatible with Spring >= 4.3 (so spring-boot >= 1.4).

Using JUnit 4

Use SpringJUnit4ClassRunner in conjuction with @Automocker

@Automocker
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyApplication.class)
public class MyApplicationTest {

    @Autowired
    private MyService service;

	@Test
	public void my_test() {
		// test injected service
	}
}

Using JUnit 5

Use @ExtendWith(SpringExtension.class) in conjuction with @Automocker

@Automocker
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MyApplication.class)
public class MyApplicationTest {

    @Autowired
    private MyService service;

	@Test
	public void my_test() {
		// test injected service
	}
}

Getting Started

Maven

Add the following dependency to your pom.xml

<dependency>
    <groupId>com.github.fridujo</groupId>
    <artifactId>spring-automocker</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>

Gradle

Add the following dependency to your build.gradle

repositories {
	mavenCentral()
}

// ...

dependencies {
	// ...
	testCompile('com.github.fridujo:spring-automocker:1.1.0')
	// ...
}

Building from Source

You need JDK-8 to build Spring-Automocker. Core and samples can be built with Maven using the following command.

mvn clean package

All features can be tested through samples with Maven using the following command.

mvn clean test

Since Maven has incremental build support, you can usually omit executing the clean goal.

Installing in the Local Maven Repository

Core and samples can be installed in a local Maven Repository for usage in other projects via the following command.

mvn clean install
com.github.fridujo

Fridujo

It's Esperanto for freezer

Versions

Version
1.2.1
1.2.0