diff --git a/adc.sh b/adc.sh
index 6990530..480456e 100755
--- a/adc.sh
+++ b/adc.sh
@@ -509,6 +509,20 @@ register application_list List all applications available on the controller
describe application_list << EOF
List all applications available on the controller. This command requires no further arguments.
EOF
+function application_create {
+ apiCall -X POST -d "{\"name\": \"\${n}\", \"description\": \"\"}" "/controller/restui/allApplications/createApplication?applicationType=\${t}" "$@"
+}
+register application_create Create a new application
+describe application_create << EOF
+Create a new application. Provide a name and a type (APM or WEB) as parameter.
+EOF
+function application_delete {
+ apiCall -X POST -d "\${a}" "/controller/restui/allApplications/deleteApplication" "$@"
+}
+register application_delete Delete an application
+describe application_delete << EOF
+Delete an application. Provide application id as parameter.
+EOF
function application_export {
local APPLICATION_ID=$*
if [[ $APPLICATION_ID =~ ^[0-9]+$ ]]; then
diff --git a/commands/application/create.sh b/commands/application/create.sh
new file mode 100644
index 0000000..2e2c948
--- /dev/null
+++ b/commands/application/create.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+function application_create {
+ apiCall -X POST -d "{\"name\": \"\${n}\", \"description\": \"\"}" "/controller/restui/allApplications/createApplication?applicationType=\${t}" "$@"
+}
+
+register application_create Create a new application
+
+describe application_create << EOF
+Create a new application. Provide a name and a type (APM or WEB) as parameter.
+EOF
diff --git a/commands/application/delete.sh b/commands/application/delete.sh
new file mode 100644
index 0000000..6dceb2a
--- /dev/null
+++ b/commands/application/delete.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+function application_delete {
+ apiCall -X POST -d "\${a}" "/controller/restui/allApplications/deleteApplication" "$@"
+}
+
+register application_delete Delete an application
+
+describe application_delete << EOF
+Delete an application. Provide application id as parameter.
+EOF
diff --git a/main.sh b/main.sh
index 3f2ca65..45fe812 100755
--- a/main.sh
+++ b/main.sh
@@ -56,6 +56,8 @@ source ./commands/portal/login.sh
source ./commands/portal/download.sh
source ./commands/application/list.sh
+source ./commands/application/create.sh
+source ./commands/application/delete.sh
source ./commands/application/export.sh
source ./commands/bt/list.sh
diff --git a/test.sh b/test.sh
index c2f36b3..dc3cbf0 100755
--- a/test.sh
+++ b/test.sh
@@ -17,6 +17,16 @@ function assert_equals {
fi
}
+function assert_empty {
+ TEST_COUNTER=$TEST_COUNTER+1
+ if [[ -z "$1" ]]; then
+ SUCCESS_COUNTER=$SUCCESS_COUNTER+1
+ echo -en "\033[0;32m.\033[0m"
+ else
+ echo -e "\n\033[0;31mTest failed: \033[0;33m$1\033[0;31m is not an empty string."
+ fi
+}
+
function assert_contains_substring {
TEST_COUNTER=$TEST_COUNTER+1
if [[ $2 == *$1* ]]; then
@@ -50,24 +60,35 @@ assert_contains_substring "Login Successful" "`${ADC} controller login`"
assert_contains_substring "true" "`${ADC} controller status`"
assert_regex "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" "`${ADC} controller version`"
-##### List different entities #####
-assert_contains_substring "" "`${ADC} application list`"
-assert_contains_substring "" "`${ADC} tier list -a 5`"
-assert_contains_substring "" "`${ADC} bt list -a 5`"
-
-##### Error handling #####
-assert_equals "Error" "`env CONFIG_HTTP_TIMEOUT=1 ./adc.sh -H 127.0.0.2:8009 controller ping`"
-
-##### Database Collector Create, List, Get, Delete #####
-CREATE="`${ADC} dbmon create -i adc_test_collector -h localhost -n db -u user -a "Default Database Agent" -t DB2 -p 1555 -s password`"
-assert_contains_substring '"name" : "adc_test_collector",' "$CREATE"
-assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon list`"
-if [[ $CREATE =~ \"id\"\ \:\ ([0-9]+) ]] ; then
- COLLECTOR_ID=${BASH_REMATCH[1]}
- assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon get $COLLECTOR_ID`"
- assert_contains_substring '"status" : "SUCCESS",' "`${ADC} dbmon delete $COLLECTOR_ID`"
-fi
+##### Create a test application
+APPNAME="ADC_TEST_APPLICATION_${RANDOM}"
+CREATE_APPLICATION="`${ADC} application create -t APM -n "$APPNAME"`"
+assert_contains_substring "\"name\" : \"${APPNAME}\"," "$CREATE_APPLICATION"
+if [[ $CREATE_APPLICATION =~ \"id\"\ \:\ ([0-9]+) ]] ; then
+ APPLICATION_ID=${BASH_REMATCH[1]}
+
+
+ ##### List different entities #####
+ assert_contains_substring "" "`${ADC} application list`"
+ assert_contains_substring "" "`${ADC} tier list -a $APPLICATION_ID`"
+ assert_contains_substring "" "`${ADC} bt list -a $APPLICATION_ID`"
+
+ ##### Database Collector Create, List, Get, Delete #####
+ CREATE_DBMON="`${ADC} dbmon create -i adc_test_collector -h localhost -n db -u user -a "Default Database Agent" -t DB2 -p 1555 -s password`"
+ assert_contains_substring '"name" : "adc_test_collector",' "$CREATE_DBMON"
+ assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon list`"
+ if [[ $CREATE_DBMON =~ \"id\"\ \:\ ([0-9]+) ]] ; then
+ COLLECTOR_ID=${BASH_REMATCH[1]}
+ assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon get $COLLECTOR_ID`"
+ assert_contains_substring '"status" : "SUCCESS",' "`${ADC} dbmon delete $COLLECTOR_ID`"
+ fi
+ ##### Error handling #####
+ assert_equals "Error" "`env CONFIG_HTTP_TIMEOUT=1 ./adc.sh -H 127.0.0.2:8009 controller ping`"
+
+ ##### Delete the test application
+ assert_empty "`${ADC} application delete $APPLICATION_ID`"
+fi
#### END TESTS ####
declare -i PERCENTAGE
@@ -75,11 +96,11 @@ declare -i PERCENTAGE
PERCENTAGE=$((($SUCCESS_COUNTER*100)/($TEST_COUNTER)))
if [ $PERCENTAGE -eq 100 ]; then
- echo -e "\033[0;32m"
+ echo -e "\033[0;32m"
elif [ $PERCENTAGE -ge 80 ]; then
- echo -e "\033[0;33m"
+ echo -e "\033[0;33m"
else
- echo -e "\033[0;31m"
+ echo -e "\033[0;31m"
fi
rm $COOKIE_PATH