Skip to content

Instantly share code, notes, and snippets.

@corinnekrych
Last active December 18, 2015 02:38
Show Gist options
  • Save corinnekrych/5712058 to your computer and use it in GitHub Desktop.
Save corinnekrych/5712058 to your computer and use it in GitHub Desktop.
MarJUG proposal

Purpose

Server wants to push notification to client. How to provide an unified way of pushing notification? Aerogear Unified push. See spec for explanation.

You want to contribute to this effort? What about writing functional tests! Yes... It's fun it's with Spock.

If you want to try it

Let's setup your environment for pushee (unified push server) + simplePush Note that this is a work in progress.

=> Install pushee and run it

git clone https://github.com/matzew/pushee.git
cd pushee
mvn package jboss-as:deploy
./bin/standalone.sh -b 0.0.0.0

=> Register app: send te curl described here

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name" : "MyApp", "description" :  "awesome app" }' http://localhost:8080/ag-push/rest/applications

=> Register variant for app id: get id from previous response and send curl

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"pushNetworkURL" : "http://localhost:7777/endpoint/"}' http://localhost:8080/ag-push/rest/applications/{PUSH_ID}/simplePush 

Keep you variant id, you will use it later! Note that all thoses ids (push app id + variant id) are stored in database. Even restarting your server you won't need to do thoses steps again.

=> Modify HTML page with variant id

vi pushee/src/main/webapp/websocket.html

Enter your variant id

<!-- Config for AeroGear.SimplePush -->
<script>
    var AeroGearSimplePush = {
        ariantID: "402881ef3ea36c3e013ea36c8de90001"
    };
</script>

=> Rebuid and redeploy

cd pushee
mvn package jboss-as:deploy    

=> Clone SimplePush

git clone https://github.com/danbev/aerogear-simplepush-server

=> SimplePush required vert.x to build

git clone https://github.com/vert-x/vert.x
cd vert.x
./gradlew install

If you run into the same problems I had here is my tip

=> SimplePush required netty-component

git clone https://github.com/danbev/netty-subsystem.git
cd netty-subsystem
mvn install

=> Build SimplePush

cd aerogear-simplepush-server
mvn install

=> Launch SimplePush

mvn exec:java -Dexec.args="8888 false 10000 60000"

=> send msg using web interface

http://localhost:8080/ag-push/websocket.html

Set up test env

=> fork or clone Karels's repo

git clone https://github.com/kpiwko/pushee-integration-tests.git

Note You should install pushee-integration-tests as a sibling of pushee. Those two need each other.

=> follow requirements section on readme. https://github.com/kpiwko/pushee-integration-tests#requirements. To sum up you will need to clone and build those

git clone https://github.com/kpiwko/arquillian-testrunner-spock.git
cd arquillian-testrunner-spock
git checkout spock-0.7-update
mvn install
cd ..
git clone https://github.com/shrinkwrap/resolver.git
cd resolver
mvn install

I had to update pon.xml file of shrinkwrap and rolllbact to previous version

<version.org.jboss.shrinkwrap.resolver>2.0.0-cr-1-SNAPSHOT</version.org.jboss.shrinkwrap.resolver>

=> Once all pre-requisites are done, launch integration test(s)

cd pushee-integration-tests
mvn verify

as you can see there is only one test. Time to contribute!

Write tests

We going to write in-container tests using arquillian + Spock.

If your favorite IDE is Intellij, add the property Configure test... in VM option add:

-DjbossHome=/Users/corinne/aerogear/pushee-test/pushee-integration-tests/target/jboss-as-7.1.1.Final
-DjbossHome=/Users/corinne/aerogear/unified-push/aerogear-unified-push-server/target/jboss-as-7.1.1.Final

in working directory set the path to your current module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment