forked from cityindex-attic/JsTestDriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates a ProxyConfigurationFilter hook and cleans up the related Guice
bindings. git-svn-id: http://js-test-driver.googlecode.com/svn/trunk@887 205c1ca0-44cf-11de-84a6-839b6ed6c72e
- Loading branch information
robertsdionne
committed
Feb 16, 2011
1 parent
a2a7d05
commit e32227e
Showing
5 changed files
with
69 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
JsTestDriver/src/com/google/jstestdriver/hooks/ProxyConfigurationFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2011 Google Inc. All Rights Reserved. | ||
package com.google.jstestdriver.hooks; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.inject.ImplementedBy; | ||
import com.google.jstestdriver.requesthandlers.DefaultProxyConfigurationFilter; | ||
|
||
/** | ||
* @author [email protected] (Robert Dionne) | ||
*/ | ||
@ImplementedBy(DefaultProxyConfigurationFilter.class) | ||
public interface ProxyConfigurationFilter { | ||
|
||
JsonArray filter(JsonArray proxyConfig); | ||
} |
38 changes: 38 additions & 0 deletions
38
...stDriver/src/com/google/jstestdriver/requesthandlers/DefaultProxyConfigurationFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2011 Google Inc. All Rights Reserved. | ||
package com.google.jstestdriver.requesthandlers; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.inject.Inject; | ||
import com.google.jstestdriver.hooks.ProxyConfigurationFilter; | ||
import com.google.jstestdriver.hooks.ProxyDestination; | ||
|
||
/** | ||
* @author [email protected] (Robert Dionne) | ||
*/ | ||
public class DefaultProxyConfigurationFilter implements ProxyConfigurationFilter { | ||
|
||
@Inject(optional=true) private ProxyDestination destination; | ||
|
||
public JsonArray filter(JsonArray proxyConfig) { | ||
if (destination == null) { | ||
return proxyConfig; | ||
} else { | ||
JsonObject entry = new JsonObject(); | ||
entry.addProperty("matcher", "*"); | ||
entry.addProperty("server", destination.getDestinationAddress()); | ||
proxyConfig = copy(proxyConfig); | ||
proxyConfig.add(entry); | ||
return proxyConfig; | ||
} | ||
} | ||
|
||
private JsonArray copy(JsonArray original) { | ||
JsonArray copy = new JsonArray(); | ||
for (JsonElement element : original) { | ||
copy.add(element); | ||
} | ||
return copy; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
JsTestDriver/src/com/google/jstestdriver/requesthandlers/ProxyMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2011 Google Inc. All Rights Reserved. | ||
package com.google.jstestdriver.requesthandlers; | ||
|
||
/** | ||
* @author [email protected] (Robert Dionne) | ||
*/ | ||
public class ProxyMapping { | ||
public String matcher; | ||
public String server; | ||
} |