blob: 6885679cc4b4f605302a4a67f6bc80dc3ca8297c [file]
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
---
name: Basic HTTP Call Tests
location: localhost
services:
- type: org.apache.brooklyn.test.framework.TestCase
brooklyn.children:
- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
id: tomcat
brooklyn.config:
war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: Status Code 200
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
applyAssertionTo: status
assert:
equalTo: 200
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: Status Code 404
url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
timeout: 10s
applyAssertionTo: status
assert:
equals: 404
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: String match
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
applyAssertionTo: body
# This example illustrates the use of a list of maps in order to repeat a key multiple times.
assert:
- contains: Sample
- contains: Brooklyn
- contains: Deployed
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: Regex match
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
applyAssertionTo: body
# the matches assert uses java.lang.String under the hood so if the url is expected to returns
# a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
# See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
assert:
matches: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
...
---
name: HTTP Call Test with Effector
location: localhost
services:
- type: org.apache.brooklyn.test.framework.TestCase
brooklyn.children:
- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
id: tomcat
brooklyn.config:
war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: / Status Code 200
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
applyAssertionTo: status
assert:
isEqualTo: 200
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: /newcontext Status Code 404
url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
applyAssertionTo: status
assert:
equalTo: 404
- type: org.apache.brooklyn.test.framework.TestEffector
name: Deploy WAR in /newcontext
target: $brooklyn:component("tomcat")
effector: deploy
params:
url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
targetName: newcontext
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: /newcontext Status Code 200
url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
# Give Tomcat time to make the newly deployed War accessible
timeout: 10s
applyAssertionTo: status
assert:
equals: 200
...
---
name: HTTP Call Test with Eventual String and Regex Matches
location: localhost
services:
- type: org.apache.brooklyn.test.framework.TestCase
brooklyn.children:
- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
id: tomcat
brooklyn.config:
war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
- type: org.apache.brooklyn.test.framework.TestEffector
name: Deploy WAR in /newcontext
target: $brooklyn:component("tomcat")
effector: deploy
params:
url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
targetName: newcontext
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: Regex match
url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
timeout: 10s
assert:
- matches: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
- type: org.apache.brooklyn.test.framework.TestEffector
name: Deploy WAR in /newcontext2
target: $brooklyn:component("tomcat")
effector: deploy
params:
url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
targetName: newcontext2
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: String match
url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
timeout: 10s
assert:
- contains: Sample Brooklyn Deployed
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: String match
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
assert:
- contains: Sample Brooklyn Deployed
- type: org.apache.brooklyn.test.framework.TestHttpCall
name: Regex match
url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
# the regex assert uses java.lang.String under the hood so if the url is expected to returns
# a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
# See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
assert:
- matches: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
...