forked from roastedroot/proxy-wasm-java-host
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostponeRequestsTest.java
More file actions
40 lines (30 loc) · 1.3 KB
/
PostponeRequestsTest.java
File metadata and controls
40 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package io.roastedroot.proxywasm;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.dylibso.chicory.wasm.Parser;
import java.nio.file.Path;
import org.junit.jupiter.api.Test;
/**
* Java port of https://github.com/proxy-wasm/proxy-wasm-go-sdk/blob/master/examples/postpone_requests/main_test.go
*/
public class PostponeRequestsTest {
@Test
public void testSetEffectiveContext() throws StartException {
var handler = new MockHandler();
// Load the WASM module
var module = Parser.parse(Path.of("./src/test/go-examples/postpone_requests/main.wasm"));
// Create and configure the ProxyWasm instance
try (var host = ProxyWasm.builder().withPluginHandler(handler).build(module)) {
// Initialize context
try (var context = host.createHttpContext(handler)) {
// Call OnHttpRequestHeaders
Action action = context.callOnRequestHeaders(false);
assertEquals(
Action.PAUSE, action, "Expected PAUSE action for OnHttpRequestHeaders");
// Call OnTick
host.tick();
action = handler.getAction();
assertEquals(Action.CONTINUE, action, "Expected CONTINUE action after OnTick");
}
}
}
}