-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add native test and support #18
Open
dufoli
wants to merge
5
commits into
quarkiverse:main
Choose a base branch
from
dufoli:native
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
79 changes: 79 additions & 0 deletions
79
integration-tests/src/test/java/io/quarkiverse/rsocket/test/RSocketTestCaseIT.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,79 @@ | ||
package io.quarkiverse.rsocket.test; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.CharBuffer; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collections; | ||
|
||
import org.jboss.logging.Logger; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.google.common.base.Charsets; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.ByteBufAllocator; | ||
import io.netty.buffer.CompositeByteBuf; | ||
import io.quarkiverse.rsocket.runtime.JsonEncoder; | ||
import io.quarkus.test.junit.NativeImageTest; | ||
import io.rsocket.Payload; | ||
import io.rsocket.core.RSocketConnector; | ||
import io.rsocket.metadata.CompositeMetadataCodec; | ||
import io.rsocket.metadata.RoutingMetadata; | ||
import io.rsocket.metadata.TaggingMetadataCodec; | ||
import io.rsocket.metadata.WellKnownMimeType; | ||
import io.rsocket.transport.netty.client.TcpClientTransport; | ||
import io.rsocket.util.DefaultPayload; | ||
|
||
@NativeImageTest | ||
public class RSocketTestCaseIT { | ||
private static final Logger LOGGER = Logger.getLogger(RSocketTestCase.class); | ||
|
||
@Test | ||
public void testRSocketRoute() { | ||
String hello = "Hello RSocket"; | ||
CompositeByteBuf metadata = ByteBufAllocator.DEFAULT.compositeBuffer(); | ||
RoutingMetadata routingMetadata = TaggingMetadataCodec.createRoutingMetadata(ByteBufAllocator.DEFAULT, | ||
Collections.singletonList("/foo")); | ||
CompositeMetadataCodec.encodeAndAddMetadata(metadata, | ||
ByteBufAllocator.DEFAULT, | ||
WellKnownMimeType.MESSAGE_RSOCKET_ROUTING, | ||
routingMetadata.getContent()); | ||
ByteBuf data = ByteBufAllocator.DEFAULT.buffer().writeBytes(hello.getBytes(Charsets.UTF_8)); | ||
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(CharBuffer.wrap(hello)); | ||
Payload rspPayload = RSocketConnector.create() | ||
.metadataMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()) | ||
//.payloadDecoder(PayloadDecoder.ZERO_COPY) | ||
.connect(TcpClientTransport.create("127.0.0.1", 7000)) | ||
.block() | ||
.requestResponse(DefaultPayload.create(byteBuffer, metadata.nioBuffer())) | ||
.block(); | ||
metadata.release(); | ||
Assertions.assertEquals(hello, rspPayload.getDataUtf8(), "failed to get response"); | ||
} | ||
|
||
@Test | ||
public void testRSocketEncoder() { | ||
|
||
CompositeByteBuf metadata = ByteBufAllocator.DEFAULT.compositeBuffer(); | ||
RoutingMetadata routingMetadata = TaggingMetadataCodec.createRoutingMetadata(ByteBufAllocator.DEFAULT, | ||
Collections.singletonList("/foo")); | ||
CompositeMetadataCodec.encodeAndAddMetadata(metadata, | ||
ByteBufAllocator.DEFAULT, | ||
WellKnownMimeType.MESSAGE_RSOCKET_ROUTING, | ||
routingMetadata.getContent()); | ||
Car c = new Car(); | ||
c.setName("batmobile"); | ||
JsonEncoder encoder = new JsonEncoder(); | ||
Payload payload = encoder.encode(c); | ||
Payload rspPayload = RSocketConnector.create() | ||
.metadataMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()) | ||
//.payloadDecoder(PayloadDecoder.ZERO_COPY) | ||
.connect(TcpClientTransport.create("127.0.0.1", 7000)) | ||
.block() | ||
.requestResponse(DefaultPayload.create(payload.getData(), metadata.nioBuffer())) | ||
.block(); | ||
metadata.release(); | ||
Assertions.assertEquals("{\"name\":\"batmobile\"}", rspPayload.getDataUtf8(), "failed to get response"); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you are physically limiting the Maven reactor to just this one module
integration-tests
, which is fine, but this will need theruntime
anddeployment
modules of the extension in the local repo. Otherwise resolution of those modules/artifacts will fail (because they are not part of the reactor).Therefore you will have to use
install
in the previous "Build - JVM" step.To avoid having the resulting extension artifacts in the Maven cache (they should be built freshly for each run), you should add something like the following (after this step):
/cc @gastaldi I haven't had a look at how other quarkiverse extensions work, so you might have another suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@famod that makes sense, I don't think we're doing anything like that in the other extensions too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad , I have merges 2 files from different project....
I just focused on pom files because I was thinking it come from that...