You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by es...@apache.org on 2011/02/05 15:00:20 UTC

svn commit: r1067442 - /esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Author: esjewett
Date: Sat Feb  5 14:00:20 2011
New Revision: 1067442

URL: http://svn.apache.org/viewvc?rev=1067442&view=rev
Log:
[ESME-330] This fixes the problem with the test that was no longer working correctly.

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

Modified: esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=1067442&r1=1067441&r2=1067442&view=diff
==============================================================================
--- esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
+++ esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sat Feb  5 14:00:20 2011
@@ -30,7 +30,8 @@ import Helpers._
 import org.apache.esme._
 import model._
 import net.liftweb.http._
-import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
+import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse} 
+import scala.xml.{Text}
 
 import _root_.junit.framework.AssertionFailedError
 
@@ -592,18 +593,20 @@ object Api2Specs extends Specification w
         for{
           sess <- post_session
           mess_res <- sess.post("user/messages", "message"->"test")
+          mess_xml <- mess_res.xml
           wait <- sleep(1000)
-          mess_res <- sess.post("user/messages",
+          mess_res2 <- sess.post("user/messages",
                                 "message" -> "test_convo",
-                                "replyto" -> 9)
+                                "replyto" -> (mess_xml \\ "message" \ "id").text)
           wait2 <- sleep(1000)
-          res <- sess.get("conversations/9")
-        } {                     
-          res.code must be equalTo 200
-          ( res.xml.open_! \\ "message" ).last must \\(<conversation>9</conversation>)
-          ( res.xml.open_! \\ "message" ).last must \\(<replyto>9</replyto>)
-          ( res.xml.open_! \\ "message" ).first must \\(<conversation>9</conversation>)
-          ( res.xml.open_! \\ "message" ).first must \\(<replyto></replyto>)
+          res <- sess.get("/conversations/" + (mess_xml \\ "message" \ "id").text)
+        } {                                       
+          val conv_id = (mess_xml \\ "message" \ "id").text  
+          res.code must be equalTo 200
+          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<conversation>{conv_id}</conversation>)
+          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<replyto>{conv_id}</replyto>)
+          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<conversation>{conv_id}</conversation>)
+          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<replyto></replyto>)
         }
       }
 



Re: svn commit: r1067442 - /esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Posted by Ethan Jewett <es...@gmail.com>.
Hi Dick,

It took a little time to figure it out, but a long time ago when I
wrote these tests I hard-coded the message ids in the tests and left a
comment saying that this was a dangerous way to do things. Well ...
the message ids changed.

So I've rewritten this particular test to work no matter what the
message ID that the test creates happens to be.

I'm letting Hudson build and test right now. Hopefully this will get
our build stable again and I will then move on to some of the other
remaining 1.2 issues.

Ethan

On Sat, Feb 5, 2011 at 3:03 PM, Richard Hirsch <hi...@gmail.com> wrote:
> @Ethan - thanks -  why was the test was failing?
>
> D.
>
> On Sat, Feb 5, 2011 at 3:00 PM,  <es...@apache.org> wrote:
>> Author: esjewett
>> Date: Sat Feb  5 14:00:20 2011
>> New Revision: 1067442
>>
>> URL: http://svn.apache.org/viewvc?rev=1067442&view=rev
>> Log:
>> [ESME-330] This fixes the problem with the test that was no longer working correctly.
>>
>> Modified:
>>    esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
>>
>> Modified: esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
>> URL: http://svn.apache.org/viewvc/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=1067442&r1=1067441&r2=1067442&view=diff
>> ==============================================================================
>> --- esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
>> +++ esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sat Feb  5 14:00:20 2011
>> @@ -30,7 +30,8 @@ import Helpers._
>>  import org.apache.esme._
>>  import model._
>>  import net.liftweb.http._
>> -import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
>> +import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
>> +import scala.xml.{Text}
>>
>>  import _root_.junit.framework.AssertionFailedError
>>
>> @@ -592,18 +593,20 @@ object Api2Specs extends Specification w
>>         for{
>>           sess <- post_session
>>           mess_res <- sess.post("user/messages", "message"->"test")
>> +          mess_xml <- mess_res.xml
>>           wait <- sleep(1000)
>> -          mess_res <- sess.post("user/messages",
>> +          mess_res2 <- sess.post("user/messages",
>>                                 "message" -> "test_convo",
>> -                                "replyto" -> 9)
>> +                                "replyto" -> (mess_xml \\ "message" \ "id").text)
>>           wait2 <- sleep(1000)
>> -          res <- sess.get("conversations/9")
>> -        } {
>> -          res.code must be equalTo 200
>> -          ( res.xml.open_! \\ "message" ).last must \\(<conversation>9</conversation>)
>> -          ( res.xml.open_! \\ "message" ).last must \\(<replyto>9</replyto>)
>> -          ( res.xml.open_! \\ "message" ).first must \\(<conversation>9</conversation>)
>> -          ( res.xml.open_! \\ "message" ).first must \\(<replyto></replyto>)
>> +          res <- sess.get("/conversations/" + (mess_xml \\ "message" \ "id").text)
>> +        } {
>> +          val conv_id = (mess_xml \\ "message" \ "id").text
>> +          res.code must be equalTo 200
>> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<conversation>{conv_id}</conversation>)
>> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<replyto>{conv_id}</replyto>)
>> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<conversation>{conv_id}</conversation>)
>> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<replyto></replyto>)
>>         }
>>       }
>>
>>
>>
>>
>

Re: svn commit: r1067442 - /esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Posted by Richard Hirsch <hi...@gmail.com>.
@Ethan - thanks -  why was the test was failing?

D.

On Sat, Feb 5, 2011 at 3:00 PM,  <es...@apache.org> wrote:
> Author: esjewett
> Date: Sat Feb  5 14:00:20 2011
> New Revision: 1067442
>
> URL: http://svn.apache.org/viewvc?rev=1067442&view=rev
> Log:
> [ESME-330] This fixes the problem with the test that was no longer working correctly.
>
> Modified:
>    esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
>
> Modified: esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
> URL: http://svn.apache.org/viewvc/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=1067442&r1=1067441&r2=1067442&view=diff
> ==============================================================================
> --- esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
> +++ esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sat Feb  5 14:00:20 2011
> @@ -30,7 +30,8 @@ import Helpers._
>  import org.apache.esme._
>  import model._
>  import net.liftweb.http._
> -import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
> +import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
> +import scala.xml.{Text}
>
>  import _root_.junit.framework.AssertionFailedError
>
> @@ -592,18 +593,20 @@ object Api2Specs extends Specification w
>         for{
>           sess <- post_session
>           mess_res <- sess.post("user/messages", "message"->"test")
> +          mess_xml <- mess_res.xml
>           wait <- sleep(1000)
> -          mess_res <- sess.post("user/messages",
> +          mess_res2 <- sess.post("user/messages",
>                                 "message" -> "test_convo",
> -                                "replyto" -> 9)
> +                                "replyto" -> (mess_xml \\ "message" \ "id").text)
>           wait2 <- sleep(1000)
> -          res <- sess.get("conversations/9")
> -        } {
> -          res.code must be equalTo 200
> -          ( res.xml.open_! \\ "message" ).last must \\(<conversation>9</conversation>)
> -          ( res.xml.open_! \\ "message" ).last must \\(<replyto>9</replyto>)
> -          ( res.xml.open_! \\ "message" ).first must \\(<conversation>9</conversation>)
> -          ( res.xml.open_! \\ "message" ).first must \\(<replyto></replyto>)
> +          res <- sess.get("/conversations/" + (mess_xml \\ "message" \ "id").text)
> +        } {
> +          val conv_id = (mess_xml \\ "message" \ "id").text
> +          res.code must be equalTo 200
> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<conversation>{conv_id}</conversation>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<replyto>{conv_id}</replyto>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<conversation>{conv_id}</conversation>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<replyto></replyto>)
>         }
>       }
>
>
>
>

Re: svn commit: r1067442 - /esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Posted by Richard Hirsch <hi...@gmail.com>.
@Ethan - thanks -  why was the test was failing?

D.

On Sat, Feb 5, 2011 at 3:00 PM,  <es...@apache.org> wrote:
> Author: esjewett
> Date: Sat Feb  5 14:00:20 2011
> New Revision: 1067442
>
> URL: http://svn.apache.org/viewvc?rev=1067442&view=rev
> Log:
> [ESME-330] This fixes the problem with the test that was no longer working correctly.
>
> Modified:
>    esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
>
> Modified: esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
> URL: http://svn.apache.org/viewvc/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=1067442&r1=1067441&r2=1067442&view=diff
> ==============================================================================
> --- esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
> +++ esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sat Feb  5 14:00:20 2011
> @@ -30,7 +30,8 @@ import Helpers._
>  import org.apache.esme._
>  import model._
>  import net.liftweb.http._
> -import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
> +import testing.{ReportFailure, TestKit, HttpResponse, TestFramework, TestResponse}
> +import scala.xml.{Text}
>
>  import _root_.junit.framework.AssertionFailedError
>
> @@ -592,18 +593,20 @@ object Api2Specs extends Specification w
>         for{
>           sess <- post_session
>           mess_res <- sess.post("user/messages", "message"->"test")
> +          mess_xml <- mess_res.xml
>           wait <- sleep(1000)
> -          mess_res <- sess.post("user/messages",
> +          mess_res2 <- sess.post("user/messages",
>                                 "message" -> "test_convo",
> -                                "replyto" -> 9)
> +                                "replyto" -> (mess_xml \\ "message" \ "id").text)
>           wait2 <- sleep(1000)
> -          res <- sess.get("conversations/9")
> -        } {
> -          res.code must be equalTo 200
> -          ( res.xml.open_! \\ "message" ).last must \\(<conversation>9</conversation>)
> -          ( res.xml.open_! \\ "message" ).last must \\(<replyto>9</replyto>)
> -          ( res.xml.open_! \\ "message" ).first must \\(<conversation>9</conversation>)
> -          ( res.xml.open_! \\ "message" ).first must \\(<replyto></replyto>)
> +          res <- sess.get("/conversations/" + (mess_xml \\ "message" \ "id").text)
> +        } {
> +          val conv_id = (mess_xml \\ "message" \ "id").text
> +          res.code must be equalTo 200
> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<conversation>{conv_id}</conversation>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).last must \\(<replyto>{conv_id}</replyto>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<conversation>{conv_id}</conversation>)
> +          ( res.xml.openOr(Text("")) \\ "message" ).first must \\(<replyto></replyto>)
>         }
>       }
>
>
>
>