forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.8.x' of github.com:micronaut-projects/micronaut-core …
…into 4.8.x
- Loading branch information
Showing
9 changed files
with
126 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
http-netty/src/test/groovy/io/micronaut/http/netty/body/AvailableNettyByteBodySpec.groovy
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,19 @@ | ||
package io.micronaut.http.netty.body | ||
|
||
import io.netty.buffer.Unpooled | ||
import spock.lang.Specification | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
class AvailableNettyByteBodySpec extends Specification { | ||
def move() { | ||
given: | ||
def a = new AvailableNettyByteBody(Unpooled.copiedBuffer("foo", StandardCharsets.UTF_8)) | ||
def b = a.move() | ||
|
||
when: | ||
a.close() | ||
then: | ||
b.buffer().get().toString(StandardCharsets.UTF_8) == "foo" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
http-netty/src/test/groovy/io/micronaut/http/netty/body/StreamingNettyByteBodySpec.groovy
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,21 @@ | ||
package io.micronaut.http.netty.body | ||
|
||
import io.netty.buffer.Unpooled | ||
import io.netty.channel.embedded.EmbeddedChannel | ||
import reactor.core.publisher.Flux | ||
import spock.lang.Specification | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
class StreamingNettyByteBodySpec extends Specification { | ||
def move() { | ||
given: | ||
def a = NettyBodyAdapter.adapt(Flux.just(Unpooled.copiedBuffer("foo", StandardCharsets.UTF_8)), new EmbeddedChannel().eventLoop()) | ||
def b = a.move() | ||
|
||
when: | ||
a.close() | ||
then: | ||
b.buffer().get().toString(StandardCharsets.UTF_8) == "foo" | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
http/src/test/groovy/io/micronaut/http/body/stream/AvailableByteArrayBodySpec.groovy
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,19 @@ | ||
package io.micronaut.http.body.stream | ||
|
||
import io.micronaut.core.io.buffer.ByteArrayBufferFactory | ||
import spock.lang.Specification | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
class AvailableByteArrayBodySpec extends Specification { | ||
def move() { | ||
given: | ||
def a = AvailableByteArrayBody.create(ByteArrayBufferFactory.INSTANCE, "foo".getBytes(StandardCharsets.UTF_8)) | ||
def b = a.move() | ||
|
||
when: | ||
a.close() | ||
then: | ||
b.buffer().get().toString(StandardCharsets.UTF_8) == "foo" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
http/src/test/groovy/io/micronaut/http/body/stream/InputStreamByteBodySpec.groovy
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,24 @@ | ||
package io.micronaut.http.body.stream | ||
|
||
import io.micronaut.core.io.buffer.ByteArrayBufferFactory | ||
import spock.lang.Specification | ||
|
||
import java.nio.charset.StandardCharsets | ||
import java.util.concurrent.Executors | ||
|
||
class InputStreamByteBodySpec extends Specification { | ||
def move() { | ||
given: | ||
def pool = Executors.newCachedThreadPool() | ||
def a = InputStreamByteBody.create(new ByteArrayInputStream("foo".getBytes(StandardCharsets.UTF_8)), OptionalLong.empty(), pool, ByteArrayBufferFactory.INSTANCE) | ||
def b = a.move() | ||
|
||
when: | ||
a.close() | ||
then: | ||
b.buffer().get().toString(StandardCharsets.UTF_8) == "foo" | ||
|
||
cleanup: | ||
pool.shutdown() | ||
} | ||
} |