Merge branch '1.1.x'

This commit is contained in:
Marcin Grzejszczak
2017-09-04 12:34:52 +02:00
6 changed files with 28 additions and 18 deletions

View File

@@ -44,8 +44,8 @@ class RegexPatterns {
protected static final Pattern ANY_DATE = Pattern.compile('(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])')
protected static final Pattern ANY_DATE_TIME = Pattern.compile('([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])')
protected static final Pattern ANY_TIME = Pattern.compile('(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])')
protected static final Pattern NON_EMPTY = Pattern.compile(/.+/)
protected static final Pattern NON_BLANK = Pattern.compile(/.*(\S+|\R).*|!^\R*$/)
protected static final Pattern NON_EMPTY = Pattern.compile(/[\S\s]+/)
protected static final Pattern NON_BLANK = Pattern.compile(/^\s*\S[\S\s]*/)
protected static final Pattern ISO8601_WITH_OFFSET = Pattern.compile(/([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.\d{3})?(Z|[+-][01]\d:[0-5]\d)/)
protected static Pattern anyOf(String... values){

View File

@@ -229,20 +229,28 @@ class RegexPatternsSpec extends Specification {
expect:
shouldMatch == Pattern.compile(regexPatterns.nonBlank()).matcher(textToMatch).matches()
where:
textToMatch || shouldMatch
'Not Empty' || true
'' || false
' ' || false
textToMatch || shouldMatch
'Not Empty' || true
'' || false
' ' || false
'\nFoo\nBar\n' || true
'\r\n' || false
' \r\n\t\f' || false
}
def "should generate a regex for a non empty string [#textToMatch] that should match [#shouldMatch]"() {
expect:
shouldMatch == Pattern.compile(regexPatterns.nonEmpty()).matcher(textToMatch).matches()
where:
textToMatch || shouldMatch
'Not Empty' || true
'' || false
' ' || true
textToMatch || shouldMatch
'Not Empty' || true
'' || false
' ' || true
'\nFoo\nBar\n' || true
'\r\n' || true
' \r\n\t\f' || true
}
def "should generate a regex for an enumerated value [#textToMatch] that should match [#shouldMatch]"(){

View File

@@ -302,9 +302,11 @@ public class AetherStubDownloader implements StubDownloader {
Files.delete(file.toPath());
}
}
} catch (IOException e) {
if (log.isDebugEnabled()) {
log.debug("Failed to remove temporary file", e);
} catch (NoClassDefFoundError | IOException e) {
// Added NoClassDefFoundError cause sometimes it's visible in the builds
// this error is completely harmless
if (log.isTraceEnabled()) {
log.trace("Failed to remove temporary file", e);
}
}
}

View File

@@ -1068,8 +1068,8 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
test.contains('assertThatJson(parsedJson).field("[\'dateTime\']").matches("([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])")')
test.contains('assertThatJson(parsedJson).field("[\'time\']").matches("(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])")')
test.contains('assertThatJson(parsedJson).field("[\'iso8601WithOffset\']").matches("([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\\\.\\\\d{3})?(Z|[+-][01]\\\\d:[0-5]\\\\d)")')
test.contains('assertThatJson(parsedJson).field("[\'nonBlankString\']").matches(".*(\\\\S+|\\\\R).*|!^\\\\R*' + endOfLineRegexSymbol + '")')
test.contains('assertThatJson(parsedJson).field("[\'nonEmptyString\']").matches(".+")')
test.contains('assertThatJson(parsedJson).field("[\'nonBlankString\']").matches("^\\\\s*\\\\S[\\\\S\\\\s]*")')
test.contains('assertThatJson(parsedJson).field("[\'nonEmptyString\']").matches("[\\\\S\\\\s]+")')
test.contains('assertThatJson(parsedJson).field("[\'anyOf\']").matches("^foo' + endOfLineRegexSymbol + '|^bar' + endOfLineRegexSymbol + '")')
!test.contains('cursor')
!test.contains('REGEXP>>')

View File

@@ -2001,8 +2001,8 @@ World.'''"""
test.contains('assertThatJson(parsedJson).field("[\'dateTime\']").matches("([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])')
test.contains('assertThatJson(parsedJson).field("[\'time\']").matches("(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])")')
test.contains('assertThatJson(parsedJson).field("[\'iso8601WithOffset\']").matches("([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\\\.\\\\d{3})?(Z|[+-][01]\\\\d:[0-5]\\\\d)")')
test.contains('assertThatJson(parsedJson).field("[\'nonBlankString\']").matches(".*(\\\\S+|\\\\R).*|!^\\\\R*' + endOfLineRegExSymbol + '")')
test.contains('assertThatJson(parsedJson).field("[\'nonEmptyString\']").matches(".+")')
test.contains('assertThatJson(parsedJson).field("[\'nonBlankString\']").matches("^\\\\s*\\\\S[\\\\S\\\\s]*")')
test.contains('assertThatJson(parsedJson).field("[\'nonEmptyString\']").matches("[\\\\S\\\\s]+")')
test.contains('assertThatJson(parsedJson).field("[\'anyOf\']").matches("^foo' + endOfLineRegExSymbol + '|^bar' + endOfLineRegExSymbol + '")')
!test.contains('cursor')
!test.contains('REGEXP>>')

View File

@@ -1587,7 +1587,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}, {
"matches" : ".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"someBooleanParameter\\"\\r\\n(Content-Type: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n(true|false)\\r\\n--\\\\1.*"
}, {
"matches" : ".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"file\\"; filename=\\".+\\"\\r\\n(Content-Type: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n.+\\r\\n--\\\\1.*"
"matches" : ".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"file\\"; filename=\\"[\\\\S\\\\s]+\\"\\r\\n(Content-Type: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n[\\\\S\\\\s]+\\r\\n--\\\\1.*"
} ]
},
"response" : {