Index: src/test/java/org/apache/kitty/client/ClientTest.groovy =================================================================== --- src/test/java/org/apache/kitty/client/ClientTest.groovy (revision 0) +++ src/test/java/org/apache/kitty/client/ClientTest.groovy (revision 0) @@ -0,0 +1,58 @@ +/* + * 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.kitty.client; + +import static org.junit.Assert.*; +import org.apache.kitty.client.Client +import javax.management.MBeanServerConnection +import org.junit.Test; + +class ClientTest { + + @Test + public void should_correctly_set_a_new_domain_value() { + def mbean_server_connection = { + ['a', 'b', 'c']as String[] + } as MBeanServerConnection + Client client = new Client() + client.remote = mbean_server_connection + + assert client.domain == null + assert client.mBeansPath == null + + client.setDomain 'a' + + assert client.domain == 'a' + assert client.mBeansPath == [] + } + + @Test + public void should_keep_actual_domain_when_trying_to_set_it_with_invalid_value() throws Exception { + def mbean_server_connection = { + ['a', 'b', 'c']as String[] + } as MBeanServerConnection + Client client = new Client() + client.remote = mbean_server_connection + client.domain = 'a' + client.mBeansPath = [] + + client.setDomain 'invalid_value' + + assert client.domain == 'a' + } +} Index: src/main/java/org/apache/kitty/CmdShell.groovy =================================================================== --- src/main/java/org/apache/kitty/CmdShell.groovy (revision 1103627) +++ src/main/java/org/apache/kitty/CmdShell.groovy (working copy) @@ -369,7 +369,6 @@ println "Setting the domain to $domain..." if (remote) { getClient().setDomain(domain) - println "The domain is set to $domain" } else { println Constants.ERROR_NOT_CONNECTED Index: src/main/java/org/apache/kitty/client/Client.groovy =================================================================== --- src/main/java/org/apache/kitty/client/Client.groovy (revision 1103627) +++ src/main/java/org/apache/kitty/client/Client.groovy (working copy) @@ -133,6 +133,7 @@ if (it.equals(_domain)) { this.domain = _domain this.mBeansPath = [] + println "The domain is set to $domain" return } }