Skip to content

Commit

Permalink
Using ConfigurationManager to set properties in test
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Oct 28, 2014
1 parent 845b0ff commit 0e243d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ apply from: file('gradle/release.gradle')
testCompile 'org.mockito:mockito-all:1.9.5'
}

test {
testLogging {
exceptionFormat = 'full'
}
}

run {
systemProperty 'eureka.validateInstanceId', 'false'
systemProperty 'eureka.serviceUrl.default', 'http://localhost:8080/eureka/v2/'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.netflix.prana.http.api;

import com.netflix.config.ConfigurationManager;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelOption;
import io.reactivex.netty.RxNetty;
Expand Down Expand Up @@ -40,7 +41,7 @@ public void tearDown() throws InterruptedException {

@Test
public void shouldReturnListOfProperties() {
System.setProperty("foo", "bar");
ConfigurationManager.getConfigInstance().setProperty("foo", "bar");
HttpClientRequest<ByteBuf> request = HttpClientRequest.<ByteBuf>createGet("/dynamicproperties?id=foo");
assertEquals("[\"bar\"]", Utils.getResponse(request, client));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.netflix.prana.http.api;

import com.netflix.config.ConfigurationManager;
import com.netflix.config.DynamicProperty;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelOption;
import io.netty.handler.codec.http.HttpResponseStatus;
Expand All @@ -11,10 +13,7 @@
import io.reactivex.netty.protocol.http.server.HttpServerRequest;
import io.reactivex.netty.protocol.http.server.HttpServerResponse;
import io.reactivex.netty.protocol.http.server.RequestHandler;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import rx.Observable;

public class HealthCheckHandlerTest {
Expand Down Expand Up @@ -55,14 +54,15 @@ public void tearDown() throws InterruptedException {

@Test
public void shouldPingExternalHostsForHealthCheck() {
System.setProperty("prana.host.healthcheck.url", "http://localhost:" + externalServerPort);
ConfigurationManager.getConfigInstance().setProperty("prana.host.healthcheck.url", "http://localhost:" + externalServerPort);
HttpClientRequest<ByteBuf> request = HttpClientRequest.<ByteBuf>createGet("/healthcheck");
Assert.assertEquals("<health>ok</health>", Utils.getResponse(request, client));
}

@Test
public void shouldReturnOkIfHealthCheckURLIsSetToNull() {
System.setProperty("prana.host.healthcheck.url", "");
ConfigurationManager.getConfigInstance().setProperty("prana.host.healthcheck.url", "");
HttpClientRequest<ByteBuf> request = HttpClientRequest.<ByteBuf>createGet("/healthcheck");
Assert.assertEquals("<health>ok</health>", Utils.getResponse(request, client));
}
Expand Down

0 comments on commit 0e243d2

Please sign in to comment.