Added Spock maven plugin, tweaking Specs

This commit is contained in:
J. Brisbin
2010-11-23 11:32:07 -06:00
parent 59ac3c5d4b
commit 4e257ae1a3
7 changed files with 44 additions and 107 deletions

View File

@@ -1,5 +1,6 @@
<?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"
<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>org.springframework.data</groupId>
@@ -17,6 +18,7 @@
<org.codehaus.jackson.version>1.6.1</org.codehaus.jackson.version>
<org.mockito.version>1.8.4</org.mockito.version>
<org.slf4j.version>1.5.8</org.slf4j.version>
<org.spockframework.version>0.5-groovy-1.7-SNAPSHOT</org.spockframework.version>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
<!-- dist.* properties are used by the antrun tasks below -->
<dist.id>spring-datastore-keyvalue</dist.id>
@@ -100,15 +102,19 @@
<distributionManagement>
<site>
<id>spring-site-staging</id>
<url>file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/docs</url>
<url>file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/docs
</url>
</site>
<repository>
<id>spring-milestone-staging</id>
<url>file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/milestone</url>
<url>
file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/milestone
</url>
</repository>
<snapshotRepository>
<id>spring-snapshot-staging</id>
<url>file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/snapshot</url>
<url>file:///${java.io.tmpdir}/spring-data/datastore-keyvalue/snapshot
</url>
</snapshotRepository>
</distributionManagement>
</profile>
@@ -265,7 +271,13 @@
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-spring</artifactId>
<version>0.5-groovy-1.7-SNAPSHOT</version>
<version>${org.spockframework.version}</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
@@ -432,6 +444,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.spockframework</groupId>
<artifactId>spock-maven</artifactId>
<version>${org.spockframework.version}</version>
<executions>
<execution>
<goals>
<goal>find-specs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
@@ -447,6 +471,9 @@
<id>spockframework</id>
<name>Spock Framework</name>
<url>http://m2repo.spockframework.org/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<repositories>
@@ -476,6 +503,9 @@
<id>spockframework</id>
<name>Spock Framework</name>
<url>http://m2repo.spockframework.org/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

View File

@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<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>
<parent>
@@ -121,6 +122,10 @@
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
</plugin>
<plugin>
<groupId>org.spockframework</groupId>
<artifactId>spock-maven</artifactId>
</plugin>
</plugins>
</build>

View File

@@ -1,10 +0,0 @@
package org.springframework.datastore.riak.core;
/**
* @author J. Brisbin <jon@jbrisbin.com>
*/
public interface BucketSchema {
String getName();
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (c) 2010 by J. Brisbin <jon@jbrisbin.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.datastore.riak.core;
/**
* @author J. Brisbin <jon@jbrisbin.com>
*/
public class KeyValueStoreKey {
protected Object family;
protected Object key;
public KeyValueStoreKey() {
}
public KeyValueStoreKey(Object family, Object key) {
this.family = family;
this.key = key;
}
public Object getFamily() {
return family;
}
public void setFamily(Object family) {
this.family = family;
}
public Object getKey() {
return key;
}
public void setKey(Object key) {
this.key = key;
}
@Override
public String toString() {
if (null == family && null == key) {
return super.toString();
} else {
return (null != family ? family.toString() : "") + ":" + (null != key ? key.toString() : "");
}
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright (c) 2010 by J. Brisbin <jon@jbrisbin.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.datastore.riak.core;
import org.springframework.datastore.riak.DataStoreOperationException;
/**
* @author J. Brisbin <jon@jbrisbin.com>
*/
public interface RiakOperationCallback<OUT, IN> {
public OUT execute(IN in) throws DataStoreOperationException;
}

View File

@@ -691,7 +691,6 @@ public class RiakTemplate extends RestGatewaySupport implements KeyValueStoreOpe
}
}
/*----------------- Utilities -----------------*/
protected BucketKeyPair resolveBucketKeyPair(Object key, Object val) {

View File

@@ -160,18 +160,18 @@ class RiakTemplateSpec extends Specification {
given:
MapReduceJob job = riak.createMapReduceJob()
def mapJs = new JavascriptMapReduceOperation("function(m){ var o=Riak.mapValuesJson(m); return [1]; }")
def mapJs = new JavascriptMapReduceOperation("function(v){ var o=Riak.mapValuesJson(v); return [o[0].integer]; }")
def mapPhase = new RiakMapReducePhase("map", "javascript", mapJs)
def reduceJs = new JavascriptMapReduceOperation("function(r){ return r.length; }")
def reduceJs = new JavascriptMapReduceOperation("function(v){ return v.length; }")
def reducePhase = new RiakMapReducePhase("reduce", "javascript", reduceJs)
reducePhase.keepResults = true
job.addInputs(["test"]).
addPhase(mapPhase).
addPhase(reducePhase)
when:
println "M/R: ${job.toJson()}"
def result = riak.execute(job, Integer)
then: