Skip to content

Instantly share code, notes, and snippets.

View musketyr's full-sized avatar
🖥️
I may be slow to respond.

Vladimir Orany musketyr

🖥️
I may be slow to respond.
View GitHub Profile
@musketyr
musketyr / gist:8863308
Created February 7, 2014 14:12
Rewritten parametrized JUnit test to Spock
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
import java.util.regex.Pattern
/**
* @author musketyr
*/
class EmailValidatorSpec extends Specification {
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;
# 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
<?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>
@musketyr
musketyr / inlineXml.groovy
Last active August 29, 2015 14:06
Merge XML Schemas
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 = []) {
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 / mc.gdsl
Created November 13, 2014 07:20
Enabling DSL with for delegating script
contributor (context(filetypes: ['mc'], scope: scriptScope())) {
delegatesTo(findClass('org.modelcatalogue.core.util.CatalogueBuilder'))
}
@musketyr
musketyr / example-invalid.xml
Last active August 29, 2015 14:13
Example XSD and valid XML from W3School to test MC validation
<?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 February 18, 2015 13:58
how to be sure the test runs only against data from fixtures
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())
@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")