incubator-kitty-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovar...@apache.org
Subject svn commit: r1178983 - in /incubator/kitty/trunk/src: main/groovy/org/apache/kitty/client/Client.groovy test/groovy/org/apache/kitty/client/ClientTest.groovy
Date Tue, 04 Oct 2011 22:22:34 GMT
Author: anovarini
Date: Tue Oct  4 22:22:34 2011
New Revision: 1178983

URL: http://svn.apache.org/viewvc?rev=1178983&view=rev
Log:
Fixed KITTY-18

Modified:
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/client/Client.groovy
    incubator/kitty/trunk/src/test/groovy/org/apache/kitty/client/ClientTest.groovy

Modified: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/client/Client.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/client/Client.groovy?rev=1178983&r1=1178982&r2=1178983&view=diff
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/client/Client.groovy (original)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/client/Client.groovy Tue Oct  4
22:22:34 2011
@@ -37,7 +37,7 @@ import org.apache.kitty.exceptions.*
  * This class is for development purposes only and will not be used in production.
  * </p>
  * </pre>
- * 
+ *
  * @version $Id$
  *
  */
@@ -131,27 +131,23 @@ class Client {
 	 */
 	public setDomain(def _domain) {
 		if (this.remote) {
-			if (_domain.equals("")) {
-				this.domain = null
-				return
-			}
 
 			this.domainList = remote.getDomains()
-			this.domainList.each {
-				if (it.equals(_domain)) {
+
+            def domainFound = domainList.findAll { it == _domain }
+
+			if (domainFound.size() == 1) {
 					this.domain = _domain
 					this.mBeansPath = []
-					return
-				}
 			}
-		}
-		else {
-			println "domain not found"
-		}
+            else {
+                println "domain $_domain not found"
+            }
+        }
 	}
 
 	/**
-	 * 
+	 *
 	 * @return
 	 */
 	public ls() {
@@ -251,14 +247,14 @@ class Client {
 	}
 
 	/**
-	 * 
+	 *
 	 * @return
 	 */
 	public cd(String path) {
 		if (this.remote) {
 			if (this.domain) {
 				if (path == "..") {
-					if (this.mBeansPath.length()) {
+					if (this.mBeansPath.size()) {
 						this.mBeansPath.pop()
 					}
 				}
@@ -272,7 +268,7 @@ class Client {
 	}
 
 	/**
-	 * 
+	 *
 	 */
 	public get(att) {
 		if (this.remote) {
@@ -332,7 +328,7 @@ class Client {
 	}
 
 	/**
-	 * 
+	 *
 	 * @return
 	 */
 	public set(att, val) {
@@ -376,7 +372,7 @@ class Client {
 	}
 
 	/**
-	 * 
+	 *
 	 * @param op
 	 * @param params
 	 * @return

Modified: incubator/kitty/trunk/src/test/groovy/org/apache/kitty/client/ClientTest.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/test/groovy/org/apache/kitty/client/ClientTest.groovy?rev=1178983&r1=1178982&r2=1178983&view=diff
==============================================================================
--- incubator/kitty/trunk/src/test/groovy/org/apache/kitty/client/ClientTest.groovy (original)
+++ incubator/kitty/trunk/src/test/groovy/org/apache/kitty/client/ClientTest.groovy Tue Oct
 4 22:22:34 2011
@@ -28,7 +28,7 @@ import org.apache.kitty.exceptions.Domai
 class ClientTest {
 
     @Test
-    public void should_correctly_set_a_new_domain_value() {
+    public void shouldCorrectlySetNewDomain() {
         def mbean_server_connection = {
             ['a', 'b', 'c']as String[]
         } as MBeanServerConnection
@@ -45,9 +45,9 @@ class ClientTest {
     }
 
     @Test
-    public void should_keep_actual_domain_when_trying_to_set_it_with_invalid_value() throws
Exception {
+    public void shouldKeepActualDomainWhenSettingWithInvalidValue() throws Exception {
         def mbean_server_connection = {
-            ['a', 'b', 'c']as String[]
+            ['a', 'b', 'c'] as String[]
         } as MBeanServerConnection
         Client client = new Client()
         client.remote = mbean_server_connection
@@ -60,7 +60,7 @@ class ClientTest {
     }
 
     @Test
-    public void should_list_names_for_domain() throws Exception {
+    public void shouldListNamesForDomain() throws Exception {
        Client client = new Client()
 
        // Mock the remote connection
@@ -94,4 +94,18 @@ class ClientTest {
            }
        }
     }
+
+    @Test
+    public void shouldChangeDirectoryToParent() throws Exception {
+
+        def client = new Client()
+        client.remote = true
+        client.domain = true
+
+        client.mBeansPath = ["a" , "b" , "c"]
+
+        client.cd ".."
+
+        assertEquals (["a" , "b"] , client.mBeansPath)
+    }
 }



Mime
View raw message