diff --git a/activemq-spring/pom.xml b/activemq-spring/pom.xml index f1b85212411..920b377610a 100644 --- a/activemq-spring/pom.xml +++ b/activemq-spring/pom.xml @@ -222,6 +222,40 @@ + + + + src/main/resources + false + + META-INF/spring.schemas + + + + src/main/resources + true + + META-INF/spring.schemas + + + + + + src/test/resources + false + + spring-schemas-test.properties + + + + src/test/resources + true + + spring-schemas-test.properties + + + org.apache.xbean diff --git a/activemq-spring/src/main/resources/META-INF/spring.schemas b/activemq-spring/src/main/resources/META-INF/spring.schemas index ee94cc85065..54b9eb3d5d8 100644 --- a/activemq-spring/src/main/resources/META-INF/spring.schemas +++ b/activemq-spring/src/main/resources/META-INF/spring.schemas @@ -24,7 +24,10 @@ http\://activemq.apache.org/schema/core/activemq-core-6.1.2.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-6.2.0.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-6.3.0.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-6.4.0.xsd=activemq.xsd -http\://activemq.apache.org/schema/core/activemq-core-6.5.0.xsd=activemq.xsd +## The entry for the version being built is generated from the project +## version by resource filtering at build time. When bumping the development +## version after a release, add the released version above as a fixed entry. +http\://activemq.apache.org/schema/core/activemq-core-${project.version}.xsd=activemq.xsd http\://camel.apache.org/schema/osgi/camel-osgi.xsd=camel-osgi.xsd http\://camel.apache.org/schema/spring/camel-spring.xsd=camel-spring.xsd diff --git a/activemq-spring/src/test/java/org/apache/activemq/spring/SpringSchemasTest.java b/activemq-spring/src/test/java/org/apache/activemq/spring/SpringSchemasTest.java new file mode 100644 index 00000000000..2b0dc375799 --- /dev/null +++ b/activemq-spring/src/test/java/org/apache/activemq/spring/SpringSchemasTest.java @@ -0,0 +1,65 @@ +/** + * 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 + * + * http://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.apache.activemq.spring; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.util.Properties; + +import org.junit.Test; + +/** + * Verifies that META-INF/spring.schemas contains a mapping for the version + * being built. The versioned entry is generated from the project version by + * resource filtering, so releases do not require a manual edit of the file. + */ +public class SpringSchemasTest { + + private static final String SCHEMA_BASE = "http://activemq.apache.org/schema/core"; + + @Test + public void testCurrentVersionIsMapped() throws Exception { + var schemas = load("/META-INF/spring.schemas"); + var version = load("/spring-schemas-test.properties").getProperty("project.version"); + + assertNotNull("project.version not resolved in test resource", version); + assertFalse("project.version was not filtered", version.contains("${")); + + assertEquals("activemq.xsd", schemas.getProperty(SCHEMA_BASE + "/activemq-core-" + version + ".xsd")); + assertEquals("activemq.xsd", schemas.getProperty(SCHEMA_BASE + "/activemq-core.xsd")); + assertEquals("activemq.xsd", schemas.getProperty(SCHEMA_BASE)); + } + + @Test + public void testNoUnresolvedPlaceholders() throws Exception { + var schemas = load("/META-INF/spring.schemas"); + for (var name : schemas.stringPropertyNames()) { + assertFalse("unresolved placeholder in schema mapping: " + name, name.contains("${")); + } + } + + private Properties load(String resource) throws Exception { + var properties = new Properties(); + try (var in = getClass().getResourceAsStream(resource)) { + assertNotNull("resource not found: " + resource, in); + properties.load(in); + } + return properties; + } +} diff --git a/activemq-spring/src/test/resources/spring-schemas-test.properties b/activemq-spring/src/test/resources/spring-schemas-test.properties new file mode 100644 index 00000000000..5452df7b587 --- /dev/null +++ b/activemq-spring/src/test/resources/spring-schemas-test.properties @@ -0,0 +1,17 @@ +# 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 +# +# http://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. + +# filtered at build time; used by SpringSchemasTest +project.version=${project.version}