Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cameo-tests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Cameo
cameo-tests
Commits
2206b7b2
Commit
2206b7b2
authored
Nov 09, 2018
by
legoc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The return of the server process
parent
8cc98f4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
12 deletions
+102
-12
cameo-tests-jeromq/pom.xml
cameo-tests-jeromq/pom.xml
+13
-1
src/main/java/fr/ill/ics/cameo/TestSelector.java
src/main/java/fr/ill/ics/cameo/TestSelector.java
+89
-11
No files found.
cameo-tests-jeromq/pom.xml
View file @
2206b7b2
...
@@ -12,14 +12,26 @@
...
@@ -12,14 +12,26 @@
<groupId>
fr.ill.ics
</groupId>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
cameo-server-jeromq
</artifactId>
<artifactId>
cameo-server-jeromq
</artifactId>
<version>
0.1.3
</version>
<version>
0.1.3
</version>
<!-- <exclusions>
<exclusion>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-process-handle-default</artifactId>
</exclusion>
</exclusions> -->
</dependency>
</dependency>
<dependency>
<!-- <dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-process-handle-null</artifactId>
<version>0.0.1</version>
</dependency> -->
<dependency>
<groupId>
fr.ill.ics
</groupId>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
cameo-api-java-jeromq
</artifactId>
<artifactId>
cameo-api-java-jeromq
</artifactId>
<version>
0.1.2
</version>
<version>
0.1.2
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<sourceDirectory>
../src/main/java
</sourceDirectory>
<sourceDirectory>
../src/main/java
</sourceDirectory>
</build>
</build>
...
...
src/main/java/fr/ill/ics/cameo/TestSelector.java
View file @
2206b7b2
package
fr.ill.ics.cameo
;
package
fr.ill.ics.cameo
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.security.CodeSource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
public
class
TestSelector
{
public
class
TestSelector
{
public
static
Process
startServer
(
String
config
)
{
System
.
out
.
println
(
"Starting server"
);
String
jarFileName
=
""
;
CodeSource
codeSource
=
TestSelector
.
class
.
getProtectionDomain
().
getCodeSource
();
try
{
File
jarFile
=
new
File
(
codeSource
.
getLocation
().
toURI
().
getPath
());
jarFileName
=
jarFile
.
toString
();
}
catch
(
URISyntaxException
e1
)
{
e1
.
printStackTrace
();
System
.
exit
(
1
);
}
ArrayList
<
String
>
commandList
=
new
ArrayList
<
String
>();
commandList
.
add
(
"java"
);
String
javaLibraryPath
=
System
.
getProperty
(
"java.library.path"
);
if
(
javaLibraryPath
!=
null
)
{
commandList
.
add
(
"-Djava.library.path="
+
javaLibraryPath
);
}
commandList
.
add
(
"-classpath"
);
commandList
.
add
(
jarFileName
);
commandList
.
add
(
"fr.ill.ics.cameo.server.Server"
);
commandList
.
add
(
config
);
// Prepare the command
String
command
[]
=
new
String
[
commandList
.
size
()];
commandList
.
toArray
(
command
);
String
serverCommand
=
""
;
for
(
String
c
:
command
)
{
serverCommand
+=
c
+
" "
;
}
System
.
out
.
println
(
"Server command : "
+
serverCommand
);
ProcessBuilder
builder
=
new
ProcessBuilder
(
command
);
builder
.
redirectErrorStream
(
true
);
try
{
System
.
out
.
println
(
"Server started"
);
return
builder
.
start
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
void
startApplication
(
Server
server
,
String
appName
,
String
[]
appArgs
)
{
public
static
void
startApplication
(
Server
server
,
String
appName
,
String
[]
appArgs
)
{
Application
.
Instance
instance
=
server
.
start
(
appName
,
appArgs
,
Option
.
OUTPUTSTREAM
);
Application
.
Instance
instance
=
server
.
start
(
appName
,
appArgs
,
Option
.
OUTPUTSTREAM
);
...
@@ -44,15 +99,23 @@ public class TestSelector {
...
@@ -44,15 +99,23 @@ public class TestSelector {
System
.
out
.
printf
(
"Usage: <application name> <number of iterations>"
);
System
.
out
.
printf
(
"Usage: <application name> <number of iterations>"
);
System
.
exit
(
1
);
System
.
exit
(
1
);
}
}
// Send the command.
int
argsIndex
=
0
;
Server
server
=
new
Server
(
"tcp://localhost:10000"
);
if
(!
server
.
isAvailable
())
{
// Define the server process.
System
.
out
.
printf
(
"Start the server before running the tests"
);
Process
serverProcess
=
null
;
System
.
exit
(
1
);
// Start the server.
serverProcess
=
startServer
(
args
[
0
]);
Server
server
=
new
Server
(
"tcp://localhost:10000"
);
// change depending on config
if
(
server
.
isAvailable
())
{
System
.
out
.
println
(
"Server is available"
);
}
}
argsIndex
=
1
;
try
{
try
{
boolean
all
=
false
;
boolean
all
=
false
;
String
appName
;
String
appName
;
...
@@ -74,7 +137,7 @@ public class TestSelector {
...
@@ -74,7 +137,7 @@ public class TestSelector {
apps
.
add
(
"startnpubcpp"
);
apps
.
add
(
"startnpubcpp"
);
apps
.
add
(
"startrepcpp"
);
apps
.
add
(
"startrepcpp"
);
if
(
args
.
length
<
1
)
{
if
(
args
.
length
<
argsIndex
+
1
)
{
System
.
out
.
println
(
"Available applications:"
);
System
.
out
.
println
(
"Available applications:"
);
...
@@ -85,15 +148,15 @@ public class TestSelector {
...
@@ -85,15 +148,15 @@ public class TestSelector {
return
;
return
;
}
}
else
{
else
{
appName
=
args
[
0
];
appName
=
args
[
argsIndex
];
if
(
appName
.
equals
(
"all"
))
{
if
(
appName
.
equals
(
"all"
))
{
all
=
true
;
all
=
true
;
}
}
appArgs
=
new
String
[
args
.
length
-
1
];
appArgs
=
new
String
[
args
.
length
-
1
-
argsIndex
];
for
(
int
i
=
0
;
i
<
args
.
length
-
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
args
.
length
-
1
-
argsIndex
;
++
i
)
{
appArgs
[
i
]
=
args
[
i
+
1
];
appArgs
[
i
]
=
args
[
argsIndex
+
i
+
1
];
}
}
}
}
...
@@ -111,6 +174,21 @@ public class TestSelector {
...
@@ -111,6 +174,21 @@ public class TestSelector {
}
finally
{
}
finally
{
// Terminate the server.
// Terminate the server.
server
.
terminate
();
server
.
terminate
();
// If the server process exists.
if
(
serverProcess
!=
null
)
{
// Destroy the server process.
serverProcess
.
destroyForcibly
();
// Waiting for the server that should not return without
// interruption.
try
{
serverProcess
.
waitFor
();
}
catch
(
InterruptedException
e
)
{
// Do nothing.
}
}
}
}
}
}
}
}
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