Skip to content

Instantly share code, notes, and snippets.

View msvab's full-sized avatar
🚀
On it!

Michal Šváb msvab

🚀
On it!
View GitHub Profile
@msvab
msvab / gist:2950517
Created June 18, 2012 20:28
Testing Camel routes
public void testSendError() throws Exception {
// first advice the route to replace the input, and catch sending to FTP servers
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith("direct:input);
// intercept valid messages
interceptSendToEndpoint("ftp://hostname/valid")
.skipSendToOriginalEndpoint()
@msvab
msvab / gist:5458197
Created April 25, 2013 07:57
JUnit - Concurrent Test Suite
import junit.extensions.ActiveTestSuite;
import junit.extensions.RepeatedTest;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class ConcurrentTestSample extends TestCase {
public static Test suite() {
@msvab
msvab / api.feature
Created August 13, 2013 13:40 — forked from guenter/api.feature
Test API with Cucumber
Feature: API
In order to use the service from third party apps
As a user
I want to be able to use an API
Background:
Given a user exists # Pickle
And I login as the user using basic auth
Scenario Outline: Get a ticket
@msvab
msvab / gist:6450019
Created September 5, 2013 13:21
Testing Backbone app with sinon.js
var returnData = {
pageNumber: 3,
summaryList: [ { id: 5, name: 'name1'}, { id: 6, name: 'name2'} ]
};
JobSummary = Backbone.Model.extend({});
JobSummaryList = Backbone.Collection.extend({
model: JobSummary
});
@msvab
msvab / gist:9638903
Last active August 29, 2015 13:57
Stubbed HTTP service using Moco and JUnit @ClassRule
package stub;
import com.github.dreamhead.moco.HttpServer;
import com.github.dreamhead.moco.Runner;
import com.github.dreamhead.moco.monitor.Slf4jMonitor;
import lombok.Delegate;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import static com.github.dreamhead.moco.Moco.httpserver;
h2:before {
display: block;
content: " ";
margin-top: -285px;
height: 285px;
visibility: hidden;
}
@msvab
msvab / gist:10898867
Created April 16, 2014 15:59
Run load tests from command line
#!/bin/bash
set -o errexit # Exit on simple commands that return non-zero status.
set -o errtrace # Makes shell functions, command substitutions, and
# commands in subshells inherit traps on ERR
set -o nounset # Exit on use of unset variables.
run_test() {
TEST=$1
TEST_PREFIX=`echo $TEST | cut -d'_' -f1`
@msvab
msvab / gist:f083be3341db40486a64
Created May 22, 2015 14:54
ansible mvn snapshot fix
prev_state = "absent"
if os.path.isdir(dest):
dest = dest + "/" + artifact_id + "-" + version + "." + extension
if os.path.lexists(dest):
if not artifact.is_snapshot():
prev_state = "present"
elif downloader.verify_md5(dest, downloader.find_uri_for_artifact(artifact) + '.md5'):
prev_state = "present"
else:
path = os.path.dirname(dest)
@msvab
msvab / gist:d05222b552271dbda3be
Created June 2, 2015 08:51
postgres createdb
sudo su - postgres
createdb mydb
psql -s mydb
create user someuser password 'somepassword';
GRANT ALL PRIVILEGES ON DATABASE mydb TO someuser;
@msvab
msvab / gist:8422e88118b3a1127536
Created February 12, 2016 11:37 — forked from tamoyal/gist:2ea1fcdf99c819b4e07d
Upgrade Postgres 9.3 to 9.4 on Ubuntu
# Be sure to save your config files. Optional but I do:
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~
# Package repo (for apt-get)
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Also probably optional but I like to update sources and upgrade
sudo apt-get update