Skip to content

Commit

Permalink
Merge pull request #125 from allenxwang/2.x-ssl
Browse files Browse the repository at this point in the history
Dependency changes.
  • Loading branch information
allenxwang committed Jul 9, 2014
2 parents 6e5171a + 5f0c003 commit 6492d70
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ subprojects {
compile 'com.google.guava:guava:14.0.1'
compile 'com.netflix.archaius:archaius-core:0.5.12'
compile 'com.netflix.netflix-commons:netflix-commons-util:0.1.1'
compile 'commons-collections:commons-collections:3.2.1'
testCompile 'org.powermock:powermock-easymock-release-full:1.4.10'
testCompile 'org.easymock:easymock:3.1'
testCompile 'org.slf4j:slf4j-log4j12:1.7.2'
Expand All @@ -55,6 +54,7 @@ project(':ribbon-httpclient') {
dependencies {
compile project(':ribbon-core')
compile project(':ribbon-loadbalancer')
compile 'commons-collections:commons-collections:3.2.1'
compile 'org.apache.httpcomponents:httpclient:4.2.1'
compile 'com.sun.jersey:jersey-client:1.11'
compile 'com.sun.jersey:jersey-core:1.11'
Expand All @@ -71,9 +71,9 @@ project(':ribbon-transport') {
dependencies {
compile project(':ribbon-core')
compile project(':ribbon-loadbalancer')
compile 'com.netflix.rxnetty:rx-netty:0.3.8'
compile 'com.netflix.rxnetty:rx-netty-contexts:0.3.8'
compile 'com.netflix.rxnetty:rx-netty-servo:0.3.8'
compile 'com.netflix.rxnetty:rx-netty:0.3.9'
compile 'com.netflix.rxnetty:rx-netty-contexts:0.3.9'
compile 'com.netflix.rxnetty:rx-netty-servo:0.3.9'
testCompile 'com.google.mockwebserver:mockwebserver:20130706'
testCompile project(':ribbon-test')
}
Expand All @@ -84,7 +84,7 @@ project(':ribbon-eureka') {
dependencies {
compile project(':ribbon-core')
compile project(':ribbon-loadbalancer')
compile 'com.netflix.eureka:eureka-client:1.1.126'
compile 'com.netflix.eureka:eureka-client:1.1.136'
}
}

Expand Down
3 changes: 3 additions & 0 deletions ribbon/src/main/java/com/netflix/ribbon/http/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public final String getKey() {
this.cacheProvider = null;
}
this.template = requestBuilder.template();
if (!ByteBuf.class.isAssignableFrom(template.getClassType())) {
throw new IllegalArgumentException("Return type other than ByteBuf is not currently supported as serialization functionality is still work in progress");
}
}

RibbonHystrixObservableCommand<T> createHystrixCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

import static org.junit.Assert.assertEquals;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.reactivex.netty.protocol.http.client.HttpClientRequest;
import io.reactivex.netty.protocol.http.client.HttpRequestHeaders;

import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;

Expand All @@ -39,18 +41,18 @@

public class TemplateBuilderTest {

private static class FakeCacheProvider implements CacheProvider<String> {
private static class FakeCacheProvider implements CacheProvider<ByteBuf> {
String id;

FakeCacheProvider(String id) {
this.id = id;
}

@Override
public Observable<String> get(final String key,
public Observable<ByteBuf> get(final String key,
Map<String, Object> requestProperties) {
if (key.equals(id)) {
return Observable.just(id);
return Observable.just(Unpooled.buffer().writeBytes(id.getBytes(Charset.defaultCharset())));

} else {
return Observable.error(new IllegalArgumentException());
Expand All @@ -77,14 +79,14 @@ public void testVarReplacement() {
public void testCacheKeyTemplates() {
HttpResourceGroup group = Ribbon.createHttpResourceGroup("test");

HttpRequestTemplate<String> template = group.newRequestTemplate("testCacheKeyTemplates", String.class);
HttpRequestTemplate<ByteBuf> template = group.newRequestTemplate("testCacheKeyTemplates", ByteBuf.class);
template.withUriTemplate("/foo/{id}")
.withMethod("GET")
.withCacheProvider("/cache/{id}", new FakeCacheProvider("/cache/5"));

RibbonRequest<String> request = template.requestBuilder().withRequestProperty("id", 5).build();
String result = request.execute();
assertEquals("/cache/5", result);
RibbonRequest<ByteBuf> request = template.requestBuilder().withRequestProperty("id", 5).build();
ByteBuf result = request.execute();
assertEquals("/cache/5", result.toString(Charset.defaultCharset()));
}

@Test
Expand Down Expand Up @@ -118,12 +120,12 @@ public void testHystrixProperties() {
.withMaxTotalConnections(400)
.withReadTimeout(2000);
HttpResourceGroup group = Ribbon.createHttpResourceGroup("test", clientOptions);
HttpRequestTemplate<String> template = group.newRequestTemplate("testHystrixProperties", String.class);
HttpRequest<String> request = (HttpRequest<String>) template.withMethod("GET")
HttpRequestTemplate<ByteBuf> template = group.newRequestTemplate("testHystrixProperties", ByteBuf.class);
HttpRequest<ByteBuf> request = (HttpRequest<ByteBuf>) template.withMethod("GET")
.withMethod("GET")
.withUriTemplate("/foo/bar")
.requestBuilder().build();
HystrixObservableCommand<String> command = request.createHystrixCommand();
HystrixObservableCommand<ByteBuf> command = request.createHystrixCommand();
HystrixCommandProperties props = command.getProperties();
assertEquals(400, props.executionIsolationSemaphoreMaxConcurrentRequests().get().intValue());
assertEquals(12000, props.executionIsolationThreadTimeoutInMilliseconds().get().intValue());
Expand Down

0 comments on commit 6492d70

Please sign in to comment.