Commit 15cae4d1 authored by Yoshiharu Hirose's avatar Yoshiharu Hirose

dummyhttpserver.properties で設定できるようにしました。

parent 67b66fe8
......@@ -9,13 +9,20 @@ iaac-sdk のユニットテストを通すための通信先となるHTTPサー
・URLで指定されたファイル名を特定のフォルダ配下から検索して返す(指定されたパスは無視)
※もし同名のファイルが複数存在する場合は先に見つかったもの
■実行方法
> activator "run (ベースディレクトリ)"
※HTTPサーバから返却するxmlが格納されたディレクトリを指定する。
■実行例
実行方法
------------------------------------------------------------------------
1.dummyhttpserver.properties を作成し、ベースディレクトリ(返却するxmlファイルが
格納されているディレクトリのトップ)を指定
dummyhttpserver.properties (例)
basedir=D:\\project\\nifty\\clisdk\\dev\\iaas-sdk\\src\\test\\resources
2. 実行
> set HTTP_PROXY=http://proxy2:8080
> set HTTPS_PROXY=http://proxy2:8080
> activator "run D:\project\nifty\clisdk\dev\iaas-sdk\src\test\resources"
> activator run
※初回実行時はProxy設定が必要。(依存ライブラリをダウンロードするため時間がかかる。)
basedir=D:\\project\\nifty\\clisdk\\dev\\iaas-sdk\\src\\test\\resources
#ports=80,8080,38080
import java.io._
import java.net.InetSocketAddress
import java.util.Properties
import com.sun.net.httpserver.{HttpExchange, HttpHandler, HttpServer}
import scala.collection.JavaConversions._
object DummyHttpServer {
val PORTS = Array(80, 8080, 38080)
val PROPERTIES_FILE = "dummyhttpserver.properties"
val DEFAULT_PORTS = Array(80, 8080, 38080)
def main(args: Array[String]) {
if (args.length > 0) {
printf("Starting server.\nbasedir = %s\n", args(0))
PORTS.foreach { port => startServer(args(0), port) }
// Load properties
val properties = new Properties()
try {
val is = new FileInputStream(new File(PROPERTIES_FILE))
properties.load(is)
is.close()
} catch {
case e: FileNotFoundException => ()
}
val basedirOps = Option(if (args.length > 0) args(0) else properties.getProperty("basedir"))
val portsOps = Option(properties.getProperty("ports")).map(_.split(",").map(_.toInt)).getOrElse(DEFAULT_PORTS)
for (basedir <- basedirOps; port <- portsOps) {
printf("Starting server. basedir: %s, port: %d\n", basedir, port)
startServer(basedir, port)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment