├── .editorconfig
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ └── 01-compatible-certification-request.md
└── workflows
│ └── build.yml
├── .gitignore
├── CONTRIBUTING.adoc
├── LICENSE
├── NOTICE
├── README.adoc
├── api
├── bnd.bnd
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── eclipse
│ │ └── microprofile
│ │ └── reactive
│ │ └── messaging
│ │ ├── Acknowledgment.java
│ │ ├── Channel.java
│ │ ├── Emitter.java
│ │ ├── Incoming.java
│ │ ├── Message.java
│ │ ├── OnOverflow.java
│ │ ├── Outgoing.java
│ │ ├── package-info.java
│ │ └── spi
│ │ ├── Connector.java
│ │ ├── ConnectorAttribute.java
│ │ ├── ConnectorAttributes.java
│ │ ├── ConnectorFactory.java
│ │ ├── ConnectorLiteral.java
│ │ ├── IncomingConnectorFactory.java
│ │ ├── OutgoingConnectorFactory.java
│ │ └── package-info.java
│ └── resources
│ ├── LICENSE
│ └── NOTICE
├── approach.asciidoc
├── pom.xml
├── site.yaml
├── spec
├── pom.xml
└── src
│ └── main
│ └── asciidoc
│ ├── architecture.asciidoc
│ ├── images
│ ├── overall.png
│ └── reactive-system.png
│ ├── license-alv2.asciidoc
│ ├── license-efsl.adoc
│ ├── microprofile-reactive-messaging-spec.asciidoc
│ ├── rationale.asciidoc
│ └── release_notes.asciidoc
└── tck
├── README.adoc
├── pom.xml
└── src
└── main
├── java
└── org
│ └── eclipse
│ └── microprofile
│ └── reactive
│ └── messaging
│ └── tck
│ ├── ArchiveExtender.java
│ ├── BeanWithChain.java
│ ├── ProcessorChainTest.java
│ ├── SimpleIncomingBean.java
│ ├── SimpleIncomingTest.java
│ ├── StringSource.java
│ ├── TckBase.java
│ ├── ValueCollector.java
│ ├── acknowledgement
│ ├── AsynchronousMessageProcessorAckTest.java
│ ├── AsynchronousMessageSubscriberAckTest.java
│ ├── AsynchronousPayloadProcessorAckTest.java
│ ├── AsynchronousPayloadSubscriberAckTest.java
│ ├── EmitterBean.java
│ ├── EmitterOfMessageAcknowledgementTest.java
│ ├── EmitterOfPayloadAcknowledgementTest.java
│ ├── MessageProcessorAckTest.java
│ ├── PayloadProcessorAckTest.java
│ └── PayloadSubscriberAckTest.java
│ ├── channel
│ ├── BeanInjectedWithAPublisherBuilderOfMessages.java
│ ├── BeanInjectedWithAPublisherBuilderOfPayloads.java
│ ├── BeanInjectedWithAPublisherOfMessages.java
│ ├── BeanInjectedWithAPublisherOfPayloads.java
│ ├── BeanInjectedWithDifferentFlavorsOfTheSameChannel.java
│ ├── BeanWithMissingChannel.java
│ ├── ChannelInjectionDifferentFlavourSameChannelTest.java
│ ├── ChannelInjectionPublisherBuilderMessageTest.java
│ ├── ChannelInjectionPublisherBuilderPayloadTest.java
│ ├── ChannelInjectionPublisherPayloadTest.java
│ ├── ChannelInjectionPublisherTest.java
│ ├── EmitterConnectedToProcessor.java
│ ├── EmitterInjectionAfterTerminatingWithErrorTest.java
│ ├── EmitterInjectionConnectedToProcessorTest.java
│ ├── EmitterInjectionEmittingDataAfterTerminationTest.java
│ ├── EmitterInjectionEmittingMessageTest.java
│ ├── EmitterInjectionEmittingNullTest.java
│ ├── EmitterInjectionMessageBeanWithPayloadsWithAckTest.java
│ ├── EmitterInjectionMissingChannelTest.java
│ ├── EmitterInjectionPayloadsTest.java
│ ├── EmitterInjectionPayloadsWithAckTest.java
│ ├── MyBeanEmittingDataAfterTermination.java
│ ├── MyBeanEmittingDataAfterTerminationWithError.java
│ ├── MyBeanEmittingMessages.java
│ ├── MyBeanEmittingNull.java
│ ├── MyBeanEmittingPayloads.java
│ ├── MyBeanEmittingPayloadsWithAck.java
│ ├── MyMessageBean.java
│ ├── MyMessageBeanEmittingPayloadsWithAck.java
│ ├── SourceBean.java
│ └── overflow
│ │ ├── BeanUsingBufferOverflowStrategy.java
│ │ ├── BeanUsingBufferOverflowWithoutBufferSizeStrategy.java
│ │ ├── BeanUsingDefaultOverflow.java
│ │ ├── BeanUsingDropOverflowStrategy.java
│ │ ├── BeanUsingLatestOverflowStrategy.java
│ │ ├── BeanUsingThrowExceptionStrategy.java
│ │ ├── BeanWithFailOverflowStrategy.java
│ │ ├── BufferOverflowStrategyOverflowTest.java
│ │ ├── BufferOverflowStrategyTest.java
│ │ ├── DefaultOverflowStrategyOverflowTest.java
│ │ ├── DefaultOverflowStrategyOverflowWithoutBufferSizeTest.java
│ │ ├── DefaultOverflowStrategyTest.java
│ │ ├── DropOverflowStrategyOverflowTest.java
│ │ ├── DropOverflowStrategyTest.java
│ │ ├── FailOverflowStrategyOverflowTest.java
│ │ ├── LatestOverflowStrategyOverflowTest.java
│ │ ├── LatestOverflowStrategyTest.java
│ │ ├── ThrowExceptionOverflowStrategyOverflowTest.java
│ │ └── ThrowExceptionOverflowStrategyTest.java
│ ├── connector
│ ├── ConnectorTest.java
│ ├── DummyConnector.java
│ ├── MissingConnectorTest.java
│ ├── MyProcessor.java
│ └── MyProcessorWithBadStreamName.java
│ ├── extension
│ ├── AssertJArchiveAppender.java
│ ├── AwaitilityArchiveAppender.java
│ ├── ReactiveMessagingLoadableExtension.java
│ └── RxJavaArchiveAppender.java
│ ├── invalid
│ ├── BeanConsumingManyTwice.java
│ ├── BeanProducingManyTwice.java
│ ├── BeanWithBadOutgoingSignature.java
│ ├── BeanWithEmptyIncoming.java
│ ├── BeanWithEmptyOutgoing.java
│ ├── BeanWithIncompleteChain.java
│ ├── ChannelMissingUpstream.java
│ ├── ChannelMultipleUpstreams.java
│ ├── EmitterMissingDownstream.java
│ ├── EmitterMultipleDownstreams.java
│ ├── InvalidConfigurationTest.java
│ ├── ProcessorMissingDownstream.java
│ ├── ProcessorMissingUpstream.java
│ ├── ProcessorMultipleDownstreams.java
│ └── ProcessorMultipleUpstreams.java
│ ├── metrics
│ ├── ConfigAsset.java
│ ├── MetricsTest.java
│ ├── MetricsTestBean.java
│ └── TestConnector.java
│ ├── scope
│ ├── ApplicationBeans.java
│ ├── ApplicationScopeTest.java
│ ├── DependantBeans.java
│ └── DependantScopeTest.java
│ └── signatures
│ ├── invalid
│ ├── IncomingReturningNonVoid.java
│ ├── IncomingReturningNonVoidCompletionStage.java
│ └── InvalidSubscriberSignatureTest.java
│ ├── processors
│ ├── DirectProcessorBean.java
│ ├── ProcessorBean.java
│ ├── ProcessorShapeTest.java
│ ├── PublisherBean.java
│ └── TransformerBean.java
│ ├── publishers
│ ├── PublisherBean.java
│ ├── PublisherShapeTest.java
│ └── VerifierForPublisherBean.java
│ └── subscribers
│ ├── SubscriberBean.java
│ └── SubscriberShapeTest.java
└── resources
├── META-INF
├── LICENSE
├── NOTICE
├── services
│ └── org.jboss.arquillian.core.spi.LoadableExtension
└── tck
└── org
└── eclipse
└── microprofile
└── reactive
└── messaging
└── tck
└── connector
└── connector-config.properties
/.editorconfig:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | #
4 | # See the NOTICE file(s) distributed with this work for additional
5 | # information regarding copyright ownership.
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # You may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | # EditorConfig helps developers define and maintain consistent
21 | # coding styles between different editors and IDEs
22 | # http://editorconfig.org
23 |
24 | root = true
25 |
26 | [*]
27 | indent_style = space
28 | indent_size = 4
29 | end_of_line = lf
30 | charset = utf-8
31 | trim_trailing_whitespace = true
32 | insert_final_newline = true
33 |
34 | [*.md]
35 | trim_trailing_whitespace = false
36 |
37 | [*.adoc]
38 | trim_trailing_whitespace = false
39 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Handle line endings automatically for files detected as text
2 | # and leave all files detected as binary untouched.
3 | * text=auto
4 |
5 | #
6 | # The above will handle all files NOT found below
7 | #
8 | # These files are text and should be normalized (Convert crlf => lf)
9 | *.adoc text
10 | *.conf text
11 | *.config text
12 | *.css text
13 | *.df text
14 | *.extension text
15 | *.groovy text
16 | *.htm text
17 | *.html text
18 | *.java text
19 | *.js text
20 | *.json text
21 | *.jsp text
22 | *.jspf text
23 | *.md text
24 | *.properties text
25 | *.sbt text
26 | *.scala text
27 | *.sh text
28 | *.sql text
29 | *.svg text
30 | *.template text
31 | *.tld text
32 | *.txt text
33 | *.vm text
34 | *.wadl text
35 | *.wsdl text
36 | *.xhtml text
37 | *.xml text
38 | *.xsd text
39 | *.yml text
40 |
41 | cipher text
42 | jaas text
43 | LICENSE text
44 | NOTICE text
45 |
46 | # These files are binary and should be left untouched
47 | # (binary is a macro for -text -diff)
48 | *.class binary
49 | *.dll binary
50 | *.ear binary
51 | *.gif binary
52 | *.ico binary
53 | *.jar binary
54 | *.jpg binary
55 | *.jpeg binary
56 | *.png binary
57 | *.ser binary
58 | *.so binary
59 | *.war binary
60 | *.zip binary
61 | *.exe binary
62 | *.gz binary
63 |
64 | #Windows
65 | *.bat text eol=crlf
66 | *.cmd text eol=crlf
67 |
68 | #Unix/Linux
69 | *.sh text eol=lf
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/01-compatible-certification-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Compatible Certification Request
3 | about: Start a request for a compatible certification
4 | title: 'MicroProfile Reactive Messaging [Version] Compatible Certification Request'
5 | labels: 'Certification :trophy:'
6 | assignees: ''
7 |
8 | ---
9 |
10 | - [ ] Organization Name ("Organization") and, if applicable, URL:
11 | // Add here
12 | - [ ] Product Name, Version and download URL (if applicable):
13 | // Add here
14 | - [ ] Specification Name, Version and download URL:
15 | // Add here
16 | - [ ] (Optional) TCK Version, digital SHA-256 fingerprint and download URL:
17 | // Add here
18 | - [ ] Public URL of TCK Results Summary:
19 | // Add here
20 | - [ ] Any Additional Specification Certification Requirements:
21 | // Add here
22 | - [ ] Java runtime used to run the implementation:
23 | // Add here
24 | - [ ] Summary of the information for the certification environment, operating system, cloud, ...:
25 | // Add here
26 | - [ ] By checking this box I acknowledge that the Organization I represent accepts the terms of the [EFTL](https://www.eclipse.org/legal/tck.php).
27 | - [ ] By checking this box I attest that all TCK requirements have been met, including any compatibility rules.
28 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: MicroProfile Reactive Messaging Build
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - 'editorconfig'
7 | - '.gitattributes'
8 | - '.gitignore'
9 | - 'CONTRIBUTING*'
10 | - 'CODEOWNERS'
11 | - 'KEYS'
12 | - 'LICENSE'
13 | - 'NOTICE'
14 | - 'README*'
15 | - 'site.yaml'
16 | - '*.adoc'
17 | - '*.asciidoc'
18 | pull_request:
19 | paths-ignore:
20 | - 'editorconfig'
21 | - '.gitattributes'
22 | - '.gitignore'
23 | - 'CONTRIBUTING*'
24 | - 'CODEOWNERS'
25 | - 'KEYS'
26 | - 'LICENSE'
27 | - 'NOTICE'
28 | - 'README*'
29 | - 'site.yaml'
30 | - '*.adoc'
31 | - '*.asciidoc'
32 |
33 | jobs:
34 | build:
35 | runs-on: ubuntu-latest
36 | strategy:
37 | matrix:
38 | java: [11]
39 | name: build with jdk ${{matrix.java}}
40 |
41 | steps:
42 | - uses: actions/checkout@v2
43 | name: checkout
44 | with:
45 | ref: ${{ github.event.pull_request.merge_commit_sha }}
46 |
47 | - uses: actions/setup-java@v1
48 | name: set up jdk ${{matrix.java}}
49 | with:
50 | java-version: ${{matrix.java}}
51 |
52 | - name: build with maven
53 | run: mvn -ntp verify
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | .settings/
3 | .checkstyle
4 | target/
5 | tck/bin/
6 | .project
7 | build/
8 | .classpath
9 | .factorypath
10 | test-output
11 | /*.log
12 | .idea
13 | *.iml
14 | *.iwl
15 | *.ipr
16 | # Ignore a release.conf for perform_release/* script usage
17 | release.conf
18 | /bin/
19 | .~lock.*.odg#
20 | spec/.DS_Store
21 | .DS_Store
22 |
--------------------------------------------------------------------------------
/CONTRIBUTING.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | == How to contribute
21 |
22 | Do you want to contribute to this project? Here is what you can do:
23 |
24 | * Fork the repository, make changes, then do a pull request.
25 | ** Remember to https://help.github.com/articles/signing-commits/[sign your commits]
26 | ** Make sure you have signed the https://www.eclipse.org/legal/ECA.php[Eclipse Contributor Agreement]
27 | * https://github.com/eclipse/microprofile-reactive-messaging/issues[Create or fix an issue].
28 | * https://gitter.im/eclipse/microprofile-reactive[Join us on Gitter to discuss this project].
29 | * Join our https://calendar.google.com/calendar/embed?src=gbnbc373ga40n0tvbl88nkc3r4%40group.calendar.google.com[weekly meeting] on Tuesday at https://www.timeanddate.com/time/map/[10h00 GMT].
30 | ** https://docs.google.com/document/d/1UKBBNFn-CeMih3lNUGvpShcL2aTpnvmJs9LQ8qT9OI0/edit?usp=sharing[Minutes and Agenda].
31 | ** https://zoom.us/j/509807821[Meeting room].
32 | * Join the discussions on the https://groups.google.com/forum/#!forum/microprofile[MicroProfile Google Group]
33 | * https://microprofile.io/blog/[Contribute a blog post].
34 |
35 | Also see the https://wiki.eclipse.org/MicroProfile/ContributingGuidelines[MicroProfile Contributing Guidelines] on the https://wiki.eclipse.org/MicroProfile[Eclipse MicroProfile wiki page]
36 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | =========================================================================
2 | == NOTICE file corresponding to section 4(d) of the Apache License, ==
3 | == Version 2.0, in this case for Microprofile Reactive Streams ==
4 | =========================================================================
5 |
6 | This product includes software developed at
7 | The Apache Software Foundation (http://www.apache.org/).
8 |
9 | SPDXVersion: SPDX-2.1
10 | PackageName: Eclipse Microprofile
11 | PackageHomePage: http://www.eclipse.org/microprofile
12 | PackageLicenseDeclared: Apache-2.0
13 |
14 | PackageCopyrightText:
15 | James Roper james@jazzy.id.au
16 |
17 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2019 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | image:https://badges.gitter.im/eclipse/microprofile-reactive.svg[link="https://gitter.im/eclipse/microprofile-reactive"]
21 |
22 | = Reactive Messaging for MicroProfile
23 |
24 | This specification provides asynchronous messaging support based on Reactive Streams for MicroProfile.
25 |
26 | == Implementations
27 |
28 | MicroProfile Reactive Messaging does not contain an implementation itself but only provides the specified API, a TCK and documentation.
29 |
30 | The following implementations are available:
31 |
32 | * https://github.com/lightbend/microprofile-reactive-messaging[Lightbend Alpakka]
33 | * https://www.smallrye.io/smallrye-reactive-messaging[SmallRye Reactive Messaging]
34 | * https://openliberty.io/downloads/#runtime_releases[Open Liberty 19.0.0.9+] https://openliberty.io/blog/2019/09/13/microprofile-reactive-messaging-19009.html#mpreactive[usage] (via SmallRye Reactive Messaging)
35 |
36 | == Building
37 |
38 | The whole MicroProfile Reactive Messaging project can be built via Apache Maven.
39 |
40 | `$> mvn clean install`
41 |
42 | == Contributing
43 |
44 | Do you want to contribute to this project? link:CONTRIBUTING.adoc[Find out how you can help here].
45 |
--------------------------------------------------------------------------------
/api/bnd.bnd:
--------------------------------------------------------------------------------
1 | -exportcontents: \
2 | org.eclipse.microprofile.*
3 |
4 | Import-Package: \
5 | *
6 |
7 | Bundle-SymbolicName: org.eclipse.microprofile.reactive.messaging
8 | Bundle-Name: MicroProfile Reactive Messaging Bundle
9 | Bundle-License: Apache License, Version 2.0
10 |
--------------------------------------------------------------------------------
/api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 | 4.0.0
24 |
25 |
26 |
27 | org.eclipse.microprofile.reactive.messaging
28 | microprofile-reactive-messaging-parent
29 | 3.1-SNAPSHOT
30 |
31 |
32 | microprofile-reactive-messaging-api
33 | MicroProfile Reactive Messaging API
34 | MicroProfile Reactive Messaging :: API
35 |
36 |
37 |
38 | org.osgi
39 | org.osgi.annotation.versioning
40 | provided
41 |
42 |
43 | org.eclipse.microprofile.reactive-streams-operators
44 | microprofile-reactive-streams-operators-api
45 | provided
46 |
47 |
48 | org.eclipse.microprofile.config
49 | microprofile-config-api
50 | provided
51 |
52 |
53 | jakarta.enterprise
54 | jakarta.enterprise.cdi-api
55 | provided
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.apache.maven.plugins
63 | maven-javadoc-plugin
64 |
65 | true
66 | true
67 |
68 | https://jakarta.ee/specifications/cdi/3.0/apidocs/
69 | https://download.eclipse.org/microprofile/microprofile-reactive-streams-operators-${version.microprofile.reactive.streams.operators}/apidocs/
70 | https://download.eclipse.org/microprofile/microprofile-config-${version.microprofile.config}/apidocs/
71 | https://osgi.org/javadoc/r6/annotation/
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/Channel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging;
20 |
21 | import static java.lang.annotation.ElementType.CONSTRUCTOR;
22 | import static java.lang.annotation.ElementType.FIELD;
23 | import static java.lang.annotation.ElementType.METHOD;
24 | import static java.lang.annotation.ElementType.PARAMETER;
25 |
26 | import java.lang.annotation.Retention;
27 | import java.lang.annotation.RetentionPolicy;
28 | import java.lang.annotation.Target;
29 |
30 | import jakarta.enterprise.util.Nonbinding;
31 | import jakarta.inject.Qualifier;
32 |
33 | /**
34 | * This qualifier indicates which channel should be injected / populated.
35 | *
36 | * This qualifier can be used to inject a Channel containing the items and signals propagated by the specified
37 | * channel. For example, it can be used to {@code @Inject} a {@code Publisher} representing a channel managed by the
38 | * Reactive Messaging implementation.
39 | *
40 | * Can be injected:
41 | *
42 | *
Publisher<X> with X the payload type
43 | *
Publisher<Message<X>> with X the payload type
44 | *
PublisherBuilder<Message<X>> with X the payload type
45 | *
PublisherBuilder<X> with X the payload type
46 | *
47 | *
48 | * When this qualifier is used on an {@link Emitter}, it indicates which channel will receive the emitted values /
49 | * signals:
50 | *
51 | *
59 | *
60 | * A subscriber for the above channel must be found when the application starts. Otherwise,
61 | * {@link jakarta.enterprise.inject.spi.DeploymentException} must be thrown.
62 | */
63 | @Qualifier
64 | @Retention(RetentionPolicy.RUNTIME)
65 | @Target({METHOD, CONSTRUCTOR, FIELD, PARAMETER})
66 | public @interface Channel {
67 |
68 | /**
69 | * The name of the channel (indicated in the {@code @Outgoing} annotation.
70 | *
71 | * @return the channel name, mandatory, non-{@code null} and non-blank. It must matches one of the available
72 | * channels.
73 | */
74 | @Nonbinding
75 | String value();
76 | }
77 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * The MicroProfile Reactive Messaging API.
22 | *
23 | * This API provides a mechanism for declaring managed streams. CDI managed beans may declare methods annotated with
24 | * {@link org.eclipse.microprofile.reactive.messaging.Incoming} and/or
25 | * {@link org.eclipse.microprofile.reactive.messaging.Outgoing} to declare a message subscriber, publisher or processor.
26 | *
27 | * The container is responsible for running, maintaining liveness, and stopping the message streams on context shutdown.
28 | * Containers should implement restarting in case a stream fails, with an appropriate backoff strategy in the event of
29 | * repeat failures.
30 | *
31 | * The application should use Reactive Streams to provide the message stream handlers. Generally, use of
32 | * {@code org.eclipse.microprofile.reactive.streams} builders should be used in preference to either Reactive Streams
33 | * interfaces directly, or container specific implementations of streams.
34 | *
35 | * Here is an example use of this API:
36 | *
37 | *
56 | */
57 |
58 | @org.osgi.annotation.versioning.Version("2.0")
59 | package org.eclipse.microprofile.reactive.messaging;
60 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/spi/Connector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.spi;
20 |
21 | import static java.lang.annotation.ElementType.FIELD;
22 | import static java.lang.annotation.ElementType.METHOD;
23 | import static java.lang.annotation.ElementType.PARAMETER;
24 | import static java.lang.annotation.ElementType.TYPE;
25 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
26 |
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.Target;
29 |
30 | import jakarta.inject.Qualifier;
31 |
32 | /**
33 | * Qualifier used on connector implementations to indicate the associated underlying transport.
34 | *
35 | * The value indicates the name associated with the bean implementing either {@link IncomingConnectorFactory} or
36 | * {@link OutgoingConnectorFactory} or both.
37 | *
38 | * Note that the given name is a user-facing interface used in the configuration.
39 | */
40 | @Qualifier
41 | @Retention(RUNTIME)
42 | @Target({TYPE, FIELD, METHOD, PARAMETER})
43 | public @interface Connector {
44 |
45 | /**
46 | * @return The name of the connector associated with the bean implementing {@link IncomingConnectorFactory} or
47 | * {@link OutgoingConnectorFactory}. Must not be {@code null}. Returning {@code null} will cause a
48 | * deployment failure.
49 | */
50 | String value();
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/spi/ConnectorAttributes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.spi;
20 |
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | /**
27 | * This class is used to allow multiple {@link ConnectorAttribute} declarations.
28 | *
29 | * This class should not be used directly. Instead, multiple {@link ConnectorAttribute} should be used on the class
30 | * annotated with {@link Connector}.
31 | */
32 | @Retention(RetentionPolicy.CLASS)
33 | @Target(ElementType.TYPE)
34 | public @interface ConnectorAttributes {
35 |
36 | /**
37 | * @return the array of {@link ConnectorAttribute}, must not contain {@code null}.
38 | */
39 | ConnectorAttribute[] value();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/spi/ConnectorFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.spi;
20 |
21 | /**
22 | * Parent class for {@link IncomingConnectorFactory} and {@link OutgoingConnectorFactory}.
23 | */
24 | public interface ConnectorFactory {
25 |
26 | /**
27 | * The {@code channel-name} attribute name.
28 | *
29 | * This attribute is injected by the reactive messaging implementation into the
30 | * {@link org.eclipse.microprofile.config.Config} object passed to the {@link IncomingConnectorFactory} and
31 | * {@link OutgoingConnectorFactory}. The value associated with this attribute is the name of the channel being
32 | * created.
33 | */
34 | String CHANNEL_NAME_ATTRIBUTE = "channel-name";
35 |
36 | /**
37 | * The {@code connector} attribute name.
38 | *
39 | * This attribute is part of the {@link org.eclipse.microprofile.config.Config} passed to the
40 | * {@link IncomingConnectorFactory} and {@link OutgoingConnectorFactory} when a new channel is created. It indicates
41 | * the name of the connector.
42 | *
43 | * Note that each channel configured from the MicroProfile Config support must provide this attribute to indicate
44 | * which connector is used. It must match the name given to the {@link Connector} qualifier.
45 | */
46 | String CONNECTOR_ATTRIBUTE = "connector";
47 |
48 | /**
49 | * Prefix used in the MicroProfile Config to configure an {@code incoming} channel.
50 | */
51 | String INCOMING_PREFIX = "mp.messaging.incoming.";
52 |
53 | /**
54 | * Prefix used in the MicroProfile Config to configure an {@code outgoing} channel.
55 | */
56 | String OUTGOING_PREFIX = "mp.messaging.outgoing.";
57 |
58 | /**
59 | * Prefix used in the MicroProfile Config to configure properties shared by all the channels associated with a
60 | * specific connector.
61 | */
62 | String CONNECTOR_PREFIX = "mp.messaging.connector.";
63 | }
64 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/spi/ConnectorLiteral.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.spi;
20 |
21 | import jakarta.enterprise.util.AnnotationLiteral;
22 |
23 | /**
24 | * Supports inline instantiation of the {@link Connector} qualifier.
25 | */
26 | public final class ConnectorLiteral extends AnnotationLiteral implements Connector {
27 |
28 | private static final long serialVersionUID = 1L;
29 |
30 | private final String value;
31 |
32 | /**
33 | * Creates a new instance of {@link ConnectorLiteral}.
34 | *
35 | * @param value
36 | * the name of the connector, must not be {@code null}, must not be {@code blank}
37 | * @return the {@link ConnectorLiteral} instance.
38 | */
39 | public static Connector of(String value) {
40 | return new ConnectorLiteral(value);
41 | }
42 |
43 | /**
44 | * Creates a new instance of {@link ConnectorLiteral}. Users should use the {@link #of(String)} method to create
45 | * instances.
46 | *
47 | * @param value
48 | * the value.
49 | */
50 | private ConnectorLiteral(String value) {
51 | this.value = value;
52 | }
53 |
54 | /**
55 | * @return the connector name.
56 | */
57 | public String value() {
58 | return value;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/api/src/main/java/org/eclipse/microprofile/reactive/messaging/spi/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * The MicroProfile Reactive Messaging API Connector SPI
22 | *
23 | * This package provides the SPI to implement {@code connectors}. A {@code connector} can be seen as a Reactive
24 | * Messaging plug-in to support a specific messaging technology. For example, you can have a Kafka connector to deal
25 | * with Kafka, an AMQP connector to interact with AMQP brokers and routers and so on. Connector implementation should be
26 | * agnostic to the Reactive Messaging implementation.
27 | *
28 | * A connector can be seen as:
29 | *
30 | *
a source of messages - it retrieves messages and injects them into the Reactive Messaging application. To manage
31 | * this direction, the connector implementation must implement the
32 | * {@link org.eclipse.microprofile.reactive.messaging.spi.IncomingConnectorFactory} interface.
33 | *
a sink of messages - it forwards messages emitted by the Reactive Messaging application to the managed
34 | * technology. To achieve this, the connector implementation must implement the
35 | * {@link org.eclipse.microprofile.reactive.messaging.spi.OutgoingConnectorFactory} interface.
36 | *
37 | *
38 | * Connectors are implemented as CDI beans and identified using the
39 | * {@link org.eclipse.microprofile.reactive.messaging.spi.Connector} qualifier. Connectors receive the channel
40 | * configuration matching their {@link org.eclipse.microprofile.reactive.messaging.spi.Connector} name.
41 | */
42 | @org.osgi.annotation.versioning.Version("2.0")
43 | package org.eclipse.microprofile.reactive.messaging.spi;
44 |
--------------------------------------------------------------------------------
/api/src/main/resources/NOTICE:
--------------------------------------------------------------------------------
1 | =========================================================================
2 | == NOTICE file corresponding to section 4(d) of the Apache License, ==
3 | == Version 2.0, in this case for Microprofile Reactive Streams ==
4 | =========================================================================
5 |
6 | This product includes software developed at
7 | The Apache Software Foundation (http://www.apache.org/).
8 |
9 | SPDXVersion: SPDX-2.1
10 | PackageName: Eclipse Microprofile
11 | PackageHomePage: http://www.eclipse.org/microprofile
12 | PackageLicenseDeclared: Apache-2.0
13 |
14 | PackageCopyrightText:
15 | James Roper james@jazzy.id.au
16 |
17 |
--------------------------------------------------------------------------------
/site.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | #
4 | # See the NOTICE file(s) distributed with this work for additional
5 | # information regarding copyright ownership.
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # You may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | %YAML 1.2
21 | ---
22 | documentation:
23 | - title: MicroProfile Messaging
24 | file: spec/src/main/asciidoc/microprofile-reactive-messaging-spec.asciidoc
25 |
26 | - title: Architecture
27 | file: spec/src/main/asciidoc/architecture.asciidoc
28 |
29 | - title: License
30 | file: spec/src/main/asciidoc/license-alv2.asciidoc
31 |
--------------------------------------------------------------------------------
/spec/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 | 4.0.0
24 |
25 |
26 | org.eclipse.microprofile.reactive.messaging
27 | microprofile-reactive-messaging-parent
28 | 3.1-SNAPSHOT
29 |
30 |
31 | microprofile-reactive-messaging-spec
32 | pom
33 | MicroProfile Reactive Messaging Specification
34 | MicroProfile Reactive Messaging :: Specification
35 |
36 |
37 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/images/overall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microprofile/microprofile-reactive-messaging/d02aad8712f5c6e5e87d548f1771392e2ce676ce/spec/src/main/asciidoc/images/overall.png
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/images/reactive-system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microprofile/microprofile-reactive-messaging/d02aad8712f5c6e5e87d548f1771392e2ce676ce/spec/src/main/asciidoc/images/reactive-system.png
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/license-alv2.asciidoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | [subs="normal"]
21 | ....
22 |
23 | Specification: {doctitle}
24 |
25 | Version: {revnumber}
26 |
27 | Status: {revremark}
28 |
29 | Release: {revdate}
30 |
31 | Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
32 |
33 | Licensed under the Apache License, Version 2.0 (the "License");
34 | you may not use this file except in compliance with the License.
35 | You may obtain a copy of the License at
36 |
37 | http://www.apache.org/licenses/LICENSE-2.0
38 |
39 | Unless required by applicable law or agreed to in writing, software
40 | distributed under the License is distributed on an "AS IS" BASIS,
41 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 | See the License for the specific language governing permissions and
43 | limitations under the License.
44 |
45 | ....
46 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/microprofile-reactive-messaging-spec.asciidoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | = MicroProfile Reactive Messaging Specification
21 | :authors: James Roper, Clement Escoffier, Gordon Hutchison, Emily Jiang
22 | :email: james@lightbend.com, clement.escoffier@redhat.com, gordon_hutchison@uk.ibm.com, emijiang@uk.ibm.com
23 | :version-label!:
24 | :sectanchors:
25 | :doctype: book
26 | :license: Eclipse Foundation Specification License v1.0
27 | :source-highlighter: coderay
28 | :toc: left
29 | :toclevels: 4
30 | :sectnumlevels: 4
31 | :imagesdir: images
32 | ifdef::backend-pdf[]
33 | :pagenums:
34 | endif::[]
35 | :icons: font
36 |
37 | == MicroProfile Reactive Messaging
38 |
39 | :sectnums!:
40 | include::license-efsl.adoc[]
41 | :sectnums:
42 |
43 | include::rationale.asciidoc[]
44 | include::architecture.asciidoc[]
45 |
46 | include::release_notes.asciidoc[]
47 |
--------------------------------------------------------------------------------
/tck/README.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2018 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | = MicroProfile Reactive Messaging TCK
21 |
22 | This project contains the TCK for Reactive Messaging
23 |
24 |
25 | == Checking an implementation against the TCK
26 |
27 | In your implementation, create a new module depending on the TCK artifact:
28 |
29 | [source,xml]
30 | ----
31 |
32 | org.eclipse.microprofile.reactive.messaging
33 | microprofile-reactive-messaging-tck
34 | ${microprofile-reactive-messaging.version}
35 |
36 | ----
37 |
38 | Your test project that runs the TCK is also very likely to depend on your implementation project.
39 |
40 | As the tests are implemented in the TCK artifacts, you need to configure your test run to scan the tests included
41 | in this artifact. With Maven it's done using the following plugin configuration:
42 |
43 | [source,xml]
44 | ----
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-surefire-plugin
50 | 2.22.1
51 |
52 | org.eclipse.microprofile.reactive.messaging:microprofile-reactive-messaging-tck
53 |
54 |
55 |
56 |
57 | ----
58 |
59 | Finally, because the tests are going to package the "checked" application against your extension, you need to implement
60 | the `org.eclipse.microprofile.reactive.messaging.tck.ArchiveExtender` SPI that lets you add the classes required by your
61 | implementation into the tested application.
62 |
63 | The SPI must be implemented in your project and declare in the
64 | `META-INF/services/org.eclipse.microprofile.reactive.messaging.tck.ArchiveExtender` file.
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/ArchiveExtender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
22 |
23 | public interface ArchiveExtender {
24 |
25 | void extend(JavaArchive archive);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/BeanWithChain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Incoming;
25 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
26 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
27 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
28 |
29 | import jakarta.enterprise.context.ApplicationScoped;
30 |
31 | @ApplicationScoped
32 | public class BeanWithChain {
33 |
34 | private List list = new CopyOnWriteArrayList<>();
35 |
36 | @Outgoing("source")
37 | public PublisherBuilder source() {
38 | return ReactiveStreams.of("hello", "with", "MicroProfile", "reactive", "messaging");
39 | }
40 |
41 | @Incoming("source")
42 | @Outgoing("processed-a")
43 | public String toUpperCase(String payload) {
44 | return payload.toUpperCase();
45 | }
46 |
47 | @Incoming("processed-a")
48 | @Outgoing("processed-b")
49 | public PublisherBuilder filter(PublisherBuilder input) {
50 | return input.filter(item -> item.length() > 4);
51 | }
52 |
53 | @Incoming("processed-b")
54 | public void sink(String word) {
55 | list.add(word);
56 | }
57 |
58 | public List list() {
59 | return list;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/ProcessorChainTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import java.util.ServiceLoader;
25 |
26 | import org.jboss.arquillian.container.test.api.Deployment;
27 | import org.jboss.arquillian.junit.Arquillian;
28 | import org.jboss.shrinkwrap.api.Archive;
29 | import org.jboss.shrinkwrap.api.ShrinkWrap;
30 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
31 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
32 | import org.junit.Test;
33 | import org.junit.runner.RunWith;
34 |
35 | import jakarta.inject.Inject;
36 |
37 | @RunWith(Arquillian.class)
38 | public class ProcessorChainTest {
39 |
40 | @Deployment
41 | public static Archive deployment() {
42 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
43 | .addClasses(BeanWithChain.class, ArchiveExtender.class)
44 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
45 |
46 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
47 | return archive;
48 | }
49 |
50 | @Inject
51 | private BeanWithChain bean;
52 |
53 | @Test
54 | public void test() {
55 | await().until(() -> bean.list().size() == 4);
56 | assertThat(bean.list()).containsExactly("HELLO", "MICROPROFILE", "REACTIVE", "MESSAGING");
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/SimpleIncomingBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 |
23 | import jakarta.enterprise.context.ApplicationScoped;
24 |
25 | @ApplicationScoped
26 | public class SimpleIncomingBean extends ValueCollector {
27 |
28 | @Incoming("strings")
29 | public void incoming(String s) {
30 | values.add(s);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/SimpleIncomingTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import java.util.ServiceLoader;
25 |
26 | import org.jboss.arquillian.container.test.api.Deployment;
27 | import org.jboss.arquillian.junit.Arquillian;
28 | import org.jboss.shrinkwrap.api.Archive;
29 | import org.jboss.shrinkwrap.api.ShrinkWrap;
30 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
31 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
32 | import org.junit.Test;
33 | import org.junit.runner.RunWith;
34 |
35 | import jakarta.inject.Inject;
36 |
37 | @RunWith(Arquillian.class)
38 | public class SimpleIncomingTest {
39 |
40 | @Deployment
41 | public static Archive deployment() {
42 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
43 | .addClasses(SimpleIncomingBean.class, ValueCollector.class, StringSource.class, ArchiveExtender.class)
44 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
45 |
46 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
47 | return archive;
48 | }
49 |
50 | @Inject
51 | private SimpleIncomingBean simple;
52 |
53 | @Test
54 | public void testReceptionWithValues() {
55 | await().until(() -> simple.getValues().size() == StringSource.VALUES.size());
56 | assertThat(simple.getValues()).containsExactlyElementsOf(StringSource.VALUES);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/StringSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import java.util.Arrays;
22 | import java.util.List;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
25 | import org.reactivestreams.Publisher;
26 |
27 | import io.reactivex.Flowable;
28 | import jakarta.enterprise.context.Dependent;
29 |
30 | @Dependent
31 | public class StringSource {
32 |
33 | public static final List VALUES = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "e", "j");
34 |
35 | @Outgoing("strings")
36 | public Publisher strings() {
37 | return Flowable.fromIterable(VALUES);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/TckBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import java.util.ServiceLoader;
22 | import java.util.concurrent.Executor;
23 | import java.util.concurrent.Executors;
24 |
25 | import org.jboss.arquillian.junit.Arquillian;
26 | import org.jboss.shrinkwrap.api.ShrinkWrap;
27 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
28 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
29 | import org.junit.runner.RunWith;
30 |
31 | @RunWith(Arquillian.class)
32 | public abstract class TckBase {
33 |
34 | public final static Executor EXECUTOR = Executors.newSingleThreadExecutor();
35 |
36 | public static JavaArchive getBaseArchive() {
37 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
38 | .addClasses(ArchiveExtender.class, TckBase.class)
39 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
40 |
41 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
42 |
43 | return archive;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/ValueCollector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | public class ValueCollector {
25 |
26 | protected List values = new CopyOnWriteArrayList<>();
27 |
28 | public List getValues() {
29 | return values;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/acknowledgement/EmitterBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.acknowledgement;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 | import jakarta.inject.Inject;
26 |
27 | @ApplicationScoped
28 | public class EmitterBean {
29 | @Inject
30 | @Channel("data")
31 | private Emitter emitter;
32 |
33 | public Emitter getEmitter() {
34 | return emitter;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanInjectedWithAPublisherBuilderOfMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.Channel;
24 | import org.eclipse.microprofile.reactive.messaging.Message;
25 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
26 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
27 |
28 | import io.reactivex.Flowable;
29 | import jakarta.enterprise.context.ApplicationScoped;
30 | import jakarta.inject.Inject;
31 |
32 | @ApplicationScoped
33 | public class BeanInjectedWithAPublisherBuilderOfMessages {
34 |
35 | private final PublisherBuilder> constructor;
36 | @Inject
37 | @Channel("hello")
38 | private PublisherBuilder> field;
39 |
40 | public BeanInjectedWithAPublisherBuilderOfMessages() {
41 | this.constructor = null;
42 | }
43 |
44 | @Inject
45 | public BeanInjectedWithAPublisherBuilderOfMessages(
46 | @Channel("bonjour") PublisherBuilder> constructor) {
47 | this.constructor = constructor;
48 | }
49 |
50 | public List consume() {
51 | return Flowable.fromPublisher(
52 | ReactiveStreams.concat(constructor, field).map(Message::getPayload).buildRs())
53 | .toList()
54 | .blockingGet();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanInjectedWithAPublisherBuilderOfPayloads.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.Channel;
24 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
25 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
26 |
27 | import io.reactivex.Flowable;
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class BeanInjectedWithAPublisherBuilderOfPayloads {
33 |
34 | private final PublisherBuilder constructor;
35 | @Inject
36 | @Channel("hello")
37 | private PublisherBuilder field;
38 |
39 | public BeanInjectedWithAPublisherBuilderOfPayloads() {
40 | this.constructor = null;
41 | }
42 |
43 | @Inject
44 | public BeanInjectedWithAPublisherBuilderOfPayloads(@Channel("bonjour") PublisherBuilder constructor) {
45 | this.constructor = constructor;
46 | }
47 |
48 | public List consume() {
49 | return Flowable.fromPublisher(
50 | ReactiveStreams.concat(constructor, field).buildRs())
51 | .toList()
52 | .blockingGet();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanInjectedWithAPublisherOfMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.Channel;
24 | import org.eclipse.microprofile.reactive.messaging.Message;
25 | import org.reactivestreams.Publisher;
26 |
27 | import io.reactivex.Flowable;
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class BeanInjectedWithAPublisherOfMessages {
33 |
34 | private final Publisher> constructor;
35 |
36 | @Inject
37 | @Channel("hello")
38 | private Publisher> field;
39 |
40 | public BeanInjectedWithAPublisherOfMessages() {
41 | this.constructor = null;
42 | }
43 |
44 | @Inject
45 | public BeanInjectedWithAPublisherOfMessages(@Channel("bonjour") Publisher> constructor) {
46 | this.constructor = constructor;
47 | }
48 |
49 | public List consume() {
50 | return Flowable
51 | .concat(
52 | Flowable.fromPublisher(constructor),
53 | Flowable.fromPublisher(field))
54 | .map(Message::getPayload)
55 | .toList()
56 | .blockingGet();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanInjectedWithAPublisherOfPayloads.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.Channel;
24 | import org.reactivestreams.Publisher;
25 |
26 | import io.reactivex.Flowable;
27 | import jakarta.enterprise.context.ApplicationScoped;
28 | import jakarta.inject.Inject;
29 |
30 | @ApplicationScoped
31 | public class BeanInjectedWithAPublisherOfPayloads {
32 |
33 | private final Publisher constructor;
34 | @Inject
35 | @Channel("hello")
36 | private Publisher field;
37 |
38 | public BeanInjectedWithAPublisherOfPayloads() {
39 | this.constructor = null;
40 | }
41 |
42 | @Inject
43 | public BeanInjectedWithAPublisherOfPayloads(@Channel("bonjour") Publisher constructor) {
44 | this.constructor = constructor;
45 | }
46 |
47 | public List consume() {
48 | return Flowable
49 | .concat(
50 | Flowable.fromPublisher(constructor),
51 | Flowable.fromPublisher(field))
52 | .toList()
53 | .blockingGet();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanInjectedWithDifferentFlavorsOfTheSameChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.LinkedHashMap;
22 | import java.util.Map;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Message;
26 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
27 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
28 | import org.reactivestreams.Publisher;
29 |
30 | import io.reactivex.Flowable;
31 | import jakarta.enterprise.context.ApplicationScoped;
32 | import jakarta.inject.Inject;
33 |
34 | @ApplicationScoped
35 | public class BeanInjectedWithDifferentFlavorsOfTheSameChannel {
36 |
37 | @Outgoing("hello-1")
38 | public Publisher hello1() {
39 | return Flowable.fromArray("h", "e", "l", "l", "o");
40 | }
41 |
42 | @Outgoing("hello-2")
43 | public Publisher hello2() {
44 | return Flowable.fromArray("h", "e", "l", "l", "o");
45 | }
46 |
47 | @Outgoing("hello-3")
48 | public Publisher hello3() {
49 | return Flowable.fromArray("h", "e", "l", "l", "o");
50 | }
51 |
52 | @Outgoing("hello-4")
53 | public Publisher hello4() {
54 | return Flowable.fromArray("h", "e", "l", "l", "o");
55 | }
56 |
57 | @Outgoing("hello-5")
58 | public Publisher hello5() {
59 | return Flowable.fromArray("h", "e", "l", "l", "o");
60 | }
61 |
62 | @Outgoing("hello-6")
63 | public Publisher hello6() {
64 | return Flowable.fromArray("h", "e", "l", "l", "o");
65 | }
66 |
67 | @Inject
68 | @Channel("hello-1")
69 | private Publisher> field1;
70 |
71 | @Inject
72 | @Channel("hello-2")
73 | private Publisher field2;
74 |
75 | @Inject
76 | @Channel("hello-3")
77 | private PublisherBuilder field3;
78 |
79 | @Inject
80 | @Channel("hello-4")
81 | private PublisherBuilder> field4;
82 |
83 | @Inject
84 | @Channel("hello-5")
85 | private PublisherBuilder field5;
86 |
87 | @Inject
88 | @Channel("hello-6")
89 | private Publisher field6;
90 |
91 | public Map consume() {
92 | Map map = new LinkedHashMap<>();
93 | map.put("1", field1.toString());
94 | map.put("2", field2.toString());
95 | map.put("3", field3.toString());
96 | map.put("4", field4.toString());
97 | map.put("5", field5.toString());
98 | map.put("6", field6.toString());
99 | return map;
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/BeanWithMissingChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 |
24 | import jakarta.enterprise.context.Dependent;
25 | import jakarta.inject.Inject;
26 |
27 | @Dependent
28 | public class BeanWithMissingChannel {
29 | @Inject
30 | @Channel("missing")
31 | private Emitter emitter;
32 |
33 | public Emitter emitter() {
34 | return emitter;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/ChannelInjectionDifferentFlavourSameChannelTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class ChannelInjectionDifferentFlavourSameChannelTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(BeanInjectedWithDifferentFlavorsOfTheSameChannel.class);
37 | }
38 |
39 | private @Inject BeanInjectedWithDifferentFlavorsOfTheSameChannel beanInjectedWithDifferentFlavorsOfTheSameChannel;
40 | @Test
41 | public void testMultipleFieldInjection() {
42 |
43 | assertThat(beanInjectedWithDifferentFlavorsOfTheSameChannel.consume()).hasSize(6);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/ChannelInjectionPublisherBuilderMessageTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class ChannelInjectionPublisherBuilderMessageTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(SourceBean.class, BeanInjectedWithAPublisherBuilderOfMessages.class);
37 | }
38 |
39 | private @Inject BeanInjectedWithAPublisherBuilderOfMessages beanInjectedWithAPublisherBuilderOfMessages;
40 |
41 | @Test
42 | public void testInjectionOfPublisherBuilderOfMessages() {
43 |
44 | assertThat(beanInjectedWithAPublisherBuilderOfMessages.consume()).containsExactlyInAnyOrder("B", "O", "N", "J",
45 | "O", "U", "R", "h", "e", "l", "l", "o");
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/ChannelInjectionPublisherBuilderPayloadTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class ChannelInjectionPublisherBuilderPayloadTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(SourceBean.class, BeanInjectedWithAPublisherBuilderOfPayloads.class);
37 | }
38 |
39 | private @Inject BeanInjectedWithAPublisherBuilderOfPayloads beanInjectedWithAPublisherBuilderOfPayloads;
40 |
41 | @Test
42 | public void testInjectionOfPublisherBuilderOfPayloads() {
43 |
44 | assertThat(beanInjectedWithAPublisherBuilderOfPayloads.consume()).containsExactlyInAnyOrder("B", "O", "N", "J",
45 | "O", "U", "R", "h", "e", "l", "l", "o");
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/ChannelInjectionPublisherPayloadTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class ChannelInjectionPublisherPayloadTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(SourceBean.class, BeanInjectedWithAPublisherOfPayloads.class);
37 | }
38 |
39 | private @Inject BeanInjectedWithAPublisherOfPayloads beanInjectedWithAPublisherOfPayloads;
40 | @Test
41 | public void testInjectionOfPublisherOfPayloads() {
42 |
43 | assertThat(beanInjectedWithAPublisherOfPayloads.consume()).containsExactlyInAnyOrder("B", "O", "N", "J", "O",
44 | "U", "R", "h", "e", "l", "l", "o");
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/ChannelInjectionPublisherTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class ChannelInjectionPublisherTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(SourceBean.class, BeanInjectedWithAPublisherOfMessages.class);
37 | }
38 |
39 | private @Inject BeanInjectedWithAPublisherOfMessages beanInjectedWithAPublisherOfMessages;
40 |
41 | @Test
42 | public void testInjectionOfPublisherOfMessages() {
43 |
44 | assertThat(beanInjectedWithAPublisherOfMessages.consume()).containsExactlyInAnyOrder("B", "O", "N", "J", "O",
45 | "U", "R", "h", "e", "l", "l", "o");
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterConnectedToProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
28 |
29 | import jakarta.enterprise.context.ApplicationScoped;
30 | import jakarta.inject.Inject;
31 |
32 | @ApplicationScoped
33 | public class EmitterConnectedToProcessor {
34 | @Inject
35 | @Channel("foo")
36 | private Emitter emitter;
37 | private final List list = new CopyOnWriteArrayList<>();
38 |
39 | public Emitter emitter() {
40 | return emitter;
41 | }
42 |
43 | public List list() {
44 | return list;
45 | }
46 |
47 | public void run() {
48 | emitter.send("a");
49 | emitter.send("b");
50 | emitter.send("c");
51 | emitter.complete();
52 | }
53 |
54 | @Incoming("foo")
55 | @Outgoing("bar")
56 | public String process(final String s) {
57 | return s.toUpperCase();
58 | }
59 |
60 | @Incoming("bar")
61 | public void consume(final String b) {
62 | list.add(b);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionAfterTerminatingWithErrorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionAfterTerminatingWithErrorTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyBeanEmittingDataAfterTerminationWithError.class);
37 | }
38 |
39 | private @Inject MyBeanEmittingDataAfterTerminationWithError myBeanEmittingDataAfterTerminationWithError;
40 | @Test
41 | public void testTerminationWithError() {
42 |
43 | myBeanEmittingDataAfterTerminationWithError.run();
44 | assertThat(myBeanEmittingDataAfterTerminationWithError.emitter()).isNotNull();
45 | assertThat(myBeanEmittingDataAfterTerminationWithError.list()).containsExactly("a", "b");
46 | assertThat(myBeanEmittingDataAfterTerminationWithError.emitter().isCancelled()).isTrue();
47 | assertThat(myBeanEmittingDataAfterTerminationWithError.emitter().hasRequests()).isFalse();
48 | assertThat(myBeanEmittingDataAfterTerminationWithError.isCaught()).isTrue();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionConnectedToProcessorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionConnectedToProcessorTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(EmitterConnectedToProcessor.class);
37 | }
38 |
39 | private @Inject EmitterConnectedToProcessor emitterConnectedToProcessor;
40 | @Test
41 | public void testWithProcessor() {
42 | emitterConnectedToProcessor.run();
43 | assertThat(emitterConnectedToProcessor.emitter()).isNotNull();
44 | assertThat(emitterConnectedToProcessor.list()).containsExactly("A", "B", "C");
45 | assertThat(emitterConnectedToProcessor.emitter().isCancelled()).isTrue();
46 | assertThat(emitterConnectedToProcessor.emitter().hasRequests()).isFalse();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionEmittingDataAfterTerminationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionEmittingDataAfterTerminationTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyBeanEmittingDataAfterTermination.class);
37 | }
38 |
39 | private @Inject MyBeanEmittingDataAfterTermination myBeanEmittingDataAfterTermination;
40 | @Test
41 | public void testTermination() {
42 | myBeanEmittingDataAfterTermination.run();
43 | assertThat(myBeanEmittingDataAfterTermination.emitter()).isNotNull();
44 | assertThat(myBeanEmittingDataAfterTermination.list()).containsExactly("a", "b");
45 | assertThat(myBeanEmittingDataAfterTermination.emitter().isCancelled()).isTrue();
46 | assertThat(myBeanEmittingDataAfterTermination.emitter().hasRequests()).isFalse();
47 | assertThat(myBeanEmittingDataAfterTermination.isCaught()).isTrue();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionEmittingMessageTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionEmittingMessageTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyBeanEmittingMessages.class);
37 | }
38 |
39 | private @Inject MyBeanEmittingMessages myBeanEmittingMessages;
40 | @Test
41 | public void testWithMessages() {
42 |
43 | myBeanEmittingMessages.run();
44 | assertThat(myBeanEmittingMessages.emitter()).isNotNull();
45 | assertThat(myBeanEmittingMessages.list()).containsExactly("a", "b", "c");
46 | assertThat(myBeanEmittingMessages.emitter().isCancelled()).isFalse();
47 | assertThat(myBeanEmittingMessages.emitter().hasRequests()).isTrue();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionEmittingNullTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionEmittingNullTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyBeanEmittingNull.class);
37 | }
38 |
39 | private @Inject MyBeanEmittingNull myBeanEmittingNull;
40 | @Test
41 | public void testWithNull() {
42 |
43 | myBeanEmittingNull.run();
44 | assertThat(myBeanEmittingNull.emitter()).isNotNull();
45 | assertThat(myBeanEmittingNull.list()).containsExactly("a", "b", "c");
46 | assertThat(myBeanEmittingNull.hasCaughtNullPayload()).isTrue();
47 | assertThat(myBeanEmittingNull.hasCaughtNullMessage()).isTrue();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionMessageBeanWithPayloadsWithAckTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionMessageBeanWithPayloadsWithAckTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyMessageBeanEmittingPayloadsWithAck.class, MyMessageBean.class);
37 | }
38 |
39 | private @Inject MyMessageBeanEmittingPayloadsWithAck myMessageBeanEmittingPayloadsWithAck;
40 | @Test
41 | public void testMyMessageBeanWithPayloadsAndAck() {
42 |
43 | myMessageBeanEmittingPayloadsWithAck.run();
44 | assertThat(myMessageBeanEmittingPayloadsWithAck.emitter()).isNotNull();
45 | assertThat(myMessageBeanEmittingPayloadsWithAck.list()).containsExactly("a", "b", "c");
46 | assertThat(myMessageBeanEmittingPayloadsWithAck.emitter().isCancelled()).isTrue();
47 | assertThat(myMessageBeanEmittingPayloadsWithAck.emitter().hasRequests()).isFalse();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionMissingChannelTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.ServiceLoader;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.ArchiveExtender;
24 | import org.jboss.arquillian.container.test.api.Deployer;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.arquillian.container.test.api.ShouldThrowException;
27 | import org.jboss.arquillian.junit.Arquillian;
28 | import org.jboss.arquillian.test.api.ArquillianResource;
29 | import org.jboss.shrinkwrap.api.Archive;
30 | import org.jboss.shrinkwrap.api.ShrinkWrap;
31 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
32 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
33 | import org.junit.Test;
34 | import org.junit.runner.RunWith;
35 |
36 | import jakarta.enterprise.inject.spi.DeploymentException;
37 |
38 | @RunWith(Arquillian.class)
39 | public class EmitterInjectionMissingChannelTest {
40 |
41 | @Deployment(managed = false, name = "missing-emitter")
42 | @ShouldThrowException(value = DeploymentException.class, testable = true)
43 | public static Archive deployment() {
44 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
45 | .addClasses(BeanWithMissingChannel.class, ArchiveExtender.class)
46 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
47 |
48 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
49 | return archive;
50 | }
51 |
52 | @ArquillianResource
53 | private Deployer deployer;
54 |
55 | @Test
56 | public void testMissingEmitter() {
57 | deployer.deploy("missing-emitter");
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionPayloadsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
24 | import org.jboss.arquillian.container.test.api.Deployment;
25 | import org.jboss.shrinkwrap.api.Archive;
26 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
27 | import org.junit.Test;
28 |
29 | import jakarta.inject.Inject;
30 |
31 | public class EmitterInjectionPayloadsTest extends TckBase {
32 |
33 | @Deployment
34 | public static Archive deployment() {
35 | return getBaseArchive()
36 | .addClasses(MyBeanEmittingPayloads.class);
37 | }
38 |
39 | private @Inject MyBeanEmittingPayloads myBeanEmittingPayloads;
40 | @Test
41 | public void testWithPayloads() {
42 |
43 | myBeanEmittingPayloads.run();
44 | assertThat(myBeanEmittingPayloads.emitter()).isNotNull();
45 | assertThat(myBeanEmittingPayloads.list()).containsExactly("a", "b", "c");
46 | assertThat(myBeanEmittingPayloads.emitter().isCancelled()).isTrue();
47 | assertThat(myBeanEmittingPayloads.emitter().hasRequests()).isFalse();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/EmitterInjectionPayloadsWithAckTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import java.util.List;
25 | import java.util.concurrent.CompletionStage;
26 |
27 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
28 | import org.jboss.arquillian.container.test.api.Deployment;
29 | import org.jboss.shrinkwrap.api.Archive;
30 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
31 | import org.junit.Test;
32 |
33 | import jakarta.inject.Inject;
34 |
35 | public class EmitterInjectionPayloadsWithAckTest extends TckBase {
36 |
37 | @Deployment
38 | public static Archive deployment() {
39 | return getBaseArchive()
40 | .addClasses(MyBeanEmittingPayloadsWithAck.class);
41 | }
42 |
43 | private @Inject MyBeanEmittingPayloadsWithAck myBeanEmittingPayloadsWithAck;
44 | @Test
45 | public void testWithPayloadsAndAck() {
46 |
47 | myBeanEmittingPayloadsWithAck.run();
48 | List> cs = myBeanEmittingPayloadsWithAck.getCompletionStage();
49 | assertThat(myBeanEmittingPayloadsWithAck.emitter()).isNotNull();
50 | assertThat(cs.get(0).toCompletableFuture().isDone()).isTrue();
51 | assertThat(cs.get(1).toCompletableFuture().isDone()).isTrue();
52 | assertThat(cs.get(2).toCompletableFuture().isDone()).isFalse();
53 | await().until(() -> myBeanEmittingPayloadsWithAck.list().size() == 3);
54 | assertThat(myBeanEmittingPayloadsWithAck.list()).containsExactly("a", "b", "c");
55 | assertThat(myBeanEmittingPayloadsWithAck.emitter().isCancelled()).isTrue();
56 | assertThat(myBeanEmittingPayloadsWithAck.emitter().hasRequests()).isFalse();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingDataAfterTermination.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 |
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class MyBeanEmittingDataAfterTermination {
33 | @Inject
34 | @Channel("foo")
35 | private Emitter emitter;
36 | private final List list = new CopyOnWriteArrayList<>();
37 | private boolean caught;
38 |
39 | public Emitter emitter() {
40 | return emitter;
41 | }
42 |
43 | boolean isCaught() {
44 | return caught;
45 | }
46 |
47 | public List list() {
48 | return list;
49 | }
50 |
51 | public void run() {
52 | emitter.send("a");
53 | emitter.send("b");
54 | emitter.complete();
55 | try {
56 | emitter.send("c");
57 | } catch (final IllegalStateException e) {
58 | caught = true;
59 | }
60 | }
61 |
62 | @Incoming("foo")
63 | public void consume(final String s) {
64 | list.add(s);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingDataAfterTerminationWithError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 |
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class MyBeanEmittingDataAfterTerminationWithError {
33 | @Inject
34 | @Channel("foo")
35 | private Emitter emitter;
36 | private final List list = new CopyOnWriteArrayList<>();
37 | private boolean caught;
38 |
39 | public Emitter emitter() {
40 | return emitter;
41 | }
42 |
43 | boolean isCaught() {
44 | return caught;
45 | }
46 |
47 | public List list() {
48 | return list;
49 | }
50 |
51 | public void run() {
52 | emitter.send("a");
53 | emitter.send("b");
54 | emitter.error(new Exception("BOOM"));
55 | try {
56 | emitter.send("c");
57 | } catch (final IllegalStateException e) {
58 | caught = true;
59 | }
60 | }
61 |
62 | @Incoming("foo")
63 | public void consume(final String s) {
64 | list.add(s);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 | import org.eclipse.microprofile.reactive.messaging.Message;
28 |
29 | import jakarta.enterprise.context.ApplicationScoped;
30 | import jakarta.inject.Inject;
31 |
32 | @ApplicationScoped
33 | public class MyBeanEmittingMessages {
34 | @Inject
35 | @Channel("foo")
36 | private Emitter emitter;
37 | private final List list = new CopyOnWriteArrayList<>();
38 |
39 | public Emitter emitter() {
40 | return emitter;
41 | }
42 |
43 | public List list() {
44 | return list;
45 | }
46 |
47 | public void run() {
48 | emitter.send(Message.of("a"));
49 | emitter.send(Message.of("b"));
50 | emitter.send(Message.of("c"));
51 |
52 | }
53 |
54 | @Incoming("foo")
55 | public void consume(final String s) {
56 | list.add(s);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingNull.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 | import org.eclipse.microprofile.reactive.messaging.Message;
28 |
29 | import jakarta.enterprise.context.ApplicationScoped;
30 | import jakarta.inject.Inject;
31 |
32 | @ApplicationScoped
33 | public class MyBeanEmittingNull {
34 | @Inject
35 | @Channel("foo")
36 | private Emitter emitter;
37 | private final List list = new CopyOnWriteArrayList<>();
38 | private boolean caughtNullPayload;
39 | private boolean caughtNullMessage;
40 |
41 | public Emitter emitter() {
42 | return emitter;
43 | }
44 |
45 | boolean hasCaughtNullPayload() {
46 | return caughtNullPayload;
47 | }
48 |
49 | boolean hasCaughtNullMessage() {
50 | return caughtNullMessage;
51 | }
52 |
53 | public List list() {
54 | return list;
55 | }
56 |
57 | public void run() {
58 | emitter.send("a");
59 | emitter.send("b");
60 | try {
61 | emitter.send((String) null);
62 | } catch (IllegalArgumentException e) {
63 | caughtNullPayload = true;
64 | }
65 |
66 | try {
67 | emitter.send((Message) null);
68 | } catch (IllegalArgumentException e) {
69 | caughtNullMessage = true;
70 | }
71 | emitter.send("c");
72 | emitter.complete();
73 | }
74 |
75 | @Incoming("foo")
76 | public void consume(final String s) {
77 | list.add(s);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingPayloads.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 |
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class MyBeanEmittingPayloads {
33 | @Inject
34 | @Channel("foo")
35 | private Emitter emitter;
36 | private final List list = new CopyOnWriteArrayList<>();
37 |
38 | public Emitter emitter() {
39 | return emitter;
40 | }
41 |
42 | public List list() {
43 | return list;
44 | }
45 |
46 | public void run() {
47 | emitter.send("a");
48 | emitter.send("b");
49 | emitter.send("c");
50 | emitter.complete();
51 | }
52 |
53 | @Incoming("foo")
54 | public void consume(final String s) {
55 | list.add(s);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyBeanEmittingPayloadsWithAck.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CompletableFuture;
23 | import java.util.concurrent.CompletionStage;
24 | import java.util.concurrent.CopyOnWriteArrayList;
25 |
26 | import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
27 | import org.eclipse.microprofile.reactive.messaging.Acknowledgment.Strategy;
28 | import org.eclipse.microprofile.reactive.messaging.Channel;
29 | import org.eclipse.microprofile.reactive.messaging.Emitter;
30 | import org.eclipse.microprofile.reactive.messaging.Incoming;
31 | import org.eclipse.microprofile.reactive.messaging.Message;
32 |
33 | import jakarta.enterprise.context.ApplicationScoped;
34 | import jakarta.inject.Inject;
35 |
36 | @ApplicationScoped
37 | public class MyBeanEmittingPayloadsWithAck {
38 | @Inject
39 | @Channel("foo")
40 | private Emitter emitter;
41 | private final List list = new CopyOnWriteArrayList<>();
42 |
43 | private final List> csList = new CopyOnWriteArrayList<>();
44 |
45 | public Emitter emitter() {
46 | return emitter;
47 | }
48 |
49 | public List list() {
50 | return list;
51 | }
52 |
53 | public void run() {
54 | csList.add(emitter.send("a"));
55 | csList.add(emitter.send("b"));
56 | csList.add(emitter.send("c"));
57 | emitter.complete();
58 | }
59 |
60 | List> getCompletionStage() {
61 | return csList;
62 | }
63 |
64 | @Incoming("foo")
65 | @Acknowledgment(Strategy.MANUAL)
66 | public CompletionStage consume(final Message s) {
67 | list.add(s.getPayload());
68 |
69 | if (!"c".equals(s.getPayload())) {
70 | return s.ack();
71 | } else {
72 | return new CompletableFuture<>();
73 |
74 | }
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyMessageBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Message;
22 |
23 | public class MyMessageBean implements Message {
24 |
25 | private final T payload;
26 |
27 | MyMessageBean(T payload) {
28 | this.payload = payload;
29 | }
30 |
31 | @Override
32 | public T getPayload() {
33 | return payload;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/MyMessageBeanEmittingPayloadsWithAck.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 |
28 | import jakarta.enterprise.context.ApplicationScoped;
29 | import jakarta.inject.Inject;
30 |
31 | @ApplicationScoped
32 | public class MyMessageBeanEmittingPayloadsWithAck {
33 | @Inject
34 | @Channel("foo")
35 | private Emitter emitter;
36 | private final List list = new CopyOnWriteArrayList<>();
37 |
38 | public Emitter emitter() {
39 | return emitter;
40 | }
41 |
42 | public List list() {
43 | return list;
44 | }
45 |
46 | public void run() {
47 | emitter.send(new MyMessageBean<>("a"));
48 | emitter.send(new MyMessageBean<>("b"));
49 | emitter.send(new MyMessageBean<>("c"));
50 | emitter.complete();
51 | }
52 |
53 | @Incoming("foo")
54 | public void consume(final String s) {
55 | list.add(s);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/SourceBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 | import org.eclipse.microprofile.reactive.streams.operators.ProcessorBuilder;
24 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
25 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
26 | import org.reactivestreams.Publisher;
27 |
28 | import io.reactivex.Flowable;
29 | import jakarta.enterprise.context.ApplicationScoped;
30 |
31 | @ApplicationScoped
32 | public class SourceBean {
33 |
34 | @Outgoing("hello")
35 | public Publisher hello() {
36 | return Flowable.fromArray("h", "e", "l", "l", "o");
37 | }
38 |
39 | @Outgoing("bonjour")
40 | @Incoming("raw")
41 | public ProcessorBuilder bonjour() {
42 | return ReactiveStreams.builder().map(String::toUpperCase);
43 | }
44 |
45 | @Outgoing("raw")
46 | public PublisherBuilder raw() {
47 | return ReactiveStreams.of("b", "o", "n", "j", "o", "u", "r");
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/BeanUsingBufferOverflowWithoutBufferSizeStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.Channel;
25 | import org.eclipse.microprofile.reactive.messaging.Emitter;
26 | import org.eclipse.microprofile.reactive.messaging.Incoming;
27 | import org.eclipse.microprofile.reactive.messaging.OnOverflow;
28 | import org.reactivestreams.Subscriber;
29 | import org.reactivestreams.Subscription;
30 |
31 | import jakarta.enterprise.context.ApplicationScoped;
32 | import jakarta.inject.Inject;
33 |
34 | @ApplicationScoped
35 | public class BeanUsingBufferOverflowWithoutBufferSizeStrategy {
36 |
37 | @Inject
38 | @Channel("hello")
39 | @OnOverflow(value = OnOverflow.Strategy.BUFFER)
40 | private Emitter emitter;
41 |
42 | private final List accepted = new CopyOnWriteArrayList<>();
43 | private final List rejected = new CopyOnWriteArrayList<>();
44 |
45 | private volatile Throwable downstreamFailure;
46 |
47 | public Throwable failure() {
48 | return downstreamFailure;
49 | }
50 |
51 | public List accepted() {
52 | return accepted;
53 | }
54 |
55 | public List rejected() {
56 | return rejected;
57 | }
58 |
59 | public void tryEmitThree() {
60 | for (int i = 0; i < 3; i++) {
61 | tryEmit(Integer.toString(i));
62 | }
63 | }
64 |
65 | public void tryEmitThousand() {
66 | for (int i = 0; i < 1000; i++) {
67 | tryEmit(Integer.toString(i));
68 | }
69 | }
70 |
71 | private void tryEmit(String item) {
72 | try {
73 | emitter.send(item);
74 | accepted.add(item);
75 | } catch (IllegalStateException e) {
76 | rejected.add(item);
77 | }
78 | }
79 |
80 | @Incoming("hello")
81 | public Subscriber consume() {
82 | // create a subscriber sitting there and doing nothing
83 | return new Subscriber() {
84 |
85 | @Override
86 | public void onSubscribe(Subscription s) {
87 |
88 | }
89 |
90 | @Override
91 | public void onNext(String t) {
92 |
93 | }
94 |
95 | @Override
96 | public void onError(Throwable t) {
97 | downstreamFailure = t;
98 | }
99 |
100 | @Override
101 | public void onComplete() {
102 |
103 | }
104 |
105 | };
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/BufferOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static java.util.stream.Collectors.toList;
22 | import static org.assertj.core.api.Assertions.assertThat;
23 | import static org.awaitility.Awaitility.await;
24 |
25 | import java.util.stream.IntStream;
26 |
27 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
28 | import org.jboss.arquillian.container.test.api.Deployment;
29 | import org.jboss.shrinkwrap.api.Archive;
30 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
31 | import org.junit.Test;
32 |
33 | import jakarta.inject.Inject;
34 |
35 | public class BufferOverflowStrategyOverflowTest extends TckBase {
36 |
37 | @Deployment
38 | public static Archive deployment() {
39 | return getBaseArchive()
40 | .addClasses(BeanUsingBufferOverflowStrategy.class);
41 | }
42 |
43 | @Inject
44 | private BeanUsingBufferOverflowStrategy bean;
45 |
46 | @Test
47 | public void testOverflow() {
48 |
49 | bean.tryEmitThousand();
50 |
51 | assertThat(bean.accepted().size() + bean.rejected().size()).isEqualTo(1000);
52 | assertThat(bean.rejected()).isNotEmpty();
53 |
54 | // Buffer size is 300, so first 300 items should always be accepted
55 | assertThat(bean.accepted()).containsAll(IntStream.range(0, 300).mapToObj(Integer::toString).collect(toList()));
56 |
57 | await().until(() -> bean.output().size() == bean.accepted().size());
58 | assertThat(bean.accepted()).containsExactlyElementsOf(bean.accepted());
59 | assertThat(bean.failure()).isNull();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/BufferOverflowStrategyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class BufferOverflowStrategyTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingBufferOverflowStrategy.class);
38 | }
39 |
40 | @Inject
41 | private BeanUsingBufferOverflowStrategy bean;
42 |
43 | @Test
44 | public void testNormal() {
45 |
46 | bean.tryEmitThree();
47 |
48 | assertThat(bean.accepted()).containsExactly("0", "1", "2");
49 | assertThat(bean.rejected()).isEmpty();
50 |
51 | await().until(() -> bean.output().size() == 3);
52 | assertThat(bean.output()).containsExactly("0", "1", "2");
53 | assertThat(bean.failure()).isNull();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/DefaultOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2022 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class DefaultOverflowStrategyOverflowTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingDefaultOverflow.class);
38 | }
39 |
40 | private @Inject BeanUsingDefaultOverflow bean;
41 |
42 | @Test
43 | public void testOverflow() {
44 |
45 | bean.emitALotOfItems();
46 |
47 | await().until(() -> bean.exception() != null);
48 | assertThat(bean.output()).doesNotContain("999");
49 | assertThat(bean.output()).hasSizeBetween(0, 256);
50 | assertThat(bean.exception()).isNotNull().isInstanceOf(Exception.class);
51 | assertThat(bean.failure()).isNull();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/DefaultOverflowStrategyOverflowWithoutBufferSizeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static java.util.stream.Collectors.toList;
22 | import static org.assertj.core.api.Assertions.assertThat;
23 |
24 | import java.util.stream.IntStream;
25 |
26 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
27 | import org.jboss.arquillian.container.test.api.Deployment;
28 | import org.jboss.shrinkwrap.api.Archive;
29 | import org.jboss.shrinkwrap.api.asset.StringAsset;
30 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
31 | import org.junit.Test;
32 |
33 | import jakarta.inject.Inject;
34 |
35 | public class DefaultOverflowStrategyOverflowWithoutBufferSizeTest extends TckBase {
36 |
37 | @Deployment
38 | public static Archive deployment() {
39 | return getBaseArchive()
40 | .addClasses(BeanUsingBufferOverflowWithoutBufferSizeStrategy.class)
41 | .addAsManifestResource(new StringAsset(
42 | "mp.messaging.emitter.default-buffer-size=5"),
43 | "microprofile-config.properties");
44 | }
45 |
46 | private @Inject BeanUsingBufferOverflowWithoutBufferSizeStrategy bean;
47 |
48 | @Test
49 | public void testOverflow() {
50 |
51 | bean.tryEmitThousand();
52 |
53 | assertThat(bean.accepted().size() + bean.rejected().size()).isEqualTo(1000);
54 | assertThat(bean.rejected()).isNotEmpty();
55 |
56 | // Buffer size is 5, so first 5 items should always be accepted
57 | assertThat(bean.accepted()).containsAll(IntStream.range(0, 5).mapToObj(Integer::toString).collect(toList()));
58 |
59 | // Later items should be rejected as the subscriber never requests any items
60 | // Allow a little leeway for buffering in the reactive streams implementation
61 | assertThat(bean.rejected()).containsAll(IntStream.range(7, 1000).mapToObj(Integer::toString).collect(toList()));
62 |
63 | assertThat(bean.failure()).isNull();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/DefaultOverflowStrategyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class DefaultOverflowStrategyTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingDefaultOverflow.class);
38 | }
39 |
40 | private @Inject BeanUsingDefaultOverflow bean;
41 |
42 | @Test
43 | public void testNormal() {
44 | bean.emitThree();
45 | await().until(() -> bean.output().size() == 3);
46 | assertThat(bean.output()).containsExactly("1", "2", "3");
47 | assertThat(bean.exception()).isNull();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/DropOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class DropOverflowStrategyOverflowTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingDropOverflowStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingDropOverflowStrategy bean;
41 |
42 | @Test
43 | public void testOverflow() {
44 |
45 | bean.emitALotOfItems();
46 | await().until(bean::isDone);
47 | assertThat(bean.output()).isNotEmpty().hasSizeLessThan(999);
48 | assertThat(bean.failure()).isNull();
49 | assertThat(bean.exception()).isNull();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/DropOverflowStrategyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class DropOverflowStrategyTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingDropOverflowStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingDropOverflowStrategy bean;
41 |
42 | @Test
43 | public void testNormal() {
44 |
45 | bean.emitThree();
46 | await().until(() -> bean.output().size() >= 1);
47 | assertThat(bean.output()).isNotEmpty().contains("1");
48 | assertThat(bean.exception()).isNull();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/FailOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class FailOverflowStrategyOverflowTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanWithFailOverflowStrategy.class);
38 | }
39 |
40 | private @Inject BeanWithFailOverflowStrategy bean;
41 |
42 | @Test
43 | public void testOverflow() {
44 | bean.emitALotOfItems();
45 |
46 | await().until(() -> bean.failure() != null);
47 | assertThat(bean.failure()).isInstanceOf(Exception.class);
48 | assertThat(bean.output()).doesNotContain("999");
49 | assertThat(bean.output()).hasSizeLessThan(999);
50 | assertThat(bean.exception()).isInstanceOf(IllegalStateException.class);
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/LatestOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class LatestOverflowStrategyOverflowTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingLatestOverflowStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingLatestOverflowStrategy bean;
41 |
42 | @Test
43 | public void testOverflow() {
44 | bean.emitALotOfItems();
45 | await().until(bean::isDone);
46 | await().until(() -> bean.output().contains("999"));
47 | assertThat(bean.output()).hasSizeLessThan(999);
48 | assertThat(bean.failure()).isNull();
49 | assertThat(bean.exception()).isNull();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/LatestOverflowStrategyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class LatestOverflowStrategyTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingLatestOverflowStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingLatestOverflowStrategy bean;
41 |
42 | @Test
43 | public void testNormal() {
44 |
45 | bean.emitThree();
46 |
47 | await().until(() -> bean.output().size() == 3);
48 | assertThat(bean.output()).containsExactly("1", "2", "3");
49 | assertThat(bean.exception()).isNull();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/ThrowExceptionOverflowStrategyOverflowTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2022 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class ThrowExceptionOverflowStrategyOverflowTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingThrowExceptionStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingThrowExceptionStrategy bean;
41 |
42 | @Test
43 | public void testOverflow() throws InterruptedException {
44 |
45 | bean.tryEmitTen();
46 |
47 | // Assert all items either accepted or rejected
48 | assertThat(bean.accepted().size() + bean.rejected().size()).isEqualTo(10);
49 | // At least the first item should have been accepted
50 | assertThat(bean.accepted()).contains("0");
51 | // But not everything should have been accepted
52 | assertThat(bean.rejected()).isNotEmpty();
53 |
54 | // Everything accepted should eventually be processed
55 | await().until(() -> bean.output().size() == bean.accepted().size());
56 | assertThat(bean.output()).containsExactlyElementsOf(bean.accepted());
57 | assertThat(bean.failure()).isNull();
58 |
59 | int acceptedFirstRun = bean.accepted().size();
60 | int rejectedFirstRun = bean.rejected().size();
61 |
62 | // Stream should still be running, so we should be able to test this again
63 | bean.tryEmitTen();
64 |
65 | await().until(() -> bean.accepted().size() + bean.rejected().size() == 20);
66 | assertThat(bean.accepted()).hasSizeGreaterThan(acceptedFirstRun);
67 | assertThat(bean.rejected()).hasSizeGreaterThan(rejectedFirstRun);
68 |
69 | await().until(() -> bean.output().size() == bean.accepted().size());
70 | assertThat(bean.output()).containsExactlyElementsOf(bean.accepted());
71 | assertThat(bean.failure()).isNull();
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/channel/overflow/ThrowExceptionOverflowStrategyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.channel.overflow;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class ThrowExceptionOverflowStrategyTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(BeanUsingThrowExceptionStrategy.class);
38 | }
39 |
40 | private @Inject BeanUsingThrowExceptionStrategy bean;
41 |
42 | @Test
43 | public void testNormal() {
44 |
45 | bean.tryEmitOne();
46 |
47 | await().until(() -> bean.output().size() == 1);
48 | assertThat(bean.accepted()).containsExactly("1");
49 | assertThat(bean.rejected()).isEmpty();
50 | assertThat(bean.output()).containsExactly("1");
51 | assertThat(bean.failure()).isNull();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/connector/ConnectorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.connector;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import java.util.ServiceLoader;
25 |
26 | import org.eclipse.microprofile.reactive.messaging.spi.ConnectorFactory;
27 | import org.eclipse.microprofile.reactive.messaging.spi.ConnectorLiteral;
28 | import org.eclipse.microprofile.reactive.messaging.tck.ArchiveExtender;
29 | import org.jboss.arquillian.container.test.api.Deployment;
30 | import org.jboss.arquillian.junit.Arquillian;
31 | import org.jboss.shrinkwrap.api.Archive;
32 | import org.jboss.shrinkwrap.api.ShrinkWrap;
33 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
34 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
35 | import org.junit.Test;
36 | import org.junit.runner.RunWith;
37 |
38 | import jakarta.enterprise.inject.spi.BeanManager;
39 | import jakarta.inject.Inject;
40 |
41 | /*
42 | * This test deploys a dummy connector to ensure that the implementation creates the instances.
43 | */
44 | @RunWith(Arquillian.class)
45 | public class ConnectorTest {
46 |
47 | @Inject
48 | private BeanManager manager;
49 |
50 | @Deployment
51 | public static Archive deployment() {
52 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
53 | .addClasses(DummyConnector.class, MyProcessor.class, ArchiveExtender.class)
54 | .addAsManifestResource(ConnectorTest.class.getResource("connector-config.properties"),
55 | "microprofile-config.properties")
56 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
57 |
58 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
59 | return archive;
60 | }
61 |
62 | @Test
63 | public void checkConnector() {
64 | DummyConnector connector = manager.createInstance()
65 | .select(DummyConnector.class, ConnectorLiteral.of("Dummy")).get();
66 | await().until(() -> connector.elements().size() == 10);
67 | assertThat(connector.elements()).containsExactly("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
68 |
69 | // We expect configurations for dummy-source and dummy-sink.
70 | assertThat(connector.getReceivedConfigurations()).hasSizeBetween(2, 3).allSatisfy(config -> {
71 | assertThat(config.getValue("common-A", String.class)).isEqualTo("Value-A");
72 | assertThat(config.getValue("common-B", String.class)).isEqualTo("Value-B");
73 | });
74 |
75 | assertThat(connector.getReceivedConfigurations())
76 | .extracting(c -> c.getValue(ConnectorFactory.CHANNEL_NAME_ATTRIBUTE, String.class))
77 | .contains("dummy-source", "dummy-sink");
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/connector/MyProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.connector;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 |
26 | @ApplicationScoped
27 | public class MyProcessor {
28 |
29 | @Incoming("dummy-source")
30 | @Outgoing("dummy-sink")
31 | public String process(String s) {
32 | return s.toUpperCase();
33 | }
34 |
35 | @Incoming("dummy-source-2")
36 | public void consume(String s) {
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/connector/MyProcessorWithBadStreamName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.connector;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 |
26 | @ApplicationScoped
27 | public class MyProcessorWithBadStreamName {
28 |
29 | @Incoming("bad name")
30 | @Outgoing("dummy-sink")
31 | public String process(String s) {
32 | return s.toUpperCase();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/extension/AssertJArchiveAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.extension;
20 |
21 | import org.jboss.arquillian.container.test.spi.client.deployment.CachedAuxilliaryArchiveAppender;
22 | import org.jboss.shrinkwrap.api.Archive;
23 | import org.jboss.shrinkwrap.api.ShrinkWrap;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 |
26 | public class AssertJArchiveAppender extends CachedAuxilliaryArchiveAppender {
27 |
28 | @Override
29 | protected Archive> buildArchive() {
30 | return ShrinkWrap.create(JavaArchive.class, "assertj.jar")
31 | .addPackages(true, "org.assertj.core");
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/extension/AwaitilityArchiveAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.extension;
20 |
21 | import org.jboss.arquillian.container.test.spi.client.deployment.CachedAuxilliaryArchiveAppender;
22 | import org.jboss.shrinkwrap.api.Archive;
23 | import org.jboss.shrinkwrap.api.ShrinkWrap;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 |
26 | public class AwaitilityArchiveAppender extends CachedAuxilliaryArchiveAppender {
27 |
28 | @Override
29 | protected Archive> buildArchive() {
30 | return ShrinkWrap.create(JavaArchive.class, "awatility.jar")
31 | .addPackages(true, "org.awaitility");
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/extension/ReactiveMessagingLoadableExtension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.extension;
20 |
21 | import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveAppender;
22 | import org.jboss.arquillian.core.spi.LoadableExtension;
23 |
24 | public class ReactiveMessagingLoadableExtension implements LoadableExtension {
25 |
26 | @Override
27 | public void register(ExtensionBuilder builder) {
28 | builder.service(AuxiliaryArchiveAppender.class, AwaitilityArchiveAppender.class)
29 | .service(AuxiliaryArchiveAppender.class, RxJavaArchiveAppender.class)
30 | .service(AuxiliaryArchiveAppender.class, AssertJArchiveAppender.class);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/extension/RxJavaArchiveAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.extension;
20 |
21 | import org.jboss.arquillian.container.test.spi.client.deployment.CachedAuxilliaryArchiveAppender;
22 | import org.jboss.shrinkwrap.api.Archive;
23 | import org.jboss.shrinkwrap.api.ShrinkWrap;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 |
26 | public class RxJavaArchiveAppender extends CachedAuxilliaryArchiveAppender {
27 |
28 | @Override
29 | protected Archive> buildArchive() {
30 | return ShrinkWrap.create(JavaArchive.class, "rxJava.jar")
31 | .addPackages(true, "io.reactivex");
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanConsumingManyTwice.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 |
23 | import jakarta.enterprise.context.ApplicationScoped;
24 |
25 | @ApplicationScoped
26 | public class BeanConsumingManyTwice {
27 |
28 | @Incoming("many")
29 | public void consume1(String s) {
30 |
31 | }
32 |
33 | @Incoming("many")
34 | public void consume2(String s) {
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanProducingManyTwice.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
24 |
25 | import jakarta.enterprise.context.ApplicationScoped;
26 | import jakarta.inject.Inject;
27 |
28 | @ApplicationScoped
29 | public class BeanProducingManyTwice {
30 |
31 | @Outgoing("many")
32 | public String generate() {
33 | return "Hello";
34 | }
35 |
36 | @SuppressWarnings("unused")
37 | private @Inject @Channel("many") Emitter emitter;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanWithBadOutgoingSignature.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
22 |
23 | import jakarta.enterprise.context.Dependent;
24 |
25 | @Dependent
26 | public class BeanWithBadOutgoingSignature {
27 |
28 | @Outgoing("foo")
29 | public void producer() {
30 | // Invalid
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanWithEmptyIncoming.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 |
23 | import jakarta.enterprise.context.Dependent;
24 |
25 | @Dependent
26 | public class BeanWithEmptyIncoming {
27 |
28 | @Incoming("")
29 | public void consumer(String data) {
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanWithEmptyOutgoing.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
22 |
23 | import jakarta.enterprise.context.Dependent;
24 |
25 | @Dependent
26 | public class BeanWithEmptyOutgoing {
27 |
28 | @Outgoing("")
29 | public String producer() {
30 | return "hello";
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/BeanWithIncompleteChain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 |
24 | import jakarta.enterprise.context.Dependent;
25 |
26 | @Dependent
27 | public class BeanWithIncompleteChain {
28 |
29 | @Incoming("missing")
30 | @Outgoing("data")
31 | public String process(String s) {
32 | return s;
33 | }
34 |
35 | @Incoming("data")
36 | public void sink(String s) {
37 | // Do nothing.
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ChannelMissingUpstream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.reactivestreams.Publisher;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 | import jakarta.inject.Inject;
26 |
27 | @ApplicationScoped
28 | public class ChannelMissingUpstream {
29 |
30 | @SuppressWarnings("unused")
31 | private @Inject @Channel("missing") Publisher missing;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ChannelMultipleUpstreams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
24 | import org.reactivestreams.Publisher;
25 |
26 | import jakarta.enterprise.context.ApplicationScoped;
27 | import jakarta.inject.Inject;
28 |
29 | @ApplicationScoped
30 | public class ChannelMultipleUpstreams {
31 |
32 | @SuppressWarnings("unused")
33 | private @Inject @Channel("many") Publisher many;
34 |
35 | @Outgoing("many")
36 | public String generate() {
37 | return "Hello";
38 | }
39 |
40 | @SuppressWarnings("unused")
41 | private @Inject @Channel("many") Emitter emitter;
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/EmitterMissingDownstream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 | import jakarta.inject.Inject;
26 |
27 | @ApplicationScoped
28 | public class EmitterMissingDownstream {
29 |
30 | @SuppressWarnings("unused")
31 | private @Inject @Channel("missing") Emitter missing;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/EmitterMultipleDownstreams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 | import org.eclipse.microprofile.reactive.messaging.Incoming;
24 |
25 | import jakarta.enterprise.context.ApplicationScoped;
26 | import jakarta.inject.Inject;
27 |
28 | @ApplicationScoped
29 | public class EmitterMultipleDownstreams {
30 |
31 | @SuppressWarnings("unused")
32 | private @Inject @Channel("many") Emitter many;
33 |
34 | @Incoming("many")
35 | public void consume1(String s) {
36 |
37 | }
38 |
39 | @Incoming("many")
40 | public void consume2(String s) {
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ProcessorMissingDownstream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 |
26 | @ApplicationScoped
27 | public class ProcessorMissingDownstream {
28 |
29 | @Incoming("in")
30 | @Outgoing("missing")
31 | public String consume(String x) {
32 | return x;
33 | }
34 |
35 | @Outgoing("in")
36 | public String generate() {
37 | return "Hello";
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ProcessorMissingUpstream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
23 |
24 | import jakarta.enterprise.context.ApplicationScoped;
25 |
26 | @ApplicationScoped
27 | public class ProcessorMissingUpstream {
28 |
29 | @Incoming("missing")
30 | @Outgoing("out")
31 | public String consume(String x) {
32 | return x;
33 | }
34 |
35 | @Incoming("out")
36 | public void sink(String s) {
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ProcessorMultipleDownstreams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Incoming;
23 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
24 | import org.reactivestreams.Publisher;
25 |
26 | import jakarta.enterprise.context.ApplicationScoped;
27 | import jakarta.inject.Inject;
28 |
29 | @ApplicationScoped
30 | public class ProcessorMultipleDownstreams {
31 |
32 | @Incoming("in")
33 | @Outgoing("many")
34 | public String consume(String x) {
35 | return x;
36 | }
37 |
38 | @SuppressWarnings("unused")
39 | private @Inject @Channel("many") Publisher many1;
40 |
41 | @Incoming("many")
42 | public void sink(String s) {
43 |
44 | }
45 |
46 | @Outgoing("in")
47 | public String generate() {
48 | return "Hello";
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/invalid/ProcessorMultipleUpstreams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Channel;
22 | import org.eclipse.microprofile.reactive.messaging.Emitter;
23 | import org.eclipse.microprofile.reactive.messaging.Incoming;
24 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
25 |
26 | import jakarta.enterprise.context.ApplicationScoped;
27 | import jakarta.inject.Inject;
28 |
29 | @ApplicationScoped
30 | public class ProcessorMultipleUpstreams {
31 |
32 | @Outgoing("many")
33 | public String generate() {
34 | return "Hello";
35 | }
36 |
37 | @SuppressWarnings("unused")
38 | private @Inject @Channel("many") Emitter emitter;
39 |
40 | @Incoming("many")
41 | @Outgoing("out")
42 | public String consume(String x) {
43 | return x;
44 | }
45 |
46 | @Incoming("out")
47 | public void sink(String s) {
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/metrics/ConfigAsset.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.metrics;
20 |
21 | import java.io.ByteArrayInputStream;
22 | import java.io.ByteArrayOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.util.Properties;
26 |
27 | import org.jboss.shrinkwrap.api.asset.Asset;
28 |
29 | public class ConfigAsset implements Asset {
30 |
31 | private Properties properties = new Properties();
32 |
33 | public ConfigAsset put(String key, String value) {
34 | properties.put(key, value);
35 | return this;
36 | }
37 |
38 | @Override
39 | public InputStream openStream() {
40 | try {
41 | ByteArrayOutputStream out = new ByteArrayOutputStream();
42 | properties.store(out, "Config generated with ConfigAsset");
43 | return new ByteArrayInputStream(out.toByteArray());
44 | } catch (IOException e) {
45 | throw new RuntimeException(e);
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/metrics/MetricsTestBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.metrics;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
26 | import org.eclipse.microprofile.reactive.messaging.Acknowledgment.Strategy;
27 | import org.eclipse.microprofile.reactive.messaging.Incoming;
28 | import org.eclipse.microprofile.reactive.messaging.Message;
29 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
30 | import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder;
31 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
32 |
33 | import jakarta.enterprise.context.ApplicationScoped;
34 |
35 | @ApplicationScoped
36 | public class MetricsTestBean {
37 |
38 | public static final String CONNECTOR_IN = "channel-connector-in";
39 | public static final String CONNECTOR_PROCESS = "channel-connector-process";
40 | public static final String CONNECTOR_OUT = "channel-connector-out";
41 |
42 | public static final String CHANNEL_APP_A = "channel-app-a";
43 | public static final String CHANNEL_APP_B = "channel-app-b";
44 |
45 | private AtomicInteger inAppMessagesReceived = new AtomicInteger(0);
46 |
47 | @Incoming(CONNECTOR_IN)
48 | @Outgoing(CONNECTOR_PROCESS)
49 | public String simpleMapping(String a) {
50 | return a + "-test";
51 | }
52 |
53 | @Incoming(CONNECTOR_PROCESS)
54 | @Outgoing(CONNECTOR_OUT)
55 | @Acknowledgment(Strategy.PRE_PROCESSING)
56 | public PublisherBuilder> split(Message a) {
57 | List> messages = new ArrayList<>();
58 | for (int i = 1; i <= 2; i++) {
59 | messages.add(Message.of(a.getPayload() + "-" + i));
60 | }
61 | return ReactiveStreams.fromIterable(messages);
62 | }
63 |
64 | @Outgoing(CHANNEL_APP_A)
65 | public PublisherBuilder produce() {
66 | return ReactiveStreams.of("test-a", "test-b", "test-c");
67 | }
68 |
69 | @Incoming(CHANNEL_APP_A)
70 | @Outgoing(CHANNEL_APP_B)
71 | public PublisherBuilder split(String input) {
72 | List messages = new ArrayList<>();
73 | for (int i = 1; i <= 2; i++) {
74 | messages.add(input + "-" + i);
75 | }
76 | return ReactiveStreams.fromIterable(messages);
77 | }
78 |
79 | @Incoming(CHANNEL_APP_B)
80 | public void receive(String input) {
81 | inAppMessagesReceived.incrementAndGet();
82 | }
83 |
84 | public int getInAppMessagesReceived() {
85 | return inAppMessagesReceived.get();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/scope/ApplicationBeans.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.scope;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | import org.eclipse.microprofile.reactive.messaging.Incoming;
26 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
27 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
28 | import org.reactivestreams.Publisher;
29 |
30 | import jakarta.annotation.PostConstruct;
31 | import jakarta.enterprise.context.ApplicationScoped;
32 |
33 | @ApplicationScoped
34 | public class ApplicationBeans {
35 |
36 | private static final AtomicInteger COUNTER = new AtomicInteger();
37 | private int id;
38 | private List list = new ArrayList<>();
39 | private static final List STATIC_LIST = new ArrayList<>();
40 |
41 | @PostConstruct
42 | private void init() {
43 | id = COUNTER.getAndIncrement();
44 | }
45 |
46 | @Outgoing("source")
47 | public Publisher source() {
48 | return ReactiveStreams.of(id).buildRs();
49 | }
50 |
51 | @Incoming("source")
52 | @Outgoing("output")
53 | public int process(int i) {
54 | return i + 1;
55 | }
56 |
57 | @Incoming("output")
58 | public void sink(int v) {
59 | list.add(v);
60 | STATIC_LIST.add(v);
61 | }
62 |
63 | public List getList() {
64 | return list;
65 | }
66 |
67 | public static List getStaticList() {
68 | return STATIC_LIST;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/scope/ApplicationScopeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.scope;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class ApplicationScopeTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(ApplicationBeans.class);
38 | }
39 |
40 | @Inject
41 | private ApplicationBeans bean;
42 |
43 | @Test
44 | public void verify() {
45 | await().until(() -> bean.getList().size() == 1);
46 | assertThat(bean.getList()).containsExactly(1);
47 | assertThat(ApplicationBeans.getStaticList()).containsExactly(1);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/scope/DependantBeans.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.scope;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | import org.eclipse.microprofile.reactive.messaging.Incoming;
26 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
27 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
28 | import org.reactivestreams.Publisher;
29 |
30 | import jakarta.enterprise.context.Dependent;
31 |
32 | @Dependent
33 | public class DependantBeans {
34 |
35 | private static final AtomicInteger COUNTER = new AtomicInteger();
36 | private final int id;
37 | private List list = new CopyOnWriteArrayList<>();
38 | private static final List INSTANCES = new CopyOnWriteArrayList<>();
39 |
40 | public DependantBeans() {
41 | INSTANCES.add(this.toString());
42 | id = COUNTER.getAndIncrement();
43 | }
44 |
45 | static List getInstances() {
46 | return INSTANCES;
47 | }
48 |
49 | @Outgoing("source")
50 | public Publisher source() {
51 | return ReactiveStreams.of(id).buildRs();
52 | }
53 |
54 | @Incoming("source")
55 | @Outgoing("output")
56 | public int process(int i) {
57 | return i + 1;
58 | }
59 |
60 | @Incoming("output")
61 | public void sink(int v) {
62 | list.add(v);
63 | }
64 |
65 | public List getList() {
66 | return list;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/scope/DependantScopeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.scope;
20 |
21 | import static org.assertj.core.api.Assertions.assertThat;
22 | import static org.awaitility.Awaitility.await;
23 |
24 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.shrinkwrap.api.Archive;
27 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
28 | import org.junit.Test;
29 |
30 | import jakarta.inject.Inject;
31 |
32 | public class DependantScopeTest extends TckBase {
33 |
34 | @Deployment
35 | public static Archive deployment() {
36 | return getBaseArchive()
37 | .addClasses(DependantBeans.class);
38 | }
39 |
40 | @Inject
41 | private DependantBeans bean;
42 |
43 | @Test
44 | public void verify() {
45 | // the injected instance, the source, the sink, the processor
46 | await().until(() -> DependantBeans.getInstances().size() == 4);
47 | assertThat(bean.getList()).isEmpty();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/invalid/IncomingReturningNonVoid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.invalid;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.Incoming;
22 | import org.eclipse.microprofile.reactive.messaging.Message;
23 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
24 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
25 | import org.reactivestreams.Publisher;
26 |
27 | import jakarta.enterprise.context.ApplicationScoped;
28 |
29 | @ApplicationScoped
30 | public class IncomingReturningNonVoid {
31 |
32 | @Outgoing("invalid")
33 | public Publisher> sourceForStringPayload() {
34 | return ReactiveStreams.of("a", "b", "c").map(Message::of).buildRs();
35 | }
36 |
37 | @Incoming("invalid")
38 | public String invalid(String payload) {
39 | return payload;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/invalid/IncomingReturningNonVoidCompletionStage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.invalid;
20 |
21 | import java.util.concurrent.CompletionStage;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.Incoming;
24 | import org.eclipse.microprofile.reactive.messaging.Message;
25 | import org.eclipse.microprofile.reactive.messaging.Outgoing;
26 | import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams;
27 | import org.reactivestreams.Publisher;
28 |
29 | import jakarta.enterprise.context.ApplicationScoped;
30 |
31 | @ApplicationScoped
32 | public class IncomingReturningNonVoidCompletionStage {
33 |
34 | @Outgoing("invalid")
35 | public Publisher> sourceForStringPayload() {
36 | return ReactiveStreams.of("a", "b", "c").map(Message::of).buildRs();
37 | }
38 |
39 | @Incoming("invalid")
40 | public CompletionStage invalid(Message m) {
41 | return m.ack().thenApply(x -> "foo");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/invalid/InvalidSubscriberSignatureTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.invalid;
20 |
21 | import java.util.ServiceLoader;
22 |
23 | import org.eclipse.microprofile.reactive.messaging.tck.ArchiveExtender;
24 | import org.jboss.arquillian.container.test.api.Deployer;
25 | import org.jboss.arquillian.container.test.api.Deployment;
26 | import org.jboss.arquillian.container.test.api.ShouldThrowException;
27 | import org.jboss.arquillian.junit.Arquillian;
28 | import org.jboss.arquillian.test.api.ArquillianResource;
29 | import org.jboss.shrinkwrap.api.Archive;
30 | import org.jboss.shrinkwrap.api.ShrinkWrap;
31 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
32 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
33 | import org.junit.Test;
34 | import org.junit.runner.RunWith;
35 |
36 | import jakarta.enterprise.inject.spi.DefinitionException;
37 |
38 | @RunWith(Arquillian.class)
39 | public class InvalidSubscriberSignatureTest {
40 |
41 | @ArquillianResource
42 | private Deployer deployer;
43 |
44 | @Deployment(managed = false, name = "incoming-returning-object")
45 | @ShouldThrowException(value = DefinitionException.class, testable = true)
46 | public static Archive incomingReturningNonVoid() {
47 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
48 | .addClasses(IncomingReturningNonVoid.class, ArchiveExtender.class)
49 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
50 |
51 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
52 | return archive;
53 | }
54 |
55 | @Test
56 | public void checkThatIncomingShouldNotReturnObject() {
57 | deployer.deploy("incoming-returning-object");
58 | }
59 |
60 | @Deployment(managed = false, name = "incoming-returning-non-void-cs")
61 | @ShouldThrowException(value = DefinitionException.class, testable = true)
62 | public static Archive incomingReturningNonVoidCompletionStage() {
63 | JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
64 | .addClasses(IncomingReturningNonVoidCompletionStage.class, ArchiveExtender.class)
65 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
66 |
67 | ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
68 | return archive;
69 | }
70 |
71 | @Test
72 | public void checkThatIncomingShouldNotReturnNonVoidCompletionStage() {
73 | deployer.deploy("incoming-returning-non-void-cs");
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/processors/ProcessorShapeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.processors;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
22 | import org.jboss.arquillian.container.test.api.Deployment;
23 | import org.jboss.shrinkwrap.api.Archive;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 | import org.junit.Test;
26 |
27 | import jakarta.inject.Inject;
28 |
29 | public class ProcessorShapeTest extends TckBase {
30 |
31 | @Deployment
32 | public static Archive deployment() {
33 | return getBaseArchive()
34 | .addClasses(ProcessorBean.class, PublisherBean.class, DirectProcessorBean.class, TransformerBean.class);
35 | }
36 |
37 | @Inject
38 | private ProcessorBean beanContainingMethodReturningProcessors;
39 |
40 | @Inject
41 | private PublisherBean beanContainingMethodReturningPublishers;
42 |
43 | @Inject
44 | private DirectProcessorBean beanManipulatingSingleElements;
45 |
46 | @Inject
47 | private TransformerBean beanTransformingStreams;
48 |
49 | @Test
50 | public void verifySignaturesReturningProcessors() {
51 | beanContainingMethodReturningProcessors.verify();
52 | }
53 |
54 | @Test
55 | public void verifySignaturesReturningPublishers() {
56 | beanContainingMethodReturningPublishers.verify();
57 | }
58 |
59 | @Test
60 | public void verifySignaturesConsumingSingleElement() {
61 | beanManipulatingSingleElements.verify();
62 | }
63 |
64 | @Test
65 | public void verifySignatureConsumingAndProducingStreams() {
66 | beanTransformingStreams.verify();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/publishers/PublisherShapeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.publishers;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
22 | import org.jboss.arquillian.container.test.api.Deployment;
23 | import org.jboss.shrinkwrap.api.Archive;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 | import org.junit.Test;
26 |
27 | import jakarta.inject.Inject;
28 |
29 | public class PublisherShapeTest extends TckBase {
30 |
31 | @Deployment
32 | public static Archive deployment() {
33 | return getBaseArchive()
34 | .addClasses(PublisherBean.class, VerifierForPublisherBean.class);
35 | }
36 |
37 | @Inject
38 | private VerifierForPublisherBean verifier;
39 |
40 | @Test
41 | public void verifyPublisherSignatures() {
42 | verifier.verify();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/signatures/subscribers/SubscriberShapeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * You may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package org.eclipse.microprofile.reactive.messaging.tck.signatures.subscribers;
20 |
21 | import org.eclipse.microprofile.reactive.messaging.tck.TckBase;
22 | import org.jboss.arquillian.container.test.api.Deployment;
23 | import org.jboss.shrinkwrap.api.Archive;
24 | import org.jboss.shrinkwrap.api.spec.JavaArchive;
25 | import org.junit.Test;
26 |
27 | import jakarta.inject.Inject;
28 |
29 | public class SubscriberShapeTest extends TckBase {
30 |
31 | @Deployment
32 | public static Archive deployment() {
33 | return getBaseArchive()
34 | .addClasses(SubscriberBean.class);
35 | }
36 |
37 | @Inject
38 | private SubscriberBean verifier;
39 |
40 | @Test
41 | public void verifySubscriberSignatures() {
42 | verifier.verify();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/tck/src/main/resources/META-INF/NOTICE:
--------------------------------------------------------------------------------
1 | =========================================================================
2 | == NOTICE file corresponding to section 4(d) of the Apache License, ==
3 | == Version 2.0, in this case for Microprofile Reactive Streams ==
4 | =========================================================================
5 |
6 | This product includes software developed at
7 | The Apache Software Foundation (http://www.apache.org/).
8 |
9 | SPDXVersion: SPDX-2.1
10 | PackageName: Eclipse Microprofile
11 | PackageHomePage: http://www.eclipse.org/microprofile
12 | PackageLicenseDeclared: Apache-2.0
13 |
14 | PackageCopyrightText:
15 | James Roper james@jazzy.id.au
16 |
17 |
--------------------------------------------------------------------------------
/tck/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension:
--------------------------------------------------------------------------------
1 | org.eclipse.microprofile.reactive.messaging.tck.extension.ReactiveMessagingLoadableExtension
--------------------------------------------------------------------------------
/tck/src/main/resources/META-INF/tck:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microprofile/microprofile-reactive-messaging/d02aad8712f5c6e5e87d548f1771392e2ce676ce/tck/src/main/resources/META-INF/tck
--------------------------------------------------------------------------------
/tck/src/main/resources/org/eclipse/microprofile/reactive/messaging/tck/connector/connector-config.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2018, 2019 Contributors to the Eclipse Foundation
3 | #
4 | # See the NOTICE file(s) distributed with this work for additional
5 | # information regarding copyright ownership.
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # You may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | mp.messaging.connector.Dummy.common-A=Value-A
21 | mp.messaging.connector.Dummy.common-B=Value-B
22 |
23 | mp.messaging.incoming.dummy-source.connector=Dummy
24 | mp.messaging.incoming.dummy-source.attribute=value
25 | mp.messaging.incoming.dummy-source.items=a,b,c,d,e,f,g,h,i,j
26 |
27 | mp.messaging.incoming.dummy-source-2.connector=Dummy
28 | mp.messaging.incoming.dummy-source-2.attribute=value-2
29 | mp.messaging.incoming.dummy-source-2.items=x,y,z
30 |
31 | mp.messaging.outgoing.dummy-sink.connector=Dummy
32 | mp.messaging.outgoing.dummy-sink.attribute=value
33 |
--------------------------------------------------------------------------------