Skip to content

Instantly share code, notes, and snippets.

Avatar
🖥️
I may be slow to respond.

Vladimir Orany musketyr

🖥️
I may be slow to respond.
View GitHub Profile
@musketyr
musketyr / gist:8863308
Created Feb 7, 2014
Rewritten parametrized JUnit test to Spock
View gist:8863308
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
import java.util.regex.Pattern
/**
* @author musketyr
*/
class EmailValidatorSpec extends Specification {
View gist:9394815
package com.example.com;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
View .bash_profile
# Change your JAVA_HOME
function setjdk() {
if [ $# -ne 0 ];
then export JAVA_HOME=`/usr/libexec/java_home -v $@`;
fi;
java -version;
}
# Automatically set the JAVA_HOME
setjdk 1.7
View test.r.xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:echo>
<message SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/>
</ns1:echo>
</SOAP-ENV:Body>
View runAllActions.js
angular.forEach(angular.element('.glyphicon-flash'), function(runAction, index) {
setTimeout(function() {
angular.element(runAction).click()
}, 1000 * 2 * index)
setTimeout(function() {
angular.element('.modal-dialog .btn.btn-primary').click()
}, 1000 * (2 * index) + 1)
})
@musketyr
musketyr / inlineXml.groovy
Last active Aug 29, 2015
Merge XML Schemas
View inlineXml.groovy
println "Inlining schema COSDCOSD_XMLSchema-v5-0-4r.xsd"
File newOne = inlineSchema('COSDCOSD_XMLSchema-v5-0-4r.xsd')
println "Inlined schema COSDCOSD_XMLSchema-v5-0-4r.xsd to $newOne"
File inlineSchema(String schemaLocation) {
saveNodeToFile(inlineIncludes(schemaLocation), schemaLocation.replace('.xsd', '.all.xsd'))
}
Node inlineIncludes(String xsdFileName, Set<String> included = []) {
@musketyr
musketyr / mc.gdsl
Created Nov 13, 2014
Enabling DSL with for delegating script
View mc.gdsl
contributor (context(filetypes: ['mc'], scope: scriptScope())) {
delegatesTo(findClass('org.modelcatalogue.core.util.CatalogueBuilder'))
}
@musketyr
musketyr / example-invalid.xml
Last active Aug 29, 2015
Example XSD and valid XML from W3School to test MC validation
View example-invalid.xml
<?xml version="1.0" encoding="UTF-8"?>
<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipito>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
@musketyr
musketyr / AbstractIntegrationSpec.groovy
Created Feb 18, 2015
how to be sure the test runs only against data from fixtures
View AbstractIntegrationSpec.groovy
abstract class AbstractIntegrationSpec extends IntegrationSpec {
@Shared
def fixtureLoader, fixtures, initCatalogueService, sessionFactory
def loadFixtures(){
String scriptLocation = "${System.getProperty('java.io.tmpdir')}mc/testdata.sql"
def sql = new Sql(sessionFactory.currentSession.connection())
View loginGreachWifi.groovy
@Grab(group='commons-codec', module='commons-codec', version='1.10')
@Grab(group='org.gebish', module='geb-core', version='0.10.0')
@Grab(group='org.seleniumhq.selenium', module='selenium-firefox-driver', version='2.45.0')
import geb.*
import org.openqa.selenium.firefox.FirefoxDriver
new Browser(driver: new FirefoxDriver()).drive("https://invitados.upm.es/dana-na/auth/url_7/welcome.cgi") {
$('input', name: 'username').value("aplicaciones.groovy@invitadosupm")
$('input', name: 'password').value("groovy2015")