generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial java <-> go integration test (#2339)
Initial PR that tests simple interop. This will be expanded to cover as many different types and features as possible.
- Loading branch information
1 parent
9e82265
commit 907731e
Showing
15 changed files
with
364 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...time/ftl-runtime/runtime/src/main/java/xyz/block/ftl/runtime/JsonSerializationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package xyz.block.ftl.runtime; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
|
||
/** | ||
* This class configures the FTL serialization | ||
*/ | ||
public class JsonSerializationConfig { | ||
|
||
void startup(@Observes StartupEvent event, ObjectMapper mapper) { | ||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//go:build integration | ||
|
||
package ftl_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
|
||
in "github.com/TBD54566975/ftl/integration" | ||
|
||
"github.com/alecthomas/repr" | ||
) | ||
|
||
func TestJavaToGoCall(t *testing.T) { | ||
in.RunWithJava(t, "", | ||
in.CopyModule("gomodule"), | ||
in.CopyDir("javamodule", "javamodule"), | ||
in.Deploy("gomodule"), | ||
in.Deploy("javamodule"), | ||
in.Call("javamodule", "timeVerb", in.Obj{}, func(t testing.TB, response in.Obj) { | ||
message, ok := response["time"].(string) | ||
assert.True(t, ok, "time is not a string: %s", repr.String(response)) | ||
result, err := time.Parse(time.RFC3339, message) | ||
assert.NoError(t, err, "time is not a valid RFC3339 time: %s", message) | ||
assert.True(t, result.After(time.Now().Add(-time.Minute)), "time is not recent: %s", message) | ||
}), | ||
// We call both the go and pass through Java versions | ||
// To make sure the response is the same | ||
in.Call("gomodule", "emptyVerb", in.Obj{}, func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), | ||
in.Call("javamodule", "emptyVerb", in.Obj{}, func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), | ||
in.Call("gomodule", "sinkVerb", "ignored", func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), | ||
in.Call("javamodule", "sinkVerb", "ignored", func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), | ||
in.Call("gomodule", "sourceVerb", in.Obj{}, func(t testing.TB, response string) { | ||
assert.Equal(t, "Source Verb", response, "expecting empty response, got %s", response) | ||
}), | ||
in.Call("javamodule", "sourceVerb", in.Obj{}, func(t testing.TB, response string) { | ||
assert.Equal(t, "Source Verb", response, "expecting empty response, got %s", response) | ||
}), | ||
in.Fail( | ||
in.Call("gomodule", "errorEmptyVerb", in.Obj{}, func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), "verb failed"), | ||
in.Fail( | ||
in.Call("gomodule", "errorEmptyVerb", in.Obj{}, func(t testing.TB, response in.Obj) { | ||
assert.Equal(t, map[string]any{}, response, "expecting empty response, got %s", repr.String(response)) | ||
}), "verb failed"), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module = "gomodule" | ||
language = "go" | ||
|
||
[go.replace] | ||
"github.com/TBD54566975/ftl" = "../.." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ftl/gomodule | ||
|
||
go 1.22.2 | ||
|
||
replace github.com/TBD54566975/ftl => ./../../../.. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package gomodule | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type TimeRequest struct { | ||
} | ||
type TimeResponse struct { | ||
Time time.Time | ||
} | ||
|
||
//ftl:verb export | ||
func SourceVerb(ctx context.Context) (string, error) { | ||
return "Source Verb", nil | ||
} | ||
|
||
//ftl:verb export | ||
func SinkVerb(ctx context.Context, req string) error { | ||
return nil | ||
} | ||
|
||
//ftl:verb export | ||
func EmptyVerb(ctx context.Context) error { | ||
return nil | ||
} | ||
|
||
//ftl:verb export | ||
func ErrorEmptyVerb(ctx context.Context) error { | ||
return fmt.Errorf("verb failed") | ||
} | ||
|
||
//ftl:verb export | ||
func Time(ctx context.Context, req TimeRequest) (TimeResponse, error) { | ||
return TimeResponse{Time: time.Now()}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "echoclient" | ||
language = "java" |
Oops, something went wrong.