This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.actors._ | |
| import Actor._ | |
| for (i <- 1 to 500) actor { | |
| println("Starting actor... " + i) | |
| Thread.sleep(5000L) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.actors._ | |
| import Actor._ | |
| case object DoIt | |
| val worker = actor { | |
| loop { | |
| react { | |
| case DoIt => println("Time for work at " + new java.util.Date()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| JettyTestServer.start | |
| val baseUrl = "/twitter" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implicit val reportError = new ReportFailure { | |
| def fail(msg: String): Nothing = TwitterAPISpecs.this.fail(msg) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for { | |
| login <- get("/account/verify_credentials.xml", httpClient, Nil) | |
| !@ "Failed to log in" | |
| message <- login.post("/statuses/update.xml", "status" -> "test_msg1") | |
| !@ "Couldn't post message" | |
| xml <- message.xml | |
| } { | |
| // Specs' xml matcher | |
| xml must \\(<text>test_msg1</text>) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get("/account/verify_credentials.xml") | |
| ! (401, "Login should fail with Unauthorized status") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override def theHttpClient = { | |
| val theClient = buildBasicAuthClient(userName, password) | |
| theClient.getParams.setAuthenticationPreemptive(true) | |
| theClient | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait XmlResponse { | |
| self: TestResponse => | |
| def xmlMatch(f: Elem => Unit) | |
| (implicit errorFunc: ReportFailure): TestResponse = { | |
| if (this.asInstanceOf[SelfType].code != 200) | |
| errorFunc.fail("Response status is not 200!") | |
| xml match { | |
| case Full(xml) => f(xml); this | |
| case _ => errorFunc.fail("Response contains no XML!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for { | |
| message <- post("/statuses/update.xml", "status" -> "test_msg1") | |
| !@ "Couldn't post message" if message.xml must notBeEmpty | |
| xml <- message.xml | |
| } { | |
| xml must \\(<text>test_msg1</text>) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post("/statuses/update.xml", "status" -> "test_msg1") | |
| \\(<text>test_msg1</text>) | |
| \\(<screen_name>vdichev</screen_name>) | |
| get("/statuses/public_timeline.xml") \\(<text>test_msg1</text>) | |
| get("/statuses/user_timeline.xml") \\(<text>test_msg1</text>) | |
| get("/statuses/home_timeline.xml") \\(<text>test_msg1</text>) |
OlderNewer