├── .build ├── maven-ci-settings.xml └── render-documentation.sh ├── .github ├── dependabot.yml ├── project.yml └── workflows │ ├── build.yml │ ├── pre-release.yml │ ├── release.yml │ └── website.yml ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── .python-version ├── CODEOWNERS ├── CompatibilityReport.java ├── LICENSE ├── README.md ├── docs ├── api-translation.md ├── images │ ├── codegen.png │ └── redhat_reversed.svg ├── index.md ├── snippets │ └── hello.java └── using-vertx-expectations.md ├── mkdocs.yml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── pyproject.toml ├── uv.lock ├── vertx-mutiny-clients-bom └── pom.xml ├── vertx-mutiny-clients ├── .gitignore ├── pom.xml ├── vertx-mutiny-amqp-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── amqp │ │ └── AMQPClientTest.java ├── vertx-mutiny-auth-common │ └── pom.xml ├── vertx-mutiny-auth-htdigest │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── auth │ │ │ └── HtDigestAuthTest.java │ │ └── resources │ │ └── .htdigest ├── vertx-mutiny-auth-htpasswd │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── auth │ │ │ └── HtPasswordAuthTest.java │ │ └── resources │ │ └── .htpasswd ├── vertx-mutiny-auth-jdbc │ └── pom.xml ├── vertx-mutiny-auth-jwt │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── auth │ │ │ └── JwtAuthTest.java │ │ └── resources │ │ └── keystore.jceks ├── vertx-mutiny-auth-ldap │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── smallrye │ │ │ └── mutiny │ │ │ └── vertx │ │ │ └── auth │ │ │ └── LdapAuthTest.java │ │ └── resources │ │ └── ldap.ldif ├── vertx-mutiny-auth-mongo │ └── pom.xml ├── vertx-mutiny-auth-oauth2 │ └── pom.xml ├── vertx-mutiny-auth-otp │ └── pom.xml ├── vertx-mutiny-auth-properties │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── smallrye │ │ │ └── mutiny │ │ │ └── vertx │ │ │ └── auth │ │ │ └── PropertiesAuthTest.java │ │ └── resources │ │ └── test-auth.properties ├── vertx-mutiny-auth-shiro │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── smallrye │ │ │ └── mutiny │ │ │ └── vertx │ │ │ └── auth │ │ │ └── shiro │ │ │ └── ShiroTest.java │ │ └── resources │ │ └── test-auth.properties ├── vertx-mutiny-auth-sql-client │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── smallrye │ │ │ └── mutiny │ │ │ └── vertx │ │ │ └── auth │ │ │ └── AuthSqlClientTest.java │ │ └── resources │ │ └── mysql-auth-ddl-test.sql ├── vertx-mutiny-auth-webauthn │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── smallrye │ │ └── mutiny │ │ └── vertx │ │ └── auth │ │ ├── DummyStore.java │ │ └── WebAuthnTest.java ├── vertx-mutiny-bridge-common │ └── pom.xml ├── vertx-mutiny-camel-bridge │ └── pom.xml ├── vertx-mutiny-cassandra-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── cassandra │ │ └── CassandraClientTest.java ├── vertx-mutiny-circuit-breaker │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── circuitbreaker │ │ └── CircuitBreakerTest.java ├── vertx-mutiny-config │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── config │ │ │ └── ConfigTest.java │ │ └── resources │ │ └── my-config.json ├── vertx-mutiny-consul-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── consul │ │ └── ConsulClientTest.java ├── vertx-mutiny-core │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── smallrye │ │ │ └── mutiny │ │ │ └── vertx │ │ │ └── core │ │ │ ├── AbstractVerticle.java │ │ │ ├── ContextAwareExecutorWrapper.java │ │ │ ├── ContextAwareScheduler.java │ │ │ └── Expectations.java │ │ └── test │ │ └── java │ │ └── io │ │ ├── smallrye │ │ └── mutiny │ │ │ └── vertx │ │ │ └── core │ │ │ ├── ContextAwareSchedulerTest.java │ │ │ ├── ExpectationsTest.java │ │ │ └── verticle │ │ │ ├── AbstractVerticleTest.java │ │ │ ├── AsyncVerticle.java │ │ │ ├── SyncVerticle.java │ │ │ ├── VerticleFailingAsynchronously.java │ │ │ ├── VerticleFailingAsynchronouslyOnStop.java │ │ │ ├── VerticleFailingSynchronously.java │ │ │ └── VerticleFailingSynchronouslyOnStop.java │ │ └── vertx │ │ └── mutiny │ │ └── test │ │ ├── AsyncFileTest.java │ │ ├── BufferTest.java │ │ ├── CoreTest.java │ │ ├── EqualityTest.java │ │ ├── EventbusTest.java │ │ ├── ExecuteBlockingTest.java │ │ ├── RunOnContextTest.java │ │ ├── SomeCoreTest.java │ │ └── ToStringTest.java ├── vertx-mutiny-db2-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── db2 │ │ └── DB2ClientTest.java ├── vertx-mutiny-health-checks │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── web │ │ └── HealthCheckTest.java ├── vertx-mutiny-http-proxy │ └── pom.xml ├── vertx-mutiny-jdbc-client │ └── pom.xml ├── vertx-mutiny-json-schema │ └── pom.xml ├── vertx-mutiny-junit5 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── vertx │ │ │ │ └── mutiny │ │ │ │ └── junit5 │ │ │ │ └── VertxParameterProvider.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── io.vertx.junit5.VertxExtensionParameterProvider │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── junit5 │ │ └── VertxParameterProviderTest.java ├── vertx-mutiny-kafka-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── kafka │ │ └── KafkaClientTest.java ├── vertx-mutiny-mail-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── mail │ │ └── MailClientTest.java ├── vertx-mutiny-micrometer-metrics │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── micrometer │ │ └── MicrometerMetricsTest.java ├── vertx-mutiny-mongo-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── mongo │ │ └── MongoClientTest.java ├── vertx-mutiny-mqtt │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── mqtt │ │ │ ├── MqttClientTest.java │ │ │ └── MqttServerTest.java │ │ └── resources │ │ └── mosquitto.conf ├── vertx-mutiny-mssql-client │ └── pom.xml ├── vertx-mutiny-mysql-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── mysql │ │ ├── MySQLClientTest.java │ │ ├── MySqlInTransactionMultiTest.java │ │ ├── MySqlInTransactionUniTest.java │ │ └── MySqlUsingConnectionSafetyTest.java ├── vertx-mutiny-oracle-client │ └── pom.xml ├── vertx-mutiny-pg-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── postgresql │ │ ├── PGTestBase.java │ │ ├── PgInTransactionMultiTest.java │ │ ├── PgInTransactionUniTest.java │ │ ├── PgUsingConnectionSafetyTest.java │ │ └── PostGreSQLClientTest.java ├── vertx-mutiny-rabbitmq-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── rabbitmq │ │ └── RabbitMQClientTest.java ├── vertx-mutiny-redis-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── redis │ │ └── RedisClientTest.java ├── vertx-mutiny-runtime │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── smallrye │ │ └── mutiny │ │ └── vertx │ │ ├── AsyncResultUni.java │ │ ├── DelegatingConsumerHandler.java │ │ ├── DelegatingHandler.java │ │ ├── MultiHelper.java │ │ ├── MultiReadStream.java │ │ ├── MutinyDelegate.java │ │ ├── MutinyGen.java │ │ ├── MutinyHelper.java │ │ ├── ReadStreamSubscriber.java │ │ ├── TypeArg.java │ │ ├── UniHelper.java │ │ ├── WriteStreamSubscriber.java │ │ └── impl │ │ ├── MappingIterator.java │ │ └── WriteStreamSubscriberImpl.java ├── vertx-mutiny-service-discovery-backend-consul │ └── pom.xml ├── vertx-mutiny-service-discovery-backend-redis │ └── pom.xml ├── vertx-mutiny-service-discovery-backend-zookeeper │ └── pom.xml ├── vertx-mutiny-service-discovery-bridge-consul │ └── pom.xml ├── vertx-mutiny-service-discovery-bridge-docker-links │ └── pom.xml ├── vertx-mutiny-service-discovery-bridge-docker │ └── pom.xml ├── vertx-mutiny-service-discovery-bridge-kubernetes │ └── pom.xml ├── vertx-mutiny-service-discovery-bridge-zookeeper │ └── pom.xml ├── vertx-mutiny-service-discovery │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── discovery │ │ └── ServiceDiscoveryTest.java ├── vertx-mutiny-shell │ └── pom.xml ├── vertx-mutiny-sql-client-templates │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── circuitbreaker │ │ └── SqlClientTemplateTest.java ├── vertx-mutiny-sql-client │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── sqlclient │ │ │ └── SqlClientHelper.java │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── sqlclient │ │ ├── SqlClientHelperTestBase.java │ │ ├── TransactionMultiTest.java │ │ ├── TransactionUniTest.java │ │ └── UsingConnectionSafetyTest.java ├── vertx-mutiny-stomp │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── stomp │ │ └── StompTest.java ├── vertx-mutiny-tcp-eventbus-bridge │ └── pom.xml ├── vertx-mutiny-uri-template │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── uritemplate │ │ └── UriTemplateTest.java ├── vertx-mutiny-web-api-contract │ └── pom.xml ├── vertx-mutiny-web-api-service │ └── pom.xml ├── vertx-mutiny-web-client │ ├── pom.xml │ └── src │ │ └── test │ │ └── java │ │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── web │ │ ├── OtherWebClientTest.java │ │ ├── WebClientTest.java │ │ └── WineAndCheese.java ├── vertx-mutiny-web-common │ └── pom.xml ├── vertx-mutiny-web-cookie-session-store │ └── pom.xml ├── vertx-mutiny-web-graphql │ └── pom.xml ├── vertx-mutiny-web-infinispan-session-store │ └── pom.xml ├── vertx-mutiny-web-openapi │ └── pom.xml ├── vertx-mutiny-web-proxy │ └── pom.xml ├── vertx-mutiny-web-redis-session-store │ └── pom.xml ├── vertx-mutiny-web-templ-freemarker │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── FreemarkerTemplateTest.java │ │ └── resources │ │ └── template.ftl ├── vertx-mutiny-web-templ-handlebars │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── HandlebarsTemplateTest.java │ │ └── resources │ │ └── template.hbs ├── vertx-mutiny-web-templ-httl │ └── pom.xml ├── vertx-mutiny-web-templ-jade │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── JadeTemplateTest.java │ │ └── resources │ │ └── template.jade ├── vertx-mutiny-web-templ-mvel │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── MvelTemplateTest.java │ │ └── resources │ │ └── template.templ ├── vertx-mutiny-web-templ-pebble │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── PebbleTemplateTest.java │ │ └── resources │ │ └── template.peb ├── vertx-mutiny-web-templ-pug │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── PugTemplateTest.java │ │ └── resources │ │ └── template.pug ├── vertx-mutiny-web-templ-rocker │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── RockerTemplateTest.java │ │ └── resources │ │ └── templates │ │ └── MyTemplate.rocker.html ├── vertx-mutiny-web-templ-thymeleaf │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── vertx │ │ │ └── mutiny │ │ │ └── web │ │ │ └── ThymeleafTemplateTest.java │ │ └── resources │ │ └── template.html ├── vertx-mutiny-web-validation │ └── pom.xml └── vertx-mutiny-web │ ├── pom.xml │ └── src │ └── test │ ├── java │ └── io │ │ └── vertx │ │ └── mutiny │ │ └── web │ │ ├── RouterTest.java │ │ ├── TestRouteHandler.java │ │ ├── impl │ │ └── TestRouteHandlerImpl.java │ │ └── package-info.java │ └── resources │ └── assets │ └── test.txt └── vertx-mutiny-generator ├── pom.xml └── src ├── main ├── java │ └── io │ │ └── smallrye │ │ └── mutiny │ │ └── vertx │ │ └── codegen │ │ ├── MutinyGenerator.java │ │ ├── MutinyGeneratorLoader.java │ │ ├── lang │ │ ├── BufferRelatedMethodCodeWriter.java │ │ ├── ClassDeclarationCodeWriter.java │ │ ├── ClassJavadocCodeWriter.java │ │ ├── CodeGenHelper.java │ │ ├── CodeWriter.java │ │ ├── ConditionalCodeWriter.java │ │ ├── ConstantCodeWriter.java │ │ ├── ConstructorWithDelegateParameterCodeWriter.java │ │ ├── ConstructorWithGenericTypesCodeWriter.java │ │ ├── ConstructorWithObjectDelegateCodeWriter.java │ │ ├── ConsumerMethodCodeWriter.java │ │ ├── DelegateFieldCodeWriter.java │ │ ├── DelegateMethodDeclarationCodeWriter.java │ │ ├── FunctionApplyMethodCodeWriter.java │ │ ├── GetDelegateMethodCodeWriter.java │ │ ├── HashCodeAndEqualsMethodsCodeWriter.java │ │ ├── ImplClassCodeWriter.java │ │ ├── ImportDeclarationCodeWriter.java │ │ ├── IterableMethodCodeWriter.java │ │ ├── IteratorMethodsCodeWriter.java │ │ ├── MutinyGenAnnotationCodeWriter.java │ │ ├── NewInstanceMethodCodeWriter.java │ │ ├── NewInstanceWithGenericsMethodCodeWriter.java │ │ ├── NoArgConstructorCodeWriter.java │ │ ├── PackageDeclarationCodeWriter.java │ │ ├── ReadStreamMethodDeclarationCodeWriter.java │ │ ├── ToMultiMethodCodeWriter.java │ │ ├── ToStringMethodCodeWriter.java │ │ ├── ToSubscriberCodeWriter.java │ │ ├── TypeArgsConstantCodeWriter.java │ │ └── TypeHelper.java │ │ └── methods │ │ ├── AwaitMethodGenerator.java │ │ ├── ConsumerMethodGenerator.java │ │ ├── ForgetMethodGenerator.java │ │ ├── MutinyMethodDescriptor.java │ │ ├── MutinyMethodGenerator.java │ │ ├── SimpleMethodGenerator.java │ │ └── UniMethodGenerator.java └── resources │ └── META-INF │ └── services │ └── io.vertx.codegen.GeneratorLoader ├── tck └── java │ ├── META-INF │ ├── MANIFEST.MF │ └── vertx │ │ └── json-mappers.properties │ ├── com │ └── acme │ │ └── pkg │ │ ├── MyInterface.java │ │ ├── MyInterfaceImpl.java │ │ ├── package-info.java │ │ └── sub │ │ ├── SubInterface.java │ │ └── SubInterfaceImpl.java │ ├── io │ └── vertx │ │ ├── codegen │ │ └── testmodel │ │ │ ├── AbstractHandlerUserType.java │ │ │ ├── AnyJavaTypeTCK.java │ │ │ ├── AnyJavaTypeTCKImpl.java │ │ │ ├── CollectionTCK.java │ │ │ ├── CollectionTCKImpl.java │ │ │ ├── ConcreteHandlerUserType.java │ │ │ ├── ConcreteHandlerUserTypeExtension.java │ │ │ ├── ConstantTCK.java │ │ │ ├── DataObjectTCK.java │ │ │ ├── DataObjectTCKImpl.java │ │ │ ├── DataObjectWithBuffer.java │ │ │ ├── DataObjectWithListAdders.java │ │ │ ├── DataObjectWithLists.java │ │ │ ├── DataObjectWithMapAdders.java │ │ │ ├── DataObjectWithMaps.java │ │ │ ├── DataObjectWithNestedBuffer.java │ │ │ ├── DataObjectWithOnlyJsonObjectConstructor.java │ │ │ ├── DataObjectWithRecursion.java │ │ │ ├── DataObjectWithValues.java │ │ │ ├── DeprecatedType.java │ │ │ ├── Factory.java │ │ │ ├── FunctionParamTCK.java │ │ │ ├── FunctionParamTCKImpl.java │ │ │ ├── FutureTCK.java │ │ │ ├── GenericNullableRefedInterface.java │ │ │ ├── GenericRefedInterface.java │ │ │ ├── GenericRefedInterfaceImpl.java │ │ │ ├── GenericsTCK.java │ │ │ ├── GenericsTCKImpl.java │ │ │ ├── InterfaceWithApiArg.java │ │ │ ├── InterfaceWithStringArg.java │ │ │ ├── InterfaceWithVariableArg.java │ │ │ ├── JsonMapperTCK.java │ │ │ ├── JsonMapperTCKImpl.java │ │ │ ├── MyPojoToInteger.java │ │ │ ├── MyPojoToJsonArray.java │ │ │ ├── MyPojoToJsonObject.java │ │ │ ├── NullableTCK.java │ │ │ ├── NullableTCKImpl.java │ │ │ ├── RefedInterface1.java │ │ │ ├── RefedInterface1Impl.java │ │ │ ├── RefedInterface2.java │ │ │ ├── RefedInterface2Impl.java │ │ │ ├── SuperInterface1.java │ │ │ ├── SuperInterface2.java │ │ │ ├── TestCustomEnum.java │ │ │ ├── TestDataObject.java │ │ │ ├── TestEnum.java │ │ │ ├── TestGenEnum.java │ │ │ ├── TestInterface.java │ │ │ ├── TestInterfaceImpl.java │ │ │ ├── TestStringDataObject.java │ │ │ └── package-info.java │ │ └── core │ │ └── streams │ │ ├── Pipe.java │ │ ├── Pump.java │ │ ├── ReadStream.java │ │ ├── StreamBase.java │ │ ├── WriteStream.java │ │ └── package-info.java │ └── org │ └── extra │ ├── AnotherInterface.java │ ├── AnotherInterfaceImpl.java │ ├── Bar.java │ ├── ConcreteInheritsToString.java │ ├── ConcreteOverridesToString.java │ ├── ExtendsWithSameSimpleName.java │ ├── Foo.java │ ├── Generic1.java │ ├── Generic2.java │ ├── JavadocTest.java │ ├── MethodWithCompletable.java │ ├── MethodWithGenericFunctionArg.java │ ├── MethodWithMaybeString.java │ ├── MethodWithMultiCallback.java │ ├── MethodWithNullableTypeVariable.java │ ├── MethodWithNullableTypeVariableParamByVoidArg.java │ ├── MethodWithSingleString.java │ ├── NestedParameterizedType.java │ ├── NonConcreteWithToString.java │ ├── UseVertxGenDeclarationsFromAnotherPackage.java │ ├── UseVertxGenNameDeclarationsWithSameSimpleName.java │ ├── package-info.java │ └── sub │ ├── ExtendsWithSameSimpleName.java │ ├── SomeType.java │ └── UseVertxGenNameDeclarationsWithSameSimpleName.java └── test └── java └── tck ├── AnyJavaTypeTCKTest.java ├── ApiTest.java ├── AsyncResultAdapterTest.java ├── ConstantTCKTest.java ├── DeprecationTest.java ├── FakeWriteStream.java ├── GenericsTest.java ├── PublisherReadStreamAdapterBackPressureTest.java ├── ReadStreamAdapterBackPressureTest.java ├── ReadStreamAdapterTestBase.java ├── ReadStreamSubscriberTest.java ├── ReadStreamSubscriberTestBase.java ├── TestSubscriber.java └── TestUtils.java /.build/maven-ci-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | google-mirror 5 | 6 | true 7 | 8 | 9 | 10 | google-maven-central 11 | GCS Maven Central mirror EU 12 | https://maven-central.storage-download.googleapis.com/maven2/ 13 | 14 | true 15 | 16 | 17 | false 18 | 19 | 20 | 21 | 22 | 23 | google-maven-central 24 | GCS Maven Central mirror 25 | https://maven-central.storage-download.googleapis.com/maven2/ 26 | 27 | true 28 | 29 | 30 | false 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.build/render-documentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | mvn -s .build/maven-ci-settings.xml -f vertx-mutiny-clients/pom.xml -B pre-site 6 | cp -R vertx-mutiny-clients/target/reports/apidocs docs/ 7 | 8 | PROJECT_VERSION=$(cat .github/project.yml | yq eval '.release.current-version' -) 9 | uv sync --all-extras --dev 10 | uv run mkdocs build 11 | uv run mike deploy --push --update-aliases $PROJECT_VERSION latest 12 | uv run mike set-default --push latest -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | - package-ecosystem: github-actions 9 | directory: "/" 10 | schedule: 11 | interval: weekly -------------------------------------------------------------------------------- /.github/project.yml: -------------------------------------------------------------------------------- 1 | name: SmallRye Mutiny Vert.x Bindings 2 | release: 3 | current-version: 3.19.0 4 | next-version: 3.19.1-SNAPSHOT 5 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: SmallRye Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | - "1.x" 8 | - "2.x" 9 | paths-ignore: 10 | - '.gitignore' 11 | - 'CODEOWNERS' 12 | - 'LICENSE' 13 | - 'NOTICE' 14 | - 'README*' 15 | pull_request: 16 | paths-ignore: 17 | - '.gitignore' 18 | - 'CODEOWNERS' 19 | - 'LICENSE' 20 | - 'NOTICE' 21 | - 'README*' 22 | 23 | jobs: 24 | build: 25 | runs-on: ubuntu-latest 26 | strategy: 27 | matrix: 28 | java: [ 29 | { 'version': '17', 'opts': '' }, 30 | { 'version': '21', 'opts': '' }, 31 | { 'version': '23', 'opts': '' } 32 | ] 33 | name: build with jdk ${{matrix.java.version}} 34 | 35 | steps: 36 | - uses: actions/checkout@v4 37 | name: checkout 38 | - uses: actions/setup-java@v4 39 | name: set up jdk ${{matrix.java.version}} 40 | with: 41 | distribution: temurin 42 | java-version: ${{matrix.java.version}} 43 | cache: maven 44 | - name: validate format 45 | run: ./mvnw -s .build/maven-ci-settings.xml -f pom.xml -B -pl '!vertx-mutiny-clients-bom' ${{matrix.java.opts}} formatter:validate 46 | - name: build with maven 47 | run: ./mvnw -s .build/maven-ci-settings.xml -f pom.xml -B verify ${{matrix.java.opts}} 48 | -------------------------------------------------------------------------------- /.github/workflows/pre-release.yml: -------------------------------------------------------------------------------- 1 | name: SmallRye Prepare Release 2 | 3 | on: 4 | pull_request: 5 | types: [ closed ] 6 | paths: 7 | - '.github/project.yml' 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | prepare-release: 15 | name: Prepare Release 16 | if: ${{ github.event.pull_request.merged == true}} 17 | uses: smallrye/.github/.github/workflows/prepare-release.yml@main 18 | secrets: inherit -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: SmallRye Release 2 | run-name: Perform ${{github.event.inputs.tag || github.ref_name}} Release 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | workflow_dispatch: 8 | inputs: 9 | tag: 10 | description: 'Tag to release' 11 | required: true 12 | 13 | permissions: 14 | attestations: write 15 | id-token: write 16 | # Needed for the publish-* workflows 17 | contents: write 18 | 19 | concurrency: 20 | group: ${{ github.workflow }}-${{ github.ref }} 21 | cancel-in-progress: true 22 | 23 | jobs: 24 | perform-release: 25 | name: Perform Release 26 | uses: smallrye/.github/.github/workflows/perform-release.yml@main 27 | secrets: inherit 28 | with: 29 | version: ${{github.event.inputs.tag || github.ref_name}} 30 | -------------------------------------------------------------------------------- /.github/workflows/website.yml: -------------------------------------------------------------------------------- 1 | name: Publish the website 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - "!*" 7 | tags: 8 | - '[0-9]+.[0-9]+.[0-9]+' 9 | jobs: 10 | publish-website: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | name: Checkout code 15 | with: 16 | fetch-depth: 0 # fetch all commits and branches for mike to work properly 17 | - uses: actions/setup-java@v4 18 | name: Set up Java 17 19 | with: 20 | java-version: 17 21 | distribution: temurin 22 | cache: maven 23 | - name: Install uv 24 | uses: astral-sh/setup-uv@v6 25 | - uses: actions/setup-python@v5 26 | name: Set up Python 27 | with: 28 | python-version-file: "pyproject.toml" 29 | - name: Tools setup 30 | run: | 31 | git config --global user.name "SmallRye CI" 32 | git config --global user.email "smallrye@googlegroups.com" 33 | - name: Build local artifacts 34 | run: ./mvnw -s .build/maven-ci-settings.xml -B install -DskipTests 35 | - name: Render docs and publish 36 | run: .build/render-documentation.sh -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.log 3 | .vertx 4 | **/*.iml 5 | .idea 6 | .classpath 7 | .project 8 | .settings 9 | .vscode 10 | .cache 11 | .factorypath 12 | 13 | maven-settings.xml 14 | smallrye-sign.asc -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.13 -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | .github @smallrye/reactive-utils 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SmallRye Mutiny Vert.x Bindings 2 | 3 | [![Build Status](https://github.com/smallrye/smallrye-mutiny-vertx-bindings/workflows/SmallRye%20Build/badge.svg?branch=main)](https://github.com/smallrye/smallrye-mutiny-vertx-bindings/actions?query=workflow%3A%22SmallRye+Build%22) 4 | [![License](https://img.shields.io/github/license/smallrye/smallrye-fault-tolerance.svg)](http://www.apache.org/licenses/LICENSE-2.0) 5 | [![Maven](https://img.shields.io/maven-central/v/io.smallrye.reactive/smallrye-mutiny-vertx-bindings-projects?color=green)]() 6 | 7 | ## Vert.x Mutiny Clients 8 | 9 | [Mutiny](https://smallrye.io/smallrye-mutiny) is a novel approach to deal with Reactive APIs. 10 | The `vertx-mutiny-clients` module contains the Vert.x client API using the Mutiny model (`Uni` and `Multi`). 11 | 12 | It also contains the Vert.x code generator. 13 | 14 | ## Build 15 | 16 | `mvn clean install` 17 | 18 | ## Release 19 | 20 | - open a pull request updating the `.github/project.yml` file with the desired release version and next development version. 21 | - once the pull request is merged, the release will be cut (tag, deployment...) 22 | 23 | ## Compatibility Report 24 | 25 | To generate the compatibility report, you need: 26 | 27 | * jbang - https://github.com/jbangdev/jbang 28 | * asciidoctor - http://asciidoctor.org/ 29 | 30 | Generate the report with: 31 | 32 | ```bash 33 | mvn verify -DskipTests revapi:report@revapi-check -Prevapi -DskipTests -Dmaven.javadoc.skip=true -pl \!vertx-mutiny-clients-bom -pl \!vertx-mutiny-clients/vertx-mutiny-sql-client 34 | jbang CompatibilityReport.java && asciidoctor target/compatibility-report.adoc 35 | ``` 36 | 37 | The HTML report is available in `target/compatibility-report.html` 38 | 39 | -------------------------------------------------------------------------------- /docs/images/codegen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallrye/smallrye-mutiny-vertx-bindings/c2805025e641fabe7a1117db97f525344e51048f/docs/images/codegen.png -------------------------------------------------------------------------------- /docs/images/redhat_reversed.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/snippets/hello.java: -------------------------------------------------------------------------------- 1 | ///usr/bin/env jbang "$0" "$@" ; exit $? 2 | //DEPS io.smallrye.reactive:smallrye-mutiny-vertx-core:2.6.0 3 | 4 | import io.smallrye.mutiny.Uni; 5 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 6 | import io.vertx.core.DeploymentOptions; 7 | import io.vertx.mutiny.core.Vertx; 8 | 9 | public class hello { 10 | 11 | static class MyVerticle extends AbstractVerticle { 12 | 13 | private long counter = 0L; 14 | 15 | /* 16 | * Asynchronous start completion notification through a Uni. 17 | * This is the Mutiny variant of `start(Promise)` in plain Vert.x. 18 | */ 19 | @Override 20 | public Uni asyncStart() { 21 | 22 | /* 23 | * Vert.x stream (ticks every 2 seconds) to Mutiny stream (Multi), 24 | * then increment a counter. 25 | */ 26 | vertx.periodicStream(2000L) 27 | .toMulti() 28 | .subscribe().with(tick -> counter++); 29 | 30 | /* 31 | * HTTP endpoint, where `listen` returns a `Uni`. 32 | * Notifies of the start procedure completion by replacing and 33 | * returning the`Uni` by `Uni`. 34 | */ 35 | return vertx.createHttpServer() 36 | .requestHandler(req -> req.response().endAndForget("@" + counter)) 37 | .listen(8080) 38 | .onItem() 39 | .invoke(() -> System.out.println("See http://127.0.0.1:8080")) 40 | .onFailure() 41 | .invoke(Throwable::printStackTrace) 42 | .replaceWithVoid(); 43 | } 44 | } 45 | 46 | /* 47 | * Main method, deploys a verticle and awaits for the completion with 48 | * an `*AndAwait()` method. 49 | */ 50 | public static void main(String... args) { 51 | var vertx = Vertx.vertx(); 52 | System.out.println("Deployment Starting"); 53 | vertx.deployVerticleAndAwait(MyVerticle::new, new DeploymentOptions()); 54 | System.out.println("Deployment completed"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Smallrye Mutiny Vert.x bindings 2 | repo_url: https://github.com/smallrye/smallrye-mutiny-vertx-bindings 3 | edit_uri: edit/main/docs/ 4 | 5 | nav: 6 | - Overview: 'index.md' 7 | - API Translation: 'api-translation.md' 8 | - Javadoc: './apidocs/index.html' 9 | 10 | copyright: >- 11 | Sponsored by Red Hat
12 | CC by 3.0 | 13 | Privacy Policy 14 | 15 | theme: 16 | name: material 17 | palette: 18 | primary: deep purple 19 | accent: deep purple 20 | font: 21 | text: Red Hat Text 22 | code: Ubuntu Mono 23 | features: 24 | - navigation.sections 25 | 26 | markdown_extensions: 27 | - pymdownx.highlight 28 | - pymdownx.superfences 29 | - pymdownx.snippets 30 | - admonition 31 | 32 | extra: 33 | manifest: manifest.webmanifest 34 | version: 35 | provider: mike 36 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "mutiny-docs" 3 | version = "999" 4 | description = "Smallrye Mutiny Vert.x bindings Documentation powered by MkDocs" 5 | readme = "README.md" 6 | requires-python = ">=3.13" 7 | dependencies = [ 8 | "mkdocs-material>=9.5.48", 9 | "mkdocs>=1.6.1", 10 | "mkdocs-macros-plugin>=1.3.7", 11 | "mike>=2.1.3", 12 | ] -------------------------------------------------------------------------------- /vertx-mutiny-clients/.gitignore: -------------------------------------------------------------------------------- 1 | vertx-mutiny-generator/src/tck/java/io/vertx 2 | vertx-mutiny-generator/src/tck/java/com/acme/pkg 3 | vertx-mutiny-generator/src/tck/java/META-INF 4 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-htdigest/src/test/java/io/vertx/mutiny/auth/HtDigestAuthTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.auth; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import io.vertx.ext.auth.htdigest.HtdigestCredentials; 11 | import io.vertx.mutiny.core.Vertx; 12 | import io.vertx.mutiny.ext.auth.User; 13 | import io.vertx.mutiny.ext.auth.htdigest.HtdigestAuth; 14 | 15 | public class HtDigestAuthTest { 16 | 17 | private Vertx vertx; 18 | private HtdigestAuth authProvider; 19 | 20 | @Before 21 | public void setup() { 22 | vertx = Vertx.vertx(); 23 | authProvider = HtdigestAuth.create(vertx); 24 | } 25 | 26 | @After 27 | public void tearDown() { 28 | vertx.closeAndAwait(); 29 | } 30 | 31 | @Test 32 | public void testValidDigestWithQOP() { 33 | HtdigestCredentials authInfo = new HtdigestCredentials() 34 | .setMethod("GET") 35 | .setUsername("Mufasa") 36 | .setRealm("testrealm@host.com") 37 | .setNonce("dcd98b7102dd2f0e8b11d0f600bfb0c093") 38 | .setUri("/dir/index.html") 39 | .setQop("auth") 40 | .setNc("00000001") 41 | .setCnonce("0a4f113b") 42 | .setResponse("6629fae49393a05397450978507c4ef1"); 43 | 44 | User user = authProvider.authenticate(authInfo).await().indefinitely(); 45 | assertNotNull(user); 46 | assertEquals("Mufasa", user.principal().getString("username")); 47 | } 48 | 49 | @Test 50 | public void testValidDigestWithoutQOP() { 51 | HtdigestCredentials authInfo = new HtdigestCredentials() 52 | .setMethod("GET") 53 | .setUsername("Mufasa") 54 | .setRealm("testrealm@host.com") 55 | .setNonce("dcd98b7102dd2f0e8b11d0f600bfb0c093") 56 | .setUri("/dir/index.html") 57 | .setNc("00000001") 58 | .setCnonce("0a4f113b") 59 | .setResponse("670fd8c2df070c60b045671b8b24ff02"); 60 | 61 | User user = authProvider.authenticate(authInfo).await().indefinitely(); 62 | assertNotNull(user); 63 | assertNotNull(user); 64 | assertEquals("Mufasa", user.principal().getString("username")); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-htdigest/src/test/resources/.htdigest: -------------------------------------------------------------------------------- 1 | Mufasa:testrealm@host.com:939e7578ed9e3c518a452acee763bce9 2 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-htpasswd/src/test/resources/.htpasswd: -------------------------------------------------------------------------------- 1 | bcrypt:$2y$05$QwbS8vp1A/yQ1AlQ8ySDOuzONdR3U6A.xATjBHno/.nvp8O55eVaG 2 | md5:$apr1$V45rK4cb$O6ozhQ3JtwlH94GhuUKRD1 3 | sha1:{SHA}VBPuJHI7uixaa6LQGWx4s+5GKNE= 4 | crypt:0MJgtfTc6oYDE 5 | plaintext:myPassword -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-jwt/src/test/resources/keystore.jceks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallrye/smallrye-mutiny-vertx-bindings/c2805025e641fabe7a1117db97f525344e51048f/vertx-mutiny-clients/vertx-mutiny-auth-jwt/src/test/resources/keystore.jceks -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-ldap/src/test/resources/ldap.ldif: -------------------------------------------------------------------------------- 1 | version: 1 2 | dn: dc=myorg,dc=com 3 | objectClass: domain 4 | objectClass: top 5 | dc: myorg 6 | 7 | dn: ou=Users,dc=myorg,dc=com 8 | objectClass: organizationalUnit 9 | objectClass: top 10 | ou: Users 11 | 12 | dn: uid=tim,ou=Users,dc=myorg,dc=com 13 | objectClass: inetOrgPerson 14 | objectClass: organizationalPerson 15 | objectClass: person 16 | objectClass: top 17 | cn: Tim fox 18 | sn: Ldap 19 | uid: tim 20 | userPassword: sausages -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-properties/src/test/resources/test-auth.properties: -------------------------------------------------------------------------------- 1 | user.tim = sausages,morris_dancer,developer 2 | user.bob = socks,developer 3 | user.paulo = secret,administrator 4 | user.editor = secret,editor 5 | role.morris_dancer = bang_sticks 6 | role.manager=play_golf,say_buzzwords 7 | role.developer=do_actual_work 8 | role.administrator=* 9 | role.editor=newsletter:edit:* -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-shiro/src/test/java/io/smallrye/mutiny/vertx/auth/shiro/ShiroTest.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.auth.shiro; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.ext.auth.shiro.PropertiesProviderConstants; 11 | import io.vertx.ext.auth.shiro.ShiroAuthOptions; 12 | import io.vertx.ext.auth.shiro.ShiroAuthRealmType; 13 | import io.vertx.mutiny.core.Vertx; 14 | import io.vertx.mutiny.ext.auth.User; 15 | import io.vertx.mutiny.ext.auth.shiro.ShiroAuth; 16 | 17 | public class ShiroTest { 18 | 19 | private Vertx vertx; 20 | 21 | @Before 22 | public void setUp() { 23 | vertx = Vertx.vertx(); 24 | } 25 | 26 | @After 27 | public void tearDown() { 28 | vertx.closeAndAwait(); 29 | } 30 | 31 | @Test 32 | public void testAuthentication() { 33 | JsonObject config = new JsonObject(); 34 | config.put(PropertiesProviderConstants.PROPERTIES_PROPS_PATH_FIELD, "classpath:test-auth.properties"); 35 | ShiroAuth provider = ShiroAuth 36 | .create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(config)); 37 | 38 | JsonObject authInfo = new JsonObject().put("username", "tim").put("password", "sausages"); 39 | User user = provider.authenticate(authInfo).await().indefinitely(); 40 | 41 | assertNotNull(user); 42 | assertEquals(user.principal().getString("username"), "tim"); 43 | assertTrue(user.attributes().isEmpty()); 44 | 45 | authInfo = new JsonObject().put("username", "paulo").put("password", "secret"); 46 | user = provider.authenticate(authInfo).await().indefinitely(); 47 | assertNotNull(user); 48 | assertTrue(user.isAuthorized("do_actual_work").await().indefinitely()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-shiro/src/test/resources/test-auth.properties: -------------------------------------------------------------------------------- 1 | user.tim = sausages,morris_dancer,developer 2 | user.bob = socks,developer 3 | user.paulo = secret,administrator 4 | user.editor = secret,editor 5 | role.morris_dancer = bang_sticks 6 | role.manager=play_golf,say_buzzwords 7 | role.developer=do_actual_work 8 | role.administrator=* 9 | role.editor=newsletter:edit:* -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-sql-client/src/test/resources/mysql-auth-ddl-test.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `users` ( 2 | username VARCHAR(255) NOT NULL, 3 | password VARCHAR(255) NOT NULL 4 | ); 5 | 6 | CREATE TABLE `users_roles` ( 7 | username VARCHAR(255) NOT NULL, 8 | role VARCHAR(255) NOT NULL 9 | ); 10 | 11 | CREATE TABLE `roles_perms` ( 12 | role VARCHAR(255) NOT NULL, 13 | perm VARCHAR(255) NOT NULL 14 | ); 15 | 16 | ALTER TABLE `users` ADD CONSTRAINT pk_username PRIMARY KEY (username); 17 | ALTER TABLE `users_roles` ADD CONSTRAINT pk_users_roles PRIMARY KEY (username, role); 18 | ALTER TABLE `roles_perms` ADD CONSTRAINT pk_roles_perms PRIMARY KEY (role, perm); 19 | 20 | ALTER TABLE users_roles ADD CONSTRAINT fk_username FOREIGN KEY (username) REFERENCES users(username); 21 | 22 | -- Test data -- 23 | 24 | insert into users values ('lopus', '$pbkdf2$1drH02tXcgS5ipJIf8v/AlL/qm3CjAgAp7Qt3hyJx/c$/lONU4cTa3ayMRJbHIup47nX/1HhysyzDA0dpoFpsf727LoGH2OZ+SyFCGtv/pIEZK3mQtJv+yjzD+W0quF6xg'); 25 | 26 | insert into roles_perms values ('dev', 'commit_code'); 27 | insert into roles_perms values ('dev', 'eat_pizza'); 28 | insert into roles_perms values ('admin', 'merge_pr'); 29 | insert into users_roles values ('lopus', 'dev'); 30 | insert into users_roles values ('lopus', 'admin'); 31 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-auth-webauthn/src/test/java/io/smallrye/mutiny/vertx/auth/DummyStore.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.auth; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import io.smallrye.mutiny.Uni; 8 | import io.vertx.ext.auth.webauthn.Authenticator; 9 | 10 | public class DummyStore { 11 | 12 | private final List database = new ArrayList<>(); 13 | 14 | public DummyStore add(Authenticator authenticator) { 15 | this.database.add(authenticator); 16 | return this; 17 | } 18 | 19 | public void clear() { 20 | database.clear(); 21 | } 22 | 23 | public Uni> fetch(Authenticator query) { 24 | return Uni.createFrom().item( 25 | database.stream() 26 | .filter(entry -> { 27 | if (query.getUserName() != null) { 28 | return query.getUserName().equals(entry.getUserName()); 29 | } 30 | if (query.getCredID() != null) { 31 | return query.getCredID().equals(entry.getCredID()); 32 | } 33 | // This is a bad query! both username and credID are null 34 | return false; 35 | }) 36 | .collect(Collectors.toList())); 37 | } 38 | 39 | public Uni store(Authenticator authenticator) { 40 | 41 | long updated = database.stream() 42 | .filter(entry -> authenticator.getCredID().equals(entry.getCredID())) 43 | .peek(entry -> { 44 | // update existing counter 45 | entry.setCounter(authenticator.getCounter()); 46 | }).count(); 47 | 48 | if (updated > 0) { 49 | return Uni.createFrom().nullItem(); 50 | } else { 51 | database.add(authenticator); 52 | return Uni.createFrom().nullItem(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-cassandra-client/src/test/java/io/vertx/mutiny/cassandra/CassandraClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.cassandra; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | import org.testcontainers.containers.CassandraContainer; 10 | 11 | import io.vertx.cassandra.CassandraClientOptions; 12 | import io.vertx.mutiny.core.Vertx; 13 | 14 | public class CassandraClientTest { 15 | 16 | @Rule 17 | public CassandraContainer container = new CassandraContainer<>("cassandra:3.11") 18 | .withExposedPorts(9042); 19 | 20 | private Vertx vertx; 21 | 22 | @Before 23 | public void setUp() { 24 | vertx = Vertx.vertx(); 25 | assertThat(vertx).isNotNull(); 26 | } 27 | 28 | @After 29 | public void tearDown() { 30 | vertx.closeAndAwait(); 31 | } 32 | 33 | @Test 34 | public void testMutinyAPI() { 35 | CassandraClient client = CassandraClient.create(vertx, new CassandraClientOptions() 36 | .addContactPoint(container.getContainerIpAddress(), container.getMappedPort(9042))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-circuit-breaker/src/test/java/io/vertx/mutiny/circuitbreaker/CircuitBreakerTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.circuitbreaker; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.smallrye.mutiny.Uni; 10 | import io.vertx.circuitbreaker.CircuitBreakerOptions; 11 | import io.vertx.mutiny.core.Vertx; 12 | 13 | public class CircuitBreakerTest { 14 | 15 | private Vertx vertx; 16 | 17 | @Before 18 | public void setUp() { 19 | vertx = Vertx.vertx(); 20 | } 21 | 22 | @After 23 | public void tearDown() { 24 | vertx.closeAndAwait(); 25 | } 26 | 27 | @Test 28 | public void test() { 29 | CircuitBreaker cb = CircuitBreaker.create("my-circuit-breaker", vertx, 30 | new CircuitBreakerOptions().setFallbackOnFailure(true)); 31 | String result = cb.executeWithFallbackAndAwait(Uni.createFrom().item("ok"), e -> "nope"); 32 | assertThat(result).isEqualTo("ok"); 33 | result = cb.executeWithFallbackAndAwait(Uni.createFrom().failure(() -> new IllegalArgumentException("boom")), 34 | e -> "fallback"); 35 | assertThat(result).isEqualTo("fallback"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-config/src/test/java/io/vertx/mutiny/config/ConfigTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.config; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.config.ConfigRetrieverOptions; 10 | import io.vertx.config.ConfigStoreOptions; 11 | import io.vertx.core.json.JsonObject; 12 | import io.vertx.mutiny.core.Vertx; 13 | 14 | public class ConfigTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void test() { 30 | ConfigStoreOptions fileStore = new ConfigStoreOptions() 31 | .setType("file") 32 | .setConfig(new JsonObject().put("path", "my-config.json")); 33 | 34 | ConfigStoreOptions sysPropsStore = new ConfigStoreOptions().setType("sys"); 35 | ConfigRetriever retriever = ConfigRetriever.create(vertx, 36 | new ConfigRetrieverOptions().addStore(fileStore).addStore(sysPropsStore)); 37 | JsonObject config = retriever.getConfigAndAwait(); 38 | assertThat(config.getString("message")).isEqualTo("hello world!"); 39 | assertThat(config.getString("java.io.tmpdir")).isNotBlank(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-config/src/test/resources/my-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "hello world!" 3 | } -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-consul-client/src/test/java/io/vertx/mutiny/consul/ConsulClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.consul; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.UUID; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.testcontainers.containers.GenericContainer; 12 | 13 | import io.vertx.ext.consul.ConsulClientOptions; 14 | import io.vertx.ext.consul.KeyValue; 15 | import io.vertx.mutiny.core.Vertx; 16 | import io.vertx.mutiny.ext.consul.ConsulClient; 17 | 18 | public class ConsulClientTest { 19 | 20 | @Rule 21 | public GenericContainer container = new GenericContainer<>("consul:1.9") 22 | .withExposedPorts(8500); 23 | 24 | private Vertx vertx; 25 | 26 | @Before 27 | public void setUp() { 28 | vertx = Vertx.vertx(); 29 | assertThat(vertx).isNotNull(); 30 | } 31 | 32 | @After 33 | public void tearDown() { 34 | vertx.closeAndAwait(); 35 | } 36 | 37 | @Test 38 | public void testMutinyAPI() { 39 | ConsulClient client = ConsulClient.create(vertx, new ConsulClientOptions() 40 | .setHost(container.getContainerIpAddress()) 41 | .setPort(container.getMappedPort(8500))); 42 | 43 | String uuid = UUID.randomUUID().toString(); 44 | String stored = client.putValue("key", uuid) 45 | .onItem().transformToUni(x -> client.getValue("key")) 46 | .onItem().transform(KeyValue::getValue) 47 | .subscribeAsCompletionStage() 48 | .toCompletableFuture() 49 | .join(); 50 | assertThat(stored).isEqualTo(uuid); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/README.md: -------------------------------------------------------------------------------- 1 | # Mutiny - Vert.x Core API 2 | 3 | This project generates the Mutiny API for Vert.x Core. 4 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/AsyncVerticle.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import io.smallrye.mutiny.Uni; 8 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 9 | import io.vertx.mutiny.core.Vertx; 10 | 11 | public class AsyncVerticle extends AbstractVerticle { 12 | 13 | volatile static boolean DEPLOYED = false; 14 | 15 | @Override 16 | public Uni asyncStart() { 17 | assertThat(vertx).isNotNull().isInstanceOf(Vertx.class); 18 | return vertx.eventBus().consumer("foo") 19 | .handler(m -> { 20 | }) 21 | .completionHandler().onItem().invoke(x -> { 22 | DEPLOYED = true; 23 | }); 24 | } 25 | 26 | @Override 27 | public Uni asyncStop() { 28 | assertThat(vertx).isNotNull().isInstanceOf(Vertx.class); 29 | return Uni.createFrom().completionStage(() -> CompletableFuture.supplyAsync(() -> null)) 30 | .onItem().transform(x -> { 31 | DEPLOYED = false; 32 | return null; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/SyncVerticle.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 6 | import io.vertx.mutiny.core.Vertx; 7 | 8 | public class SyncVerticle extends AbstractVerticle { 9 | 10 | volatile static boolean DEPLOYED = false; 11 | 12 | @Override 13 | public void start() { 14 | assertThat(vertx).isNotNull().isInstanceOf(Vertx.class); 15 | DEPLOYED = true; 16 | } 17 | 18 | @Override 19 | public void stop() { 20 | assertThat(vertx).isNotNull().isInstanceOf(Vertx.class); 21 | DEPLOYED = false; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/VerticleFailingAsynchronously.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | import io.smallrye.mutiny.Uni; 6 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 7 | 8 | public class VerticleFailingAsynchronously extends AbstractVerticle { 9 | 10 | @Override 11 | public Uni asyncStart() { 12 | return Uni.createFrom().completionStage(() -> CompletableFuture.supplyAsync(() -> { 13 | throw new NullPointerException("boom"); 14 | })); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/VerticleFailingAsynchronouslyOnStop.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | import io.smallrye.mutiny.Uni; 6 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 7 | 8 | public class VerticleFailingAsynchronouslyOnStop extends AbstractVerticle { 9 | 10 | @Override 11 | public Uni asyncStop() { 12 | return Uni.createFrom().completionStage(() -> CompletableFuture.supplyAsync(() -> { 13 | throw new NullPointerException("boom"); 14 | })); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/VerticleFailingSynchronously.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import io.smallrye.mutiny.Uni; 4 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 5 | 6 | public class VerticleFailingSynchronously extends AbstractVerticle { 7 | 8 | @Override 9 | public Uni asyncStart() { 10 | throw new NullPointerException("boom"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/smallrye/mutiny/vertx/core/verticle/VerticleFailingSynchronouslyOnStop.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.core.verticle; 2 | 3 | import io.smallrye.mutiny.Uni; 4 | import io.smallrye.mutiny.vertx.core.AbstractVerticle; 5 | 6 | public class VerticleFailingSynchronouslyOnStop extends AbstractVerticle { 7 | 8 | @Override 9 | public Uni asyncStop() { 10 | throw new NullPointerException("boom"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/vertx/mutiny/test/AsyncFileTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.test; 2 | 3 | import static java.util.stream.Collectors.toList; 4 | 5 | import java.io.File; 6 | import java.time.Duration; 7 | import java.util.List; 8 | import java.util.function.BiFunction; 9 | import java.util.stream.IntStream; 10 | 11 | import org.junit.Test; 12 | 13 | import io.smallrye.mutiny.Multi; 14 | import io.smallrye.mutiny.Uni; 15 | import io.vertx.core.file.OpenOptions; 16 | import io.vertx.mutiny.core.Vertx; 17 | import io.vertx.mutiny.core.buffer.Buffer; 18 | import io.vertx.mutiny.core.file.AsyncFile; 19 | import io.vertx.test.core.Repeat; 20 | import io.vertx.test.core.TestUtils; 21 | import io.vertx.test.core.VertxTestBase; 22 | 23 | public class AsyncFileTest extends VertxTestBase { 24 | 25 | private Vertx vertx; 26 | 27 | @Override 28 | public void setUp() throws Exception { 29 | super.setUp(); 30 | vertx = new Vertx(super.vertx); 31 | } 32 | 33 | @Test 34 | @Repeat(times = 100) 35 | public void multiToAsyncFile() throws Exception { 36 | sourceToAsyncFile((chunks, asyncFile) -> chunks.onItem().call(asyncFile::write) 37 | .onItem().ignoreAsUni()); 38 | } 39 | 40 | private void sourceToAsyncFile(BiFunction, AsyncFile, Uni> func) throws Exception { 41 | File file = TestUtils.tmpFile("txt"); 42 | assertTrue(!file.exists() || file.delete()); 43 | 44 | List bytes = IntStream.range(0, 128 * 1024).boxed() 45 | .map(step -> (byte) TestUtils.randomChar()) 46 | .collect(toList()); 47 | 48 | Multi flow = Multi.createFrom().iterable(bytes) 49 | .group().intoLists().of(256) 50 | .onItem().transform(ba -> { 51 | Buffer buffer = Buffer.buffer(); 52 | ba.forEach(buffer::appendByte); 53 | return buffer; 54 | }); 55 | 56 | Uni writeToFile = vertx.fileSystem().open(file.toString(), new OpenOptions().setWrite(true)) 57 | .onItem().transformToUni(asyncFile -> func.apply(flow, asyncFile)); 58 | 59 | Buffer buffer = writeToFile.chain(x -> vertx.fileSystem().readFile(file.toString())) 60 | .await().atMost(Duration.ofMinutes(1)); 61 | 62 | assertEquals(buffer, bytes.stream().collect(Buffer::buffer, Buffer::appendByte, Buffer::appendBuffer)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/vertx/mutiny/test/BufferTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.test; 2 | 3 | import static junit.framework.TestCase.assertEquals; 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; 10 | 11 | import io.vertx.core.buffer.Buffer; 12 | 13 | /** 14 | * @author Julien Viet 15 | */ 16 | public class BufferTest { 17 | 18 | ObjectMapper mapper; 19 | 20 | @Before 21 | public void setUp() { 22 | mapper = new ObjectMapper(new YAMLFactory()); 23 | } 24 | 25 | @Test 26 | public void testClusterSerializable() { 27 | io.vertx.mutiny.core.buffer.Buffer buff = io.vertx.mutiny.core.buffer.Buffer.buffer("hello-world"); 28 | Buffer actual = Buffer.buffer(); 29 | buff.writeToBuffer(actual); 30 | Buffer expected = Buffer.buffer(); 31 | Buffer.buffer("hello-world").writeToBuffer(expected); 32 | assertEquals(expected, actual); 33 | buff = io.vertx.mutiny.core.buffer.Buffer.buffer("hello-world"); 34 | assertEquals(expected.length(), buff.readFromBuffer(0, expected)); 35 | assertEquals("hello-world", buff.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/vertx/mutiny/test/EqualityTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.test; 2 | 3 | import static java.util.stream.Collectors.toSet; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.junit.Assert.assertNotSame; 6 | 7 | import java.util.stream.Stream; 8 | 9 | import org.junit.Test; 10 | 11 | import io.vertx.core.net.impl.SocketAddressImpl; 12 | import io.vertx.mutiny.core.buffer.Buffer; 13 | import io.vertx.mutiny.core.net.SocketAddress; 14 | 15 | /** 16 | * @author Thomas Segismont 17 | */ 18 | public class EqualityTest { 19 | 20 | @Test 21 | public void testBufferEquality() { 22 | Buffer buf1 = Buffer.buffer("The quick brown fox jumps over the lazy dog"); 23 | Buffer buf2 = buf1.copy(); 24 | assertNotSame(buf1, buf2); 25 | assertEquals(buf1, buf2); 26 | } 27 | 28 | @Test 29 | public void testBufferSet() { 30 | Buffer buf1 = Buffer.buffer("The quick brown fox jumps over the lazy dog"); 31 | Buffer buf2 = buf1.copy(); 32 | assertEquals(1, Stream.of(buf1, buf2).collect(toSet()).size()); 33 | } 34 | 35 | @Test 36 | public void testSocketAddressEquality() { 37 | SocketAddress address1 = SocketAddress.newInstance(new SocketAddressImpl(8888, "guest")); 38 | SocketAddress address2 = SocketAddress.newInstance(new SocketAddressImpl(8888, "guest")); 39 | assertNotSame(address1, address2); 40 | assertEquals(address1, address2); 41 | } 42 | 43 | @Test 44 | public void testSocketAddressSet() { 45 | SocketAddress address1 = SocketAddress.newInstance(new SocketAddressImpl(8888, "guest")); 46 | SocketAddress address2 = SocketAddress.newInstance(new SocketAddressImpl(8888, "guest")); 47 | assertEquals(1, Stream.of(address1, address2).collect(toSet()).size()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/vertx/mutiny/test/RunOnContextTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.test; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.concurrent.CountDownLatch; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import io.vertx.mutiny.core.Context; 13 | import io.vertx.mutiny.core.Vertx; 14 | 15 | public class RunOnContextTest { 16 | 17 | private Vertx vertx; 18 | 19 | @Before 20 | public void setUp() { 21 | vertx = Vertx.vertx(); 22 | } 23 | 24 | @After 25 | public void tearDown() { 26 | vertx.closeAndAwait(); 27 | } 28 | 29 | @Test 30 | public void testRunOnContext() throws InterruptedException { 31 | CountDownLatch latch = new CountDownLatch(1); 32 | vertx.runOnContext(() -> { 33 | assertThat(Vertx.currentContext() != null); 34 | assertThat(Context.isOnVertxThread()).isTrue(); 35 | latch.countDown(); 36 | }); 37 | 38 | assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue(); 39 | } 40 | 41 | @Test 42 | public void testRunOnContextFromContext() throws InterruptedException { 43 | CountDownLatch latch = new CountDownLatch(1); 44 | Context context = vertx.getOrCreateContext(); 45 | context.runOnContext(() -> { 46 | assertThat(Vertx.currentContext() != null); 47 | assertThat(Context.isOnVertxThread()).isTrue(); 48 | latch.countDown(); 49 | }); 50 | 51 | assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-core/src/test/java/io/vertx/mutiny/test/ToStringTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.test; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import io.vertx.core.net.impl.SocketAddressImpl; 8 | import io.vertx.mutiny.core.buffer.Buffer; 9 | import io.vertx.mutiny.core.net.SocketAddress; 10 | 11 | /** 12 | * @author Thomas Segismont 13 | */ 14 | public class ToStringTest { 15 | 16 | @Test 17 | public void testBufferToString() { 18 | String string = "The quick brown fox jumps over the lazy dog"; 19 | assertEquals(string, Buffer.buffer(string).toString()); 20 | } 21 | 22 | @Test 23 | public void testSocketAddressToString() { 24 | io.vertx.core.net.SocketAddress socketAddress = new SocketAddressImpl(8888, "guest"); 25 | SocketAddress rxSocketAddress = SocketAddress.newInstance(socketAddress); 26 | assertEquals(socketAddress.toString(), rxSocketAddress.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-junit5/src/main/java/io/vertx/mutiny/junit5/VertxParameterProvider.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.junit5; 2 | 3 | import static io.vertx.junit5.VertxExtension.DEFAULT_TIMEOUT_DURATION; 4 | 5 | import java.time.Duration; 6 | import java.time.temporal.ChronoUnit; 7 | import java.util.concurrent.CompletionException; 8 | import java.util.concurrent.TimeoutException; 9 | 10 | import org.junit.jupiter.api.extension.ExtensionContext; 11 | import org.junit.jupiter.api.extension.ParameterContext; 12 | 13 | import io.vertx.core.VertxException; 14 | import io.vertx.junit5.ParameterClosingConsumer; 15 | import io.vertx.junit5.VertxExtension; 16 | import io.vertx.junit5.VertxExtensionParameterProvider; 17 | import io.vertx.mutiny.core.Vertx; 18 | 19 | public class VertxParameterProvider implements VertxExtensionParameterProvider { 20 | 21 | @Override 22 | public Class type() { 23 | return Vertx.class; 24 | } 25 | 26 | @Override 27 | public String key() { 28 | return VertxExtension.VERTX_INSTANCE_KEY; 29 | } 30 | 31 | @Override 32 | public Vertx newInstance(ExtensionContext extensionContext, ParameterContext parameterContext) { 33 | return Vertx.vertx(); 34 | } 35 | 36 | @Override 37 | public ParameterClosingConsumer parameterClosingConsumer() { 38 | return vertx -> { 39 | try { 40 | vertx.close().await().atMost(Duration.of(DEFAULT_TIMEOUT_DURATION, ChronoUnit.SECONDS)); 41 | } catch (Throwable err) { 42 | if (err instanceof TimeoutException) { 43 | throw err; 44 | } else if (err instanceof CompletionException) { 45 | throw new VertxException(err.getCause()); 46 | } else if (err instanceof Exception) { 47 | throw err; 48 | } else { 49 | throw new VertxException(err); 50 | } 51 | } 52 | }; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-junit5/src/main/resources/META-INF/services/io.vertx.junit5.VertxExtensionParameterProvider: -------------------------------------------------------------------------------- 1 | io.vertx.mutiny.junit5.VertxParameterProvider -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-junit5/src/test/java/io/vertx/mutiny/junit5/VertxParameterProviderTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.junit5; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import io.vertx.junit5.VertxExtension; 9 | import io.vertx.junit5.VertxTestContext; 10 | import io.vertx.mutiny.core.Vertx; 11 | 12 | @ExtendWith(VertxExtension.class) 13 | class VertxParameterProviderTest { 14 | 15 | @Test 16 | void smokeTest(Vertx vertx, VertxTestContext testContext) { 17 | assertNotNull(vertx); 18 | testContext.completeNow(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mail-client/src/test/java/io/vertx/mutiny/mail/MailClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mail; 2 | 3 | import static org.hamcrest.CoreMatchers.is; 4 | import static org.hamcrest.CoreMatchers.notNullValue; 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.testcontainers.containers.GenericContainer; 12 | 13 | import io.vertx.ext.mail.MailConfig; 14 | import io.vertx.ext.mail.MailMessage; 15 | import io.vertx.mutiny.core.Vertx; 16 | import io.vertx.mutiny.ext.mail.MailClient; 17 | 18 | public class MailClientTest { 19 | 20 | @Rule 21 | public GenericContainer container = new GenericContainer<>("mailhog/mailhog:latest") 22 | .withExposedPorts(1025); 23 | 24 | private Vertx vertx; 25 | 26 | @Before 27 | public void setUp() { 28 | vertx = Vertx.vertx(); 29 | assertThat(vertx, is(notNullValue())); 30 | } 31 | 32 | @After 33 | public void tearDown() { 34 | vertx.closeAndAwait(); 35 | } 36 | 37 | @Test 38 | public void testMutinyAPI() { 39 | MailClient client = MailClient.createShared(vertx, new MailConfig() 40 | .setPort(container.getMappedPort(1025)) 41 | .setHostname(container.getHost())); 42 | assertThat(client, is(notNullValue())); 43 | client.sendMail(new MailMessage().setText("hello mutiny") 44 | .setSubject("test email") 45 | .setTo("clement@apache.org") 46 | .setFrom("clement@apache.org")) 47 | .subscribeAsCompletionStage() 48 | .join(); 49 | } 50 | 51 | @Test 52 | public void testBlockingAPI() { 53 | MailClient client = MailClient.createShared(vertx, new MailConfig() 54 | .setPort(container.getMappedPort(1025)) 55 | .setHostname(container.getHost())); 56 | assertThat(client, is(notNullValue())); 57 | client.sendMailAndAwait(new MailMessage().setText("hello mutiny") 58 | .setSubject("test email") 59 | .setTo("clement@apache.org") 60 | .setFrom("clement@apache.org")); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-micrometer-metrics/src/test/java/io/vertx/mutiny/micrometer/MicrometerMetricsTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.micrometer; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.VertxOptions; 10 | import io.vertx.core.json.JsonObject; 11 | import io.vertx.ext.web.client.WebClientOptions; 12 | import io.vertx.micrometer.MicrometerMetricsOptions; 13 | import io.vertx.micrometer.VertxPrometheusOptions; 14 | import io.vertx.mutiny.core.Vertx; 15 | import io.vertx.mutiny.core.http.HttpServer; 16 | import io.vertx.mutiny.ext.web.Router; 17 | import io.vertx.mutiny.ext.web.client.WebClient; 18 | 19 | public class MicrometerMetricsTest { 20 | 21 | private Vertx vertx; 22 | 23 | @Before 24 | public void setUp() { 25 | vertx = Vertx.vertx(); 26 | } 27 | 28 | @After 29 | public void tearDown() { 30 | vertx.closeAndAwait(); 31 | } 32 | 33 | @Test 34 | public void test() { 35 | Vertx vertx = Vertx.vertx(new VertxOptions().setMetricsOptions( 36 | new MicrometerMetricsOptions() 37 | .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)) 38 | .setEnabled(true))); 39 | 40 | Router router = Router.router(vertx); 41 | router.route("/metrics").handler(x -> PrometheusScrapingHandler.create().handle(x)); 42 | HttpServer server = vertx.createHttpServer().requestHandler(router).listenAndAwait(8080); 43 | 44 | WebClient client = WebClient.create(vertx, new WebClientOptions().setDefaultPort(8080)); 45 | String s = client.get("/metrics").sendAndAwait().bodyAsString(); 46 | assertThat(s).contains("vertx_http_client_active_connections"); 47 | 48 | MetricsService metricsService = MetricsService.create(server); 49 | JsonObject metrics = metricsService.getMetricsSnapshot(); 50 | System.out.println(metrics); 51 | assertThat(metrics.getJsonArray("vertx.http.server.active.connections")).isNotNull(); 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mongo-client/src/test/java/io/vertx/mutiny/mongo/MongoClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mongo; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.List; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.testcontainers.containers.GenericContainer; 12 | 13 | import io.vertx.core.json.JsonObject; 14 | import io.vertx.mutiny.core.Vertx; 15 | import io.vertx.mutiny.ext.mongo.MongoClient; 16 | 17 | public class MongoClientTest { 18 | 19 | @Rule 20 | public GenericContainer container = new GenericContainer<>("mongo:4.4") 21 | .withExposedPorts(27017); 22 | 23 | private Vertx vertx; 24 | 25 | @Before 26 | public void setUp() { 27 | vertx = Vertx.vertx(); 28 | assertThat(vertx).isNotNull(); 29 | } 30 | 31 | @After 32 | public void tearDown() { 33 | vertx.closeAndAwait(); 34 | } 35 | 36 | @Test 37 | public void testmutinyAPI() { 38 | MongoClient client = MongoClient.createShared(vertx, new JsonObject() 39 | .put("db_name", "mutiny-test") 40 | .put("connection_string", "mongodb://" + container.getContainerIpAddress() 41 | + ":" + container.getMappedPort(27017))); 42 | 43 | JsonObject document = new JsonObject().put("title", "The Hobbit"); 44 | List list = client.save("books", document) 45 | .onItem().transformToUni(x -> client.find("books", new JsonObject().put("title", "The Hobbit"))) 46 | .subscribeAsCompletionStage() 47 | .toCompletableFuture() 48 | .join(); 49 | 50 | assertThat(list).hasSize(1) 51 | .allMatch(json -> json.getString("title").equalsIgnoreCase("The Hobbit")); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mqtt/src/test/java/io/vertx/mutiny/mqtt/MqttServerTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mqtt; 2 | 3 | import static org.hamcrest.CoreMatchers.*; 4 | import static org.hamcrest.MatcherAssert.assertThat; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import io.vertx.mqtt.MqttServerOptions; 11 | import io.vertx.mutiny.core.Vertx; 12 | 13 | public class MqttServerTest { 14 | 15 | private Vertx vertx; 16 | 17 | @Before 18 | public void setUp() { 19 | vertx = Vertx.vertx(); 20 | assertThat(vertx, is(notNullValue())); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void test() { 30 | MqttServer server = MqttServer.create(vertx, new MqttServerOptions() 31 | .setPort(0).setHost("0.0.0.0")) 32 | .endpointHandler(e -> { 33 | // do nothing. 34 | }) 35 | .listen().await().indefinitely(); 36 | assertThat(server, is(notNullValue())); 37 | assertThat(server.actualPort(), is(not(0))); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mysql-client/src/test/java/io/vertx/mutiny/mysql/MySQLClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mysql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.*; 6 | import org.testcontainers.containers.GenericContainer; 7 | 8 | import io.vertx.mutiny.core.Vertx; 9 | import io.vertx.mutiny.mysqlclient.MySQLPool; 10 | import io.vertx.mutiny.sqlclient.Pool; 11 | import io.vertx.mutiny.sqlclient.RowSet; 12 | import io.vertx.mysqlclient.MySQLConnectOptions; 13 | import io.vertx.sqlclient.PoolOptions; 14 | 15 | public class MySQLClientTest { 16 | private static final String MYSQL_ROOT_PASSWORD = "my-secret-pw"; 17 | private static final String MYSQL_DATABASE = "test"; 18 | 19 | @ClassRule 20 | public static GenericContainer container = new GenericContainer<>("mysql:8") 21 | .withExposedPorts(3306) 22 | .withEnv("MYSQL_ROOT_PASSWORD", MYSQL_ROOT_PASSWORD) 23 | .withEnv("MYSQL_DATABASE", MYSQL_DATABASE); 24 | 25 | private Vertx vertx; 26 | 27 | @Before 28 | public void setUp() { 29 | vertx = Vertx.vertx(); 30 | assertThat(vertx).isNotNull(); 31 | } 32 | 33 | @After 34 | public void tearDown() { 35 | vertx.closeAndAwait(); 36 | } 37 | 38 | @Test 39 | public void testMutinyAPI() { 40 | MySQLConnectOptions options = new MySQLConnectOptions() 41 | .setPort(container.getMappedPort(3306)) 42 | .setHost(container.getContainerIpAddress()) 43 | .setDatabase(MYSQL_DATABASE) 44 | .setUser("root") 45 | .setPassword(MYSQL_ROOT_PASSWORD); 46 | 47 | Pool client = MySQLPool.pool(vertx, options, new PoolOptions().setMaxSize(5)); 48 | 49 | RowSet join = client.query("SELECT 1") 50 | .executeAndAwait(); 51 | assertThat(join).isNotNull(); 52 | assertThat(join.size()).isEqualTo(1); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mysql-client/src/test/java/io/vertx/mutiny/mysql/MySqlInTransactionMultiTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mysql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.ClassRule; 8 | import org.testcontainers.containers.GenericContainer; 9 | 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.mysqlclient.MySQLPool; 12 | import io.vertx.mutiny.sqlclient.TransactionMultiTest; 13 | import io.vertx.mysqlclient.MySQLConnectOptions; 14 | import io.vertx.sqlclient.PoolOptions; 15 | 16 | public class MySqlInTransactionMultiTest extends TransactionMultiTest { 17 | private static final String MYSQL_ROOT_PASSWORD = "my-secret-pw"; 18 | private static final String MYSQL_DATABASE = "test"; 19 | 20 | @ClassRule 21 | public static GenericContainer container = new GenericContainer<>("mysql:8") 22 | .withExposedPorts(3306) 23 | .withEnv("MYSQL_ROOT_PASSWORD", MYSQL_ROOT_PASSWORD) 24 | .withEnv("MYSQL_DATABASE", MYSQL_DATABASE); 25 | 26 | private Vertx vertx; 27 | 28 | @Before 29 | public void setUp() { 30 | vertx = Vertx.vertx(); 31 | 32 | MySQLConnectOptions options = new MySQLConnectOptions() 33 | .setPort(container.getMappedPort(3306)) 34 | .setHost(container.getContainerIpAddress()) 35 | .setDatabase(MYSQL_DATABASE) 36 | .setUser("root") 37 | .setPassword(MYSQL_ROOT_PASSWORD); 38 | 39 | pool = MySQLPool.pool(vertx, options, new PoolOptions()); 40 | 41 | initDb(); 42 | } 43 | 44 | @After 45 | public void tearDown() { 46 | pool.close(); 47 | vertx.closeAndAwait(); 48 | } 49 | 50 | @Override 51 | protected void verifyDuplicateException(Exception e) { 52 | assertThat(e).hasMessageContaining("Duplicate entry"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mysql-client/src/test/java/io/vertx/mutiny/mysql/MySqlInTransactionUniTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mysql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.ClassRule; 8 | import org.testcontainers.containers.GenericContainer; 9 | 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.mysqlclient.MySQLPool; 12 | import io.vertx.mutiny.sqlclient.TransactionUniTest; 13 | import io.vertx.mysqlclient.MySQLConnectOptions; 14 | import io.vertx.sqlclient.PoolOptions; 15 | 16 | public class MySqlInTransactionUniTest extends TransactionUniTest { 17 | private static final String MYSQL_ROOT_PASSWORD = "my-secret-pw"; 18 | private static final String MYSQL_DATABASE = "test"; 19 | 20 | @ClassRule 21 | public static GenericContainer container = new GenericContainer<>("mysql:8") 22 | .withExposedPorts(3306) 23 | .withEnv("MYSQL_ROOT_PASSWORD", MYSQL_ROOT_PASSWORD) 24 | .withEnv("MYSQL_DATABASE", MYSQL_DATABASE); 25 | 26 | private Vertx vertx; 27 | 28 | @Before 29 | public void setUp() { 30 | vertx = Vertx.vertx(); 31 | 32 | MySQLConnectOptions options = new MySQLConnectOptions() 33 | .setPort(container.getMappedPort(3306)) 34 | .setHost(container.getContainerIpAddress()) 35 | .setDatabase(MYSQL_DATABASE) 36 | .setUser("root") 37 | .setPassword(MYSQL_ROOT_PASSWORD); 38 | 39 | pool = MySQLPool.pool(vertx, options, new PoolOptions()); 40 | 41 | initDb(); 42 | } 43 | 44 | @After 45 | public void tearDown() { 46 | pool.close(); 47 | vertx.closeAndAwait(); 48 | } 49 | 50 | @Override 51 | protected void verifyDuplicateException(Exception e) { 52 | assertThat(e).hasMessageContaining("Duplicate entry"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-mysql-client/src/test/java/io/vertx/mutiny/mysql/MySqlUsingConnectionSafetyTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.mysql; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.ClassRule; 6 | import org.testcontainers.containers.GenericContainer; 7 | 8 | import io.vertx.mutiny.core.Vertx; 9 | import io.vertx.mutiny.mysqlclient.MySQLPool; 10 | import io.vertx.mutiny.sqlclient.UsingConnectionSafetyTest; 11 | import io.vertx.mysqlclient.MySQLConnectOptions; 12 | import io.vertx.sqlclient.PoolOptions; 13 | 14 | public class MySqlUsingConnectionSafetyTest extends UsingConnectionSafetyTest { 15 | private static final String MYSQL_ROOT_PASSWORD = "my-secret-pw"; 16 | private static final String MYSQL_DATABASE = "test"; 17 | 18 | @ClassRule 19 | public static GenericContainer container = new GenericContainer<>("mysql:8") 20 | .withExposedPorts(3306) 21 | .withEnv("MYSQL_ROOT_PASSWORD", MYSQL_ROOT_PASSWORD) 22 | .withEnv("MYSQL_DATABASE", MYSQL_DATABASE); 23 | 24 | private Vertx vertx; 25 | private int maxSize; 26 | 27 | @Before 28 | public void setUp() { 29 | vertx = Vertx.vertx(); 30 | 31 | MySQLConnectOptions options = new MySQLConnectOptions() 32 | .setPort(container.getMappedPort(3306)) 33 | .setHost(container.getContainerIpAddress()) 34 | .setDatabase(MYSQL_DATABASE) 35 | .setUser("root") 36 | .setPassword(MYSQL_ROOT_PASSWORD); 37 | 38 | maxSize = 5; 39 | pool = MySQLPool.pool(vertx, options, new PoolOptions().setMaxSize(maxSize)); 40 | } 41 | 42 | @Override 43 | protected int getMaxPoolSize() { 44 | return maxSize; 45 | } 46 | 47 | @After 48 | public void tearDown() { 49 | pool.close(); 50 | vertx.closeAndAwait(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-pg-client/src/test/java/io/vertx/mutiny/postgresql/PGTestBase.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.postgresql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.AfterClass; 7 | import org.junit.Before; 8 | import org.junit.BeforeClass; 9 | import org.testcontainers.containers.PostgreSQLContainer; 10 | 11 | import io.vertx.mutiny.core.Vertx; 12 | 13 | public class PGTestBase { 14 | 15 | public static PostgreSQLContainer container = new PostgreSQLContainer<>(); 16 | 17 | @BeforeClass 18 | public static void init() { 19 | container.start(); 20 | } 21 | 22 | @AfterClass 23 | public static void shutdown() { 24 | container.stop(); 25 | } 26 | 27 | Vertx vertx; 28 | 29 | @Before 30 | public void setUp() { 31 | vertx = Vertx.vertx(); 32 | assertThat(vertx).isNotNull(); 33 | } 34 | 35 | @After 36 | public void tearDown() { 37 | vertx.closeAndAwait(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-pg-client/src/test/java/io/vertx/mutiny/postgresql/PgInTransactionMultiTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.postgresql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.AfterClass; 7 | import org.junit.Before; 8 | import org.junit.BeforeClass; 9 | import org.testcontainers.containers.PostgreSQLContainer; 10 | 11 | import io.vertx.mutiny.core.Vertx; 12 | import io.vertx.mutiny.pgclient.PgPool; 13 | import io.vertx.mutiny.sqlclient.TransactionMultiTest; 14 | import io.vertx.pgclient.PgConnectOptions; 15 | import io.vertx.sqlclient.PoolOptions; 16 | 17 | public class PgInTransactionMultiTest extends TransactionMultiTest { 18 | 19 | public static PostgreSQLContainer container = new PostgreSQLContainer<>(); 20 | 21 | @BeforeClass 22 | public static void init() { 23 | container.start(); 24 | } 25 | 26 | @AfterClass 27 | public static void shutdown() { 28 | container.stop(); 29 | } 30 | 31 | Vertx vertx; 32 | 33 | @Before 34 | public void setUp() { 35 | vertx = Vertx.vertx(); 36 | 37 | PgConnectOptions options = new PgConnectOptions() 38 | .setPort(container.getMappedPort(5432)) 39 | .setHost(container.getContainerIpAddress()) 40 | .setDatabase(container.getDatabaseName()) 41 | .setUser(container.getUsername()) 42 | .setPassword(container.getPassword()); 43 | 44 | pool = PgPool.pool(vertx, options, new PoolOptions()); 45 | 46 | initDb(); 47 | } 48 | 49 | @After 50 | public void tearDown() { 51 | pool.close(); 52 | vertx.closeAndAwait(); 53 | } 54 | 55 | @Override 56 | protected void verifyDuplicateException(Exception e) { 57 | assertThat(e).hasMessageContaining("duplicate key value violates unique constraint"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-pg-client/src/test/java/io/vertx/mutiny/postgresql/PgInTransactionUniTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.postgresql; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.AfterClass; 7 | import org.junit.Before; 8 | import org.junit.BeforeClass; 9 | import org.testcontainers.containers.PostgreSQLContainer; 10 | 11 | import io.vertx.mutiny.core.Vertx; 12 | import io.vertx.mutiny.pgclient.PgPool; 13 | import io.vertx.mutiny.sqlclient.TransactionUniTest; 14 | import io.vertx.pgclient.PgConnectOptions; 15 | import io.vertx.sqlclient.PoolOptions; 16 | 17 | public class PgInTransactionUniTest extends TransactionUniTest { 18 | 19 | public static PostgreSQLContainer container = new PostgreSQLContainer<>(); 20 | 21 | @BeforeClass 22 | public static void init() { 23 | container.start(); 24 | } 25 | 26 | @AfterClass 27 | public static void shutdown() { 28 | container.stop(); 29 | } 30 | 31 | Vertx vertx; 32 | 33 | @Before 34 | public void setUp() { 35 | vertx = Vertx.vertx(); 36 | 37 | PgConnectOptions options = new PgConnectOptions() 38 | .setPort(container.getMappedPort(5432)) 39 | .setHost(container.getContainerIpAddress()) 40 | .setDatabase(container.getDatabaseName()) 41 | .setUser(container.getUsername()) 42 | .setPassword(container.getPassword()); 43 | 44 | pool = PgPool.pool(vertx, options, new PoolOptions()); 45 | 46 | initDb(); 47 | } 48 | 49 | @After 50 | public void tearDown() { 51 | pool.close(); 52 | vertx.closeAndAwait(); 53 | } 54 | 55 | @Override 56 | protected void verifyDuplicateException(Exception e) { 57 | assertThat(e).hasMessageContaining("duplicate key value violates unique constraint"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-pg-client/src/test/java/io/vertx/mutiny/postgresql/PgUsingConnectionSafetyTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.postgresql; 2 | 3 | import org.junit.After; 4 | import org.junit.AfterClass; 5 | import org.junit.Before; 6 | import org.junit.BeforeClass; 7 | import org.testcontainers.containers.PostgreSQLContainer; 8 | 9 | import io.vertx.mutiny.core.Vertx; 10 | import io.vertx.mutiny.pgclient.PgPool; 11 | import io.vertx.mutiny.sqlclient.UsingConnectionSafetyTest; 12 | import io.vertx.pgclient.PgConnectOptions; 13 | import io.vertx.sqlclient.PoolOptions; 14 | 15 | public class PgUsingConnectionSafetyTest extends UsingConnectionSafetyTest { 16 | 17 | public static PostgreSQLContainer container = new PostgreSQLContainer<>(); 18 | 19 | @BeforeClass 20 | public static void init() { 21 | container.start(); 22 | } 23 | 24 | @AfterClass 25 | public static void shutdown() { 26 | container.stop(); 27 | } 28 | 29 | Vertx vertx; 30 | private int maxSize; 31 | 32 | @Before 33 | public void setUp() { 34 | vertx = Vertx.vertx(); 35 | 36 | PgConnectOptions options = new PgConnectOptions() 37 | .setPort(container.getMappedPort(5432)) 38 | .setHost(container.getContainerIpAddress()) 39 | .setDatabase(container.getDatabaseName()) 40 | .setUser(container.getUsername()) 41 | .setPassword(container.getPassword()); 42 | 43 | maxSize = 5; 44 | pool = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(maxSize)); 45 | } 46 | 47 | @Override 48 | protected int getMaxPoolSize() { 49 | return maxSize; 50 | } 51 | 52 | @After 53 | public void tearDown() { 54 | pool.closeAndAwait(); 55 | vertx.closeAndAwait(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-redis-client/src/test/java/io/vertx/mutiny/redis/RedisClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.redis; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Rule; 11 | import org.junit.Test; 12 | import org.testcontainers.containers.GenericContainer; 13 | 14 | import io.vertx.mutiny.core.Vertx; 15 | import io.vertx.mutiny.redis.client.Redis; 16 | import io.vertx.mutiny.redis.client.RedisAPI; 17 | import io.vertx.mutiny.redis.client.Response; 18 | import io.vertx.redis.client.RedisOptions; 19 | 20 | public class RedisClientTest { 21 | 22 | @Rule 23 | public GenericContainer container = new GenericContainer<>("redis:6.2") 24 | .withExposedPorts(6379); 25 | 26 | private Vertx vertx; 27 | 28 | @Before 29 | public void setUp() { 30 | vertx = Vertx.vertx(); 31 | assertThat(vertx).isNotNull(); 32 | } 33 | 34 | @After 35 | public void tearDown() { 36 | vertx.closeAndAwait(); 37 | } 38 | 39 | @Test 40 | public void testMutinyAPI() { 41 | Redis client = Redis.createClient(vertx, new RedisOptions() 42 | .setConnectionString("redis://" + container.getContainerIpAddress() + ":" + container.getMappedPort(6379))); 43 | RedisAPI redis = RedisAPI.api(client); 44 | 45 | Response object = redis.hset(Arrays.asList("book", "title", "The Hobbit")) 46 | .onItem().transformToUni(x -> redis.hgetall("book")) 47 | .subscribeAsCompletionStage() 48 | .join(); 49 | assertThat(object.get("title").toString()).isEqualTo("The Hobbit"); 50 | 51 | List responses = redis.keys("*") 52 | .onItem().transformToMulti(Response::toMulti) 53 | .map(Response::toString) 54 | .collect().asList() 55 | .await().indefinitely(); 56 | assertThat(responses).containsExactly("book"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | io.smallrye.reactive 7 | vertx-mutiny-clients 8 | 3.19.1-SNAPSHOT 9 | 10 | 11 | smallrye-mutiny-vertx-runtime 12 | SmallRye Mutiny - Runtime Helpers 13 | 14 | 15 | 16 | io.smallrye.reactive 17 | mutiny 18 | 19 | 20 | io.vertx 21 | vertx-core 22 | 23 | 24 | 25 | 26 | 27 | 28 | maven-jar-plugin 29 | 30 | 31 | 32 | io.smallrye.mutiny.vertx.runtime 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/AsyncResultUni.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | import java.util.function.Consumer; 5 | 6 | import io.smallrye.mutiny.Uni; 7 | import io.smallrye.mutiny.infrastructure.Infrastructure; 8 | import io.smallrye.mutiny.operators.AbstractUni; 9 | import io.smallrye.mutiny.subscription.UniSubscriber; 10 | import io.vertx.core.AsyncResult; 11 | import io.vertx.core.Handler; 12 | 13 | public class AsyncResultUni extends AbstractUni implements Uni { 14 | private final Consumer>> subscriptionConsumer; 15 | 16 | public static Uni toUni(Consumer>> subscriptionConsumer) { 17 | return new AsyncResultUni<>(subscriptionConsumer); 18 | } 19 | 20 | public AsyncResultUni(Consumer>> subscriptionConsumer) { 21 | this.subscriptionConsumer = Infrastructure.decorate(subscriptionConsumer); 22 | } 23 | 24 | @Override 25 | public void subscribe(UniSubscriber downstream) { 26 | AtomicBoolean terminated = new AtomicBoolean(); 27 | downstream.onSubscribe(() -> terminated.set(true)); 28 | 29 | if (!terminated.get()) { 30 | try { 31 | subscriptionConsumer.accept(ar -> { 32 | if (!terminated.getAndSet(true)) { 33 | if (ar.succeeded()) { 34 | T val = ar.result(); 35 | downstream.onItem(val); 36 | } else if (ar.failed()) { 37 | downstream.onFailure(ar.cause()); 38 | } 39 | } 40 | }); 41 | } catch (Exception e) { 42 | if (!terminated.getAndSet(true)) { 43 | downstream.onFailure(e); 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/DelegatingConsumerHandler.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import io.vertx.core.Handler; 6 | 7 | /** 8 | * A class being a {@link java.util.function.Consumer} and a {@link Handler} at the same time, and which delegate 9 | * {@link #hashCode()} and {@link #equals(Object)} to the consumer. 10 | * 11 | * @param 12 | */ 13 | public class DelegatingConsumerHandler implements Consumer, Handler { 14 | 15 | private final Consumer consumer; 16 | 17 | public DelegatingConsumerHandler(Consumer consumer) { 18 | this.consumer = consumer; 19 | } 20 | 21 | @Override 22 | public void handle(U event) { 23 | accept(event); 24 | } 25 | 26 | @Override 27 | public void accept(U event) { 28 | this.consumer.accept(event); 29 | } 30 | 31 | @Override 32 | public boolean equals(Object o) { 33 | if (this == o) { 34 | return true; 35 | } 36 | if (o == null || getClass() != o.getClass()) { 37 | return false; 38 | } 39 | DelegatingConsumerHandler that = (DelegatingConsumerHandler) o; 40 | return consumer.equals(that.consumer); 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | return consumer.hashCode(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/DelegatingHandler.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.util.function.Function; 4 | 5 | import io.vertx.core.Handler; 6 | 7 | /** 8 | * An implementation of {@link Handler} and which delegates {@link #hashCode()} and {@link #equals(Object)} to 9 | * the passed handler. 10 | * 11 | * @param 12 | */ 13 | public class DelegatingHandler implements Handler { 14 | 15 | private final Handler handler; 16 | private final Function mapper; 17 | 18 | public DelegatingHandler(Handler handler, Function mapper) { 19 | this.handler = handler; 20 | this.mapper = mapper; 21 | } 22 | 23 | @Override 24 | public void handle(U event) { 25 | handler.handle(mapper.apply(event)); 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (this == o) { 31 | return true; 32 | } 33 | if (o == null || getClass() != o.getClass()) { 34 | return false; 35 | } 36 | DelegatingHandler that = (DelegatingHandler) o; 37 | return handler.equals(that.handler); 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return handler.hashCode(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/MultiHelper.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.util.function.Function; 4 | 5 | import io.smallrye.mutiny.Multi; 6 | import io.vertx.core.streams.ReadStream; 7 | 8 | public class MultiHelper { 9 | 10 | /** 11 | * Adapts an Mutiny {@link Multi} to a Vert.x {@link io.vertx.core.streams.ReadStream}. The returned 12 | * {@code ReadStream} will be subscribed to the {@link Multi}. 13 | *

14 | * 15 | * @param observable the observable to adapt 16 | * @return the adapted stream 17 | */ 18 | public static ReadStream toReadStream(Multi observable) { 19 | return ReadStreamSubscriber.asReadStream(observable, Function.identity()); 20 | } 21 | 22 | /** 23 | * Like {@link #toMulti(ReadStream)} but with a {@code mapping} function 24 | */ 25 | public static Multi toMulti(ReadStream stream, Function mapping) { 26 | return new MultiReadStream<>(stream, mapping); 27 | } 28 | 29 | /** 30 | * Adapts a Vert.x {@link ReadStream} to an Mutiny {@link Multi}. After 31 | * the stream is adapted to a Multi, the original stream handlers should not be used anymore 32 | * as they will be used by the Multi adapter. 33 | *

34 | * 35 | * @param stream the stream to adapt 36 | * @return the adapted observable 37 | */ 38 | public static Multi toMulti(ReadStream stream) { 39 | return new MultiReadStream<>(stream, Function.identity()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/MutinyDelegate.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | /** 4 | * Interface implemented by every generated Mutiny type. 5 | */ 6 | public interface MutinyDelegate { 7 | 8 | /** 9 | * @return the delegate used by this Mutiny object of generated type 10 | */ 11 | Object getDelegate(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/MutinyGen.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Associate an Mutiny generated class with its original type,used for mapping the generated classes to their original type. 10 | */ 11 | 12 | @Target(ElementType.TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface MutinyGen { 15 | 16 | /** 17 | * @return the wrapped class 18 | */ 19 | Class value(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/TypeArg.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.function.Function; 5 | 6 | @SuppressWarnings("unchecked") 7 | public class TypeArg { 8 | 9 | private static final TypeArg UNKNOWN = new TypeArg<>(Function.identity(), Function.identity()); 10 | 11 | public static TypeArg of(Class type) { 12 | MutinyGen gen = type.getAnnotation(MutinyGen.class); 13 | if (gen != null) { 14 | try { 15 | Field field = type.getField("__TYPE_ARG"); 16 | return (TypeArg) field.get(null); 17 | } catch (Exception ignore) { 18 | } 19 | } 20 | return unknown(); 21 | } 22 | 23 | public static TypeArg unknown() { 24 | return (TypeArg) UNKNOWN; 25 | } 26 | 27 | public final Function wrap; 28 | public final Function unwrap; 29 | 30 | public TypeArg(Function wrap, Function unwrap) { 31 | this.wrap = wrap; 32 | this.unwrap = unwrap; 33 | } 34 | 35 | public T wrap(Object o) { 36 | return o != null ? (T) wrap.apply(o) : null; 37 | } 38 | 39 | public X unwrap(T o) { 40 | return o != null ? (X) unwrap.apply(o) : null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/WriteStreamSubscriber.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx; 2 | 3 | import java.util.concurrent.Flow.Subscriber; 4 | import java.util.function.Consumer; 5 | 6 | /** 7 | * A {@link io.vertx.core.streams.WriteStream} to {@link Subscriber} adapter. 8 | * 9 | * @param the type of item. 10 | */ 11 | @SuppressWarnings("SubscriberImplementation") 12 | public interface WriteStreamSubscriber extends Subscriber { 13 | 14 | /** 15 | * Sets the handler to invoke on failure events. 16 | *

17 | * The underlying {@link io.vertx.core.streams.WriteStream#end()} method is not invoked in this case. 18 | * 19 | * @param callback the callback invoked with the failure 20 | * @return a reference to this, so the API can be used fluently 21 | */ 22 | WriteStreamSubscriber onFailure(Consumer callback); 23 | 24 | /** 25 | * Sets the handler to invoke on completion events. 26 | *

27 | * The underlying {@link io.vertx.core.streams.WriteStream#end()} method is invoked before the 28 | * given {@code callback}. 29 | * 30 | * @param callback the callback invoked when the completion event is received 31 | * @return a reference to this, so the API can be used fluently 32 | */ 33 | WriteStreamSubscriber onComplete(Runnable callback); 34 | 35 | /** 36 | * Sets the handler to invoke if the adapted {@link io.vertx.core.streams.WriteStream} fails. 37 | *

38 | * The underlying {@link io.vertx.core.streams.WriteStream#end()} method is not invoked in this case. 39 | * 40 | * @param callback the callback invoked with the failure 41 | * @return a reference to this, so the API can be used fluently 42 | */ 43 | WriteStreamSubscriber onWriteStreamError(Consumer callback); 44 | } 45 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-runtime/src/main/java/io/smallrye/mutiny/vertx/impl/MappingIterator.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.impl; 2 | 3 | import java.util.Iterator; 4 | import java.util.function.Function; 5 | 6 | /** 7 | * @author Thomas Segismont 8 | */ 9 | public class MappingIterator implements Iterator { 10 | 11 | private final Iterator iterator; 12 | private final Function mapping; 13 | 14 | public MappingIterator(Iterator iterator, Function mapping) { 15 | this.iterator = iterator; 16 | this.mapping = mapping; 17 | } 18 | 19 | @Override 20 | public boolean hasNext() { 21 | return iterator.hasNext(); 22 | } 23 | 24 | @Override 25 | public V next() { 26 | return mapping.apply(iterator.next()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-service-discovery/src/test/java/io/vertx/mutiny/discovery/ServiceDiscoveryTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.discovery; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import io.vertx.core.json.JsonObject; 8 | import io.vertx.mutiny.core.Vertx; 9 | import io.vertx.mutiny.servicediscovery.ServiceDiscovery; 10 | import io.vertx.mutiny.servicediscovery.types.HttpEndpoint; 11 | import io.vertx.servicediscovery.Record; 12 | import io.vertx.servicediscovery.ServiceDiscoveryOptions; 13 | 14 | public class ServiceDiscoveryTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void test() { 30 | ServiceDiscovery discovery = ServiceDiscovery.create(vertx); 31 | 32 | discovery = ServiceDiscovery.create(vertx, 33 | new ServiceDiscoveryOptions() 34 | .setAnnounceAddress("service-announce") 35 | .setName("my-name")); 36 | 37 | Record record = new Record() 38 | .setType("eventbus-service-proxy") 39 | .setLocation(new JsonObject().put("endpoint", "the-service-address")) 40 | .setName("my-service") 41 | .setMetadata(new JsonObject().put("some-label", "some-value")); 42 | 43 | discovery.publishAndAwait(record); 44 | 45 | record = HttpEndpoint.createRecord("some-rest-api", "localhost", 8080, "/api"); 46 | discovery.publishAndAwait(record); 47 | 48 | discovery.close(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-sql-client-templates/src/test/java/io/vertx/mutiny/circuitbreaker/SqlClientTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.circuitbreaker; 2 | 3 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 4 | 5 | import java.util.Collections; 6 | import java.util.Map; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Rule; 11 | import org.junit.Test; 12 | import org.testcontainers.containers.PostgreSQLContainer; 13 | 14 | import io.vertx.mutiny.core.Vertx; 15 | import io.vertx.mutiny.pgclient.PgPool; 16 | import io.vertx.mutiny.sqlclient.Pool; 17 | import io.vertx.mutiny.sqlclient.templates.SqlTemplate; 18 | import io.vertx.pgclient.PgConnectOptions; 19 | import io.vertx.pgclient.PgException; 20 | import io.vertx.sqlclient.PoolOptions; 21 | 22 | public class SqlClientTemplateTest { 23 | 24 | @Rule 25 | public PostgreSQLContainer container = new PostgreSQLContainer<>(); 26 | 27 | private Vertx vertx; 28 | 29 | @Before 30 | public void setUp() { 31 | vertx = Vertx.vertx(); 32 | } 33 | 34 | @After 35 | public void tearDown() { 36 | vertx.closeAndAwait(); 37 | } 38 | 39 | @Test 40 | public void test() { 41 | PgConnectOptions options = new PgConnectOptions() 42 | .setPort(container.getMappedPort(5432)) 43 | .setHost(container.getContainerIpAddress()) 44 | .setDatabase(container.getDatabaseName()) 45 | .setUser(container.getUsername()) 46 | .setPassword(container.getPassword()); 47 | 48 | Pool client = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(5)); 49 | 50 | Map parameters = Collections.singletonMap("id", 1); 51 | 52 | assertThatThrownBy(() -> SqlTemplate 53 | .forQuery(client, "SELECT * FROM users WHERE id=#{id}") 54 | .executeAndAwait(parameters)).isInstanceOf(PgException.class); // Table not created. 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-sql-client/src/test/java/io/vertx/mutiny/sqlclient/SqlClientHelperTestBase.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.sqlclient; 2 | 3 | import static java.util.stream.Collectors.toList; 4 | import static org.assertj.core.api.Assertions.assertThat; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import java.util.stream.Stream; 9 | 10 | import io.smallrye.mutiny.Multi; 11 | import io.smallrye.mutiny.Uni; 12 | 13 | public abstract class SqlClientHelperTestBase { 14 | 15 | protected static final List NAMES = Arrays.asList("John", "Paul", "Peter", "Andrew", "Steven"); 16 | 17 | protected static final String UNIQUE_NAMES_SQL = "select distinct firstname from folks order by firstname asc"; 18 | 19 | protected static final String INSERT_FOLK_SQL = "insert into folks (firstname) values ('%s')"; 20 | 21 | protected Pool pool; 22 | 23 | public void initDb() { 24 | pool.query("drop table if exists folks").executeAndAwait(); 25 | pool.query("create table folks (firstname varchar(255) not null unique)").executeAndAwait(); 26 | for (String name : NAMES) { 27 | pool.query(String.format(INSERT_FOLK_SQL, name)).executeAndAwait(); 28 | } 29 | } 30 | 31 | protected void assertTableContainsInitDataOnly() throws Exception { 32 | List actual = uniqueNames(pool).collect().asList().await().indefinitely(); 33 | assertThat(actual).isEqualTo(NAMES.stream().sorted().distinct().collect(toList())); 34 | } 35 | 36 | protected static Multi uniqueNames(SqlClient client) { 37 | return client.query(UNIQUE_NAMES_SQL).execute() 38 | .onItem().transformToMulti(RowSet::toMulti) 39 | .onItem().transform(row -> row.getString(0)); 40 | } 41 | 42 | protected static Uni insertExtraFolks(SqlClient client) { 43 | return client.query(String.format(INSERT_FOLK_SQL, "Georges")).execute() 44 | .onItem().transformToUni(v -> client.query(String.format(INSERT_FOLK_SQL, "Henry")).execute()) 45 | .onItem().ignore().andContinueWithNull(); 46 | } 47 | 48 | protected static List namesWithExtraFolks() { 49 | return Stream.concat(NAMES.stream(), Stream.of("Georges", "Henry")).sorted().distinct().collect(toList()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-sql-client/src/test/java/io/vertx/mutiny/sqlclient/TransactionMultiTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.sqlclient; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.concurrent.CompletionException; 9 | 10 | import org.junit.Test; 11 | 12 | import io.smallrye.mutiny.Multi; 13 | 14 | public abstract class TransactionMultiTest extends SqlClientHelperTestBase { 15 | 16 | List emitted = Collections.synchronizedList(new ArrayList<>()); 17 | 18 | @Test 19 | public void inTransactionSuccess() throws Exception { 20 | inTransaction(false, null); 21 | assertThat(emitted).isEqualTo(namesWithExtraFolks()); 22 | } 23 | 24 | @Test 25 | public void inTransactionUserFailure() throws Exception { 26 | Exception failure = new Exception(); 27 | try { 28 | inTransaction(true, failure); 29 | } catch (Exception e) { 30 | assertThat(e).isInstanceOf(CompletionException.class).getCause().isEqualTo(failure); 31 | assertThat(emitted).isEqualTo(namesWithExtraFolks()); 32 | } 33 | assertTableContainsInitDataOnly(); 34 | } 35 | 36 | @Test 37 | public void inTransactionDBFailure() throws Exception { 38 | try { 39 | inTransaction(true, null); 40 | } catch (Exception e) { 41 | verifyDuplicateException(e); 42 | assertThat(emitted).isEqualTo(namesWithExtraFolks()); 43 | } 44 | assertTableContainsInitDataOnly(); 45 | } 46 | 47 | protected abstract void verifyDuplicateException(Exception e); 48 | 49 | private void inTransaction(boolean fail, Exception e) throws Exception { 50 | SqlClientHelper.inTransactionMulti(pool, transaction -> { 51 | Multi upstream = insertExtraFolks(transaction) 52 | .onItem().transformToMulti(v -> uniqueNames(transaction)); 53 | if (!fail) { 54 | return upstream; 55 | } 56 | if (e != null) { 57 | return Multi.createBy().concatenating().streams(upstream, Multi.createFrom().failure(e)); 58 | } 59 | return Multi.createBy().concatenating().streams(upstream, upstream); 60 | }).onItem().invoke(emitted::add).collect().last().await().indefinitely(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-sql-client/src/test/java/io/vertx/mutiny/sqlclient/UsingConnectionSafetyTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.sqlclient; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.junit.Assert.fail; 5 | 6 | import java.util.function.Function; 7 | 8 | import org.junit.Test; 9 | 10 | import io.smallrye.mutiny.Uni; 11 | 12 | public abstract class UsingConnectionSafetyTest { 13 | 14 | protected Pool pool; 15 | 16 | @Test 17 | public void testUsingConnectionMulti() throws Exception { 18 | doTest(throwable -> SqlClientHelper.usingConnectionMulti(pool, conn -> { 19 | throw throwable; 20 | }).collect().first()); 21 | } 22 | 23 | @Test 24 | public void testUsingConnectionUni() throws Exception { 25 | doTest(throwable -> SqlClientHelper.usingConnectionUni(pool, conn -> { 26 | throw throwable; 27 | })); 28 | } 29 | 30 | private void doTest(Function> function) { 31 | for (int i = 0; i < getMaxPoolSize() + 1; i++) { 32 | RuntimeException expected = new RuntimeException(); 33 | try { 34 | function.apply(expected).await().indefinitely(); 35 | fail("Should not complete succesfully"); 36 | } catch (Exception e) { 37 | assertThat(e).isEqualTo(expected); 38 | } 39 | } 40 | } 41 | 42 | protected abstract int getMaxPoolSize(); 43 | } 44 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-stomp/src/test/java/io/vertx/mutiny/stomp/StompTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.stomp; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import io.vertx.ext.stomp.StompClientOptions; 12 | import io.vertx.ext.stomp.StompServerOptions; 13 | import io.vertx.mutiny.core.Vertx; 14 | import io.vertx.mutiny.core.buffer.Buffer; 15 | import io.vertx.mutiny.ext.stomp.StompClient; 16 | import io.vertx.mutiny.ext.stomp.StompServer; 17 | import io.vertx.mutiny.ext.stomp.StompServerHandler; 18 | 19 | public class StompTest { 20 | 21 | private static final int PORT = 62613; 22 | private Vertx vertx; 23 | 24 | @Before 25 | public void setUp() { 26 | vertx = Vertx.vertx(); 27 | } 28 | 29 | @After 30 | public void tearDown() { 31 | vertx.closeAndAwait(); 32 | } 33 | 34 | @Test 35 | public void test() { 36 | CompletableFuture future = new CompletableFuture<>(); 37 | StompServerHandler handler = StompServerHandler.create(vertx); 38 | StompServer server = StompServer.create(vertx, new StompServerOptions().setPort(PORT)).handler(handler) 39 | .listenAndAwait(); 40 | 41 | StompClient client = StompClient.create(vertx, new StompClientOptions().setPort(PORT)); 42 | client 43 | .connectAndAwait() 44 | .subscribeAndAwait("/q", frame -> future.complete(frame.getBodyAsString())); 45 | 46 | StompClient client2 = StompClient.create(vertx, new StompClientOptions().setPort(PORT)); 47 | client2 48 | .connectAndAwait() 49 | .sendAndAwait("/q", Buffer.buffer("hello")); 50 | 51 | String s = future.join(); 52 | assertThat(s).isEqualTo("hello"); 53 | client.close(); 54 | server.closeAndAwait(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-uri-template/src/test/java/io/vertx/mutiny/uritemplate/UriTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.uritemplate; 2 | 3 | import org.assertj.core.api.Assertions; 4 | import org.junit.Test; 5 | 6 | import io.vertx.uritemplate.UriTemplate; 7 | import io.vertx.uritemplate.Variables; 8 | 9 | public class UriTemplateTest { 10 | 11 | /** 12 | * Example taken from https://en.wikipedia.org/wiki/URI_Template. 13 | */ 14 | @Test 15 | public void test() { 16 | String string = UriTemplate.of("http://example.com/people/{firstName}-{lastName}/SSN") 17 | .expandToString(Variables.variables().set("firstName", "foo").set("lastName", "bar")); 18 | Assertions.assertThat(string).isEqualTo("http://example.com/people/foo-bar/SSN"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-client/src/test/java/io/vertx/mutiny/web/WebClientTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.hamcrest.CoreMatchers.is; 4 | import static org.hamcrest.CoreMatchers.notNullValue; 5 | import static org.hamcrest.MatcherAssert.assertThat; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.testcontainers.containers.BindMode; 12 | import org.testcontainers.containers.GenericContainer; 13 | 14 | import io.vertx.core.json.JsonObject; 15 | import io.vertx.ext.web.client.WebClientOptions; 16 | import io.vertx.mutiny.core.Vertx; 17 | import io.vertx.mutiny.ext.web.client.HttpResponse; 18 | import io.vertx.mutiny.ext.web.client.WebClient; 19 | 20 | public class WebClientTest { 21 | 22 | @Rule 23 | public GenericContainer container = new GenericContainer<>("kennethreitz/httpbin:latest") 24 | .withExposedPorts(80) 25 | .withFileSystemBind("target", "/tmp/fakemail", BindMode.READ_WRITE); 26 | 27 | private Vertx vertx; 28 | 29 | @Before 30 | public void setUp() { 31 | vertx = Vertx.vertx(); 32 | assertThat(vertx, is(notNullValue())); 33 | } 34 | 35 | @After 36 | public void tearDown() { 37 | vertx.closeAndAwait(); 38 | } 39 | 40 | @Test 41 | public void testWebClient() { 42 | WebClient client = WebClient.create(vertx, new WebClientOptions() 43 | .setDefaultPort(container.getMappedPort(80)) 44 | .setDefaultHost(container.getContainerIpAddress())); 45 | assertThat(client, is(notNullValue())); 46 | 47 | JsonObject object = client.get("/get?msg=hello").send() 48 | .subscribeAsCompletionStage() 49 | .thenApply(HttpResponse::bodyAsJsonObject) 50 | .toCompletableFuture().join(); 51 | assertThat(object.getJsonObject("args").getString("msg"), is("hello")); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-client/src/test/java/io/vertx/mutiny/web/WineAndCheese.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import java.util.Objects; 4 | 5 | public class WineAndCheese { 6 | 7 | private String wine; 8 | private String cheese; 9 | 10 | public String getWine() { 11 | return wine; 12 | } 13 | 14 | public WineAndCheese setWine(String wine) { 15 | this.wine = wine; 16 | return this; 17 | } 18 | 19 | public String getCheese() { 20 | return cheese; 21 | } 22 | 23 | public WineAndCheese setCheese(String cheese) { 24 | this.cheese = cheese; 25 | return this; 26 | } 27 | 28 | @Override 29 | public boolean equals(Object obj) { 30 | if (obj instanceof WineAndCheese) { 31 | WineAndCheese that = (WineAndCheese) obj; 32 | return Objects.equals(wine, that.wine) && Objects.equals(cheese, that.cheese); 33 | } 34 | return false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-freemarker/src/test/java/io/vertx/mutiny/web/FreemarkerTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.freemarker.FreeMarkerTemplateEngine; 13 | 14 | public class FreemarkerTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | FreeMarkerTemplateEngine engine = FreeMarkerTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "template").await().indefinitely(); 32 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-freemarker/src/test/resources/template.ftl: -------------------------------------------------------------------------------- 1 |

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-handlebars/src/test/java/io/vertx/mutiny/web/HandlebarsTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.handlebars.HandlebarsTemplateEngine; 13 | 14 | public class HandlebarsTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | HandlebarsTemplateEngine engine = HandlebarsTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "src/test/resources/template.hbs").await() 32 | .indefinitely(); 33 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-handlebars/src/test/resources/template.hbs: -------------------------------------------------------------------------------- 1 |

{{ foo }}

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-jade/src/test/java/io/vertx/mutiny/web/JadeTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.jade.JadeTemplateEngine; 13 | 14 | public class JadeTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | JadeTemplateEngine engine = JadeTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "template.jade").await() 32 | .indefinitely(); 33 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-jade/src/test/resources/template.jade: -------------------------------------------------------------------------------- 1 |

#{foo}

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-mvel/src/test/java/io/vertx/mutiny/web/MvelTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.mvel.MVELTemplateEngine; 13 | 14 | public class MvelTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | MVELTemplateEngine engine = MVELTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "template.templ").await() 32 | .indefinitely(); 33 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-mvel/src/test/resources/template.templ: -------------------------------------------------------------------------------- 1 |

@{foo}

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-pebble/src/test/java/io/vertx/mutiny/web/PebbleTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.pebble.PebbleTemplateEngine; 13 | 14 | public class PebbleTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | PebbleTemplateEngine engine = PebbleTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "template.peb").await() 32 | .indefinitely(); 33 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-pebble/src/test/resources/template.peb: -------------------------------------------------------------------------------- 1 |

{{ foo }}

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-pug/src/test/java/io/vertx/mutiny/web/PugTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.pug.PugTemplateEngine; 13 | 14 | public class PugTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | PugTemplateEngine engine = PugTemplateEngine.create(vertx); 31 | Buffer buffer = engine.renderAndAwait(new JsonObject().put("foo", "hello"), "template.pug"); 32 | assertThat(buffer.toString()).contains("

hello

"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-pug/src/test/resources/template.pug: -------------------------------------------------------------------------------- 1 | p= foo -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-rocker/src/test/java/io/vertx/mutiny/web/RockerTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.rocker.RockerTemplateEngine; 13 | 14 | public class RockerTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | RockerTemplateEngine engine = RockerTemplateEngine.create(); 31 | 32 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "templates/MyTemplate.rocker.html") 33 | .await().indefinitely(); 34 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-rocker/src/test/resources/templates/MyTemplate.rocker.html: -------------------------------------------------------------------------------- 1 | @args (String foo) 2 |

@foo

-------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-thymeleaf/src/test/java/io/vertx/mutiny/web/ThymeleafTemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | import io.vertx.mutiny.core.Vertx; 11 | import io.vertx.mutiny.core.buffer.Buffer; 12 | import io.vertx.mutiny.ext.web.templ.thymeleaf.ThymeleafTemplateEngine; 13 | 14 | public class ThymeleafTemplateTest { 15 | 16 | private Vertx vertx; 17 | 18 | @Before 19 | public void setUp() { 20 | vertx = Vertx.vertx(); 21 | } 22 | 23 | @After 24 | public void tearDown() { 25 | vertx.closeAndAwait(); 26 | } 27 | 28 | @Test 29 | public void testTemplate() { 30 | ThymeleafTemplateEngine engine = ThymeleafTemplateEngine.create(vertx); 31 | Buffer buffer = engine.render(new JsonObject().put("foo", "hello"), "template.html").await() 32 | .indefinitely(); 33 | assertThat(buffer.toString()).contains("hello").doesNotContain("foo"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web-templ-thymeleaf/src/test/resources/template.html: -------------------------------------------------------------------------------- 1 |

2 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web/src/test/java/io/vertx/mutiny/web/TestRouteHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 2.0 5 | * (the "License"); you may not use this file except in compliance with the 6 | * License. You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | package io.vertx.mutiny.web; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | import io.vertx.core.Handler; 21 | import io.vertx.ext.web.RoutingContext; 22 | import io.vertx.mutiny.web.impl.TestRouteHandlerImpl; 23 | 24 | @VertxGen 25 | public interface TestRouteHandler extends Handler { 26 | static TestRouteHandler create() { 27 | return new TestRouteHandlerImpl(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web/src/test/java/io/vertx/mutiny/web/impl/TestRouteHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package io.vertx.mutiny.web.impl; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | 5 | import io.vertx.ext.web.RoutingContext; 6 | import io.vertx.ext.web.impl.OrderListener; 7 | import io.vertx.mutiny.web.TestRouteHandler; 8 | 9 | public class TestRouteHandlerImpl implements TestRouteHandler, OrderListener { 10 | 11 | private final AtomicBoolean called = new AtomicBoolean(); 12 | 13 | @Override 14 | public void handle(RoutingContext rc) { 15 | if (called.get()) { 16 | rc.response().end(); 17 | } else { 18 | rc.fail(500); 19 | } 20 | } 21 | 22 | @Override 23 | public void onOrder(int order) { 24 | called.set(true); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web/src/test/java/io/vertx/mutiny/web/package-info.java: -------------------------------------------------------------------------------- 1 | @ModuleGen(name = "webtest", groupPackage = "io.vertx") 2 | package io.vertx.mutiny.web; 3 | 4 | import io.vertx.codegen.annotations.ModuleGen; 5 | -------------------------------------------------------------------------------- /vertx-mutiny-clients/vertx-mutiny-web/src/test/resources/assets/test.txt: -------------------------------------------------------------------------------- 1 | This is a test. -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/MutinyGeneratorLoader.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen; 2 | 3 | import java.util.stream.Stream; 4 | 5 | import javax.annotation.processing.ProcessingEnvironment; 6 | 7 | import io.vertx.codegen.Generator; 8 | import io.vertx.codegen.GeneratorLoader; 9 | 10 | public class MutinyGeneratorLoader implements GeneratorLoader { 11 | @Override 12 | public Stream> loadGenerators(ProcessingEnvironment processingEnv) { 13 | return Stream.of(new MutinyGenerator()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/BufferRelatedMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | import io.vertx.core.buffer.Buffer; 7 | 8 | /** 9 | * Add the buffer specific methods. 10 | */ 11 | public class BufferRelatedMethodCodeWriter implements ConditionalCodeWriter { 12 | 13 | @Override 14 | public void generate(ClassModel model, PrintWriter writer) { 15 | writer.println(" @Override"); 16 | writer.println(" public void writeToBuffer(io.vertx.core.buffer.Buffer buffer) {"); 17 | writer.println(" delegate.writeToBuffer(buffer);"); 18 | writer.println(" }"); 19 | writer.println(); 20 | writer.println(" @Override"); 21 | writer.println(" public int readFromBuffer(int pos, io.vertx.core.buffer.Buffer buffer) {"); 22 | writer.println(" return delegate.readFromBuffer(pos, buffer);"); 23 | writer.println(" }"); 24 | writer.println(); 25 | } 26 | 27 | @Override 28 | public boolean test(ClassModel model) { 29 | return model.isConcrete() && model.getType().getName().equals(Buffer.class.getName()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ClassJavadocCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | import io.vertx.codegen.doc.Doc; 7 | import io.vertx.codegen.doc.Token; 8 | import io.vertx.codegen.type.ClassTypeInfo; 9 | 10 | public class ClassJavadocCodeWriter implements CodeWriter { 11 | @Override 12 | public void generate(ClassModel model, PrintWriter writer) { 13 | ClassTypeInfo type = model.getType(); 14 | Doc doc = model.getDoc(); 15 | if (doc != null) { 16 | writer.println("/**"); 17 | Token.toHtml(doc.getTokens(), " *", CodeGenHelper::renderLinkToHtml, "\n", writer); 18 | writer.println(" *"); 19 | writer.println(" *

"); 20 | writer.print(" * NOTE: This class has been automatically generated from the {@link "); 21 | writer.print(type.getName()); 22 | writer.println(" original} non Mutiny-ified interface using Vert.x codegen."); 23 | writer.println(" */"); 24 | writer.println(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/CodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.codegen.MutinyGenerator; 4 | import io.vertx.codegen.ClassModel; 5 | import io.vertx.codegen.type.ClassKind; 6 | import io.vertx.codegen.type.ParameterizedTypeInfo; 7 | import io.vertx.codegen.type.TypeInfo; 8 | 9 | import java.io.PrintWriter; 10 | import java.util.function.BiFunction; 11 | 12 | import static java.util.stream.Collectors.joining; 13 | 14 | public interface CodeWriter extends BiFunction { 15 | 16 | void generate(ClassModel model, PrintWriter writer); 17 | 18 | default Void apply(ClassModel model, PrintWriter writer) { 19 | generate(model, writer); 20 | return null; 21 | } 22 | 23 | default String genTypeName(TypeInfo type) { 24 | if (type.isParameterized()) { 25 | ParameterizedTypeInfo pt = (ParameterizedTypeInfo) type; 26 | return genTypeName(pt.getRaw()) + pt.getArgs().stream().map(this::genTypeName) 27 | .collect(joining(", ", "<", ">")); 28 | } else if (type.getKind() == ClassKind.API) { 29 | return type.translateName(MutinyGenerator.ID); 30 | } else { 31 | return type.getSimpleName(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ConditionalCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.function.Predicate; 5 | 6 | import io.vertx.codegen.ClassModel; 7 | 8 | public interface ConditionalCodeWriter extends Predicate, CodeWriter { 9 | 10 | default Void apply(ClassModel model, PrintWriter writer) { 11 | if (test(model)) { 12 | generate(model, writer); 13 | } 14 | return null; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ConstantCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | 4 | import java.io.PrintWriter; 5 | import java.util.Map; 6 | 7 | import io.vertx.codegen.ClassModel; 8 | import io.vertx.codegen.ConstantInfo; 9 | import io.vertx.codegen.MethodInfo; 10 | import io.vertx.codegen.doc.Doc; 11 | import io.vertx.codegen.doc.Token; 12 | import io.vertx.codegen.type.TypeInfo; 13 | 14 | import static io.smallrye.mutiny.vertx.codegen.lang.CodeGenHelper.genConvReturn; 15 | 16 | public class ConstantCodeWriter implements CodeWriter { 17 | 18 | private final Map> methodTypeArgMap; 19 | 20 | public ConstantCodeWriter(Map> methodTypeArgMap) { 21 | this.methodTypeArgMap = methodTypeArgMap; 22 | } 23 | 24 | @Override 25 | public void generate(ClassModel model, PrintWriter writer) { 26 | for (ConstantInfo constant : model.getConstants()) { 27 | genConstant(model, constant, writer); 28 | } 29 | } 30 | 31 | private void genConstant(ClassModel model, ConstantInfo constant, PrintWriter writer) { 32 | Doc doc = constant.getDoc(); 33 | if (doc != null) { 34 | writer.println(" /**"); 35 | Token.toHtml(doc.getTokens(), " *", CodeGenHelper::renderLinkToHtml, "\n", writer); 36 | writer.println(" */"); 37 | } 38 | writer.print(model.isConcrete() ? " public static final" : ""); 39 | writer.format(" %s %s = %s;%n", 40 | genTypeName(constant.getType()), 41 | constant.getName(), 42 | genConvReturn(methodTypeArgMap, constant.getType(), null, model.getType().getName() + "." + constant.getName())); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ConstructorWithDelegateParameterCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ClassModel; 4 | import io.vertx.codegen.Helper; 5 | import io.vertx.codegen.TypeParamInfo; 6 | 7 | import java.io.PrintWriter; 8 | import java.util.List; 9 | 10 | public class ConstructorWithDelegateParameterCodeWriter implements ConditionalCodeWriter { 11 | 12 | private final String constructor; 13 | 14 | public ConstructorWithDelegateParameterCodeWriter(String constructor) { 15 | this.constructor = constructor; 16 | } 17 | 18 | public ConstructorWithDelegateParameterCodeWriter() { 19 | this.constructor = null; 20 | } 21 | 22 | @Override 23 | public void generate(ClassModel model, PrintWriter writer) { 24 | // Constructor taking delegate as parameter. 25 | String cst = constructor; 26 | if (cst == null) { 27 | cst = model.getIfaceSimpleName(); 28 | } 29 | 30 | List typeParams = model.getTypeParams(); 31 | writer.print(" public "); 32 | writer.print(cst); 33 | writer.print("("); 34 | writer.print(Helper.getNonGenericType(model.getIfaceFQCN())); 35 | writer.println(" delegate) {"); 36 | 37 | if (model.isConcrete() && CodeGenHelper.hasParentClass(model)) { 38 | writer.println(" super(delegate);"); 39 | } 40 | writer.println(" this.delegate = delegate;"); 41 | for (TypeParamInfo.Class typeParam : typeParams) { 42 | writer.print(" this.__typeArg_"); 43 | writer.print(typeParam.getIndex()); 44 | writer.print(" = io.smallrye.mutiny.vertx.TypeArg.unknown();"); 45 | } 46 | writer.println(" }"); 47 | writer.println(); 48 | } 49 | 50 | @Override 51 | public boolean test(ClassModel classModel) { 52 | return classModel.isConcrete(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ConstructorWithGenericTypesCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ClassModel; 4 | import io.vertx.codegen.Helper; 5 | import io.vertx.codegen.TypeParamInfo; 6 | 7 | import java.io.PrintWriter; 8 | import java.util.List; 9 | 10 | public class ConstructorWithGenericTypesCodeWriter implements ConditionalCodeWriter { 11 | private final String constructor; 12 | 13 | public ConstructorWithGenericTypesCodeWriter(String constructor) { 14 | this.constructor = constructor; 15 | } 16 | 17 | public ConstructorWithGenericTypesCodeWriter() { 18 | this.constructor = null; 19 | } 20 | 21 | @Override 22 | public void generate(ClassModel model, PrintWriter writer) { 23 | String cst = constructor; 24 | if (cst == null) { 25 | cst = model.getIfaceSimpleName(); 26 | } 27 | List typeParams = model.getTypeParams(); 28 | if (typeParams.size() > 0) { 29 | writer.print(" public "); 30 | writer.print(cst); 31 | writer.print("("); 32 | writer.print(Helper.getNonGenericType(model.getIfaceFQCN())); 33 | writer.print(" delegate"); 34 | for (TypeParamInfo.Class typeParam : typeParams) { 35 | writer.print(", io.smallrye.mutiny.vertx.TypeArg<"); 36 | writer.print(typeParam.getName()); 37 | writer.print("> typeArg_"); 38 | writer.print(typeParam.getIndex()); 39 | } 40 | writer.println(") {"); 41 | if (model.isConcrete() && CodeGenHelper.hasParentClass(model)) { 42 | writer.println(" super(delegate);"); 43 | } 44 | writer.println(" this.delegate = delegate;"); 45 | for (TypeParamInfo.Class typeParam : typeParams) { 46 | writer.print(" this.__typeArg_"); 47 | writer.print(typeParam.getIndex()); 48 | writer.print(" = typeArg_"); 49 | writer.print(typeParam.getIndex()); 50 | writer.println(";"); 51 | } 52 | writer.println(" }"); 53 | writer.println(); 54 | } 55 | } 56 | 57 | @Override 58 | public boolean test(ClassModel classModel) { 59 | return classModel.isConcrete(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ConsumerMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ClassModel; 4 | 5 | import java.io.PrintWriter; 6 | 7 | /** 8 | * If the class implements {@code Handler}, we added {@code Consumer} and so we need to implement that method. 9 | */ 10 | public class ConsumerMethodCodeWriter implements ConditionalCodeWriter { 11 | @Override 12 | public void generate(ClassModel model, PrintWriter writer) { 13 | if (model.isConcrete()) { 14 | writer.println(" public void accept(" + genTypeName(model.getHandlerArg()) + " item) {"); 15 | writer.println(" handle(item);"); 16 | writer.println(" }"); 17 | } else { 18 | writer.println(" default public void accept(" + genTypeName(model.getHandlerArg()) + " item) {"); 19 | writer.println(" handle(item);"); 20 | writer.println(" }"); 21 | } 22 | } 23 | 24 | @Override 25 | public boolean test(ClassModel classModel) { 26 | return classModel.isHandler(); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/DelegateFieldCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.TypeArg; 4 | import io.vertx.codegen.ClassModel; 5 | import io.vertx.codegen.Helper; 6 | import io.vertx.codegen.TypeParamInfo; 7 | 8 | import java.io.PrintWriter; 9 | import java.util.List; 10 | 11 | import static java.util.stream.Collectors.joining; 12 | 13 | public class DelegateFieldCodeWriter implements ConditionalCodeWriter { 14 | @Override 15 | public void generate(ClassModel model, PrintWriter writer) { 16 | writer.print(" private final "); 17 | writer.print(Helper.getNonGenericType(model.getIfaceFQCN())); 18 | List typeParams = model.getTypeParams(); 19 | if (typeParams.size() > 0) { 20 | writer.print(typeParams.stream().map(TypeParamInfo.Class::getName).collect(joining(",", "<", ">"))); 21 | } 22 | writer.println(" delegate;"); 23 | 24 | for (TypeParamInfo.Class typeParam : typeParams) { 25 | writer.print(" public final " + TypeArg.class.getName() + "<"); 26 | writer.print(typeParam.getName()); 27 | writer.print("> __typeArg_"); 28 | writer.print(typeParam.getIndex()); 29 | writer.println(";"); 30 | } 31 | writer.println(" "); 32 | } 33 | 34 | @Override 35 | public boolean test(ClassModel classModel) { 36 | return classModel.isConcrete(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/DelegateMethodDeclarationCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | 7 | public class DelegateMethodDeclarationCodeWriter implements ConditionalCodeWriter { 8 | @Override 9 | public void generate(ClassModel model, PrintWriter writer) { 10 | writer.print(" "); 11 | writer.print(model.getType().getName()); 12 | writer.println(" getDelegate();"); 13 | writer.println(); 14 | } 15 | 16 | @Override 17 | public boolean test(ClassModel classModel) { 18 | return !classModel.isConcrete(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/GetDelegateMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ClassModel; 4 | 5 | import java.io.PrintWriter; 6 | 7 | public class GetDelegateMethodCodeWriter implements ConditionalCodeWriter { 8 | @Override 9 | public void generate(ClassModel model, PrintWriter writer) { 10 | writer.println(" @Override"); 11 | writer.print(" public "); 12 | writer.print(model.getType().getName()); 13 | writer.println(" getDelegate() {"); 14 | writer.println(" return delegate;"); 15 | writer.println(" }"); 16 | writer.println(); 17 | } 18 | 19 | @Override 20 | public boolean test(ClassModel classModel) { 21 | return classModel.isConcrete(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/HashCodeAndEqualsMethodsCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | import io.vertx.codegen.type.ClassTypeInfo; 7 | 8 | /** 9 | * Add the equals and hashCode methods. 10 | */ 11 | public class HashCodeAndEqualsMethodsCodeWriter implements ConditionalCodeWriter { 12 | 13 | @Override 14 | public void generate(ClassModel model, PrintWriter writer) { 15 | ClassTypeInfo type = model.getType(); 16 | writer.println(" @Override"); 17 | writer.println(" public boolean equals(Object o) {"); 18 | writer.println(" if (this == o) return true;"); 19 | writer.println(" if (o == null || getClass() != o.getClass()) return false;"); 20 | writer.print(" "); 21 | writer.print(type.getSimpleName()); 22 | writer.print(" that = ("); 23 | writer.print(type.getSimpleName()); 24 | writer.println(") o;"); 25 | writer.println(" return delegate.equals(that.delegate);"); 26 | writer.println(" }"); 27 | writer.println(" "); 28 | 29 | writer.println(" @Override"); 30 | writer.println(" public int hashCode() {"); 31 | writer.println(" return delegate.hashCode();"); 32 | writer.println(" }"); 33 | writer.println(); 34 | } 35 | 36 | @Override 37 | public boolean test(ClassModel model) { 38 | return model.isConcrete(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ImplClassCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.codegen.MutinyGenerator; 4 | import io.vertx.codegen.ClassModel; 5 | import io.vertx.codegen.Helper; 6 | import io.vertx.codegen.type.ClassTypeInfo; 7 | 8 | import java.io.PrintWriter; 9 | 10 | public class ImplClassCodeWriter implements ConditionalCodeWriter { 11 | private final MutinyGenerator generator; 12 | 13 | public ImplClassCodeWriter(MutinyGenerator mutinyGenerator) { 14 | this.generator = mutinyGenerator; 15 | } 16 | 17 | @Override 18 | public void generate(ClassModel model, PrintWriter writer) { 19 | ClassTypeInfo type = model.getType(); 20 | writer.println(); 21 | writer.print("class "); 22 | writer.print(type.getSimpleName()); 23 | writer.print("Impl"); 24 | writer.print(CodeGenHelper.genOptTypeParamsDecl(type, "")); 25 | writer.print(" implements "); 26 | writer.print(Helper.getSimpleName(model.getIfaceFQCN())); 27 | writer.println(" {"); 28 | 29 | // By-pass conditions 30 | new DelegateFieldCodeWriter().generate(model, writer); 31 | new GetDelegateMethodCodeWriter().generate(model, writer); 32 | new NoArgConstructorCodeWriter(type.getSimpleName() + "Impl").generate(model, writer); 33 | new ConstructorWithDelegateParameterCodeWriter(type.getSimpleName() + "Impl").generate(model, writer); 34 | new ConstructorWithGenericTypesCodeWriter(type.getSimpleName() + "Impl").generate(model, writer); 35 | if (model.isReadStream()) { 36 | new ToMultiMethodCodeWriter().generate(model, writer); 37 | } 38 | 39 | generator.generateClassBody(model, writer); 40 | writer.println("}"); 41 | } 42 | 43 | @Override 44 | public boolean test(ClassModel classModel) { 45 | return !classModel.isConcrete(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ImportDeclarationCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.HashSet; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import java.util.stream.Collectors; 8 | 9 | import io.smallrye.common.annotation.CheckReturnValue; 10 | import io.smallrye.mutiny.vertx.TypeArg; 11 | import io.vertx.codegen.annotations.Fluent; 12 | 13 | import io.smallrye.mutiny.Multi; 14 | import io.smallrye.mutiny.Uni; 15 | import io.vertx.codegen.ClassModel; 16 | import io.vertx.codegen.type.ClassKind; 17 | import io.vertx.codegen.type.ClassTypeInfo; 18 | 19 | public class ImportDeclarationCodeWriter implements CodeWriter { 20 | @Override 21 | public void generate(ClassModel model, PrintWriter writer) { 22 | writer.println("import " + Map.class.getName() + ";"); 23 | writer.println("import " + Collectors.class.getName() + ";"); 24 | writer.println("import " + Multi.class.getName() + ";"); 25 | writer.println("import " + Uni.class.getName() + ";"); 26 | writer.println("import " + TypeArg.class.getName() + ";"); 27 | writer.println("import " + Fluent.class.getName() + ";"); 28 | writer.println("import " + CheckReturnValue.class.getName() + ";"); 29 | 30 | Set imported = new HashSet<>(); 31 | for (ClassTypeInfo importedType : model.getImportedTypes()) { 32 | if (importedType.getKind() != ClassKind.API) { 33 | if (!importedType.getPackageName().equals("java.lang")) { 34 | if (imported.add(importedType.getSimpleName())) { 35 | writer.println("import " + importedType + ";"); 36 | } 37 | } 38 | } 39 | } 40 | writer.println(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/MutinyGenAnnotationCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | 7 | public class MutinyGenAnnotationCodeWriter implements CodeWriter { 8 | @Override 9 | public void generate(ClassModel model, PrintWriter writer) { 10 | writer.print("@io.smallrye.mutiny.vertx.MutinyGen("); 11 | writer.print(model.getType().getName()); 12 | writer.println(".class)"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/NewInstanceMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | import io.vertx.codegen.type.ClassTypeInfo; 7 | 8 | public class NewInstanceMethodCodeWriter implements CodeWriter { 9 | @Override 10 | public void generate(ClassModel model, PrintWriter writer) { 11 | ClassTypeInfo type = model.getType(); 12 | writer.print(" public static "); 13 | writer.print(CodeGenHelper.genOptTypeParamsDecl(type, " ")); 14 | writer.print(type.getSimpleName()); 15 | writer.print(CodeGenHelper.genOptTypeParamsDecl(type, "")); 16 | writer.print(" newInstance("); 17 | writer.print(type.getName()); 18 | writer.println(" arg) {"); 19 | 20 | writer.print(" return arg != null ? new "); 21 | writer.print(type.getSimpleName()); 22 | if (!model.isConcrete()) { 23 | writer.print("Impl"); 24 | } 25 | writer.print(CodeGenHelper.genOptTypeParamsDecl(type, "")); 26 | writer.println("(arg) : null;"); 27 | writer.println(" }"); 28 | writer.println(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/NewInstanceWithGenericsMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.TypeArg; 4 | import io.vertx.codegen.ClassModel; 5 | import io.vertx.codegen.TypeParamInfo; 6 | import io.vertx.codegen.type.ClassTypeInfo; 7 | 8 | import java.io.PrintWriter; 9 | 10 | import static io.smallrye.mutiny.vertx.codegen.lang.CodeGenHelper.genOptTypeParamsDecl; 11 | 12 | public class NewInstanceWithGenericsMethodCodeWriter implements ConditionalCodeWriter { 13 | @Override 14 | public void generate(ClassModel model, PrintWriter writer) { 15 | ClassTypeInfo type = model.getType(); 16 | writer.println(); 17 | writer.print(" public static "); 18 | writer.print(genOptTypeParamsDecl(type, " ")); 19 | writer.print(type.getSimpleName()); 20 | writer.print(genOptTypeParamsDecl(type, "")); 21 | writer.print(" newInstance("); 22 | writer.print(type.getName()); 23 | writer.print(" arg"); 24 | for (TypeParamInfo typeParam : type.getParams()) { 25 | writer.print(", " + TypeArg.class.getName() + "<"); 26 | writer.print(typeParam.getName()); 27 | writer.print("> __typeArg_"); 28 | writer.print(typeParam.getName()); 29 | } 30 | writer.println(") {"); 31 | 32 | writer.print(" return arg != null ? new "); 33 | writer.print(type.getSimpleName()); 34 | if (!model.isConcrete()) { 35 | writer.print("Impl"); 36 | } 37 | writer.print(genOptTypeParamsDecl(type, "")); 38 | writer.print("(arg"); 39 | for (TypeParamInfo typeParam : type.getParams()) { 40 | writer.print(", __typeArg_"); 41 | writer.print(typeParam.getName()); 42 | } 43 | writer.println(") : null;"); 44 | writer.println(" }"); 45 | writer.println(); 46 | } 47 | 48 | @Override 49 | public boolean test(ClassModel classModel) { 50 | return !classModel.getType().getParams().isEmpty(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/NoArgConstructorCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ClassModel; 4 | import io.vertx.codegen.TypeParamInfo; 5 | 6 | import java.io.PrintWriter; 7 | import java.util.List; 8 | 9 | public class NoArgConstructorCodeWriter implements ConditionalCodeWriter { 10 | private String constructor; 11 | 12 | public NoArgConstructorCodeWriter(String constructor) { 13 | this.constructor = constructor; 14 | } 15 | 16 | public NoArgConstructorCodeWriter() { 17 | this.constructor = null; 18 | } 19 | 20 | @Override 21 | public void generate(ClassModel model, PrintWriter writer) { 22 | String cst = constructor; 23 | if (cst == null) { 24 | cst = model.getIfaceSimpleName(); 25 | } 26 | 27 | List typeParams = model.getTypeParams(); 28 | // Constructor without parameter, used by CDI 29 | writer.println(" /**"); 30 | writer.println(" * Empty constructor used by CDI, do not use this constructor directly."); 31 | writer.println(" **/"); 32 | writer.print(" "); 33 | writer.print(cst); 34 | writer.println("() {"); 35 | if (model.isConcrete() && CodeGenHelper.hasParentClass(model)) { 36 | writer.println(" super(null);"); 37 | } 38 | writer.println(" this.delegate = null;"); 39 | for (TypeParamInfo.Class typeParam : typeParams) { 40 | writer.print(" this.__typeArg_"); 41 | writer.print(typeParam.getIndex()); 42 | writer.print(" = io.smallrye.mutiny.vertx.TypeArg.unknown();"); 43 | } 44 | writer.println(" }"); 45 | writer.println(); 46 | } 47 | 48 | @Override 49 | public boolean test(ClassModel classModel) { 50 | return classModel.isConcrete(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/PackageDeclarationCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.codegen.MutinyGenerator; 4 | import io.vertx.codegen.ClassModel; 5 | 6 | import java.io.PrintWriter; 7 | 8 | public class PackageDeclarationCodeWriter implements CodeWriter { 9 | 10 | @Override 11 | public void generate(ClassModel model, PrintWriter writer) { 12 | writer.print("package "); 13 | writer.print(model.getType().translatePackageName(MutinyGenerator.ID)); 14 | writer.println(";"); 15 | writer.println(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ReadStreamMethodDeclarationCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.List; 5 | 6 | import io.smallrye.mutiny.Multi; 7 | import io.vertx.codegen.ClassModel; 8 | import io.vertx.codegen.TypeParamInfo; 9 | 10 | public class ReadStreamMethodDeclarationCodeWriter implements ConditionalCodeWriter { 11 | @Override 12 | public void generate(ClassModel model, PrintWriter writer) { 13 | List params = model.getType().getParams(); 14 | writer.print(" @CheckReturnValue\n"); 15 | writer.print(" " + Multi.class.getName() + "<"); 16 | writer.print(params.get(0).getName()); 17 | writer.println("> toMulti();"); 18 | writer.println(); 19 | } 20 | 21 | @Override 22 | public boolean test(ClassModel classModel) { 23 | return !classModel.isConcrete() 24 | && classModel.getType().getRaw().getName().equals("io.vertx.core.streams.ReadStream"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ToStringMethodCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.List; 5 | 6 | import io.vertx.codegen.ClassModel; 7 | import io.vertx.codegen.MethodInfo; 8 | 9 | /** 10 | * Add toString if not in the list of method 11 | */ 12 | public class ToStringMethodCodeWriter implements ConditionalCodeWriter { 13 | 14 | @Override 15 | public void generate(ClassModel model, PrintWriter writer) { 16 | writer.println(" @Override"); 17 | writer.println(" public String toString() {"); 18 | writer.println(" return delegate.toString();"); 19 | writer.println(" }"); 20 | writer.println(); 21 | } 22 | 23 | @Override 24 | public boolean test(ClassModel model) { 25 | List methods = model.getMethods(); 26 | return model.isConcrete() 27 | && methods.stream().noneMatch(it -> it.getParams().isEmpty() && "toString".equals(it.getName())); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/ToSubscriberCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import io.vertx.codegen.ClassModel; 6 | import io.vertx.codegen.type.ClassKind; 7 | import io.vertx.codegen.type.TypeInfo; 8 | 9 | public class ToSubscriberCodeWriter implements ConditionalCodeWriter { 10 | @Override 11 | public void generate(ClassModel model, PrintWriter writer) { 12 | TypeInfo itemType = model.getWriteStreamArg(); 13 | writer.format(" private io.smallrye.mutiny.vertx.WriteStreamSubscriber<%s> subscriber;%n", 14 | genTypeName(itemType)); 15 | 16 | writer.println(); 17 | 18 | genToSubscriber(itemType, writer); 19 | } 20 | 21 | private void genToSubscriber(TypeInfo itemType, PrintWriter writer) { 22 | writer.format(" @CheckReturnValue\n"); 23 | writer.format(" public synchronized io.smallrye.mutiny.vertx.WriteStreamSubscriber<%s> toSubscriber() {%n", 24 | genTypeName(itemType)); 25 | writer.format(" if (%s == null) {%n", "subscriber"); 26 | 27 | if (itemType.getKind() == ClassKind.API) { 28 | writer.format(" java.util.function.Function<%s, %s> conv = %s::getDelegate;%n", genTypeName(itemType.getRaw()), 29 | itemType.getName(), genTypeName(itemType)); 30 | writer.format(" %s = io.smallrye.mutiny.vertx.MutinyHelper.toSubscriber(getDelegate(), conv);%n", 31 | "subscriber"); 32 | } else if (itemType.isVariable()) { 33 | String typeVar = itemType.getSimpleName(); 34 | writer.format( 35 | " java.util.function.Function<%s, %s> conv = (java.util.function.Function<%s, %s>) __typeArg_0.unwrap;%n", 36 | typeVar, typeVar, typeVar, typeVar); 37 | writer.format(" %s = io.smallrye.mutiny.vertx.MutinyHelper.toSubscriber(getDelegate(), conv);%n", 38 | "subscriber"); 39 | } else { 40 | writer.format(" %s = io.smallrye.mutiny.vertx.MutinyHelper.toSubscriber(getDelegate());%n", "subscriber"); 41 | } 42 | 43 | writer.println(" }"); 44 | writer.format(" return %s;%n", "subscriber"); 45 | writer.println(" }"); 46 | writer.println(); 47 | } 48 | 49 | @Override 50 | public boolean test(ClassModel classModel) { 51 | return classModel.isConcrete() && classModel.isWriteStream(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/TypeArgsConstantCodeWriter.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.smallrye.mutiny.vertx.TypeArg; 4 | import io.vertx.codegen.ClassModel; 5 | import io.vertx.codegen.type.ClassTypeInfo; 6 | 7 | import java.io.PrintWriter; 8 | 9 | public class TypeArgsConstantCodeWriter implements ConditionalCodeWriter { 10 | @Override 11 | public void generate(ClassModel model, PrintWriter writer) { 12 | ClassTypeInfo type = model.getType(); 13 | String simpleName = type.getSimpleName(); 14 | 15 | writer.print(" public static final " + TypeArg.class.getName() + "<"); 16 | writer.print(simpleName); 17 | writer.print("> __TYPE_ARG = new " + TypeArg.class.getName() + "<>("); 18 | writer.print(" obj -> new "); 19 | writer.print(simpleName); 20 | writer.print("(("); 21 | writer.print(type.getName()); 22 | writer.println(") obj),"); 23 | writer.print(" "); 24 | writer.print(simpleName); 25 | writer.println("::getDelegate"); 26 | writer.println(" );"); 27 | writer.println(); 28 | } 29 | 30 | @Override 31 | public boolean test(ClassModel classModel) { 32 | return classModel.isConcrete(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/java/io/smallrye/mutiny/vertx/codegen/lang/TypeHelper.java: -------------------------------------------------------------------------------- 1 | package io.smallrye.mutiny.vertx.codegen.lang; 2 | 3 | import io.vertx.codegen.ParamInfo; 4 | import io.vertx.codegen.type.ParameterizedTypeInfo; 5 | import io.vertx.codegen.type.TypeInfo; 6 | import io.vertx.core.Handler; 7 | import io.vertx.core.Promise; 8 | 9 | import java.util.function.Consumer; 10 | 11 | public class TypeHelper { 12 | 13 | public static boolean isHandlerOfPromise(ParamInfo it) { 14 | boolean parameterized = it.getType().isParameterized(); 15 | if (! parameterized) { 16 | return false; 17 | } 18 | ParameterizedTypeInfo type = (ParameterizedTypeInfo) it.getType(); 19 | if (! type.getRaw().getName().equals(Handler.class.getName())) { 20 | return false; 21 | } 22 | TypeInfo arg = type.getArg(0); 23 | if (arg.isParameterized()) { 24 | return arg.getRaw().getName().equals(Promise.class.getName()); 25 | } else { 26 | return arg.getName().equals(Promise.class.getName()); 27 | } 28 | } 29 | 30 | public static boolean isConsumerOfPromise(ParamInfo it) { 31 | return isConsumerOfPromise(it.getType()); 32 | } 33 | 34 | public static boolean isConsumerOfPromise(TypeInfo type) { 35 | if (! type.isParameterized()) { 36 | return false; 37 | } 38 | ParameterizedTypeInfo parameterized = (ParameterizedTypeInfo) type; 39 | if (! parameterized.getRaw().getName().equals(Consumer.class.getName())) { 40 | return false; 41 | } 42 | TypeInfo arg = parameterized.getArg(0); 43 | if (arg.isParameterized()) { 44 | return arg.getRaw().getName().equals(Promise.class.getName()); 45 | } else { 46 | return arg.getName().equals(Promise.class.getName()); 47 | } 48 | } 49 | 50 | public static boolean isConsumerOfVoid(TypeInfo type) { 51 | if (! type.isParameterized()) { 52 | return false; 53 | } 54 | ParameterizedTypeInfo parameterized = (ParameterizedTypeInfo) type; 55 | if (! parameterized.getRaw().getName().equals(Consumer.class.getName())) { 56 | return false; 57 | } 58 | TypeInfo arg = parameterized.getArg(0); 59 | return arg.isVoid() || arg.getName().equals(Void.class.getName()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/main/resources/META-INF/services/io.vertx.codegen.GeneratorLoader: -------------------------------------------------------------------------------- 1 | io.smallrye.mutiny.vertx.codegen.MutinyGeneratorLoader 2 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Plexus Archiver 3.5 3 | 4 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/META-INF/vertx/json-mappers.properties: -------------------------------------------------------------------------------- 1 | io.vertx.codegen.testmodel.MyPojoToInteger.serializer=io.vertx.codegen.testmodel.JsonMapperTCK#serializeMyPojoToInteger 2 | io.vertx.codegen.testmodel.MyPojoToInteger.deserializer=io.vertx.codegen.testmodel.JsonMapperTCK#deserializeMyPojoToInteger 3 | io.vertx.codegen.testmodel.MyPojoToJsonObject.serializer=io.vertx.codegen.testmodel.JsonMapperTCK#serializeMyPojoToJsonObject 4 | io.vertx.codegen.testmodel.MyPojoToJsonObject.deserializer=io.vertx.codegen.testmodel.JsonMapperTCK#deserializeMyPojoToJsonObject 5 | io.vertx.codegen.testmodel.MyPojoToJsonArray.serializer=io.vertx.codegen.testmodel.JsonMapperTCK#serializeMyPojoToJsonArray 6 | io.vertx.codegen.testmodel.MyPojoToJsonArray.deserializer=io.vertx.codegen.testmodel.JsonMapperTCK#deserializeMyPojoToJsonArray 7 | java.time.ZonedDateTime.serializer=io.vertx.codegen.testmodel.JsonMapperTCK#serializeZonedDateTime 8 | java.time.ZonedDateTime.deserializer=io.vertx.codegen.testmodel.JsonMapperTCK#deserializeZonedDateTime 9 | io.vertx.codegen.testmodel.TestCustomEnum.serializer=io.vertx.codegen.testmodel.JsonMapperTCK#serializeCustomEnum 10 | io.vertx.codegen.testmodel.TestCustomEnum.deserializer=io.vertx.codegen.testmodel.JsonMapperTCK#deserializeCustomEnum 11 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/com/acme/pkg/MyInterface.java: -------------------------------------------------------------------------------- 1 | package com.acme.pkg; 2 | 3 | import com.acme.pkg.sub.SubInterface; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.codegen.testmodel.TestInterface; 6 | 7 | /** 8 | * @author Julien Viet 9 | */ 10 | @VertxGen 11 | public interface MyInterface { 12 | 13 | static MyInterface create() { 14 | return new MyInterfaceImpl(); 15 | } 16 | 17 | SubInterface sub(); 18 | 19 | TestInterface method(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/com/acme/pkg/MyInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package com.acme.pkg; 2 | 3 | import com.acme.pkg.sub.SubInterface; 4 | import com.acme.pkg.sub.SubInterfaceImpl; 5 | import io.vertx.codegen.testmodel.TestInterface; 6 | import io.vertx.codegen.testmodel.TestInterfaceImpl; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | public class MyInterfaceImpl implements MyInterface { 12 | 13 | @Override 14 | public SubInterface sub() { 15 | return new SubInterfaceImpl(); 16 | } 17 | 18 | @Override 19 | public TestInterface method() { 20 | return new TestInterfaceImpl(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/com/acme/pkg/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Julien Viet 3 | */ 4 | @ModuleGen(name = "acme", groupPackage = "com.acme") 5 | package com.acme.pkg; 6 | 7 | import io.vertx.codegen.annotations.ModuleGen; 8 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/com/acme/pkg/sub/SubInterface.java: -------------------------------------------------------------------------------- 1 | package com.acme.pkg.sub; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Julien Viet 7 | */ 8 | @VertxGen 9 | public interface SubInterface { 10 | 11 | String reverse(String s); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/com/acme/pkg/sub/SubInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package com.acme.pkg.sub; 2 | 3 | /** 4 | * @author Julien Viet 5 | */ 6 | public class SubInterfaceImpl implements SubInterface { 7 | 8 | @Override 9 | public String reverse(String s) { 10 | return new StringBuilder(s).reverse().toString(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/AbstractHandlerUserType.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.Handler; 5 | 6 | /** 7 | * @author Julien Viet 8 | */ 9 | @VertxGen(concrete = false) 10 | public interface AbstractHandlerUserType extends Handler { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/AnyJavaTypeTCK.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.GenIgnore; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | 8 | import java.net.Socket; 9 | import java.util.List; 10 | import java.util.Map; 11 | import java.util.Set; 12 | 13 | @VertxGen() 14 | public interface AnyJavaTypeTCK { 15 | 16 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithJavaTypeParam(Socket socket); 17 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithListOfJavaTypeParam(List socketList); 18 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithSetOfJavaTypeParam(Set socketSet); 19 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithMapOfJavaTypeParam(Map socketMap); 20 | 21 | @GenIgnore(GenIgnore.PERMITTED_TYPE) Socket methodWithJavaTypeReturn(); 22 | @GenIgnore(GenIgnore.PERMITTED_TYPE) List methodWithListOfJavaTypeReturn(); 23 | @GenIgnore(GenIgnore.PERMITTED_TYPE) Set methodWithSetOfJavaTypeReturn(); 24 | @GenIgnore(GenIgnore.PERMITTED_TYPE) Map methodWithMapOfJavaTypeReturn(); 25 | 26 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerJavaTypeParam(Handler socketHandler); 27 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerListOfJavaTypeParam(Handler> socketListHandler); 28 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerSetOfJavaTypeParam(Handler> socketSetHandler); 29 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerMapOfJavaTypeParam(Handler> socketMapHandler); 30 | 31 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerAsyncResultJavaTypeParam(Handler> socketHandler); 32 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerAsyncResultListOfJavaTypeParam(Handler>> socketListHandler); 33 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerAsyncResultSetOfJavaTypeParam(Handler>> socketSetHandler); 34 | @GenIgnore(GenIgnore.PERMITTED_TYPE) void methodWithHandlerAsyncResultMapOfJavaTypeParam(Handler>> socketMapHandler); 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/ConcreteHandlerUserType.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.Handler; 5 | 6 | /** 7 | * @author Julien Viet 8 | */ 9 | @VertxGen 10 | public interface ConcreteHandlerUserType extends Handler { 11 | } 12 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/ConcreteHandlerUserTypeExtension.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Julien Viet 7 | */ 8 | @VertxGen 9 | public interface ConcreteHandlerUserTypeExtension extends ConcreteHandlerUserType { 10 | } 11 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DataObjectTCK.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * todo: 7 | * - Buffer support 8 | * 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface DataObjectTCK { 13 | 14 | DataObjectWithValues getDataObjectWithValues(); 15 | 16 | void setDataObjectWithValues(DataObjectWithValues dataObject); 17 | 18 | DataObjectWithLists getDataObjectWithLists(); 19 | 20 | void setDataObjectWithLists(DataObjectWithLists dataObject); 21 | 22 | DataObjectWithMaps getDataObjectWithMaps(); 23 | 24 | void setDataObjectWithMaps(DataObjectWithMaps dataObject); 25 | 26 | void methodWithOnlyJsonObjectConstructorDataObject(DataObjectWithOnlyJsonObjectConstructor dataObject); 27 | 28 | void setDataObjectWithBuffer(DataObjectWithNestedBuffer dataObject); 29 | 30 | void setDataObjectWithListAdders(DataObjectWithListAdders dataObject); 31 | 32 | void setDataObjectWithMapAdders(DataObjectWithMapAdders dataObject); 33 | 34 | void setDataObjectWithRecursion(DataObjectWithRecursion dataObject); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DataObjectWithBuffer.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.buffer.Buffer; 5 | import io.vertx.core.json.JsonArray; 6 | import io.vertx.core.json.JsonObject; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author Julien Viet 13 | */ 14 | @DataObject(generateConverter = true) 15 | public class DataObjectWithBuffer { 16 | 17 | private Buffer buffer; 18 | 19 | public DataObjectWithBuffer() { 20 | } 21 | 22 | public DataObjectWithBuffer(JsonObject json) { 23 | byte[] buffer = json.getBinary("buffer"); 24 | this.buffer = buffer != null ? Buffer.buffer(buffer) : null; 25 | 26 | } 27 | 28 | public Buffer getBuffer() { 29 | return buffer; 30 | } 31 | 32 | public void setBuffer(Buffer buffer) { 33 | this.buffer = buffer; 34 | } 35 | 36 | public JsonObject toJson() { 37 | JsonObject json = new JsonObject(); 38 | if (buffer != null) { 39 | json.put("buffer", buffer.getBytes()); 40 | } 41 | return json; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DataObjectWithNestedBuffer.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.buffer.Buffer; 5 | import io.vertx.core.json.JsonArray; 6 | import io.vertx.core.json.JsonObject; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author Julien Viet 13 | */ 14 | @DataObject(generateConverter = true) 15 | public class DataObjectWithNestedBuffer { 16 | 17 | private Buffer buffer; 18 | private DataObjectWithBuffer nested; 19 | private List buffers; 20 | 21 | public DataObjectWithNestedBuffer() { 22 | } 23 | 24 | public DataObjectWithNestedBuffer(JsonObject json) { 25 | byte[] buffer = json.getBinary("buffer"); 26 | this.buffer = buffer != null ? Buffer.buffer(buffer) : null; 27 | JsonObject nested = json.getJsonObject("nested"); 28 | this.nested = nested != null ? new DataObjectWithBuffer(nested) : null; 29 | JsonArray buffers_ = json.getJsonArray("buffers"); 30 | if (buffers_ != null) { 31 | this.buffers = new ArrayList<>(); 32 | for (int i = 0;i < buffers_.size();i++) { 33 | buffers.add(Buffer.buffer(buffers_.getBinary(i))); 34 | } 35 | } 36 | 37 | } 38 | 39 | public Buffer getBuffer() { 40 | return buffer; 41 | } 42 | 43 | public void setBuffer(Buffer buffer) { 44 | this.buffer = buffer; 45 | } 46 | 47 | public List getBuffers() { 48 | return buffers; 49 | } 50 | 51 | public void setBuffers(List buffers) { 52 | this.buffers = buffers; 53 | } 54 | 55 | public DataObjectWithBuffer getNested() { 56 | return nested; 57 | } 58 | 59 | public void setNested(DataObjectWithBuffer nested) { 60 | this.nested = nested; 61 | } 62 | 63 | public JsonObject toJson() { 64 | JsonObject json = new JsonObject(); 65 | if (buffer != null) { 66 | json.put("buffer", buffer.getBytes()); 67 | } 68 | if (buffers != null) { 69 | JsonArray arr = new JsonArray(); 70 | for (Buffer b : buffers) { 71 | arr.add(b.getBytes()); 72 | } 73 | json.put("buffers", arr); 74 | } 75 | if (nested != null) { 76 | json.put("nested", nested.toJson()); 77 | } 78 | return json; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DataObjectWithOnlyJsonObjectConstructor.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.json.JsonObject; 5 | 6 | /** 7 | * @author Dan O'Reilly 8 | */ 9 | @DataObject(generateConverter = true) 10 | public class DataObjectWithOnlyJsonObjectConstructor { 11 | private String foo; 12 | 13 | public DataObjectWithOnlyJsonObjectConstructor(JsonObject jsonObject) { 14 | this.foo = jsonObject.getString("foo"); 15 | } 16 | 17 | public JsonObject toJson() { 18 | return new JsonObject().put("foo", foo); 19 | } 20 | 21 | public String getFoo() { 22 | return foo; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DataObjectWithRecursion.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.json.JsonObject; 5 | 6 | /** 7 | * @author Julien Viet 8 | */ 9 | @DataObject(generateConverter = true) 10 | public class DataObjectWithRecursion { 11 | 12 | private String data; 13 | private DataObjectWithRecursion next; 14 | 15 | public DataObjectWithRecursion(JsonObject json) { 16 | data = json.getString("data"); 17 | if (json.getJsonObject("next") != null) { 18 | next = new DataObjectWithRecursion(json.getJsonObject("next")); 19 | } 20 | } 21 | 22 | public String getData() { 23 | return data; 24 | } 25 | 26 | public DataObjectWithRecursion setData(String data) { 27 | this.data = data; 28 | return this; 29 | } 30 | 31 | public DataObjectWithRecursion getNext() { 32 | return next; 33 | } 34 | 35 | public DataObjectWithRecursion setNext(DataObjectWithRecursion next) { 36 | this.next = next; 37 | return this; 38 | } 39 | 40 | public JsonObject toJson() { 41 | JsonObject json = new JsonObject(); 42 | if (data != null) { 43 | json.put("data", data); 44 | } 45 | if (next != null) { 46 | json.put("next", next.toJson()); 47 | } 48 | return json; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/DeprecatedType.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | @VertxGen 6 | @Deprecated 7 | public interface DeprecatedType { 8 | 9 | void someMethod(); 10 | 11 | @Deprecated 12 | void someOtherMethod(); 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/Factory.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.Handler; 5 | 6 | /** 7 | * @author Julien Viet 8 | */ 9 | @VertxGen 10 | public interface Factory { 11 | 12 | static ConcreteHandlerUserType createConcreteHandlerUserType(Handler handler) { 13 | return handler::handle; 14 | } 15 | 16 | static AbstractHandlerUserType createAbstractHandlerUserType(Handler handler) { 17 | return handler::handle; 18 | } 19 | 20 | static ConcreteHandlerUserTypeExtension createConcreteHandlerUserTypeExtension(Handler handler) { 21 | return handler::handle; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/FutureTCK.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Future; 6 | import io.vertx.core.Handler; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface FutureTCK { 13 | 14 | Future asyncMethod(); 15 | void asyncMethod(Handler> handler); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/GenericNullableRefedInterface.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations.Nullable; 5 | import io.vertx.codegen.annotations.VertxGen; 6 | 7 | /** 8 | * @author Julien Viet 9 | */ 10 | @VertxGen 11 | public interface GenericNullableRefedInterface { 12 | 13 | @Nullable T getValue(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/GenericRefedInterface.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | 6 | /** 7 | * @author Julien Viet 8 | */ 9 | @VertxGen 10 | public interface GenericRefedInterface { 11 | 12 | @Fluent 13 | GenericRefedInterface setValue(T value); 14 | 15 | T getValue(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/GenericRefedInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | /** 4 | * @author Julien Viet 5 | */ 6 | public class GenericRefedInterfaceImpl implements GenericRefedInterface { 7 | 8 | private T value; 9 | 10 | @Override 11 | public GenericRefedInterface setValue(T value) { 12 | this.value = value; 13 | return this; 14 | } 15 | 16 | @Override 17 | public T getValue() { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/InterfaceWithApiArg.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Julien Viet 7 | */ 8 | @VertxGen 9 | public interface InterfaceWithApiArg extends GenericRefedInterface { 10 | 11 | void meth(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/InterfaceWithStringArg.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Julien Viet 7 | */ 8 | @VertxGen 9 | public interface InterfaceWithStringArg extends GenericRefedInterface { 10 | 11 | void meth(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/InterfaceWithVariableArg.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Julien Viet 7 | */ 8 | @VertxGen 9 | public interface InterfaceWithVariableArg extends GenericRefedInterface { 10 | 11 | void setOtherValue(T value); 12 | 13 | T getOtherValue(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/MyPojoToInteger.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import java.util.Objects; 4 | 5 | public class MyPojoToInteger { 6 | 7 | int a; 8 | 9 | public MyPojoToInteger() { 10 | } 11 | 12 | public MyPojoToInteger(int a) { 13 | this.a = a; 14 | } 15 | 16 | public int getA() { 17 | return a; 18 | } 19 | 20 | public void setA(int a) { 21 | this.a = a; 22 | } 23 | 24 | @Override 25 | public boolean equals(Object o) { 26 | if (this == o) return true; 27 | if (o == null || getClass() != o.getClass()) return false; 28 | MyPojoToInteger that = (MyPojoToInteger) o; 29 | return a == that.a; 30 | } 31 | 32 | @Override 33 | public int hashCode() { 34 | return Objects.hash(a); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/MyPojoToJsonArray.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import java.util.List; 4 | import java.util.Objects; 5 | 6 | public class MyPojoToJsonArray { 7 | 8 | List stuff; 9 | 10 | public MyPojoToJsonArray() { } 11 | 12 | public MyPojoToJsonArray(List stuff) { 13 | this.stuff = stuff; 14 | } 15 | 16 | public List getStuff() { 17 | return stuff; 18 | } 19 | 20 | public void setStuff(List stuff) { 21 | this.stuff = stuff; 22 | } 23 | 24 | @Override 25 | public boolean equals(Object o) { 26 | if (this == o) return true; 27 | if (o == null || getClass() != o.getClass()) return false; 28 | MyPojoToJsonArray that = (MyPojoToJsonArray) o; 29 | return Objects.equals(stuff, that.stuff); 30 | } 31 | 32 | @Override 33 | public int hashCode() { 34 | return Objects.hash(stuff); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/MyPojoToJsonObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import java.util.Objects; 4 | 5 | public class MyPojoToJsonObject { 6 | 7 | int v; 8 | 9 | public MyPojoToJsonObject() { } 10 | 11 | public MyPojoToJsonObject(int v) { 12 | this.v = v; 13 | } 14 | 15 | public int getV() { 16 | return v; 17 | } 18 | 19 | public void setV(int v) { 20 | this.v = v; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (this == o) return true; 26 | if (o == null || getClass() != o.getClass()) return false; 27 | MyPojoToJsonObject that = (MyPojoToJsonObject) o; 28 | return v == that.v; 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return Objects.hash(v); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/RefedInterface1.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations 5 | .VertxGen; 6 | 7 | /** 8 | * @author Tim Fox 9 | */ 10 | @VertxGen 11 | public interface RefedInterface1 { 12 | 13 | String getString(); 14 | 15 | @Fluent 16 | RefedInterface1 setString(String str); 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/RefedInterface1Impl.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | /** 4 | * @author Tim Fox 5 | */ 6 | public class RefedInterface1Impl implements RefedInterface1 { 7 | 8 | private String str; 9 | 10 | @Override 11 | public String getString() { 12 | return str; 13 | } 14 | 15 | @Override 16 | public RefedInterface1 setString(String str) { 17 | this.str = str; 18 | return this; 19 | } 20 | 21 | @Override 22 | public boolean equals(Object obj) { 23 | if (!(obj instanceof RefedInterface1Impl)) 24 | return false; 25 | return ((RefedInterface1Impl) obj).str.equals(str); 26 | } 27 | 28 | @Override 29 | public int hashCode() { 30 | return str != null ? str.hashCode() : 0; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "TestInterface1[str=" + str + "]"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/RefedInterface2.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | 6 | /** 7 | * @author Tim Fox 8 | */ 9 | @VertxGen(concrete = false) 10 | public interface RefedInterface2 { 11 | 12 | String getString(); 13 | 14 | @Fluent 15 | RefedInterface2 setString(String str); 16 | } 17 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/RefedInterface2Impl.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | /** 4 | * @author Tim Fox 5 | */ 6 | public class RefedInterface2Impl implements RefedInterface2 { 7 | 8 | private String str; 9 | 10 | @Override 11 | public String getString() { 12 | return str; 13 | } 14 | 15 | @Override 16 | public RefedInterface2 setString(String str) { 17 | this.str = str; 18 | return this; 19 | } 20 | 21 | @Override 22 | public boolean equals(Object obj) { 23 | return ((RefedInterface2Impl) obj).str.equals(str); 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "TestInterface2[str=" + str + "]"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/SuperInterface1.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Tim Fox 7 | */ 8 | @VertxGen 9 | public interface SuperInterface1 { 10 | 11 | void superMethodWithBasicParams(byte b, short s, int i, long l, float f, double d, boolean bool, char ch, String str); 12 | 13 | int superMethodOverloadedBySubclass(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/SuperInterface2.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Tim Fox 7 | */ 8 | @VertxGen(concrete = false) 9 | public interface SuperInterface2 { 10 | 11 | void otherSuperMethodWithBasicParams(byte b, short s, int i, long l, float f, double d, boolean bool, char ch, String str); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/TestCustomEnum.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | public enum TestCustomEnum { 4 | 5 | DEV("dev", "development"), 6 | 7 | ITEST("itest", "integration-test"); 8 | 9 | public static TestCustomEnum of(String pName) { 10 | for (TestCustomEnum item : TestCustomEnum.values()) { 11 | if (item.names[0].equalsIgnoreCase(pName) || item.names[1].equalsIgnoreCase(pName) 12 | || pName.equalsIgnoreCase(item.name())) { 13 | return item; 14 | } 15 | } 16 | return DEV; 17 | } 18 | 19 | private String[] names = new String[2]; 20 | 21 | TestCustomEnum(String pShortName, String pLongName) { 22 | names[0] = pShortName; 23 | names[1] = pLongName; 24 | } 25 | 26 | public String getLongName() { 27 | return names[1]; 28 | } 29 | 30 | public String getShortName() { 31 | return names[0]; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/TestDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | import io.vertx.core.json.JsonObject; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author Tim Fox 10 | */ 11 | @DataObject 12 | public class TestDataObject { 13 | 14 | private String foo; 15 | private int bar; 16 | private double wibble; 17 | 18 | public TestDataObject() { 19 | } 20 | 21 | public TestDataObject(TestDataObject other) { 22 | this.foo = other.foo; 23 | this.bar = other.bar; 24 | this.wibble = other.wibble; 25 | } 26 | 27 | public TestDataObject(JsonObject json) { 28 | this.foo = json.getString("foo", null); 29 | this.bar = json.getInteger("bar", 0); 30 | this.wibble = json.getDouble("wibble", 0d); 31 | } 32 | 33 | public String getFoo() { 34 | return foo; 35 | } 36 | 37 | public TestDataObject setFoo(String foo) { 38 | this.foo = foo; 39 | return this; 40 | } 41 | 42 | public int getBar() { 43 | return bar; 44 | } 45 | 46 | public TestDataObject setBar(int bar) { 47 | this.bar = bar; 48 | return this; 49 | } 50 | 51 | public double getWibble() { 52 | return wibble; 53 | } 54 | 55 | public TestDataObject setWibble(double wibble) { 56 | this.wibble = wibble; 57 | return this; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | if (obj instanceof TestDataObject) { 63 | TestDataObject that = (TestDataObject) obj; 64 | return Objects.equals(foo, that.foo) && bar == that.bar && wibble == that.wibble; 65 | } 66 | return false; 67 | } 68 | 69 | @Override 70 | public int hashCode() { 71 | return Objects.hash(getFoo(), getBar(), getWibble()); 72 | } 73 | 74 | public JsonObject toJson() { 75 | JsonObject json = new JsonObject(); 76 | json.put("foo", this.foo); 77 | json.put("bar", this.bar); 78 | json.put("wibble", this.wibble); 79 | return json; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/TestEnum.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | /** 4 | * @author Tim Fox 5 | */ 6 | public enum TestEnum { 7 | TIM, JULIEN, NICK, WESTON 8 | } 9 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/TestGenEnum.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Tim Fox 7 | */ 8 | @VertxGen 9 | public enum TestGenEnum { 10 | LAURA, BOB, MIKE, LELAND 11 | } 12 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/TestStringDataObject.java: -------------------------------------------------------------------------------- 1 | package io.vertx.codegen.testmodel; 2 | 3 | import io.vertx.codegen.annotations.DataObject; 4 | 5 | import java.util.Objects; 6 | 7 | /** 8 | * @author Tim Fox 9 | */ 10 | @DataObject 11 | public class TestStringDataObject { 12 | 13 | private String value; 14 | 15 | public TestStringDataObject() { 16 | } 17 | 18 | public TestStringDataObject(TestStringDataObject other) { 19 | this.value = other.value; 20 | } 21 | 22 | public TestStringDataObject(String value) { 23 | this.value = value; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | 30 | public TestStringDataObject setValue(String value) { 31 | this.value = value; 32 | return this; 33 | } 34 | 35 | 36 | @Override 37 | public boolean equals(Object obj) { 38 | if (obj instanceof TestStringDataObject) { 39 | TestStringDataObject that = (TestStringDataObject) obj; 40 | return Objects.equals(value, that.value); 41 | } 42 | return false; 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hash(value); 48 | } 49 | 50 | public String toJson() { 51 | return value; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/codegen/testmodel/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Julien Viet 3 | */ 4 | @ModuleGen( 5 | name = "testmodel", 6 | groupPackage = "io.vertx") 7 | package io.vertx.codegen.testmodel; 8 | 9 | import io.vertx.codegen.annotations.ModuleGen; 10 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/core/streams/StreamBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.core.streams; 13 | 14 | import io.vertx.codegen.annotations.Fluent; 15 | import io.vertx.codegen.annotations.Nullable; 16 | import io.vertx.codegen.annotations.VertxGen; 17 | import io.vertx.core.Handler; 18 | 19 | /** 20 | * Base interface for a stream. 21 | * 22 | * @author Tim Fox 23 | */ 24 | @VertxGen(concrete = false) 25 | public interface StreamBase { 26 | 27 | /** 28 | * Set an exception handler. 29 | * 30 | * @param handler the handler 31 | * @return a reference to this, so the API can be used fluently 32 | */ 33 | @Fluent 34 | StreamBase exceptionHandler(@Nullable Handler handler); 35 | } 36 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/io/vertx/core/streams/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Public License 2.0 which is available at 6 | * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 7 | * which is available at https://www.apache.org/licenses/LICENSE-2.0. 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 10 | */ 11 | 12 | package io.vertx.core.streams; 13 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/AnotherInterface.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * @author Clement Escoffier 7 | */ 8 | @VertxGen 9 | public interface AnotherInterface { 10 | 11 | static AnotherInterface create() { 12 | return new AnotherInterfaceImpl(); 13 | } 14 | 15 | T methodWithClassParam(Class tClass); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/AnotherInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * @author Clement Escoffier 7 | */ 8 | public class AnotherInterfaceImpl implements AnotherInterface { 9 | @Override 10 | public T methodWithClassParam(Class tClass) { 11 | Objects.requireNonNull(tClass); 12 | try { 13 | return tClass.getDeclaredConstructor().newInstance(); 14 | } catch (Exception e) { 15 | throw new RuntimeException(e); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/Bar.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.GenIgnore; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | 6 | /** 7 | * @author Clement Escoffier 8 | */ 9 | @VertxGen 10 | public interface Bar { 11 | @GenIgnore 12 | class Impl implements Bar { 13 | } 14 | } -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/ConcreteInheritsToString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 2.0 5 | * (the "License"); you may not use this file except in compliance with the 6 | * License. You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | package org.extra; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | 21 | /** 22 | * @author Thomas Segismont 23 | */ 24 | @VertxGen 25 | public interface ConcreteInheritsToString extends NonConcreteWithToString { 26 | void doSomething(); 27 | } 28 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/ConcreteOverridesToString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 2.0 5 | * (the "License"); you may not use this file except in compliance with the 6 | * License. You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | package org.extra; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | 21 | /** 22 | * @author Thomas Segismont 23 | */ 24 | @VertxGen 25 | public interface ConcreteOverridesToString extends NonConcreteWithToString { 26 | void doSomething(); 27 | 28 | /** 29 | * My even more special toString method 30 | */ 31 | String toString(); 32 | } 33 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/ExtendsWithSameSimpleName.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.CacheReturn; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | import io.vertx.core.streams.ReadStream; 8 | import org.extra.sub.UseVertxGenNameDeclarationsWithSameSimpleName; 9 | 10 | import java.util.function.Function; 11 | 12 | @VertxGen 13 | public interface ExtendsWithSameSimpleName extends 14 | UseVertxGenNameDeclarationsWithSameSimpleName, 15 | Handler, 16 | ReadStream { 17 | 18 | @CacheReturn 19 | UseVertxGenNameDeclarationsWithSameSimpleName foo(UseVertxGenNameDeclarationsWithSameSimpleName arg); 20 | 21 | void function( 22 | Function function); 23 | 24 | void asyncResult(Handler> handler); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/Foo.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.GenIgnore; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | 6 | /** 7 | * @author Clement Escoffier 8 | */ 9 | @VertxGen 10 | public interface Foo { 11 | @GenIgnore 12 | class Impl implements Foo { 13 | } 14 | } -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/Generic1.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations.GenIgnore; 5 | import io.vertx.codegen.annotations.VertxGen; 6 | 7 | @VertxGen 8 | public interface Generic1 { 9 | 10 | T getValue(); 11 | @Fluent 12 | Generic1 setValue(T value); 13 | 14 | @GenIgnore 15 | class Impl implements Generic1 { 16 | T value; 17 | @Override 18 | public T getValue() { 19 | return value; 20 | } 21 | @Override 22 | public Impl setValue(T value) { 23 | this.value = value; 24 | return this; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/Generic2.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.Fluent; 4 | import io.vertx.codegen.annotations.GenIgnore; 5 | import io.vertx.codegen.annotations.VertxGen; 6 | 7 | @VertxGen 8 | public interface Generic2 { 9 | 10 | T getValue1(); 11 | @Fluent 12 | Generic2 setValue1(T value); 13 | U getValue2(); 14 | @Fluent 15 | Generic2 setValue2(U value); 16 | 17 | @GenIgnore 18 | class Impl implements Generic2 { 19 | T value1 = null; 20 | U value2 = null; 21 | @Override 22 | public T getValue1() { 23 | return value1; 24 | } 25 | @Override 26 | public Impl setValue1(T value) { 27 | value1 = value; 28 | return this; 29 | } 30 | @Override 31 | public U getValue2() { 32 | return value2; 33 | } 34 | @Override 35 | public Impl setValue2(U value) { 36 | value2 = value; 37 | return this; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/JavadocTest.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Handler; 6 | 7 | import java.util.Collection; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | @VertxGen 12 | public interface JavadocTest { 13 | 14 | 15 | /** 16 | * Do something. 17 | * @param list list 18 | * @param handler handler 19 | */ 20 | void doSomething(List list, Handler> handler); 21 | 22 | /** 23 | * Do something. 24 | * @param list1 list 25 | * @param list2 list 26 | * @param handler handler 27 | */ 28 | void doSomething2(List list1, List list2, Handler> handler); 29 | 30 | 31 | /** 32 | * Do something. 33 | * @param list list 34 | */ 35 | void doSomething3(List list, Handler> handler); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithCompletable.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Handler; 6 | 7 | /** 8 | * @author Julien Viet 9 | */ 10 | @VertxGen 11 | public interface MethodWithCompletable { 12 | 13 | void doSomethingWithResult(Handler> handler); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithGenericFunctionArg.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.json.JsonObject; 5 | 6 | import java.util.function.Function; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface MethodWithGenericFunctionArg { 13 | MethodWithGenericFunctionArg doSomething(Function, T> theFunction); 14 | } 15 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithMaybeString.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.Nullable; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface MethodWithMaybeString { 13 | void doSomethingWithMaybeResult(Handler> handler); 14 | } 15 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithMultiCallback.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.Nullable; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface MethodWithMultiCallback { 13 | void multiCompletable(Handler> handler); 14 | 15 | void multiMaybe(Handler> handler); 16 | 17 | void multiSingle(Handler> handler); 18 | } 19 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithNullableTypeVariable.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.Nullable; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface MethodWithNullableTypeVariable { 13 | void doSomethingWithMaybeResult(Handler> handler); 14 | } 15 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithNullableTypeVariableParamByVoidArg.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | /** 6 | * Special case : we need to generate {@code Maybe} because of covariant return type and because 7 | * {@code Completable} does not extend {@code Maybe}. 8 | * 9 | * @author Julien Viet 10 | */ 11 | @VertxGen 12 | public interface MethodWithNullableTypeVariableParamByVoidArg extends MethodWithNullableTypeVariable { 13 | } 14 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/MethodWithSingleString.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Handler; 6 | 7 | /** 8 | * @author Julien Viet 9 | */ 10 | @VertxGen 11 | public interface MethodWithSingleString { 12 | 13 | void doSomethingWithResult(Handler> handler); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/NestedParameterizedType.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | @VertxGen 6 | public interface NestedParameterizedType { 7 | 8 | static Generic2, Generic2> someGeneric() { 9 | return new Generic2.Impl, Generic2>() 10 | .setValue1(new Generic1.Impl().setValue(new Foo.Impl())) 11 | .setValue2(new Generic2.Impl().setValue1(new Foo.Impl()).setValue2(new Bar.Impl())); 12 | } 13 | } -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/NonConcreteWithToString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 2.0 5 | * (the "License"); you may not use this file except in compliance with the 6 | * License. You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | package org.extra; 18 | 19 | import io.vertx.codegen.annotations.VertxGen; 20 | 21 | /** 22 | * @author Thomas Segismont 23 | */ 24 | @VertxGen(concrete = false) 25 | public interface NonConcreteWithToString { 26 | /** 27 | * My very special toString method 28 | */ 29 | String toString(); 30 | } 31 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/UseVertxGenDeclarationsFromAnotherPackage.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.CacheReturn; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import org.extra.sub.SomeType; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Handler; 8 | import io.vertx.core.streams.ReadStream; 9 | 10 | import java.util.function.Function; 11 | 12 | @VertxGen 13 | public interface UseVertxGenDeclarationsFromAnotherPackage extends 14 | SomeType, 15 | Handler, 16 | ReadStream { 17 | @CacheReturn 18 | SomeType foo(SomeType arg); 19 | 20 | void function(Function function); 21 | 22 | void asyncResult(Handler> handler); 23 | 24 | Handler returnHandler(); 25 | 26 | Handler> returnHandlerAsyncResult(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/UseVertxGenNameDeclarationsWithSameSimpleName.java: -------------------------------------------------------------------------------- 1 | package org.extra; 2 | 3 | import io.vertx.codegen.annotations.CacheReturn; 4 | import io.vertx.codegen.annotations.VertxGen; 5 | import io.vertx.core.AsyncResult; 6 | import io.vertx.core.Handler; 7 | import io.vertx.core.streams.ReadStream; 8 | 9 | import java.util.function.Function; 10 | 11 | @VertxGen 12 | public interface UseVertxGenNameDeclarationsWithSameSimpleName extends 13 | org.extra.sub.UseVertxGenNameDeclarationsWithSameSimpleName, 14 | Handler, 15 | ReadStream { 16 | @CacheReturn 17 | org.extra.sub.UseVertxGenNameDeclarationsWithSameSimpleName foo( 18 | org.extra.sub.UseVertxGenNameDeclarationsWithSameSimpleName arg); 19 | 20 | void function( 21 | Function function); 22 | 23 | void asyncResult( 24 | Handler> handler); 25 | 26 | Handler returnHandler(); 27 | 28 | Handler> returnHandlerAsyncResult(); 29 | } 30 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | @ModuleGen(name = "extra", groupPackage = "org.extra") 3 | package org.extra; 4 | 5 | import io.vertx.codegen.annotations.ModuleGen; -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/sub/ExtendsWithSameSimpleName.java: -------------------------------------------------------------------------------- 1 | package org.extra.sub; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | @VertxGen 6 | public interface ExtendsWithSameSimpleName { 7 | } 8 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/sub/SomeType.java: -------------------------------------------------------------------------------- 1 | package org.extra.sub; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | @VertxGen 6 | public interface SomeType { 7 | } 8 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/tck/java/org/extra/sub/UseVertxGenNameDeclarationsWithSameSimpleName.java: -------------------------------------------------------------------------------- 1 | package org.extra.sub; 2 | 3 | import io.vertx.codegen.annotations.VertxGen; 4 | 5 | @VertxGen 6 | public interface UseVertxGenNameDeclarationsWithSameSimpleName { 7 | } 8 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/AnyJavaTypeTCKTest.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import io.vertx.codegen.testmodel.AnyJavaTypeTCKImpl; 4 | import org.junit.Test; 5 | 6 | import java.net.Socket; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertFalse; 13 | 14 | public class AnyJavaTypeTCKTest { 15 | 16 | final io.vertx.mutiny.codegen.testmodel.AnyJavaTypeTCK obj = new io.vertx.mutiny.codegen.testmodel.AnyJavaTypeTCK(new AnyJavaTypeTCKImpl()); 17 | 18 | @Test 19 | public void testHandlersWithAsyncResult() throws Exception { 20 | List socketsRxList = obj.methodWithHandlerAsyncResultListOfJavaTypeParam().await().indefinitely(); 21 | 22 | Set socketSetRx = obj.methodWithHandlerAsyncResultSetOfJavaTypeParam().await().indefinitely(); 23 | 24 | Map stringSocketMapRx = obj.methodWithHandlerAsyncResultMapOfJavaTypeParam().await().indefinitely(); 25 | 26 | for (Socket socket : socketsRxList) { 27 | assertFalse(socket.isConnected()); 28 | } 29 | 30 | for (Socket socket : socketSetRx) { 31 | assertFalse(socket.isConnected()); 32 | } 33 | 34 | for (Map.Entry entry : stringSocketMapRx.entrySet()) { 35 | assertEquals("1", entry.getKey()); 36 | assertFalse(entry.getValue().isConnected()); 37 | } 38 | 39 | assertEquals(1, socketsRxList.size()); 40 | assertEquals(1, socketSetRx.size()); 41 | assertEquals(1, stringSocketMapRx.size()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/AsyncResultAdapterTest.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import org.extra.mutiny.MethodWithCompletable; 4 | import org.extra.mutiny.MethodWithMaybeString; 5 | import org.extra.mutiny.MethodWithSingleString; 6 | import io.vertx.test.core.VertxTestBase; 7 | import org.junit.Test; 8 | 9 | import java.util.concurrent.CompletionStage; 10 | 11 | public class AsyncResultAdapterTest extends VertxTestBase { 12 | 13 | @Test 14 | public void testSingleReportingSubscribeUncheckedException() { 15 | RuntimeException cause = new RuntimeException(); 16 | MethodWithSingleString meth = new MethodWithSingleString(handler -> { 17 | throw cause; 18 | }); 19 | CompletionStage single = meth.doSomethingWithResult().subscribeAsCompletionStage(); 20 | single.whenComplete((result, err) -> { 21 | assertNull(result); 22 | assertNotNull(err); 23 | testComplete(); 24 | }); 25 | await(); 26 | } 27 | 28 | @Test 29 | public void testMaybeReportingSubscribeUncheckedException() { 30 | RuntimeException cause = new RuntimeException(); 31 | MethodWithMaybeString meth = new MethodWithMaybeString(handler -> { 32 | throw cause; 33 | }); 34 | CompletionStage single = meth.doSomethingWithMaybeResult().subscribeAsCompletionStage(); 35 | single.whenComplete((result, err) -> { 36 | assertNull(result); 37 | assertNotNull(err); 38 | testComplete(); 39 | }); 40 | await(); 41 | } 42 | 43 | @Test 44 | public void testCompletableReportingSubscribeUncheckedException() { 45 | RuntimeException cause = new RuntimeException(); 46 | MethodWithCompletable meth = new MethodWithCompletable(handler -> { 47 | throw cause; 48 | }); 49 | CompletionStage single = meth.doSomethingWithResult().subscribeAsCompletionStage(); 50 | single.whenComplete((result, err) -> { 51 | assertNull(result); 52 | assertNotNull(err); 53 | testComplete(); 54 | }); 55 | await(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/DeprecationTest.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import io.vertx.mutiny.codegen.testmodel.DeprecatedType; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.*; 7 | 8 | public class DeprecationTest { 9 | 10 | @Test 11 | public void checkThatAnnotationsAreForwarded() throws NoSuchMethodException { 12 | Deprecated[] annotationsByType = DeprecatedType.class.getAnnotationsByType(Deprecated.class); 13 | assertEquals(1, annotationsByType.length); 14 | 15 | Deprecated deprecated = DeprecatedType.class.getMethod("someMethod").getAnnotation(Deprecated.class); 16 | assertNull(deprecated); 17 | 18 | deprecated = DeprecatedType.class.getMethod("someOtherMethod").getAnnotation(Deprecated.class); 19 | assertNotNull(deprecated); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/GenericsTest.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import org.extra.mutiny.Bar; 4 | import org.extra.mutiny.Foo; 5 | import org.extra.mutiny.Generic1; 6 | import org.extra.mutiny.Generic2; 7 | import org.extra.mutiny.NestedParameterizedType; 8 | import org.junit.Test; 9 | 10 | public class GenericsTest { 11 | 12 | @Test 13 | public void testNestedParameterizedTypes() { 14 | // Test we don't get class cast when types are unwrapped or rewrapped 15 | Generic2, Generic2> o = NestedParameterizedType.someGeneric(); 16 | Generic1 value1 = o.getValue1(); 17 | Foo nested1 = value1.getValue(); 18 | value1.setValue(nested1); 19 | Generic2 value2 = o.getValue2(); 20 | o.setValue2(value2); 21 | Foo nested2 = value2.getValue1(); 22 | value2.setValue1(nested2); 23 | Bar nested3 = value2.getValue2(); 24 | value2.setValue2(nested3); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/ReadStreamSubscriberTest.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import io.smallrye.mutiny.vertx.ReadStreamSubscriber; 4 | import java.util.concurrent.Flow.Subscription; 5 | 6 | import java.util.function.Function; 7 | 8 | /** 9 | * @author Julien Viet 10 | */ 11 | public class ReadStreamSubscriberTest extends ReadStreamSubscriberTestBase { 12 | 13 | @Override 14 | public long bufferSize() { 15 | return ReadStreamSubscriber.BUFFER_SIZE; 16 | } 17 | 18 | @Override 19 | protected Sender sender() { 20 | return new Sender() { 21 | 22 | private ReadStreamSubscriber subscriber = new ReadStreamSubscriber<>(Function.identity()); 23 | 24 | { 25 | stream = subscriber; 26 | subscriber.onSubscribe(new Subscription() { 27 | @Override 28 | public void request(long n) { 29 | requested += n; 30 | } 31 | 32 | @Override 33 | public void cancel() { 34 | } 35 | }); 36 | } 37 | 38 | protected void emit() { 39 | subscriber.onNext("" + seq++); 40 | } 41 | 42 | protected void complete() { 43 | subscriber.onComplete(); 44 | } 45 | 46 | protected void fail(Throwable cause) { 47 | subscriber.onError(cause); 48 | } 49 | 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vertx-mutiny-generator/src/test/java/tck/TestUtils.java: -------------------------------------------------------------------------------- 1 | package tck; 2 | 3 | import java.util.concurrent.Flow.Publisher; 4 | import java.util.concurrent.Flow.Subscriber; 5 | import java.util.concurrent.Flow; 6 | 7 | /** 8 | * @author Julien Viet 9 | */ 10 | public class TestUtils { 11 | 12 | public static void subscribe(Publisher obs, TestSubscriber sub) { 13 | obs.subscribe(new Subscriber() { 14 | boolean unsubscribed; 15 | 16 | @Override 17 | public void onSubscribe(Flow.Subscription s) { 18 | sub.onSubscribe(new TestSubscriber.Subscription() { 19 | @Override 20 | public void fetch(long val) { 21 | if (val > 0) { 22 | s.request(val); 23 | } 24 | } 25 | 26 | @Override 27 | public void unsubscribe() { 28 | unsubscribed = true; 29 | s.cancel(); 30 | } 31 | 32 | @Override 33 | public boolean isUnsubscribed() { 34 | return unsubscribed; 35 | } 36 | }); 37 | 38 | } 39 | 40 | @Override 41 | public void onNext(T buffer) { 42 | sub.onNext(buffer); 43 | } 44 | 45 | @Override 46 | public void onError(Throwable t) { 47 | unsubscribed = true; 48 | sub.onError(t); 49 | } 50 | 51 | @Override 52 | public void onComplete() { 53 | unsubscribed = true; 54 | sub.onCompleted(); 55 | } 56 | }); 57 | } 58 | } 59 | --------------------------------------------------------------------------------