Skip to content

Commit

Permalink
More modularisation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Aug 24, 2024
1 parent 9f540e0 commit f82e7a8
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 30 deletions.
14 changes: 0 additions & 14 deletions convex-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@
<groupId>world.convex</groupId>
<artifactId>convex-restapi</artifactId>
<version>${convex.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>com.bladejava</groupId>
<artifactId>blade-log</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import convex.core.lang.RT;
import convex.test.generators.*;

@SuppressWarnings("exports")
@RunWith(JUnitQuickcheck.class)
public class GenTestDataStructures {


@Property
public void empty(@From(DataStructureGen.class) ADataStructure<@From(ValueGen.class) ACell> a) {
long c = a.count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public void testLongFunctions(@From(LongGenerator.class) Long a) {
assertNull(RT.vec(a));
}

@SuppressWarnings("exports")
@Property
public void testCoreArgs(@From(VectorGen.class) AVector<@From(ValueGen.class) ACell> a) throws IOException {
Context ctx=new CoreTest().context();
Expand Down
2 changes: 2 additions & 0 deletions convex-core/src/test/java/convex/core/lang/GenTestRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@RunWith(JUnitQuickcheck.class)
public class GenTestRT {

@SuppressWarnings("exports")
@Property
public void setConversion(@From(CollectionGen.class) ACollection<@From(ValueGen.class) ACell> a) {
long ac = a.count();
Expand All @@ -35,6 +36,7 @@ public void strTest(@From(ValueGen.class) ACell b) {
assertNotNull(s);
}

@SuppressWarnings("exports")
@Property
public void conjTest(@From(CollectionGen.class) ACollection<@From(ValueGen.class) ACell> a, @From(ValueGen.class) ACell b) {
ACollection<ACell> ac = a.conj(b);
Expand Down
21 changes: 20 additions & 1 deletion convex-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<artifactId>convex</artifactId>
<version>0.7.14-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>world.convex</groupId>
Expand All @@ -32,10 +32,29 @@
<artifactId>convex-core</artifactId>
<version>${convex.version}</version>
</dependency>
<dependency>
<groupId>world.convex</groupId>
<artifactId>convex-restapi</artifactId>
<version>${convex.version}</version>
</dependency>

<dependency>
<groupId>world.convex</groupId>
<artifactId>convex-java</artifactId>
<version>${convex.version}</version>
</dependency>

<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions convex-java/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

requires transitive convex.core;
requires json.simple;
requires org.apache.httpcomponents.client5.httpclient5;
requires org.apache.httpcomponents.core5.httpcore5;
requires transitive org.apache.httpcomponents.client5.httpclient5;
requires transitive org.apache.httpcomponents.core5.httpcore5;
}
10 changes: 10 additions & 0 deletions convex-restapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,15 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${hc.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-fluent</artifactId>
<version>${hc.version}</version>
</dependency>
</dependencies>
</project>
11 changes: 8 additions & 3 deletions convex-restapi/src/main/java/convex/restapi/RESTServer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package convex.restapi;

import java.io.Closeable;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -27,7 +28,7 @@
import io.javalin.openapi.plugin.redoc.ReDocPlugin;
import io.javalin.openapi.plugin.swagger.SwaggerPlugin;

public class RESTServer {
public class RESTServer implements Closeable {
protected static final Logger log = LoggerFactory.getLogger(RESTServer.class.getName());

protected final Server server;
Expand Down Expand Up @@ -58,7 +59,7 @@ private RESTServer(Server server) {
config.staticFiles.add(staticFiles -> {
staticFiles.hostedPath = "/";
staticFiles.location = Location.CLASSPATH; // Specify resources from classpath
staticFiles.directory = "/public"; // Resource location in classpath
staticFiles.directory = "/convex/restapi/pub"; // Resource location in classpath
staticFiles.precompress = false; // if the files should be pre-compressed and cached in memory
// (optimization)
staticFiles.aliasCheck = null; // you can configure this to enable symlinks (=
Expand Down Expand Up @@ -108,7 +109,7 @@ protected void addOpenApiPlugins(JavalinConfig config) {
pluginConfig
.withDocumentationPath(docsPath)
.withDefinitionConfiguration((version, definition) -> {
definition.withOpenApiInfo(info -> {
definition.withInfo(info -> {
info.setTitle("Convex REST API");
info.setVersion("0.7.0");
});
Expand Down Expand Up @@ -187,6 +188,10 @@ public void stop() {
app.stop();
// app.close(); // Gone In Javalin 6?
}

public void close() {
stop();
}

public Convex getConvex() {
return convex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Package for static resources used by convex-restapi
*/
package convex.restapi.pub;
6 changes: 4 additions & 2 deletions convex-restapi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module convex.restapi {
exports convex.restapi.api;
exports convex.restapi;
exports convex.restapi.model;

Expand All @@ -13,10 +12,13 @@
requires javalin.swagger.plugin;
// requires static com.fasterxml.jackson.databind;
requires jetty.servlet.api;
requires kotlin.stdlib;
requires transitive kotlin.stdlib;
requires kotlin.reflect;
requires org.eclipse.jetty.server;

requires org.slf4j;
requires convex.java;
// requires org.junit.jupiter.api;

opens convex.restapi.pub;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package convex.restapi;
package convex.restapi.test;

import convex.peer.API;
import convex.peer.Server;
import convex.restapi.RESTServer;

public class Main {

public static void main(String[] args) {
Server s=API.launchPeer();
System.out.println("Using Ed25519 seed: "+s.getKeyPair().getSeed());
RESTServer rs=RESTServer.create(s);
rs.start();

System.out.println("Complete");
try (RESTServer rs=RESTServer.create(s)) {
rs.start();
System.out.println("Complete");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package convex.restapi;
package convex.restapi.test;

import java.io.IOException;

import org.apache.hc.client5.http.fluent.Request;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import convex.peer.API;
import convex.peer.Server;
import convex.restapi.RESTServer;

public class RESTAPITest {
static RESTServer server;
Expand All @@ -22,10 +26,16 @@ public static void init() {

@AfterAll
public static void cleanShutdown() {
server.stop();
if (server!=null) {
server.stop();
}
}

@Test public void testDataAPI() {

}

@Test public void testSwagger() throws IOException {
Request.get("http://localhost:" + server.getPort()+"/swagger").execute().returnContent();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.restapi;
package convex.restapi.test;

import java.util.ArrayList;
import java.util.Map;
Expand All @@ -15,6 +15,7 @@
import convex.java.JSON;
import convex.peer.API;
import convex.peer.Server;
import convex.restapi.RESTServer;

public class StressTest {

Expand Down

0 comments on commit f82e7a8

Please sign in to comment.