Skip to content

Commit

Permalink
#108 created a TCK module so test dependencies chain together properly
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Nov 10, 2013
1 parent dee47e3 commit b617257
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class TapeModeSpec extends Specification {

where:
mode << [READ_ONLY, READ_SEQUENTIAL]
request = new BasicRequest("GET", endpoint.url)
}

void "in #mode mode a new interaction is recorded"() {
Expand Down
1 change: 1 addition & 0 deletions betamax-httpclient/betamax-httpclient.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
compile project(":betamax-core")

testCompile project(":betamax-junit")
testCompile project(":betamax-tck")
testCompile project(":betamax-test-support")
testCompile commonDependencies.httpBuilder

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
/*
* Copyright 2013 the original author or authors.
*
* 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 co.freeside.betamax.tape

import co.freeside.betamax.Configuration
import co.freeside.betamax.httpclient.BetamaxHttpClient
import co.freeside.betamax.junit.RecorderRule
import co.freeside.betamax.tck.MultiThreadedTapeWritingSpec
import org.apache.http.client.methods.HttpGet
import org.junit.Rule

Expand Down
1 change: 1 addition & 0 deletions betamax-proxy/betamax-proxy.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
compile commonDependencies.netty

testCompile project(":betamax-junit")
testCompile project(":betamax-tck")
testCompile project(":betamax-test-support")
testCompile("commons-httpclient:commons-httpclient:3.1") {
exclude module: "commons-codec"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.google.common.io.Files
import org.junit.ClassRule
import spock.lang.*
import static co.freeside.betamax.TapeMode.READ_WRITE
import static java.net.HttpURLConnection.HTTP_OK
import static com.google.common.net.HttpHeaders.VIA
import static java.net.HttpURLConnection.HTTP_OK

@Betamax(mode = READ_WRITE)
@Unroll
Expand All @@ -35,7 +35,7 @@ class RequestMethodsSpec extends Specification {
@Shared def configuration = ProxyConfiguration.builder().tapeRoot(tapeRoot).build()
@Shared @ClassRule RecorderRule recorder = new RecorderRule(configuration)

@Shared @AutoCleanup("stop") def endpoint = new SimpleServer(EchoHandler)
@Shared @AutoCleanup("stop") def endpoint = new SimpleServer(OkHandler)

void setupSpec() {
endpoint.start()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
/*
* Copyright 2013 the original author or authors.
*
* 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 co.freeside.betamax.tape

import co.freeside.betamax.ProxyConfiguration
import co.freeside.betamax.junit.RecorderRule
import co.freeside.betamax.tck.MultiThreadedTapeWritingSpec
import org.junit.Rule

class ProxyMultiThreadedTapeWritingSpec extends MultiThreadedTapeWritingSpec {
Expand Down
11 changes: 11 additions & 0 deletions betamax-tck/betamax-tck.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply from: "$rootDir/gradle/groovyModule.gradle"

repositories {
mavenRepo url: "http://repository.codehaus.org"
}

dependencies {
compile project(":betamax-core")
compile project(":betamax-test-support")
compile commonDependencies.spock
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package co.freeside.betamax.tape
package co.freeside.betamax.tck

import java.util.concurrent.CountDownLatch
import co.freeside.betamax.junit.Betamax
Expand Down
1 change: 1 addition & 0 deletions betamax-test-support/betamax-test-support.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ repositories {

dependencies {
compile project(":betamax-core")
compile project(":betamax-junit")
compile commonDependencies.netty
compile commonDependencies.httpBuilder
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@ class EchoHandler extends ExceptionHandlingHandlerAdapter {
@Override
void channelRead(ChannelHandlerContext ctx, Object msg) {
def request = msg as FullHttpRequest
def response = new DefaultFullHttpResponse(
HTTP_1_1,
OK,
request.content()
)
def response = new DefaultFullHttpResponse(HTTP_1_1, OK)

writeLine response, "$request.method ${relativeURI(request)} $request.protocolVersion"
request.headers().entries().each {
writeLine response, "$it.key: $it.value"
}
if (request.content().readableBytes() > 0) {
writeLine response, ""
response.content().writeBytes(request.content())
}
writeLine response, ""
response.content().writeBytes(request.content())

response.headers().set(CONTENT_TYPE, PLAIN_TEXT_UTF_8.toString())
ctx.writeAndFlush(response).addListener(CLOSE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2013 the original author or authors.
*
* 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 co.freeside.betamax.util.server

import co.freeside.betamax.util.server.internal.ExceptionHandlingHandlerAdapter
import io.netty.channel.*
import io.netty.handler.codec.http.DefaultFullHttpResponse
import static io.netty.channel.ChannelFutureListener.CLOSE
import static io.netty.handler.codec.http.HttpResponseStatus.OK
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1

@ChannelHandler.Sharable
class OkHandler extends ExceptionHandlingHandlerAdapter {

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
def response = new DefaultFullHttpResponse(HTTP_1_1, OK)
ctx.writeAndFlush(response).addListener(CLOSE)
}

}
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ include "betamax-core",
"betamax-httpclient",
"betamax-proxy",
"betamax-manual",
"betamax-test-support"
"betamax-test-support",
"betamax-tck"

rootProject.name = "betamax"

Expand Down

0 comments on commit b617257

Please sign in to comment.