borinquenkid commented on code in PR #16586: URL: https://github.com/apache/grails-core/pull/16586#discussion_r4262785049
########## grails-core/src/test/groovy/org/grails/spring/context/annotation/ClosureClassIgnoringComponentScanBeanDefinitionParserSpec.groovy: ########## @@ -0,0 +1,129 @@ +/* + * 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. + */ +package org.grails.spring.context.annotation + +import java.nio.charset.StandardCharsets + +import org.springframework.beans.factory.support.DefaultListableBeanFactory +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader +import org.springframework.context.annotation.ClassPathBeanDefinitionScanner +import org.springframework.core.io.ByteArrayResource +import org.springframework.core.type.filter.AssignableTypeFilter +import spock.lang.Specification + +import grails.plugins.GrailsPluginManager +import org.grails.spring.context.annotation.fixture.ScanFixtureNestedHolder +import org.grails.spring.context.annotation.fixture.ScanFixtureUnannotated + +/** + * Exercises the parser the way an application does: through a {@code <grails:component-scan>} + * element parsed by {@link XmlBeanDefinitionReader}, which resolves the Grails namespace via + * {@code META-INF/spring.handlers} to {@link GrailsContextNamespaceHandler} and from there to this parser. + */ +class ClosureClassIgnoringComponentScanBeanDefinitionParserSpec extends Specification { + + static final String FIXTURE_PACKAGE = 'org.grails.spring.context.annotation.fixture' + + static DefaultListableBeanFactory scanWith(DefaultListableBeanFactory registry) { + String xml = """\ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:grails="http://grails.org/schema/context"> + <grails:component-scan base-package="${FIXTURE_PACKAGE}"/> +</beans> +""" + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry) + // the Grails schema is not on the classpath, so parse namespace-aware without XSD validation + reader.validating = false Review Comment: Filed as #16635, with the `processResources` snippet. Once it is packaged the specs that parse `<grails:component-scan>` can validate against the schema again. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
