Skip to content

Instantly share code, notes, and snippets.

@arey
arey / TestSpringDbSetup.java
Created September 6, 2013 06:14
Test case mixing both the DbSetup and the Spring frameworks
package com.javametmoi.test.dbsetup;
import static com.ninja_squad.dbsetup.Operations.insertInto;
import static com.ninja_squad.dbsetup.Operations.sequenceOf;
import static org.junit.Assert.assertEquals;
import java.sql.SQLException;
import javax.sql.DataSource;
@arey
arey / TransactionAwareDestination.java
Created September 5, 2013 17:05
A DbSetup destination which wraps a DataSource and gets its connection from a JDBC DataSource, adding awareness of Spring-managed transactions.
package com.javametmoi.test.dbsetup;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
@arey
arey / applicationContext-mockito.xml
Created August 26, 2013 13:55
Injecting Mockito mocks into a Spring bean Avoid NoSuchBeanDefinitionException
<bean id="myService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<bean class="org.mockito.Mockito" factory-method="mock">
<constructor-arg
value="com.javaetmoi.IService" />
</bean>
</property>
<property name="proxyInterfaces">
<value>com.javaetmoi.IService</value>
</property>
@arey
arey / pom-ear-jboss.xml
Created January 4, 2013 11:12
Configuration du plugin maven-ear-plugin générant e fichier jboss-app.xml avec isolation du classloader de l'EAR.
<!-- Generation du classPath dans le Manifest de l'EAR, paramétrage du classloader -->
<!-- et recopie centralisée des JARs des WARs dans le répertoire lib -->
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>5</version>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<applicationXml>${project.build.directory}/application.xml</applicationXml>
<archive>
<manifest>
@arey
arey / jboss-app.xml
Created January 4, 2013 11:07
Fichier META-INF\jboss-app.xml d'un EAR permettant d'isoler le classloader de JBoss.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app PUBLIC
"-//JBoss//DTD Java EE Application 5.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
<jboss-app>
<loader-repository>com.javaetmoi:archive=monapplication-ear
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>
@arey
arey / pom-maven-replace-arobase.xml
Created July 16, 2012 18:38
Configuration maven permettant d'utiliser des délimiteurs de filtre maven sur plusieurs caractères
<build>
<!-- Filtres les fichiers de ressources -->
<resources>
<resource>
<directory>target/generated-resources</directory>
<!-- Utilise les délimiteurs par défaut ${*} et @ -->
<filtering>true</filtering>
</resource>
</resources>
<filters>
@arey
arey / ViewStateExtractor.java
Created May 24, 2012 18:24
Extracteur JMeter d'identifiant du view state JSF à l’aide d'une regex
import java.util.HashSet;
import java.util.Set;
import org.apache.jmeter.extractor.RegexExtractor;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.testelement.TestElement;
import com.javaetmoi.tests.jmeter.TestElementProcessor;
import com.javaetmoi.tests.jmeter.TestElementTree;