-
Notifications
You must be signed in to change notification settings - Fork 0
DVC-6643 - Update variable() to use new WASM variableForUser function #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d473668
Adding data fixtures matching the other server SDKs
6cda04d
simple server for unit tests to validate client
4464f9c
changing the unit test to use the new config server and data fixtures
21bdc43
fixing some logic and adding new WASM variable function
bf48e11
tweaked how fixtures work
bd10a8c
fixed missing test annotation and optimized imports
580f365
adding more unit tests, bug fixes and code cleanup
5136851
review feedback
75f0180
update test to actually create a new client properly
5982645
Making LocalBucketing an instance member not static
33e482d
comments and formatting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
42 changes: 42 additions & 0 deletions
42
src/test/java/com/devcycle/sdk/server/helpers/LocalConfigServer.java
This file contains hidden or 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,42 @@ | ||
| package com.devcycle.sdk.server.helpers; | ||
|
|
||
| import com.sun.net.httpserver.HttpExchange; | ||
| import com.sun.net.httpserver.HttpServer; | ||
|
|
||
| import java.io.*; | ||
| import java.net.InetSocketAddress; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| public class LocalConfigServer { | ||
| private HttpServer server; | ||
| private String configData = ""; | ||
| public LocalConfigServer(String configData) throws IOException{ | ||
| this.configData = configData; | ||
| InetSocketAddress address = new InetSocketAddress(8000); | ||
| server = HttpServer.create(address, 0); | ||
| server.createContext("/", this::handleConfigRequest); | ||
| server.setExecutor(null); // use the default executor | ||
| System.out.println("Starting config server on " + address); | ||
| } | ||
|
|
||
| public void handleConfigRequest(HttpExchange exchange) throws IOException { | ||
| byte[] responseData = configData.getBytes(StandardCharsets.UTF_8); | ||
| exchange.sendResponseHeaders(200, responseData.length); | ||
| OutputStream outputStream = exchange.getResponseBody(); | ||
| outputStream.write(responseData); | ||
| outputStream.flush(); | ||
| outputStream.close(); | ||
| } | ||
|
|
||
| public void setConfigData(String configData) { | ||
| this.configData = configData; | ||
| } | ||
|
|
||
| public void start() { | ||
| this.server.start(); | ||
| } | ||
|
|
||
| public void stop() { | ||
| this.server.stop(0); | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/test/java/com/devcycle/sdk/server/helpers/TestDataFixtures.java
This file contains hidden or 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,43 @@ | ||
| package com.devcycle.sdk.server.helpers; | ||
| import java.io.BufferedReader; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.InputStreamReader; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| public class TestDataFixtures { | ||
| /** | ||
| * Loads the config data from the file in the resources folder | ||
| * @param fileName name of the file to load | ||
| * @return the String contents of that resource file | ||
| */ | ||
| private static String loadConfigData(String fileName) { | ||
| String configData = ""; | ||
| ClassLoader classLoader = TestDataFixtures.class.getClassLoader(); | ||
| try (InputStream inputStream = classLoader.getResourceAsStream(fileName); | ||
| InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); | ||
| BufferedReader reader = new BufferedReader(streamReader)) { | ||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| configData += line; | ||
| } | ||
| } catch (IOException e) { | ||
| System.out.println("Failed to load config data ["+fileName+"]: " + e.getMessage()); | ||
| e.printStackTrace(); | ||
| } | ||
| return configData; | ||
| } | ||
|
|
||
|
|
||
| public static String SmallConfig() { | ||
| return loadConfigData("fixture_small_config.json"); | ||
| } | ||
|
|
||
| public static String LargeConfig() { | ||
| return loadConfigData("fixture_large_config.json"); | ||
| } | ||
|
|
||
| public static String SmallConfigWithSpecialCharacters() { | ||
| return loadConfigData("fixture_small_config_special_characters.json"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.