diff --git a/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/JVMCodeGenerator.java b/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/JVMCodeGenerator.java index b88cd68f14..ec793af632 100644 --- a/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/JVMCodeGenerator.java +++ b/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/JVMCodeGenerator.java @@ -51,7 +51,12 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { if (!fileName.endsWith(".pb")) { continue; } - var module = Module.parseFrom(Files.readAllBytes(file)); + Module module; + try { + module = Module.parseFrom(Files.readAllBytes(file)); + } catch (Exception e) { + throw new CodeGenException("Failed to parse " + file, e); + } for (var decl : module.getDeclsList()) { String packageName = PACKAGE_PREFIX + module.getName(); if (decl.hasTypeAlias()) { diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/pom.xml b/jvm-runtime/ftl-runtime/java/integration-tests/pom.xml deleted file mode 100644 index 2161409dc3..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - - - xyz.block.ftl - ftl-java-runtime-parent - 1.0-SNAPSHOT - - ftl-jvm-runtime-integration-tests - Ftl JVM Runtime - Integration Tests - - - true - - - - - xyz.block.ftl - ftl-java-runtime - - - xyz.block.ftl - ftl-jvm-test-framework - test - - - io.rest-assured - rest-assured - test - - - - xyz.block.ftl - ftl-java-runtime-deployment - test - - - io.quarkus - quarkus-junit5-mockito - - - - - - - io.quarkus - quarkus-maven-plugin - - - - build - generate-code - generate-code-tests - - - - - - maven-failsafe-plugin - - - - integration-test - verify - - - - - - ${project.build.directory}/${project.build.finalName}-runner - org.jboss.logmanager.LogManager - ${maven.home} - - - - - - - - - native-image - - - native - - - - - - maven-surefire-plugin - - ${native.surefire.skip} - - - - - - false - true - - - - diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/builtin.pb b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/builtin.pb deleted file mode 100644 index 83a40d59ed..0000000000 Binary files a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/builtin.pb and /dev/null differ diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/echo.pb b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/echo.pb deleted file mode 100644 index 6f55e044cd..0000000000 Binary files a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/echo.pb and /dev/null differ diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/time.pb b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/time.pb deleted file mode 100644 index 5388d67667..0000000000 Binary files a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/ftl-module-schema/time.pb and /dev/null differ diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResource.java b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResource.java deleted file mode 100644 index e746c1d442..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResource.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package xyz.block.ftl.java.runtime.it; - -import java.nio.charset.StandardCharsets; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.MediaType; - -import ftl.echo.EchoClient; -import ftl.echo.EchoRequest; -import xyz.block.ftl.Verb; - -@Path("/test") -@ApplicationScoped -public class FtlJavaRuntimeResource { - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("/post") - public String post(Person person, HelloClient helloClient) { - return helloClient.call(person.first() + " " + person.last()); - } - - @POST - @Path("/bytes") - public String bytesHttp(byte[] data) { - return "Hello " + new String(data, StandardCharsets.UTF_8); - } - - /** - * This is a verb FOOO - * - * @param name - * @param echoClient - * @return - */ - @Verb - public String hello(String name, EchoClient echoClient) { - return "Hello " + echoClient.call(new EchoRequest().setName(name)).getMessage(); - } - - @Verb - public void publish(Person person, MyTopic topic) { - topic.publish(person); - } - - @Verb - public byte[] bytes(byte[] bytes) { - return bytes; - } -} diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/HelloClient.java b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/HelloClient.java deleted file mode 100644 index 830dcf00a7..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/HelloClient.java +++ /dev/null @@ -1,8 +0,0 @@ -package xyz.block.ftl.java.runtime.it; - -import xyz.block.ftl.VerbClient; -import xyz.block.ftl.VerbClientDefinition; - -@VerbClientDefinition(name = "hello") -public interface HelloClient extends VerbClient { -} \ No newline at end of file diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/MyTopic.java b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/MyTopic.java deleted file mode 100644 index 0e5ef1e996..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/MyTopic.java +++ /dev/null @@ -1,10 +0,0 @@ -package xyz.block.ftl.java.runtime.it; - -import xyz.block.ftl.Export; -import xyz.block.ftl.Topic; -import xyz.block.ftl.TopicDefinition; - -@Export -@TopicDefinition(value = "testTopic") -public interface MyTopic extends Topic { -} diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/Person.java b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/Person.java deleted file mode 100644 index d7233db37a..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/java/xyz/block/ftl/java/runtime/it/Person.java +++ /dev/null @@ -1,5 +0,0 @@ -package xyz.block.ftl.java.runtime.it; - -public record Person(String first, String last) { - -} diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/main/resources/application.properties b/jvm-runtime/ftl-runtime/java/integration-tests/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/jvm-runtime/ftl-runtime/java/integration-tests/src/test/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResourceTest.java b/jvm-runtime/ftl-runtime/java/integration-tests/src/test/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResourceTest.java deleted file mode 100644 index 036273e1c0..0000000000 --- a/jvm-runtime/ftl-runtime/java/integration-tests/src/test/java/xyz/block/ftl/java/runtime/it/FtlJavaRuntimeResourceTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package xyz.block.ftl.java.runtime.it; - -import java.nio.charset.StandardCharsets; -import java.util.function.Function; - -import jakarta.inject.Inject; - -import org.hamcrest.Matchers; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import ftl.builtin.HttpRequest; -import ftl.builtin.HttpResponse; -import ftl.echo.EchoClient; -import ftl.echo.EchoRequest; -import ftl.echo.EchoResponse; -import io.quarkus.test.common.WithTestResource; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import xyz.block.ftl.VerbClient; -import xyz.block.ftl.VerbClientDefinition; -import xyz.block.ftl.VerbClientSink; -import xyz.block.ftl.java.test.FTLManaged; -import xyz.block.ftl.java.test.internal.FTLTestResource; -import xyz.block.ftl.java.test.internal.TestVerbServer; - -@QuarkusTest -@WithTestResource(FTLTestResource.class) -public class FtlJavaRuntimeResourceTest { - - @FTLManaged - @Inject - PublishVerbClient myVerbClient; - - @FTLManaged - @Inject - HelloClient helloClient; - - @FTLManaged - @Inject - BytesClient bytesClient; - - @Test - public void testHelloEndpoint() { - TestVerbServer.registerFakeVerb("echo", "echo", new Function() { - @Override - public EchoResponse apply(EchoRequest s) { - return new EchoResponse(s.getName()); - } - }); - EchoClient echoClient = Mockito.mock(EchoClient.class); - Mockito.when(echoClient.call(Mockito.any())).thenReturn(new EchoResponse().setMessage("Stuart")); - Assertions.assertEquals("Hello Stuart", helloClient.call("Stuart")); - } - - @Test - @Disabled - public void testTopic() { - myVerbClient.call(new Person("Stuart", "Douglas")); - } - - @Test - public void testBytesSerialization() { - Assertions.assertArrayEquals(new byte[] { 1, 2 }, bytesClient.call(new byte[] { 1, 2 })); - } - - @Test - public void testHttpPost() { - RestAssured.with().body(new Person("Stuart", "Douglas")) - .contentType(ContentType.JSON) - .post("/test/post") - .then() - .statusCode(200) - .body(Matchers.equalTo("Hello Stuart Douglas")); - } - - @Test - public void testHttpBytes() { - - RestAssured.with().body("Stuart Douglas".getBytes(java.nio.charset.StandardCharsets.UTF_8)) - .contentType(ContentType.JSON) - .post("/test/bytes") - .then() - .statusCode(200) - .body(Matchers.equalTo("Hello Stuart Douglas")); - } - - @VerbClientDefinition(name = "publish") - interface PublishVerbClient extends VerbClientSink { - } - - @VerbClientDefinition(name = "bytes") - interface BytesClient extends VerbClient { - } - - @VerbClientDefinition(name = "bytesHttp") - interface BytesHTTPClient extends VerbClient, HttpResponse> { - } -} diff --git a/jvm-runtime/ftl-runtime/java/pom.xml b/jvm-runtime/ftl-runtime/java/pom.xml index e03d255a32..18a04d44b2 100644 --- a/jvm-runtime/ftl-runtime/java/pom.xml +++ b/jvm-runtime/ftl-runtime/java/pom.xml @@ -16,7 +16,6 @@ deployment runtime - integration-tests build-parent