diff --git a/unleash-client-java/src/main/no/finn/unleash/repository/HTTPToggleRepository.java b/unleash-client-java/src/main/no/finn/unleash/repository/HTTPToggleRepository.java index 3273898274..e42a27710d 100644 --- a/unleash-client-java/src/main/no/finn/unleash/repository/HTTPToggleRepository.java +++ b/unleash-client-java/src/main/no/finn/unleash/repository/HTTPToggleRepository.java @@ -11,6 +11,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +//TODO: take advantage of Etag and 304 responses. public class HTTPToggleRepository implements ToggleRepository { private static final Log LOG = LogFactory.getLog(HTTPToggleRepository.class); diff --git a/unleash-client-java/src/test/no/finn/unleash/ManualTesting.java b/unleash-client-java/src/test/no/finn/unleash/ManualTesting.java new file mode 100644 index 0000000000..6ccd96d756 --- /dev/null +++ b/unleash-client-java/src/test/no/finn/unleash/ManualTesting.java @@ -0,0 +1,52 @@ +package no.finn.unleash; + +import java.util.Random; +import no.finn.unleash.repository.HTTPToggleRepository; +import no.finn.unleash.repository.PollingToggleRepository; +import no.finn.unleash.repository.ToggleRepository; + +public class ManualTesting { + public static void main(String[] args) throws Exception { + HTTPToggleRepository httpRepo = new HTTPToggleRepository("http://localhost:4242/features"); + ToggleRepository repository = new PollingToggleRepository(httpRepo, 1); + + + Unleash unleash = new Unleash(repository); + + for(int i=0;i<100;i++) { + (new Thread(new UnleashThread(unleash, "thread-"+i, 100))).start(); + } + } + + static class UnleashThread implements Runnable { + + final Unleash unleash; + final String name; + final int maxRounds; + int currentRound = 0; + + UnleashThread(Unleash unleash, String name, int maxRounds) { + this.unleash = unleash; + this.name = name; + this.maxRounds = maxRounds; + } + + public void run() { + while(currentRound < maxRounds) { + currentRound++; + long startTime = System.nanoTime(); + boolean enabled = unleash.isEnabled("featureX"); + long timeUsed = System.nanoTime() - startTime; + + System.out.println(name + "\t" +"featureX" +":" + enabled + "\t " + timeUsed + "ns"); + + try { + //Wait 1 to 10ms before next round + Thread.sleep(new Random().nextInt(10000)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } +} diff --git a/unleash-client-java/src/test/resources/features.json b/unleash-client-java/src/test/resources/features.json index 2f4ff05d65..17a4fe3413 100644 --- a/unleash-client-java/src/test/resources/features.json +++ b/unleash-client-java/src/test/resources/features.json @@ -1 +1,23 @@ -{"features":[{"name":"featureX","status":"on","strategy":"default"},{"name":"featureY","status":"off","strategy":"baz","parameters":{"foo":"bar"}},{"name":"featureZ","status":"on","strategy":"baz","parameters":{"foo":"rab"}}]} \ No newline at end of file +{"features": [ + { + "name": "featureX", + "enabled": true, + "strategy": "default" + }, + { + "name": "featureY", + "enabled": false, + "strategy": "baz", + "parameters": { + "foo": "bar" + } + }, + { + "name": "featureZ", + "enabled": true, + "strategy": "baz", + "parameters": { + "foo": "rab" + } + } +]} \ No newline at end of file