Make Git Bash Awesome Again

Add some spice to git bash to help battle the cubicle blues.

Add some sweet ascii art

Edit your ~/.bashrc file and add the following

cat << EOF

<insert ascii art here>

EOF

Spice up the prompt

This one is a little more tricky, but start by editing the C:\Program Files\Git\etc\profile.d\git-prompt.sh

You will see a line that starts

PS1=

Edit this line to make whatever your heart desires. Here is a fun one that creates the shrug emoji.

PS1='\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]' # set window title
PS1="$PS1"'\n'                 # new line
PS1="$PS1"'\[\033[32m\]'       # change to green
PS1="$PS1"'\u@\h '             # user@host<space>
PS1="$PS1"'\[\033[35m\]'       # change to purple
PS1="$PS1"'¯\(°_o)/¯ '         # shrug
PS1="$PS1"'\[\033[33m\]'       # change to brownish yellow
PS1="$PS1"'\w'                 # current working directory
Leave a comment

Mule ESB Enterprise in Docker on Openshift 3.x

Here is a useful Dockerfile for running Mule ESB EE in Docker. We are currently running this on Red Hat’s Openshift (kubernetes-based) container server and it runs quite well.

FROM openshift/base-centos7

ENV MULE_HOME /opt/mule
ENV MULE_VERSION 3.7.3

EXPOSE 8080

# Set labels used in OpenShift to describe the builder image
LABEL io.k8s.description="Platform for building Mule ESB EE Applications" \
      io.k8s.display-name="Mule ESB 3.7.3 Enterprise" \
      io.openshift.expose-services="8080:http" \
      io.openshift.tags="builder,mule,3.x,java"

# we need some tools from yum
# and install mule ee standalone
RUN yum update -y \
    && yum install -y java-1.8.0-openjdk-devel maven zip \
    && yum clean all -y \
    && cd /opt \
    && curl -o mule.tar.gz https://s3.amazonaws.com/MuleEE/fe49c9b102bcce22304d198936ea663f/mule-ee-distribution-standalone-3.7.3.tar.gz \
    && tar -xf mule.tar.gz \
    && mv mule-enterprise-standalone-$MULE_VERSION mule \
    && rm mule.tar.gz*

# Copy configuration files
COPY ./conf/* $MULE_HOME/conf/

# Installing license file
COPY ./license/license.lic $MULE_HOME/license.lic
RUN $MULE_HOME/bin/mule -installLicense $MULE_HOME/license.lic

# Copy application files
COPY ./target/*.zip $MULE_HOME/apps/

# run as non-root user
RUN chown -R 1001:0 $MULE_HOME && \
    chmod -R g+wrx $MULE_HOME

# Openshift runtime user
USER 1001

# engage
CMD exec $MULE_HOME/bin/mule $MULE_OPTS_APPEND
Leave a comment

REST API Testing with Cucumber and Javascript

There are a great many tools available for testing REST Api’s by various vendors, open source plugins, browser plugins, and the old classic curl.

If you’re looking for a really simple way to test REST Api’s that is easy to maintain and entirely automated then you should consider using Cucumber with Javascript. If you’re not familiar with Cucumber, its an adapter that handles gherkin, a domain specific language for writing ATDD tests.

Here is what a simple automated test looks like using gherkin DSL:

Scenario: Making a simple GET request
    When I make a GET request to "/posts/1"
    Then The response property "userId" should be "1"
    And The response property "id" should be "1"

Any member of your team, whether it’s a developer, tester, or analyst can read and understand the scripts, which really makes it easier to collaborate as a team and eliminate confusion.

A simple POST request might look like this

Scenario: Making a POST request using tabular data
    Given The request data
    | title | body | userId |
    | foo   | bar  | 1      |
    When I make a POST request to "/posts"
    Then The response property "userId" should be "1"
    And The response property "id" should be "101"

Or if you prefer to use json (I certainly do), you can use this alternate format

Scenario: Making a POST request with json data
    Given The json request data
    """json
    {
        "title": "foo",
        "body": "bar",
        "userId": 1
    }
    """
    When I make a POST request to "/posts"
    Then The response property "userId" should be "1"
    And The response property "id" should be "101"

I have written a small framework as a starting point that you can clone from Github and start writing tests today. The framework can be customized as you go along and expanded to cover any testing need you have.

https://github.com/carbonrobot/relish

One Response to “REST API Testing with Cucumber and Javascript”

Show comments