Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dummyhttpserver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoshiharu Hirose
dummyhttpserver
Commits
15cae4d1
Commit
15cae4d1
authored
Apr 06, 2016
by
Yoshiharu Hirose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dummyhttpserver.properties で設定できるようにしました。
parent
67b66fe8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
9 deletions
+32
-9
README.TXT
README.TXT
+12
-5
dummyhttpserver.properties.sample
dummyhttpserver.properties.sample
+2
-0
DummyHttpServer.scala
src/main/scala/DummyHttpServer.scala
+18
-4
No files found.
README.TXT
View file @
15cae4d1
...
...
@@ -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設定が必要。(依存ライブラリをダウンロードするため時間がかかる。)
dummyhttpserver.properties.sample
0 → 100644
View file @
15cae4d1
basedir=D:\\project\\nifty\\clisdk\\dev\\iaas-sdk\\src\\test\\resources
#ports=80,8080,38080
src/main/scala/DummyHttpServer.scala
View file @
15cae4d1
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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment