Skip to content

Instantly share code, notes, and snippets.

Avatar

stephan-mueller

  • adesso SE
  • Paderborn / Metropole Ruhr, Germany
View GitHub Profile
@stephan-mueller
stephan-mueller / persistence.xml
Last active Jul 21, 2016
persistence.xml with ExampleDS
View persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence">
<persistence-unit name="default" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
@stephan-mueller
stephan-mueller / JUnitAssertionTest.java
Last active Oct 26, 2015
JUnit test to demonstrate AssertJ assertions.
View JUnitAssertionTest.java
@Test
public void assertjAssertion() throws Exception {
String openKnowledge = "offen, kundig, gut!";
Assertions.assertThat(openKnowledge).startsWith("offen").contains("kundig").endsWith("gut!");
}
@stephan-mueller
stephan-mueller / JUnitAssertionTest.java
Last active Oct 26, 2015
JUnit test to demonstrate hamcrest assertions.
View JUnitAssertionTest.java
@Test
public void hamcrestAssertion() throws Exception {
String openKnowledge = "offen, kundig, gut!";
MatcherAssert.assertThat(openKnowledge, CoreMatchers.allOf(CoreMatchers.startsWith("offen"),
CoreMatchers.containsString("kundig"),
CoreMatchers.endsWith("gut!")));
}
@stephan-mueller
stephan-mueller / JUnitAssertionTest.java
Last active Oct 26, 2015
JUnit test to demonstrate junit assertions.
View JUnitAssertionTest.java
@Test
public void junitAssertion() throws Exception {
String openKnowledge = "offen, kundig, gut!";
Assert.assertTrue(openKnowledge.startsWith("offen"));
Assert.assertTrue(openKnowledge.contains("kundig"));
Assert.assertTrue(openKnowledge.endsWith("gut!"));
}
@stephan-mueller
stephan-mueller / TimeoutTest.java
Created Sep 29, 2015
JUnit test to demonstrate the usage of the timeout parameter and the timeout rule
View TimeoutTest.java
public class TimeoutTest {
@Rule
public Timeout rule = new Timeout(7, TimeUnit.MILLISECONDS);
@Test(timeout = 5)
public void shouldFailWithTimeout() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
assertThat(latch.await(10, TimeUnit.MILLISECONDS)).isTrue();
}
@stephan-mueller
stephan-mueller / CustomerBuilderAssertjTest.java
Created Sep 29, 2015
Test class for the builder {@link CustomerBuilder} with AssertJ assertions
View CustomerBuilderAssertjTest.java
public class CustomerBuilderAssertjTest {
private Customer customer;
@Before
public void setUp() throws Exception {
customer = Customer.newBuilder()
.setFirstName("Max")
.setLastName("Mustermann")
.setEmail("max.mustermann@openknowledge.de")
@stephan-mueller
stephan-mueller / CustomerBuilderHamcrestTest.java
Created Sep 29, 2015
Test class for the builder {@link CustomerBuilder} with Hamcrest assertions
View CustomerBuilderHamcrestTest.java
public class CustomerBuilderHamcrestTest {
private Customer customer;
@Before
public void setUp() throws Exception {
customer = Customer.newBuilder()
.setFirstName("Max")
.setLastName("Mustermann")
.setEmail("max.mustermann@openknowledge.de")
@stephan-mueller
stephan-mueller / Customer.java
Created Sep 29, 2015
An entity that represents a customer
View Customer.java
public class Customer implements Serializable {
private Long id;
private String firstName;
private String lastName;
private String email;
@stephan-mueller
stephan-mueller / SpecializedMailServiceIT.java
Created Sep 28, 2015
Arquillian test for the cdi service specializes {@link SpecializedMailService}.
View SpecializedMailServiceIT.java
@RunWith(Arquillian.class)
public class SpecializedMailServiceIT {
private static final Logger LOG = LoggerFactory.getLogger(SpecializedMailServiceIT.class);
@Deployment
public static Archive createDeployment() {
PomEquippedResolveStage pomFile = Maven.resolver().loadPomFromFile("pom.xml");
WebArchive archive = ShrinkWrap.create(WebArchive.class)
@stephan-mueller
stephan-mueller / SpecializedMailService.java
Created Sep 28, 2015
Specialized implementation for the service {@link MailService}.
View SpecializedMailService.java
@Specializes
public class SpecializedMailService extends MailService {
public static CountDownLatch latch;
@Override
public void sendMail(final String subject, final String body, final String... recipients) {
latch.countDown();
}
}