adding error messages to test cases
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ef89aa9f Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ef89aa9f Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ef89aa9f Branch: refs/heads/master Commit: ef89aa9fbfb24599deda517bad4d9f11694bd065 Parents: 5b733ad Author: reka <[email protected]> Authored: Tue Aug 4 14:43:05 2015 +0530 Committer: reka <[email protected]> Committed: Tue Aug 4 15:02:12 2015 +0530 ---------------------------------------------------------------------- .../tests/ApplicationPolicyTest.java | 28 +++++-- .../integration/tests/ApplicationTest.java | 49 +++++++---- .../tests/AutoscalingPolicyTest.java | 27 ++++-- .../integration/tests/CartridgeGroupTest.java | 28 +++++-- .../integration/tests/CartridgeTest.java | 28 +++++-- .../integration/tests/DeploymentPolicyTest.java | 28 +++++-- .../integration/tests/NetworkPartitionTest.java | 28 +++++-- .../tests/SampleApplicationsTest.java | 1 + .../update/g-sc-G123-1-v1.json | 86 ++++++++++++++++++++ 9 files changed, 241 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java index b1b37b2..05110bb 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java @@ -58,9 +58,12 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the application policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add application policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the application policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get application policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -109,9 +115,12 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the application policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update application policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -135,9 +144,12 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the application policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove application policy"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java index 284401e..d4f77a6 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java @@ -59,9 +59,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while deploying the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not deploy application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -111,9 +117,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while undeploying the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not undeploy application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -137,9 +146,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while force undeploying the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not forcefully undeploy application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -164,9 +176,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -188,9 +203,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update application"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -212,9 +230,12 @@ public class ApplicationTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the application"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove application"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java index f5f3786..c76c0ef 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java @@ -57,9 +57,11 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + log.error("An unknown error occurred while trying to add autoscaling policy...."); + throw new RuntimeException("An unknown error occurred while trying to add autoscaling policy"); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add Autoscaling policy...."; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -84,9 +86,12 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the autosclaing policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get autoscaling policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -108,9 +113,12 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the autosclaing policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not updating autoscaling policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -134,9 +142,12 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the autosclaing policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove autoscaling policy"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java index dcbe5c9..4da1185 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java @@ -58,9 +58,12 @@ public class CartridgeGroupTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the cartridge group"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add cartridge group"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class CartridgeGroupTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the cartridge group"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get cartridge group"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -109,9 +115,12 @@ public class CartridgeGroupTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the cartridge group"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update cartridge group"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -135,9 +144,12 @@ public class CartridgeGroupTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the cartridge group"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove cartridge group"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java index 7cd5412..680d8a7 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java @@ -58,9 +58,12 @@ public class CartridgeTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the cartridge"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add cartridge"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class CartridgeTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the cartridge"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get cartridge"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -109,9 +115,12 @@ public class CartridgeTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the cartridge"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update cartridge"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -135,9 +144,12 @@ public class CartridgeTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the cartridge"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove cartridge"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java index e7e80eb..d7d4dd4 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java @@ -58,9 +58,12 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the deployment policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add deployment policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the deployment policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get deployment policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -111,9 +117,12 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the deployment policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update deployment policy"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -137,9 +146,12 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the deployment policy"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove deployment policy"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java index f0b46cf..42dff0a 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java @@ -58,9 +58,12 @@ public class NetworkPartitionTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while adding the networkpartition"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not add networkpartition"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -85,9 +88,12 @@ public class NetworkPartitionTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while getting the networkpartition"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not get networkpartition"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -109,9 +115,12 @@ public class NetworkPartitionTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while updating the networkpartition"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not update networkpartition"; + log.error(message, e); throw new RuntimeException(message, e); } } @@ -135,9 +144,12 @@ public class NetworkPartitionTest extends StratosArtifactsUtils { } } } - throw new RuntimeException("An unknown error occurred"); + String msg = "An unknown error occurred while removing the networkpartition"; + log.error(msg); + throw new RuntimeException(msg); } catch (Exception e) { - String message = "Could not start mock instance"; + String message = "Could not remove networkpartition"; + log.error(message, e); throw new RuntimeException(message, e); } } http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java index a4ad8e9..5f4eea6 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java @@ -496,6 +496,7 @@ public class SampleApplicationsTest extends StratosTestServerManager { restClient); assertEquals(removedDep, false); + //Un-deploying the application boolean unDeployed = applicationTest.undeployApplication("g-sc-G123-1", endpoint, restClient); assertEquals(unDeployed, true); http://git-wip-us.apache.org/repos/asf/stratos/blob/ef89aa9f/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1-v1.json ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1-v1.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1-v1.json new file mode 100644 index 0000000..fb5e000 --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1-v1.json @@ -0,0 +1,86 @@ +{ + "alias": "g-sc-G123-1", + "applicationId": "g-sc-G123-1", + "components": { + "cartridges": [], + "groups": [ + { + "name": "G1", + "groupMaxInstances": 5, + "groupMinInstances": 4, + "alias": "group1", + "cartridges": [ + { + "cartridgeMin": 2, + "cartridgeMax": 3, + "type": "c1", + "subscribableInfo": { + "alias": "c1-1x0", + "deploymentPolicy": "deployment-policy-1", + "artifactRepository": { + "repoUsername": "user", + "repoUrl": "http://stratos.apache.org:10080/git/default.git", + "privateRepo": true, + "repoPassword": "c-policy" + }, + "autoscalingPolicy": "autoscaling-policy-1" + } + } + ], + "groups": [ + { + "name": "G2", + "groupMaxInstances": 1, + "groupMinInstances": 1, + "alias": "group2", + "cartridges": [ + { + "cartridgeMin": 2, + "cartridgeMax": 4, + "type": "c2", + "subscribableInfo": { + "alias": "c2-1x0", + "deploymentPolicy": "deployment-policy-1", + "artifactRepository": { + "repoUsername": "user", + "repoUrl": "http://stratos.apache.org:10080/git/default.git", + "privateRepo": true, + "repoPassword": "c-policy" + }, + "autoscalingPolicy": "autoscaling-policy-1" + } + } + ], + "groups": [ + { + "name": "G3", + "groupMaxInstances": 3, + "groupMinInstances": 2, + "deploymentPolicy": "static-1", + "alias": "group3", + "cartridges": [ + { + "cartridgeMin": 2, + "cartridgeMax": 3, + "type": "c3", + "subscribableInfo": { + "alias": "c3-1x0", + "artifactRepository": { + "repoUsername": "user", + "repoUrl": "http://stratos.apache.org:10080/git/default.git", + "privateRepo": true, + "repoPassword": "c-policy" + }, + "autoscalingPolicy": "autoscaling-policy-1" + } + } + ], + "groups": [] + } + ] + } + ] + } + ] + } +}
