allthingssecurity commented on code in PR #30915: URL: https://github.com/apache/camel/pull/30915#discussion_r4716906304
########## components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppConsumerStopDuringDelayedStartTest.java: ########## @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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. + */ +package org.apache.camel.component.xmpp; + +import java.net.InetAddress; +import java.net.ServerSocket; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantLock; + +import org.apache.camel.ServiceStatus; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.DefaultCamelContext; +import org.jivesoftware.smack.ConnectionConfiguration; +import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +/** + * With testConnectionOnStartup=false the consumer starts in the background when the server cannot be reached at start. + * That delayed start waits for the account's lock while another consumer or producer of the account connects or logs + * in. When the route is stopped meanwhile, the delayed start must not start the stopped consumer when it gets the lock: + * no listener on the connection, no connection monitor, and the account's connection is closed once its other users + * released it. + */ +class XmppConsumerStopDuringDelayedStartTest { + + private static final String ROOM = "dev@conference." + FakeXmppServer.DOMAIN; + + private DefaultCamelContext context; + private FakeXmppServer server; + + @AfterEach + void stop() throws Exception { + if (context != null) { + context.stop(); + } + if (server != null) { + server.close(); + } + } + + @Test + void chatConsumerStoppedWhileItsDelayedStartWaitsForTheLockIsNotStarted() throws Exception { Review Comment: Thanks, adding @Timeout(30) to both tests in the follow-up #30928, as this PR is merged. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
