Skip to content

Instantly share code, notes, and snippets.

View chbaranowski's full-sized avatar

Christian Baranowski chbaranowski

View GitHub Profile
import javax.ws.rs.*;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.headers.RequireCapability;
@Component
@Path("/echo")
@Requieres.JAXRS_Whiteboard
public class SampleRessource {
@chbaranowski
chbaranowski / SampleRessource.java
Created February 22, 2015 16:59
RequireCapability in a REST SampleRessource
@Component
@Path("/echo")
@RequireCapability(
ns="osgi.whiteboard",
filter="(osgi.whiteboard=java.ee.jaxrs)",
effective="active"
)
public class SampleRessource {
@GET
@chbaranowski
chbaranowski / bnd.bnd
Created February 22, 2015 16:58
Provide-Capability and Require-Capability headers
# provider bundle
Provide-Capability: \
osgi.whiteboard;\
osgi.whiteboard="java.ee.jaxrs";\
version:Version="1.0.0"; \
effective:=active
# consumer bundle
Require-Capability:
osgi.whiteboard; \
package spock.console
import semester.*
import spock.lang.*
class SemsterSpec extends Specification {
SemestergebuehrService service = new SemestergebuehrService()
@Unroll
@chbaranowski
chbaranowski / SemsterSpec.groovy
Created November 27, 2014 15:41
SemsterSpec.groovy
import semester.*
import spock.lang.*
class SemsterSpec extends Specification {
def "berechne die Semestergebuehrn"() {
given:
SemestergebuehrService service = new SemestergebuehrService()
when:
def gebuehr = service.getSemestergebuehr(5, 2)
@chbaranowski
chbaranowski / QuicksortTest.java
Created October 16, 2014 20:22
Quicksort Test Example
import static org.fest.assertions.Assertions.*;
import java.util.Arrays;
import org.junit.Test;
public class QuicksortTest {
Quicksort<String> textSorter = Quicksort.createTextSorter();
Quicksort<Integer> intSorter = Quicksort.createIntSorter();
@chbaranowski
chbaranowski / StackSpec.groovy
Last active August 29, 2015 14:06
Spock Old Feature
import spock.lang.*
class StackSpec extends Specification {
@Subject stack = new Stack()
def "push a element into a stack"(element) {
when:
stack.push(element)
then:
import spock.lang.Specification;
class FixedSizeListSpec extends Specification {
def "T1 - clear a empty list"() {
given: "a empty list"
List list = list(maxsize: 2)
when: "clear the list"
list.clear()
then: "the list should be empty"
@chbaranowski
chbaranowski / HotReloadConfiguration.java
Last active August 29, 2015 14:02
HotReloadConfiguration Spring Boot
@Configuration
@Conditional(HotReloadConfiguration.HotReloadCondition.class)
public class HotReloadConfiguration {
public static class HotReloadCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
String hotReloadEnabledProperty = context.getEnvironment().getProperty("hotReload.enabled");
return StringUtils.equals(hotReloadEnabledProperty, "true");
}
import static org.junit.Assert.*;
import org.junit.*;
public class CalcTest {
Calc calc;
@Before
public void setup() {