Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
c20d5eb2
Commit
c20d5eb2
authored
Apr 12, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test module with jar generated from documentation
parent
661d57f7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
21 deletions
+187
-21
pom.xml
drip-tests/pom.xml
+7
-1
ec2_test.properties
drip-tests/src/main/resources/ec2_test.properties
+4
-0
DRIPTest.java
.../src/test/java/nl/uva/sne/drip/test/manager/DRIPTest.java
+33
-6
TestCloudCredentialsController.java
...sne/drip/test/manager/TestCloudCredentialsController.java
+45
-14
TestKeysController.java
...java/nl/uva/sne/drip/test/manager/TestKeysController.java
+98
-0
No files found.
drip-tests/pom.xml
View file @
c20d5eb2
...
...
@@ -31,7 +31,13 @@
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.5
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
javax
</groupId>
<artifactId>
javaee-web-api
</artifactId>
...
...
drip-tests/src/main/resources/ec2_test.properties
0 → 100644
View file @
c20d5eb2
access.key.id
=
lferpoiewp
secret.key
=
erfiru
cloud.provider.name
=
ec2
cloud.private.key.paths
=
/home/alogo/Virginia.pem,/home/alogo/California.pem
\ No newline at end of file
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/DRIPTest.java
View file @
c20d5eb2
...
...
@@ -15,27 +15,54 @@
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
import
javax.net.ssl.SSLContext
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.ws.rs.client.Client
;
import
javax.ws.rs.client.ClientBuilder
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
*
* @author
alogo
* @author
S. Koulouzis
*/
public
class
DRIPTest
{
private
static
List
<
String
>
PROPERTIES_FILE_PATHS
;
public
static
List
<
Properties
>
propertiesList
=
new
ArrayList
<>();
public
static
final
String
ACCESS_KEY_ID_PROPPERTY_NAME
=
"access.key.id"
;
static
String
CLOUD_PROPVIDER_PROPPERTY_NAME
=
"cloud.provider.name"
;
static
String
SECRET_KEY_PROPERTY_NAME
=
"secret.key"
;
static
String
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
=
"cloud.private.key.paths"
;
public
DRIPTest
()
{
PROPERTIES_FILE_PATHS
=
new
ArrayList
<>();
}
@BeforeClass
public
static
void
setUpClass
()
{
for
(
String
propFile
:
PROPERTIES_FILE_PATHS
)
{
try
(
Reader
inStream
=
new
FileReader
(
new
File
(
propFile
)))
{
Properties
prop
=
new
Properties
();
prop
.
load
(
inStream
);
propertiesList
.
add
(
prop
);
}
catch
(
FileNotFoundException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
@AfterClass
...
...
@@ -76,7 +103,7 @@ public class DRIPTest {
// LOGGER.warn("Null SSL context, skipping client SSL configuration", npe);
// }
// return builder.build();
return
null
;
return
null
;
}
}
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/TestCloudCredentialsController.java
View file @
c20d5eb2
...
...
@@ -15,6 +15,16 @@
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -25,13 +35,21 @@ import javax.ws.rs.client.Entity;
import
javax.ws.rs.client.Invocation
;
import
javax.ws.rs.core.Response
;
import
nl.uva.sne.drip.data.v1.external.CloudCredentials
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.data.v1.external.KeyType
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
*
* @author S. Koulouzis.
*/
public
class
TestCloudCredentialsController
{
public
class
TestCloudCredentialsController
extends
DRIPTest
{
@BeforeClass
public
static
void
setUpClass
()
{
...
...
@@ -41,23 +59,36 @@ public class TestCloudCredentialsController {
public
static
void
tearDownClass
()
{
}
@Before
public
void
setUp
()
{
@Test
public
void
testPOST_GETCloudCredentials
()
{
for
(
Properties
p
:
DRIPTest
.
propertiesList
)
{
String
[]
paths
=
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
.
split
(
","
);
for
(
String
cloudPrivateKeyPath
:
paths
)
{
try
{
KeyPair
keyPair
=
new
KeyPair
();
Key
privateKey
=
new
Key
();
privateKey
.
setName
(
FileUtils
.
readFileToString
(
new
File
(
cloudPrivateKeyPath
),
"UTF-8"
));
privateKey
.
setKey
(
FilenameUtils
.
getBaseName
(
cloudPrivateKeyPath
));
privateKey
.
setType
(
KeyType
.
PRIVATE
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
cloudPrivateKeyPath
,
cloudPrivateKeyPath
);
privateKey
.
setAttributes
(
map
);
keyPair
.
setPrivateKey
(
privateKey
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
@After
public
void
tearDown
()
{
}
@Test
public
void
hello
()
{
System
.
err
.
println
(
""
);
CloudCredentials
cc
=
new
CloudCredentials
();
cc
.
setAccessKeyId
(
""
);
cc
.
setAccessKeyId
(
p
.
getProperty
(
ACCESS_KEY_ID_PROPPERTY_NAME
));
cc
.
setCloudProviderName
(
p
.
getProperty
(
CLOUD_PROPVIDER_PROPPERTY_NAME
));
cc
.
setSecretKey
(
p
.
getProperty
(
DRIPTest
.
SECRET_KEY_PROPERTY_NAME
));
cc
.
setKeyPairIDs
(
keyPairIDs
);
}
}
private
void
post
(
String
lcmId
,
String
metadataId
,
String
storageId
,
int
expected
)
{
private
void
post
(
int
expected
)
{
// String payload = "{\"local-storage-id\" : \"" + storageId + "\"}";
// Entity<String> entity = Entity.entity(payload, "application/json");
// Response resp = getWebTarget().path(TRIGGER_PATH).path(lcmId).path("metadata").path(metadataId)
...
...
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/TestKeysController.java
0 → 100644
View file @
c20d5eb2
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.data.v1.external.KeyType
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
*
* @author alogo
*/
public
class
TestKeysController
extends
DRIPTest
{
public
TestKeysController
()
{
}
@BeforeClass
public
static
void
setUpClass
()
{
}
@AfterClass
public
static
void
tearDownClass
()
{
}
@Before
public
void
setUp
()
{
}
@After
public
void
tearDown
()
{
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public
void
test_POST_GETCoudKeys
()
{
String
[]
paths
=
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
.
split
(
","
);
for
(
String
cloudPrivateKeyPath
:
paths
)
{
try
{
KeyPair
keyPair
=
new
KeyPair
();
Key
privateKey
=
createPrivateCloudKey
(
cloudPrivateKeyPath
);
keyPair
.
setPrivateKey
(
privateKey
);
post
(
keyPair
,
200
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
private
void
post
(
KeyPair
keyPair
,
int
expected
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
}
private
Key
createPrivateCloudKey
(
String
cloudPrivateKeyPath
)
throws
IOException
{
Key
privateKey
=
new
Key
();
privateKey
.
setName
(
FileUtils
.
readFileToString
(
new
File
(
cloudPrivateKeyPath
),
"UTF-8"
));
privateKey
.
setKey
(
FilenameUtils
.
getBaseName
(
cloudPrivateKeyPath
));
privateKey
.
setType
(
KeyType
.
PRIVATE
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"attribute"
,
"value"
);
privateKey
.
setAttributes
(
map
);
return
privateKey
;
}
}
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