|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * 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, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.activemq.artemis.tests.smoke.simpleStart; |
| 19 | + |
| 20 | +import javax.jms.Connection; |
| 21 | +import javax.jms.ConnectionFactory; |
| 22 | +import javax.jms.MessageConsumer; |
| 23 | +import javax.jms.MessageProducer; |
| 24 | +import javax.jms.Session; |
| 25 | +import javax.jms.TextMessage; |
| 26 | +import java.io.File; |
| 27 | +import java.util.concurrent.TimeUnit; |
| 28 | + |
| 29 | +import org.apache.activemq.artemis.cli.commands.helper.HelperCreate; |
| 30 | +import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase; |
| 31 | +import org.apache.activemq.artemis.tests.util.CFUtil; |
| 32 | +import org.apache.activemq.artemis.utils.FileUtil; |
| 33 | +import org.apache.activemq.artemis.utils.RandomUtil; |
| 34 | +import org.junit.jupiter.api.BeforeEach; |
| 35 | +import org.junit.jupiter.api.Test; |
| 36 | + |
| 37 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 38 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 39 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 40 | + |
| 41 | +public class DefaultServerSmokeTest extends SmokeTestBase { |
| 42 | + |
| 43 | + private static final String SERVER_NAME = "default-server"; |
| 44 | + private static File SERVER_LOCATION = getFileServerLocation(SERVER_NAME); |
| 45 | + |
| 46 | + private final String queueName = "queue" + RandomUtil.randomUUIDString(); |
| 47 | + |
| 48 | + @BeforeEach |
| 49 | + public void setupServer() throws Exception { |
| 50 | + |
| 51 | + deleteDirectory(SERVER_LOCATION); |
| 52 | + |
| 53 | + { |
| 54 | + HelperCreate cliCreateServer = helperCreate(); |
| 55 | + cliCreateServer.setRole("amq").setUser("admin").setPassword("admin").setAllowAnonymous(true).setNoWeb(false).setArtemisInstance(SERVER_LOCATION); |
| 56 | + cliCreateServer.addArgs("--queues", queueName); |
| 57 | + cliCreateServer.createServer(); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void testValidateDefaultConfigurationNoWarning() throws Exception { |
| 63 | + |
| 64 | + Process process = startServer(SERVER_NAME, 0, 5000); |
| 65 | + |
| 66 | + ConnectionFactory factory = CFUtil.createConnectionFactory("CORE", "tcp://localhost:61616"); |
| 67 | + |
| 68 | + try (Connection connection = factory.createConnection()) { |
| 69 | + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); |
| 70 | + MessageProducer producer = session.createProducer(session.createQueue(queueName)); |
| 71 | + producer.send(session.createTextMessage("hello")); |
| 72 | + } |
| 73 | + |
| 74 | + try (Connection connection = factory.createConnection()) { |
| 75 | + connection.start(); |
| 76 | + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); |
| 77 | + MessageConsumer c = session.createConsumer(session.createQueue(queueName)); |
| 78 | + TextMessage message = (TextMessage) c.receive(5000); |
| 79 | + assertNotNull(message); |
| 80 | + assertEquals("hello", message.getText()); |
| 81 | + } |
| 82 | + |
| 83 | + stopServerWithFile(SERVER_LOCATION.getAbsolutePath()); |
| 84 | + |
| 85 | + process.waitFor(1, TimeUnit.SECONDS); |
| 86 | + |
| 87 | + File log = new File(SERVER_LOCATION, "/log/artemis.log"); |
| 88 | + assertFalse(FileUtil.find(log, l -> l.contains("WARN"))); |
| 89 | + |
| 90 | + } |
| 91 | + |
| 92 | +} |
0 commit comments