Skip to content

Instantly share code, notes, and snippets.

View tkrueger's full-sized avatar

Thorsten Krüger tkrueger

View GitHub Profile
@tkrueger
tkrueger / ClockExample.java
Created October 10, 2013 09:35
Design for testability: example of using wrappers around static method calls
public class ClockExample {
public class Clock {
public long now() {
return System.currentTimeMillis();
}
}
public class TestClock extends Clock {
DateTime current = DateTime.now();
@tkrueger
tkrueger / pojo Configuration.java
Created September 28, 2013 12:43
Mocking static method calls with Powermock vs. simple POJOs
package de.tk.mocks.staticaccess.custommock;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Configuration {
private SystemPropertyAccessor systemProperties;
private Properties properties = new Properties();
@tkrueger
tkrueger / talks.md
Last active December 17, 2015 06:39
A collection of interesting talks and other resources.
@tkrueger
tkrueger / load-generator.js
Created August 28, 2012 16:57
generate and measure CPU load with node.js
#!/usr/bin/env node
require(__dirname+"/processor-usage.js").startWatching();
var shouldRun = true;
var desiredLoadFactor = .5;
function blockCpuFor(ms) {
var now = new Date().getTime();
var result = 0