Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<surefire-plugin.version>3.5.2</surefire-plugin.version>
<failsafe-plugin.version>${surefire-plugin.version}</failsafe-plugin.version>
<jandex.version>3.2.7</jandex.version>
<javadoc-plugin.version>3.11.2</javadoc-plugin.version>
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
<dependency-plugin.version>3.8.1</dependency-plugin.version>

<!-- test time versions -->
Expand Down Expand Up @@ -211,6 +211,28 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<doclint>all</doclint>
<source>11</source>
<release>${maven.compiler.release}</release>
<sourceFileExcludes>
<sourceFileExclude>**/internal/**</sourceFileExclude>
</sourceFileExcludes>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</pluginManagement>
Expand Down
5 changes: 1 addition & 4 deletions proxy-wasm-java-host/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc-plugin.version}</version>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<sourceFileExcludes>
<sourceFileExclude>**/internal/**</sourceFileExclude>
</sourceFileExcludes>
<links>
<link>https://www.javadoc.io/doc/com.dylibso.chicory/wasm/${chicory.version}/</link>
<link>https://www.javadoc.io/doc/com.dylibso.chicory/runtime/${chicory.version}/</link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
*/
public class SimpleMetricsHandler implements MetricsHandler {

/**
* Default constructor.
*/
public SimpleMetricsHandler() {
// Default constructor for SimpleMetricsHandler
}

/**
* Represents an individual metric managed by {@link SimpleMetricsHandler}.
* Stores the metric's ID, type, name, and its current value.
Expand All @@ -42,27 +49,35 @@ public Metric(int id, MetricType type, String name) {
}

/**
* Gets the unique integer ID of the metric.
*
* @return The unique integer ID of the metric.
*/
public int id() {
return id;
}

/**
* Gets the type of the metric.
*
* @return The {@link MetricType} of the metric.
*/
public MetricType type() {
return type;
}

/**
* Gets the name of the metric.
*
* @return The name of the metric.
*/
public String name() {
return name;
}

/**
* Gets the current value of the metric.
*
* @return The current value of the metric.
*/
public long getValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*/
public class SimpleSharedDataHandler implements SharedDataHandler {

/**
* Default constructor.
*/
public SimpleSharedDataHandler() {
// Default constructor for SimpleSharedDataHandler
}

private final HashMap<String, SharedData> sharedData = new HashMap<>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
*/
public class SimpleSharedQueueHandler implements SharedQueueHandler {

/**
* Default constructor.
*/
public SimpleSharedQueueHandler() {
// Default constructor for SimpleSharedQueueHandler
}

/**
* Represents an individual shared queue managed by {@link SimpleSharedQueueHandler}.
* Each queue has a unique name (within its VM), a host-assigned ID, and holds its data
Expand Down
5 changes: 1 addition & 4 deletions proxy-wasm-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc-plugin.version}</version>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<sourceFileExcludes>
<sourceFileExclude>**/internal/**</sourceFileExclude>
</sourceFileExcludes>
<offlineLinks>
<offlineLink>
<url>https://www.javadoc.io/doc/io.roastedroot/proxy-wasm-java-host/${project.version}/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
* <p>If you are using a CDI container like quarkus, you will be using the
* {@link io.roastedroot.proxywasm.jaxrs.cdi.WasmPluginFeature} instead.
*
* <pre>{@code
* <pre>
* public class MyApplication extends jakarta.ws.rs.core.Application {
* @Override
* public Set<Class<?>> getClasses() {
* Set<Class<?>> resources = new HashSet<>();
* &#64;Override
* public Set&lt;Class&lt;?&gt;&gt; getClasses() {
* Set&lt;Class&lt;?&gt;&gt; resources = new HashSet&lt;&gt;();
* resources.add(MyResource.class);
* return resources;
* }
*
* @Override
* public Set<Object> getSingletons() {
* Set<Object> singletons = new HashSet<>();
* &#64;Override
* public Set&lt;Object&gt; getSingletons() {
* Set&lt;Object&gt; singletons = new HashSet&lt;&gt;();
* try {
* // Assuming a ServerAdaptor and PluginFactory are available
* ServerAdaptor serverAdaptor = ...;
Expand All @@ -41,7 +41,7 @@
* return singletons;
* }
* }
* }</pre>
* </pre>
*
* @see WasmPlugin
* @see WasmPluginFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,37 @@
import com.dylibso.chicory.wasm.WasmModule;
import io.roastedroot.proxywasm.Plugin;
import io.roastedroot.proxywasm.PluginFactory;
import io.roastedroot.proxywasm.StartException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import java.nio.file.Path;

/**
* Application configuration class for the proxy-wasm JAX-RS example.
* Sets up the Wasm PluginFactory for the example plugin.
*/
@ApplicationScoped
public class App {

/**
* Default constructor.
*/
public App() {
// Default constructor
}

private static WasmModule module =
Parser.parse(
Path.of("../proxy-wasm-java-host/src/test/go-examples/unit_tester/main.wasm"));

// configure the the example wasm plugin
/**
* Produces the PluginFactory for the example Wasm plugin.
* Configures the plugin with necessary settings like name, shared status,
* plugin configuration, and machine factory.
*
* @return A configured PluginFactory for the example plugin.
*/
@Produces
public PluginFactory example() throws StartException {
public PluginFactory example() {
return () ->
Plugin.builder(module)
.withName("example")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

/**
* JAX-RS resource class for the proxy-wasm example.
* Defines endpoints for testing the Wasm plugin.
*/
@Path("/")
public class Resources {

/**
* Default constructor.
*/
public Resources() {
// Default constructor
}

/**
* Handles GET requests to the /test path.
* Applies the "example" Wasm plugin.
*
* @return A simple "Hello World" string.
*/
@Path("/test")
@GET
@WasmPlugin("example") // filter with example wasm plugin
Expand Down
2 changes: 1 addition & 1 deletion quarkus-proxy-wasm/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc-plugin.version}</version>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,43 @@
import java.nio.file.Path;
import java.util.Map;

/**
* Application configuration for integration tests.
* Provides CDI producers for various {@link PluginFactory} configurations used in tests.
*/
@ApplicationScoped
public class App {

/**
* Default constructor.
*/
public App() {
// Default constructor
}

/**
* Directory containing the example Wasm modules used for testing.
*/
public static final String EXAMPLES_DIR = "../../proxy-wasm-java-host/src/test";

private static final Gson gson = new Gson();

/**
* Parses a Wasm module from the specified file path relative to the examples directory.
*
* @param file The relative path to the Wasm module file.
* @return The parsed {@link WasmModule}.
*/
public static WasmModule parseTestModule(String file) {
return Parser.parse(Path.of(EXAMPLES_DIR + file));
}

/**
* Produces a {@link PluginFactory} for header manipulation tests (shared instance).
*
* @return A configured {@link PluginFactory}.
* @throws StartException If plugin initialization fails.
*/
@Produces
public PluginFactory headerTests() throws StartException {
return () ->
Expand All @@ -34,6 +61,12 @@ public PluginFactory headerTests() throws StartException {
.build();
}

/**
* Produces a {@link PluginFactory} for header manipulation tests (non-shared instances).
*
* @return A configured {@link PluginFactory}.
* @throws StartException If plugin initialization fails.
*/
@Produces
public PluginFactory headerTestsNotShared() throws StartException {
return () ->
Expand All @@ -45,6 +78,12 @@ public PluginFactory headerTestsNotShared() throws StartException {
.build();
}

/**
* Produces a {@link PluginFactory} for tick-based tests.
*
* @return A configured {@link PluginFactory}.
* @throws StartException If plugin initialization fails.
*/
@Produces
public PluginFactory tickTests() throws StartException {
return () ->
Expand All @@ -57,6 +96,12 @@ public PluginFactory tickTests() throws StartException {
.build();
}

/**
* Produces a {@link PluginFactory} for Foreign Function Interface (FFI) tests.
*
* @return A configured {@link PluginFactory}.
* @throws StartException If plugin initialization fails.
*/
@Produces
public PluginFactory ffiTests() throws StartException {
return () ->
Expand All @@ -70,6 +115,12 @@ public PluginFactory ffiTests() throws StartException {
.build();
}

/**
* Reverses the byte order of the input data. Used as an FFI function in tests.
*
* @param data The byte array to reverse.
* @return A new byte array with the reversed content.
*/
public static byte[] reverse(byte[] data) {
byte[] reversed = new byte[data.length];
for (int i = 0; i < data.length; i++) {
Expand All @@ -78,6 +129,12 @@ public static byte[] reverse(byte[] data) {
return reversed;
}

/**
* Produces a {@link PluginFactory} for HTTP call tests.
*
* @return A configured {@link PluginFactory}.
* @throws StartException If plugin initialization fails.
*/
@Produces
public PluginFactory httpCallTests() throws StartException {
return () ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
import io.roastedroot.proxywasm.LogLevel;
import java.util.ArrayList;

/**
* A mock implementation of {@link LogHandler} for testing purposes.
* Stores logged messages in memory and optionally prints them to the console if DEBUG is enabled.
*/
public class MockLogger implements LogHandler {

static final boolean DEBUG = "true".equals(System.getenv("DEBUG"));

final ArrayList<String> loggedMessages = new ArrayList<>();
private final String name;

/**
* Constructs a new MockLogger with the given name.
*
* @param name The name to associate with logged messages.
*/
public MockLogger(String name) {
this.name = name;
}
Expand All @@ -28,6 +37,11 @@ public synchronized LogLevel getLogLevel() {
return LogLevel.TRACE;
}

/**
* Retrieves a copy of all messages logged by this instance.
*
* @return A new {@link ArrayList} containing the logged messages.
*/
public synchronized ArrayList<String> loggedMessages() {
return new ArrayList<>(loggedMessages);
}
Expand Down
Loading