Skip to content

Instantly share code, notes, and snippets.

View vyo's full-sized avatar
💜
Pony/JS/Lua

Manu Weidmann vyo

💜
Pony/JS/Lua
View GitHub Profile
@Mock
private EchoService echoService;
// ...
initMocks(this);
when(echoService.reverse(eq("input"))).thenReturn("tupni");
private EchoController echoController;
// ...
@Before
public void setup() {
initMocks(this);
when(echoService.reverse(eq("input"))).thenReturn("tupni");
echoController = new EchoController(echoService);
}
@Override
protected Application configure() {
setup();
ResourceConfig resourceConfig = new ResourceConfig(EchoController.class);
resourceConfig.register(new AbstractBinder() {
protected void configure() {
bind(echoController).to(EchoController.class);
}
});
@GET
public Echo userEcho(@User EchoUser user) {
// ...
return echo;
}
@Mock
EchoUserProvider echoUserProviderMock;
@Override
protected Application configure() {
setup();
ResourceConfig resourceConfig = new ResourceConfig(
EchoController.class,
EchoUserProvider.class);
public class EchoControllerTest extends ControllerTest<EchoController> {
private EchoService echoService;
@Before
public void setup() {
echoService = (EchoService) getField(EchoService.class);
when(echoService.reverse(eq("input"))).thenReturn("tupni");
}
@Test
public abstract class ControllerTest<T> extends JerseyTest {
private Class<T> controllerClass;
private T controller;
private Map<String, Object> args;
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
public class Util {
/**
* Creates a custom ResourceConfig for use in Jersey Tests.
*
* Registers all resource/class definitions to be used in this test configuration.
*
* Optionally binds specifically configured instances to those definitions, e.g. mocks.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sevenp.blog</groupId>
<artifactId>automagic</artifactId>
<version>0.1.0</version>
<dependencies>
@vyo
vyo / codename_watsonkitty.swift
Last active July 10, 2017 06:42
Raw, Unsafe, Pointy: CapnSwifty Babysteps
// watsonkitty playground
import Cocoa
protocol CapnSwiftyReader {
}
protocol CapnSwiftyBuilder {