Skip to content

Commit 0652f59

Browse files
authored
Referencing code as examples for using this extension (#28)
<!-- Please describe your pull request here. --> ## References - TODO <!-- References to relevant GitHub issues and pull requests, esp. upstream and downstream changes --> ## Submitter checklist - [ ] The PR request is well described and justified, including the body and the references - [ ] The PR title represents the desired changelog entry - [ ] The repository's code style is followed (see the contributing guide) - [ ] Test coverage that demonstrates that the change works as expected - [ ] For new features, there's necessary documentation in this pull request or in a subsequent PR to [wiremock.org](https://github.com/wiremock/wiremock.org) <!-- Put an `x` into the [ ] to show you have filled the information. The template comes from https://github.com/wiremock/.github/blob/main/.github/pull_request_template.md You can override it by creating .github/pull_request_template.md in your own repository -->
1 parent d6cd5cc commit 0652f59

9 files changed

+33
-415
lines changed

README.md

Lines changed: 3 additions & 398 deletions
Large diffs are not rendered by default.

src/test/java/org/wiremock/extensions/state/StateExtensionListExampleTest.java renamed to src/test/java/org/wiremock/extensions/state/examples/StateExtensionListExampleTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.examples;
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,6 +32,8 @@
3232
import org.junit.jupiter.api.TestInstance;
3333
import org.junit.jupiter.api.extension.RegisterExtension;
3434
import org.junit.jupiter.api.parallel.Execution;
35+
import org.wiremock.extensions.state.CaffeineStore;
36+
import org.wiremock.extensions.state.StateExtension;
3537

3638
import java.net.URI;
3739
import java.util.Map;
@@ -44,6 +46,9 @@
4446
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4547
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;
4648

49+
/**
50+
* Sample test for creating a mock for a queue with java.
51+
*/
4752
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4853
@Execution(SAME_THREAD)
4954
class StateExtensionListExampleTest {

src/test/java/org/wiremock/extensions/state/StateExtensionStateExampleTest.java renamed to src/test/java/org/wiremock/extensions/state/examples/StateExtensionStateExampleTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.examples;
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,6 +32,8 @@
3232
import org.junit.jupiter.api.TestInstance;
3333
import org.junit.jupiter.api.extension.RegisterExtension;
3434
import org.junit.jupiter.api.parallel.Execution;
35+
import org.wiremock.extensions.state.CaffeineStore;
36+
import org.wiremock.extensions.state.StateExtension;
3537

3638
import java.net.URI;
3739
import java.util.Map;
@@ -45,6 +47,9 @@
4547
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4648
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;
4749

50+
/**
51+
* Sample test for using this extension to record a state in java.
52+
*/
4853
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4954
@Execution(SAME_THREAD)
5055
class StateExtensionStateExampleTest {

src/test/java/org/wiremock/extensions/state/IntegrationTest.java renamed to src/test/java/org/wiremock/extensions/state/examples/StubMappingLoadingExampleTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.wiremock.extensions.state;
1+
package org.wiremock.extensions.state.examples;
22

33
import com.github.tomakehurst.wiremock.WireMockServer;
44
import com.github.tomakehurst.wiremock.client.WireMock;
@@ -15,9 +15,10 @@
1515
import org.junit.jupiter.api.Test;
1616
import org.junit.jupiter.api.TestInstance;
1717
import org.junit.jupiter.api.parallel.Execution;
18+
import org.wiremock.extensions.state.CaffeineStore;
19+
import org.wiremock.extensions.state.StateExtension;
1820
import org.wiremock.extensions.state.internal.ContextManager;
1921

20-
import java.io.File;
2122
import java.net.URI;
2223
import java.time.Duration;
2324
import java.util.Locale;
@@ -30,20 +31,20 @@
3031
import static org.hamcrest.Matchers.is;
3132
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;
3233

34+
/**
35+
* Sample test to demonstrate remote loading of stub mapping with this extension.
36+
*/
3337
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
3438
@Execution(SAME_THREAD)
35-
public class IntegrationTest {
36-
37-
static WireMockServer wireMockServer;
38-
static WireMock wmClient;
39-
static Stubbing wm;
39+
public class StubMappingLoadingExampleTest {
4040

41+
private static WireMockServer wireMockServer;
4142
private static final Store<String, Object> store = new CaffeineStore();
4243
static final ContextManager contextManager = new ContextManager(store);
4344

4445

4546
@BeforeAll
46-
public static void initWithTempDir() throws Exception {
47+
public static void initWithTempDir() {
4748
WireMockConfiguration options = wireMockConfig().withRootDirectory(Resources.getResource("remoteloader").getPath())
4849
.templatingEnabled(true).globalTemplating(true)
4950
.extensions(new StateExtension(store));
@@ -56,10 +57,10 @@ public static void initWithTempDir() throws Exception {
5657
wireMockServer = new WireMockServer(options);
5758
wireMockServer.start();
5859
WireMock.configureFor(wireMockServer.port());
59-
wm = wireMockServer;
60+
Stubbing wm = wireMockServer;
6061

6162
Locale.setDefault(Locale.ENGLISH);
62-
wmClient = WireMock.create().port(wireMockServer.port()).build();
63+
WireMock.create().port(wireMockServer.port()).build();
6364
}
6465

6566
@Test

src/test/java/org/wiremock/extensions/state/AbstractTestBase.java renamed to src/test/java/org/wiremock/extensions/state/functionality/AbstractTestBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.wiremock.extensions.state;
1+
package org.wiremock.extensions.state.functionality;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import com.github.tomakehurst.wiremock.common.ConsoleNotifier;
@@ -10,6 +10,8 @@
1010
import org.junit.jupiter.api.TestInstance;
1111
import org.junit.jupiter.api.extension.RegisterExtension;
1212
import org.junit.jupiter.api.parallel.Execution;
13+
import org.wiremock.extensions.state.CaffeineStore;
14+
import org.wiremock.extensions.state.StateExtension;
1315
import org.wiremock.extensions.state.internal.ContextManager;
1416

1517
import java.time.Duration;

src/test/java/org/wiremock/extensions/state/DeleteStateEventListenerTest.java renamed to src/test/java/org/wiremock/extensions/state/functionality/DeleteStateEventListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.functionality;
1717

1818
import com.github.tomakehurst.wiremock.client.WireMock;
1919
import com.github.tomakehurst.wiremock.extension.Parameters;

src/test/java/org/wiremock/extensions/state/RecordStateEventListenerTest.java renamed to src/test/java/org/wiremock/extensions/state/functionality/RecordStateEventListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.functionality;
1717

1818
import com.github.tomakehurst.wiremock.client.WireMock;
1919
import com.github.tomakehurst.wiremock.extension.Parameters;

src/test/java/org/wiremock/extensions/state/StateRequestMatcherTest.java renamed to src/test/java/org/wiremock/extensions/state/functionality/StateRequestMatcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.functionality;
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import com.github.tomakehurst.wiremock.client.WireMock;

src/test/java/org/wiremock/extensions/state/StateTemplateHelperProviderExtensionTest.java renamed to src/test/java/org/wiremock/extensions/state/functionality/StateTemplateHelperProviderExtensionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.wiremock.extensions.state;
16+
package org.wiremock.extensions.state.functionality;
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import com.github.tomakehurst.wiremock.client.WireMock;

0 commit comments

Comments
 (0)