Skip to content

Commit fc78b8d

Browse files
author
graeme
committed
option to define log4j config as a string, more tests for constraints
git-svn-id: https://svn.codehaus.org/grails/trunk@5755 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent d642bcb commit fc78b8d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

scripts/Package.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,20 @@ target(generateLog4j:"Generates the Log4j config File") {
162162
def log4jConfig = config.log4j
163163
try {
164164
if(log4jConfig) {
165-
def props = log4jConfig.toProperties("log4j")
166-
log4jFile.withOutputStream { out ->
167-
props.store(out, "Grails' Log4j Configuration")
165+
if(log4jConfig instanceof ConfigObject) {
166+
def props = log4jConfig.toProperties("log4j")
167+
log4jFile.withOutputStream { out ->
168+
props.store(out, "Grails' Log4j Configuration")
169+
}
170+
}
171+
else {
172+
log4jFile.write(log4jConfig.toString())
168173
}
169174
}
170175
else {
171176
// default log4j settings
172177
createDefaultLog4J(log4jFile)
173178
}
174-
175179
}
176180
catch(Exception e) {
177181
event("StatusFinal", [ "Error creating Log4j config: " + e.message ])

test/groovy/org/codehaus/groovy/grails/validation/ConstraintsBuilderTests.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ class ConstraintsBuilderTests extends AbstractGrailsMockTests {
5454
def instance = theClass.newInstance()
5555
def validator = configureValidator(theClass, instance)
5656

57+
instance.anotherURL = "http://grails.org"
5758
def errors = validateInstance(instance, validator)
59+
assert !errors.hasErrors()
60+
61+
instance.anotherURL = "a_bad_url"
62+
errors = validateInstance(instance, validator)
63+
assert errors.hasErrors()
64+
65+
instance.anotherURL = "http://grails.org"
66+
errors = validateInstance(instance, validator)
5867

5968
assert !errors.hasErrors()
6069

@@ -65,6 +74,9 @@ class ConstraintsBuilderTests extends AbstractGrailsMockTests {
6574
instance.url = new URL("http://localhost:8080/tau_gwi_00/clif/cb/19")
6675
errors = validateInstance(instance, validator)
6776
assert !errors.hasErrors()
77+
78+
79+
6880

6981
}
7082

@@ -106,8 +118,10 @@ class Site {
106118
Long id
107119
Long version
108120
URL url
121+
String anotherURL
109122
static constraints = {
110123
url(url:true, nullable:true)
124+
anotherURL(url:true, nullable:true)
111125
}
112126
}
113127
''')

0 commit comments

Comments
 (0)