Skip to content

Instantly share code, notes, and snippets.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class BookstoreWjugTest {
@Resource
private BookstoreSEI bookstore;
@Test
public void shouldReturnTrueForCxfBook() throws Exception {
Book book = new Book("Apache CXF Web Service Development", "Naveen Balani & Rajeev Hathi");
4 1
5 3
6 5
7 8
8 12
9 17
10 24
11 32
12 42
13 54
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import static java.lang.System.currentTimeMillis;
import static org.apache.commons.lang.time.DateUtils.MILLIS_PER_SECOND;
public class DelayQueueMain {
public static void main(String[] args) throws InterruptedException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("root");
rootElement.appendChild(doc.createTextNode("A\u0000B"));
doc.appendChild(rootElement);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
def message(date: DateTime) =
messages collectFirst {
case (pred, msg) if pred(date) => msg
}
(function () {
//From: http://yasintrm.blogspot.no/2012/05/how-to-install-syntax-highlighter-on.html
var arr, counter = 0,
doc = document,
len, load, callBack, url = 'http://agorbatchev.typepad.com/pub/sh/3_0_83/';
if (window.SyntaxHighlighter && !window.SyntaxHighlighterLoading) {
SyntaxHighlighter.highlight();
} else if (!window.SyntaxHighlighterLoading) {
window.SyntaxHighlighterLoading = true;
import java.util.HashSet;
import java.util.Set;
public class MagicalLand {
public static void main(String[] args) {
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
System.out.println("UNICORN #1: PAT THIS UNICORN ONCE");
}
}
def peak(list: List[Int]): Option[Int] =
list.sliding(3).collectFirst{case(List(x, y, z)) if(y > x && y > z) => y}
def raisePeak(list: List[Int]): Option[List[Int]] =
peak(list).map(p => List(p + 1))
import static org.mockito.Mockito.doAnswer;
//...
doAnswer(slowly()).when(timeConsumingExternalServiceMock).process();
//...
private static Answer<Object> slowly() {
return new Answer<Object>() {
scala> Stream.
iterate("*"){_ + "*"}.
take(5).
foreach(println)
*
**
***
****
*****