diff --git a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/CompilerPluginTest.java b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/CompilerPluginTest.java index 1f50175f..d82ed22b 100644 --- a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/CompilerPluginTest.java +++ b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/CompilerPluginTest.java @@ -403,6 +403,17 @@ public void testCompilerPluginForListenerImplicitInitWithCheckExpr() { Assert.assertEquals(diagnostic.message(), expectedCode.getDescription()); } + @Test + public void testCompilerPluginForListenerInitWithPortConfig() { + Package currentPackage = loadPackage("sample_25"); + PackageCompilation compilation = currentPackage.getCompilation(); + DiagnosticResult diagnosticResult = compilation.diagnosticResult(); + List errorDiagnostics = diagnosticResult.diagnostics().stream() + .filter(d -> DiagnosticSeverity.ERROR.equals(d.diagnosticInfo().severity())) + .toList(); + Assert.assertEquals(errorDiagnostics.size(), 0); + } + private Package loadPackage(String path) { Path projectDirPath = RESOURCE_DIRECTORY.resolve(path); BuildProject project = BuildProject.load(getEnvironmentBuilder(), projectDirPath); diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/Ballerina.toml b/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/Ballerina.toml new file mode 100644 index 00000000..623c51ae --- /dev/null +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/Ballerina.toml @@ -0,0 +1,7 @@ +[package] +org = "websub_test" +name = "sample_25" +version = "0.1.0" + +[build-options] +observabilityIncluded = true diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/service.bal new file mode 100644 index 00000000..e48e9f12 --- /dev/null +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/sample_25/service.bal @@ -0,0 +1,43 @@ +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/websub; + +configurable int port = 9090; + +listener websub:Listener ln = check new(port, { + secureSocket: { + key: { + path: "tests/resources/ballerinaKeystore.pkcs12", + password: "ballerina" + } + } +}); + +@websub:SubscriberServiceConfig { +} +service /sample on new websub:Listener(port, { + secureSocket: { + key: { + path: "tests/resources/ballerinaKeystore.pkcs12", + password: "ballerina" + } + } +}) { + remote function onEventNotification(websub:ContentDistributionMessage event) { + return; + } +}