Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions activemq-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,40 @@
</dependencies>

<build>
<resources>
<!-- spring.schemas is filtered so the entry for the version being
built is generated from the project version -->
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>META-INF/spring.schemas</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>META-INF/spring.schemas</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>spring-schemas-test.properties</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>spring-schemas-test.properties</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.xbean</groupId>
Expand Down
5 changes: 4 additions & 1 deletion activemq-spring/src/main/resources/META-INF/spring.schemas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
17 changes: 17 additions & 0 deletions activemq-spring/src/test/resources/spring-schemas-test.properties
Original file line number Diff line number Diff line change
@@ -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}
Loading