Skip to content

Instantly share code, notes, and snippets.

package test;
public class HellowWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
@sebastianbenz
sebastianbenz / primefactors.clj
Created December 3, 2010 08:23
Prime-factors kata in Clojure.
(ns prime-factors
(:use clojure.test)
(:use clojure.contrib.generic.math-functions))
(defn prime-factors
[n]
(loop [remainder n
result '()
factor 2]
(cond
@sebastianbenz
sebastianbenz / Example.spec
Created February 7, 2012 22:05
Jnario Specs Overview
package introduction
import org.eclipse.xtext.xbase.lib.Procedures$Procedure1
import static de.bmw.carit.jnario.common.test.util.ResultMatchers.*
import static de.bmw.carit.jnario.tests.util.SpecExecutor.*
import static org.hamcrest.CoreMatchers.*
import static org.junit.Assert.*
import static extension de.bmw.carit.jnario.common.test.util.Helpers.*
@sebastianbenz
sebastianbenz / gist:2209317
Created March 26, 2012 20:10
A sample Stack test.
package demo;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({EmptyStack.class, StackWithOneElement.class})
public class StackTest {
}
@sebastianbenz
sebastianbenz / Json.xtend
Created May 29, 2012 07:17
Creating Json in Xtend.
package json
import org.eclipse.xtext.xbase.lib.Pair
import java.util.List
import com.google.common.collect.Maps
class Json {
def static void main(String[] args) {
val json = map(
@sebastianbenz
sebastianbenz / Mockito.spec
Created June 4, 2012 18:15
Using Mockito in Jnario
package demo
import static org.mockito.Mockito.*
import static org.mockito.MockitoAnnotations.*
import java.util.List
import org.mockito.Mock
import org.jnario.runner.CreateWith
describe "Mockito"{
@sebastianbenz
sebastianbenz / pom.xml
Created June 28, 2012 08:24
Installing Jnario Snapshots via Maven
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
@sebastianbenz
sebastianbenz / pom.xml
Created July 4, 2012 12:50
Compiling Jnario specs with Maven (SNAPSHOT).
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<repositories>
@sebastianbenz
sebastianbenz / SpringSupport.java
Created October 23, 2012 15:50
Using Spring with Jnario
package example;
import org.jnario.lib.AbstractSpecCreator;
import org.jnario.runner.SpecCreator;
import org.springframework.test.context.TestContextManager;
public class SpringSupport extends AbstractSpecCreator{
private TestContextManager testContextManager;
@sebastianbenz
sebastianbenz / Strings.java
Created December 2, 2012 21:24
Encoding Unicodes
public static String convertToJavaString(String theString, boolean useUnicode) {
int len = theString.length();
int bufLen = len * 2;
if (bufLen < 0) {
bufLen = Integer.MAX_VALUE;
}
StringBuffer outBuffer = new StringBuffer(bufLen);
for (int x = 0; x < len; x++) {
char aChar = theString.charAt(x);