diff --git a/grails-data-hibernate5/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy b/grails-data-hibernate5/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy index 0059c43fa27..d794640852d 100644 --- a/grails-data-hibernate5/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy +++ b/grails-data-hibernate5/dbmigration/src/test/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChangeLogSpec.groovy @@ -56,9 +56,18 @@ databaseChangeLog = { when: command.handle(getExecutionContext(DbmUpdateCommand)) - then: + then: 'all change-set closures executed in the documented order' + // Per-changeset Liquibase log lines (e.g. confirmation message) are + // emitted via Liquibase's LogService whose default implementation + // depends on classpath state (Slf4jLogService vs JavaLogService) and + // whose level depends on the active Logback / java.util.logging + // config. We deliberately do not assert on captured stdout/stderr + // for those messages because both legs are environment-dependent + // (e.g. they fail intermittently in the Apache Groovy joint + // validation build). The change being applied is verified by + // calledBlocks; the confirmation message is exercised by the + // changelog parser populating GroovyChange.confirmationMessage. calledBlocks == ['init', 'validate', 'change'] - output.toString().contains('confirmation message') } @@ -83,8 +92,10 @@ databaseChangeLog = { when: command.handle(getExecutionContext(DbmUpdateCommand)) - then: - output.toString().contains('warn message') + then: 'validate-with-warn closure runs and the change applies normally' + // See the explanatory comment on 'updates a database with Groovy + // Change' above - asserting on stdout for the warn message is + // unreliable across SLF4J / JUL classpath permutations. calledBlocks == ['validate', 'change'] } diff --git a/grails-data-hibernate5/dbmigration/src/test/resources/logback-test.xml b/grails-data-hibernate5/dbmigration/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..733e7454d5f --- /dev/null +++ b/grails-data-hibernate5/dbmigration/src/test/resources/logback-test.xml @@ -0,0 +1,46 @@ + + + + + + + %d{HH:mm:ss.SSS} [%t] %p %logger{39} - %m%n + + + + + + + + + + + + + + + + + + + + diff --git a/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy b/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy deleted file mode 100644 index f4b25c65a23..00000000000 --- a/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// See http://logback.qos.ch/manual/groovy.html for details on configuration -def CONSOLE_LOG_PATTERN = '%d{HH:mm:ss.SSS} [%t] %highlight(%p) %cyan(\\(%logger{39}\\)) %m%n' - -appender('STDOUT', ConsoleAppender) { - withJansi = true - encoder(PatternLayoutEncoder) { - pattern = CONSOLE_LOG_PATTERN - } -} -root(ERROR, ['STDOUT']) - -//logger("org.grails", DEBUG, ['STDOUT'], false) -logger("liquibase", DEBUG, ['STDOUT'], false) -//logger("groovy.sql", DEBUG, ['STDOUT'], false) -//logger("org.hibernate.SQL", DEBUG, ["STDOUT"], false) -logger("org.grails.datastore.gorm.GormEnhancer", INFO, ['STDOUT'], false) -logger("org.grails.plugin.datasource.TomcatJDBCPoolMBeanExporter", WARN, ['STDOUT'], false) - - -