incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r897125 - /incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
Date Fri, 08 Jan 2010 07:52:22 GMT
Author: rhirsch
Date: Fri Jan  8 07:52:22 2010
New Revision: 897125

URL: http://svn.apache.org/viewvc?rev=897125&view=rev
Log:
[ESME-153] Test Cases for Original API


Modified:
    incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala

Modified: incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala?rev=897125&r1=897124&r2=897125&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala (original)
+++ incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala Fri Jan 
8 07:52:22 2010
@@ -85,9 +85,89 @@
         status <- login.get("/api/status") !@ "Failed to get status" if (testSuccess(status))
         otherStatus <- get("/api/status") if shouldnt(testSuccess(status))
       } {
+        
         (status.xml \ "user" \ "@id").text must_== theUser.id.toString
       }
     }
+    
+     "LoginNeg" in {
+      for{
+        login <- post("/api/login", "token" -> "00000000") !@ "Login should have failed:
bad token" if shouldnt(testSuccess(login))
+        login2 <- post("/api/login", "token" -> "") !@ "Login should have failed: empty
token" if shouldnt(testSuccess(login2))
+      } {
+       }
+    }
+      
+    
+    "StatusNeg" in {
+      for{
+        status <- get("/api/status") !@ "Status should have failed: no login" if shouldnt(testSuccess(status))
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        logout <- login.get("/api/logout") !@ "Failed to log out" if (testSuccess(logout))
+        status2 <- login.get("/api/status") !@ "Status should have failed: no active login"
if shouldnt(testSuccess(status2))
+      } {
+      }
+    }
+    
+    "Logout" in {
+      for{
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        status <- login.get("/api/status") !@ "Failed to get status" if (testSuccess(status))
+        logout <- login.get("/api/logout") !@ "Failed to log out" if (testSuccess(status))
+      } {
+        (status.xml \ "user" \ "@id").text must_== theUser.id.toString
+      }
+    }
+    
+    "LogoutNeg" in {
+      for{
+         logout <- get("/api/logout") !@ "Status should have failed: no login" if shouldnt(testSuccess(logout))
+         login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+         logout2 <- login.get("/api/logout") !@ "Failed to log out" if (testSuccess(logout2))
+         logout3 <- login.get("/api/logout") !@ "logout should have failed: no active
login" if shouldnt(testSuccess(logout3))
+
+      } {
+      }
+    }
+    "SendMsg" in {
+      for{
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        status <- login.get("/api/status") !@ "Failed to get status" if (testSuccess(status))
+        send_msg <- login.post("/api/send_msg", "message" -> "hi") !@ "Failed to send
message" if (testSuccess(send_msg))
+      } {
+        (status.xml \ "user" \ "@id").text must_== theUser.id.toString
+      }
+    }
+    "SendMsgNeg" in {
+      for{
+        send_msg <- post("/api/send_msg", "message" -> "Bad") !@ "send_msg should have
failed: no login first" if shouldnt(testSuccess(send_msg))
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        send_msg2 <- login.post("/api/send_msg", "message" -> "") !@ "send_msg should
have failed: empty message" if shouldnt(testSuccess(send_msg2))
+      } {
+      }
+    }
+    "AddAction" in {
+      for{
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        add_action <- login.post("/api/add_action", "name" -> "test", "test" ->
"#moo", "action" -> "filter") !@ "Failed to add action" if (testSuccess(add_action))
+      } {
+        println(add_action.xml)
+      }
+    }
+    
+     "AddActionNeg" in {
+      for{
+        add_action <- post("/api/add_action", "name" -> "test", "test" -> "#moo",
"action" -> "filter") !@ "add_action should have failed: no login first" if shouldnt(testSuccess(add_action))
+        login <- post("/api/login", "token" -> token) !@ "Failed to log in" if (testSuccess(login))
+        add_action1 <- login.post("/api/add_action", "name" -> "test", "test" ->
"#moo") !@ "add_action should have failed: no action" if shouldnt(testSuccess(add_action1))
+        add_action2 <- login.post("/api/add_action", "name" -> "test", "action" ->
"filter") !@ "add_action should have failed: no test" if shouldnt(testSuccess(add_action2))
+        add_action3 <- login.post("/api/add_action", "action" -> "filter", "test" ->
"#moo") !@ "add_action should have failed: no name" if shouldnt(testSuccess(add_action3))
+        add_action4 <- login.post("/api/add_action", "name" -> "test", "test" ->
"moo", "action" -> "filter") !@ "add_action should have failed: no name" if shouldnt(testSuccess(add_action3))
+
+      } {
+        println(add_action3.xml)
+      }
+    }
 
 
   }



Mime
View raw message