Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Galinski jangalinski

View GitHub Profile
View jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<!--
I have a ear deployment, I'm specifying only the module which is client of the EJB Remote module running in AS5.
My client class is itself an EJB 3.1 running in JBoss AS7. It is client of an EJB 2.0 running in JBoss AS5.
-->
<sub-deployment name="my-ejb-module-on-as7-${project.version}.jar">
<dependencies>
View MyBean.java
public MyBean {
private String value;
@PostConstruct
public void initValue() {
value = new PropertyReader("file").getValue("parameter");
}
}
View MyBean.java
public MyBean {
@Inject
@Named("myValue")
private String value;
@Produces
@Named("myValue")
private static String initValue() {
return new PropertyReader("file").getValue("parameter");
View NamedProviderTest.java
package sof14839561;
import static com.google.inject.Guice.createInjector;
import static com.google.inject.name.Names.named;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import javax.inject.Inject;
import javax.inject.Named;
@jangalinski
jangalinski / Coin.java
Created Mar 21, 2013
cannot decide what to do? Just Coin.flip() to get random 50/50 decisions.
View Coin.java
import java.util.Random;
public class Coin {
private static final Random random = new Random();
@Deprecated
private Coin() {
// never instantiate
}
View FieldThrowsException.java
public class FactoryThatThrowsException {
// a String creation Factory/Builder ...
public static String getString() throws Exception {
throw new Exception();
}
// normally would not compile
private final String aString = getString();
@jangalinski
jangalinski / ActivitiTestWatchman.java
Created Apr 10, 2013
suggestion on how to extend/fix the current ProcessEngineRule
View ActivitiTestWatchman.java
/**
* Rewrite of the ActivitiRule since TestWatchman is deprecated for junit>4.9.
*
* @author Jan Galinski, Holisticon AG (jan.galinski@holisticon.de)
*/
public class ActivitiTestWatcher extends TestWatcher implements ProcessEngineRule {
/**
* Default configuration file name when not used with needle.
*/
@jangalinski
jangalinski / BeanValidationRule.java
Created Apr 11, 2013
Useful little junit-4.11 classrule that allows to assertValid() directly without looking into the validation result set every time, but still can be used as a full blown JSR303 validator if needed.
View BeanValidationRule.java
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.collection.IsEmptyCollection.empty;
import static org.junit.Assert.assertThat;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
View BeanProvider.java
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.spi.Bean;
View CustomJobExecutorSpike.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import org.camunda.bpm.engine.ManagementService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.impl.ProcessEngineImpl;
import org.camunda.bpm.engine.impl.context.Context;
import org.camunda.bpm.engine.impl.interceptor.Command;
import org.camunda.bpm.engine.impl.interceptor.CommandContext;
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor;