From 14ccd6ef5bafe58f4c6e9c13485cf5e17eca92ba Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 21 Jul 2015 18:49:15 -0400 Subject: [PATCH] INT-3767: Fix JPA Parser for `parameter-source` JIRA: https://jira.spring.io/browse/INT-3767 The `JpaInboundChannelAdapterParser` has missed to parse `parameter-source`, as well as the parser test-case has been missed. In addition fix JPA xsd for wrong type references. Conflicts: spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.xml resolved. --- .../config/xml/JpaInboundChannelAdapterParser.java | 4 +++- .../xml/JpaInboundChannelAdapterParserTests.java | 7 +++++-- .../xml/JpaInboundChannelAdapterParserTests.xml | 13 +++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java index 2896af1412..a17d594039 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.util.StringUtils; * * @author Amol Nayak * @author Gunnar Hillert + * @author Artem Bilan * @since 2.2 */ public class JpaInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser { @@ -70,6 +71,7 @@ public class JpaInboundChannelAdapterParser extends AbstractPollingInboundChanne IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, element, "flush-after-delete", "flush"); IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, element, "delete-in-batch"); IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, element, "expect-single-result"); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(jpaExecutorBuilder, element, "parameter-source"); final BeanDefinition jpaExecutorBuilderBeanDefinition = jpaExecutorBuilder.getBeanDefinition(); final String channelAdapterId = this.resolveId(element, jpaPollingChannelAdapterBuilder.getRawBeanDefinition(), parserContext); diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.java index 45eee582b7..d3b7318264 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed 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 @@ -15,6 +15,7 @@ package org.springframework.integration.jpa.config.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import org.junit.After; @@ -28,6 +29,7 @@ import org.springframework.integration.channel.AbstractMessageChannel; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.jpa.core.JpaExecutor; import org.springframework.integration.jpa.core.JpaOperations; +import org.springframework.integration.jpa.support.parametersource.ParameterSource; import org.springframework.integration.test.util.TestUtils; /** @@ -66,7 +68,8 @@ public class JpaInboundChannelAdapterParserTests { assertNotNull(jpaOperations); assertTrue(TestUtils.getPropertyValue(jpaExecutor, "expectSingleResult", Boolean.class)); - + ParameterSource parameterSource = this.context.getBean(ParameterSource.class); + assertSame(parameterSource, TestUtils.getPropertyValue(jpaExecutor, "parameterSource")); } @Test diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.xml b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.xml index dd68a9506f..a93a1996d5 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.xml +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParserTests.xml @@ -13,11 +13,16 @@ + + + + + entity-manager-factory="entityManagerFactory" + entity-class="org.springframework.integration.jpa.test.entity.StudentDomain" + expect-single-result="true" + parameter-source="jpaParameterSource" + channel="out">