Created
June 24, 2009 12:20
-
-
Save gclaramunt/135215 to your computer and use it in GitHub Desktop.
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
package webtest | |
import java.net._ | |
import scala.xml._ | |
object WebTester { | |
def open(url:URL):HttpURLConnection = url.openConnection match { | |
case c:HttpURLConnection => c | |
case _ => error("Only HTTP connections allowed") | |
} | |
def URL( address:String )= new URL(address) | |
def post(conn:HttpURLConnection, params:String)={ | |
conn.setRequestMethod("POST"); | |
conn.setDoInput(true); | |
conn.setDoOutput(true); | |
conn.connect() | |
val dataOutputStream = conn.getOutputStream(); | |
dataOutputStream.write(params.getBytes()); | |
dataOutputStream.close(); | |
conn.getInputStream | |
} | |
def get(conn:HttpURLConnection)={ | |
conn.setRequestMethod("GET"); | |
conn.setDoOutput(true); | |
conn.connect() | |
conn.getInputStream | |
} | |
def sendMsg(smrVer:Int)={ | |
println ("sending message for "+smrVer) | |
post (open (URL ("localhost:9080/DW2/sendMsg")),"q=SK.SMR.LOAD&m="+smrVer+".01") | |
} | |
def main(args:Array[String]): Unit ={ | |
//smrs1 foreach (sendMsg(_)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment