diff --git a/broker/pom.xml b/broker/pom.xml index 4d0aae65a14f350005ee66fc36be590e4d8ff79c..8cdafea34947e2526d004c2c97bfe1629fa001a1 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -65,4 +65,17 @@ javassist + + + + + maven-surefire-plugin + 2.19.1 + + 1 + false + + + + diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java index 39ee8dd2e58e9d02fc3734c553c6df0124be0d33..98ff136574b6ad2aa5be513ded9f3add08ecb59c 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java @@ -232,12 +232,10 @@ public class BrokerStartup { private static void properties2SystemEnv(Properties properties) { if (properties == null) { - log.info("No properties to set system environment"); return; } - - String rmqAddressServerDomain = properties.getProperty("rmqAddressServerDomain", MixAll.DEFAULT_NAMESRV_ADDR_LOOKUP); - String rmqAddressServerSubGroup = properties.getProperty("rmqAddressServerSubGroup", "nsaddr"); + String rmqAddressServerDomain = properties.getProperty("rmqAddressServerDomain", MixAll.WS_DOMAIN_NAME); + String rmqAddressServerSubGroup = properties.getProperty("rmqAddressServerSubGroup", MixAll.WS_DOMAIN_SUBGROUP); System.setProperty("rocketmq.namesrv.domain", rmqAddressServerDomain); System.setProperty("rocketmq.namesrv.domain.subgroup", rmqAddressServerSubGroup); } diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerStartupTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerStartupTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a5ad3ac39e2f3cb68ce835086f110bf80c2237fa --- /dev/null +++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerStartupTest.java @@ -0,0 +1,40 @@ +/* + * 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.rocketmq.broker; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Properties; +import org.junit.Assert; +import org.junit.Test; + +public class BrokerStartupTest { + + @Test + public void testProperties2SystemEnv() throws NoSuchMethodException, InvocationTargetException, + IllegalAccessException { + Properties properties = new Properties(); + Class clazz = BrokerStartup.class; + Method method = clazz.getDeclaredMethod("properties2SystemEnv", Properties.class); + method.setAccessible(true); + System.setProperty("rocketmq.namesrv.domain", "value"); + method.invoke(null, properties); + Assert.assertEquals("value", System.getProperty("rocketmq.namesrv.domain")); + } + +} \ No newline at end of file