Constretto :: Spring Integration - JUnit test helpers - 3.0.0-BETA1

Spring extensions for the Constretto configuration toolkit

License

License

ASF v2 License
GroupId

GroupId

org.constretto
ArtifactId

ArtifactId

constretto-spring-test
Last Version

Last Version

3.0.0-BETA1
Release Date

Release Date

Type

Type

jar
Description

Description

Constretto :: Spring Integration - JUnit test helpers - 3.0.0-BETA1
Spring extensions for the Constretto configuration toolkit
Project URL

Project URL

http://constretto.org/constretto-spring-test/

Download constretto-spring-test

How to add to project

<!-- https://jarcasting.com/artifacts/org.constretto/constretto-spring-test/ -->
<dependency>
    <groupId>org.constretto</groupId>
    <artifactId>constretto-spring-test</artifactId>
    <version>3.0.0-BETA1</version>
</dependency>
// https://jarcasting.com/artifacts/org.constretto/constretto-spring-test/
implementation 'org.constretto:constretto-spring-test:3.0.0-BETA1'
// https://jarcasting.com/artifacts/org.constretto/constretto-spring-test/
implementation ("org.constretto:constretto-spring-test:3.0.0-BETA1")
'org.constretto:constretto-spring-test:jar:3.0.0-BETA1'
<dependency org="org.constretto" name="constretto-spring-test" rev="3.0.0-BETA1">
  <artifact name="constretto-spring-test" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.constretto', module='constretto-spring-test', version='3.0.0-BETA1')
)
libraryDependencies += "org.constretto" % "constretto-spring-test" % "3.0.0-BETA1"
[org.constretto/constretto-spring-test "3.0.0-BETA1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.constretto : constretto-spring jar 3.0.0-BETA1
org.constretto : constretto-test jar 3.0.0-BETA1
junit : junit jar 4.12
org.springframework : spring-test jar 4.1.7.RELEASE

test (1)

Group / Artifact Type Version
org.slf4j : slf4j-simple jar 1.7.12

Project Modules

There are no modules declared in this project.

Constretto Spring Module

Support for using Constretto in Spring contexts. It includes namespace support for XML-based Spring contexts as well as a PropertyPlaceHolder implementation (allowing property placeholders refering to to Constretto configuration keys to be used in bean definitions).

** Note: This module used to be part of constretto-core but will starting with version 3 be maintained and versioned independently of constretto-core **

Build Status Coverage Status

Compatibility

The Spring module is tested with Spring 3.2.X and Java 7. Most features will probably work fine with Spring 4.X and/or Java 8, but 100% compatibility can not be guaranteed.

Adding dependency

Maven

   <dependency>
     <groupId>org.constretto</groupId>
     <artifactId>constretto-spring</artifactId>
     <version>3.0.0-BETA1</version>
   </dependency>

Spring XML Namespace support

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:constretto="http://constretto.org/schema/constretto"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://constretto.org/schema/constretto http://constretto.org/schema/constretto/constretto-1.2.xsd">

    <constretto:configuration annotation-config="true" property-placeholder="true">
        <constretto:stores>
            <constretto:properties-store>
                <constretto:resource location="classpath:properties/test1.properties"/>
            </constretto:properties-store>
        </constretto:stores>
    </constretto:configuration>
    
    <bean class="org.constretto.beans.ExampleBean">
        <property name="field" value="${constretto.key}" />
    </bean>
</beans>

Spring JavaConfig support

There are two ways to enable Constretto support for Java-based Spring contexts. The first method is to add the @EnableConstretto annotation and a static method returning a ConstrettoConfiguration configuration

using @EnableConstretto

    @EnableConstretto
    @org.springframework.context.annotation.Configuration
    public class TestContext  {
    
        @Configuration(required = true) // Will be injected by Constretto's Configuration processor
        private String key1;
    
        @Value("${key1}") // Will be injected by Constretto's Property placeholder processor
        private String key1AsValue;
    
        // a static method returning a ConstrettoConfiguration must be defined
        public static org.constretto.ConstrettoConfiguration constrettoConfiguration() {
            return new ConstrettoBuilder()
                    .createPropertiesStore()
                    .addResource(Resource.create("classpath:properties/test1.properties"))
                    .done()
                    .getConfiguration();
        }
    }

Extending BasicConstrettoConfiguration

The second method is to extend the BasicConstrettoConfiguration class and override the constrettoConfiguration() method

    @org.springframework.context.annotation.Configuration
    public class TestContext extends BasicConstrettoConfiguration {
    
        @Configuration(required = true) // Will be injected by Constretto's Configuration processor
        private String key1;
    
        @Value("${key1}") // Will be injected by Constretto's Property placeholder processor
        private String key1AsValue;
    
        @Override
        public org.constretto.ConstrettoConfiguration constrettoConfiguration() {
            return new ConstrettoBuilder()
                    .createPropertiesStore()
                    .addResource(Resource.create("classpath:properties/test1.properties"))
                    .done()
                    .getConfiguration();
        }
    }
org.constretto

Constretto

Versions

Version
3.0.0-BETA1