From 807d585ff13713c5d056a8dae208859dfec065ef Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Thu, 28 Feb 2013 11:19:30 -0500 Subject: [PATCH] INT-2945 - StoredProc isFunction Property Not Set For reference see: https://jira.springsource.org/browse/INT-2945 * ensure that for StoredProcedure Inbound Channel Adapter the *isFunction* property is set * add test INT-2945 - Code Review - Add Tests --- ...StoredProcPollingChannelAdapterParser.java | 2 +- .../StoredProcOutboundGatewayParserTests.java | 50 ++++++++++++++++++- ...dProcPollingChannelAdapterParserTests.java | 16 +++++- ...dProcOutboundGatewayParserFunctionTest.xml | 25 ++++++++++ ...redProcPollingChannelAdapterParserTest.xml | 2 +- 5 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcOutboundGatewayParserFunctionTest.xml diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParser.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParser.java index 715d33ef07..acabc93b57 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParser.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParser.java @@ -48,7 +48,7 @@ public class StoredProcPollingChannelAdapterParser extends AbstractPollingInboun final BeanDefinitionBuilder storedProcExecutorBuilder = StoredProcParserUtils.getStoredProcExecutorBuilder(element, parserContext); IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "return-value-required"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "function"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "is-function"); IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "skip-undeclared-results"); final ManagedMap returningResultsetMap = StoredProcParserUtils.getReturningResultsetBeanDefinitions(element, parserContext); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java index cfe9a4dfa0..6e46f78b27 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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 @@ -103,6 +103,54 @@ public class StoredProcOutboundGatewayParserTests { assertFalse(skipUndeclaredResults); } + @Test + public void testIsFunctionAttributeSet() throws Exception { + setUp("storedProcOutboundGatewayParserFunctionTest.xml", getClass()); + DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway); + Object source = accessor.getPropertyValue("handler"); + accessor = new DirectFieldAccessor(source); + source = accessor.getPropertyValue("executor"); + accessor = new DirectFieldAccessor(source); + boolean isFunction = (Boolean) accessor.getPropertyValue("isFunction"); + assertTrue(isFunction); + } + + @Test + public void testIsFunctionAttributeSetToFalse() throws Exception { + setUp("storedProcOutboundGatewayParserTest.xml", getClass()); + DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway); + Object source = accessor.getPropertyValue("handler"); + accessor = new DirectFieldAccessor(source); + source = accessor.getPropertyValue("executor"); + accessor = new DirectFieldAccessor(source); + boolean isFunction = (Boolean) accessor.getPropertyValue("isFunction"); + assertFalse(isFunction); + } + + @Test + public void testIsIgnoreColumnMetaDataSetToFalse() throws Exception { + setUp("storedProcOutboundGatewayParserTest.xml", getClass()); + DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway); + Object source = accessor.getPropertyValue("handler"); + accessor = new DirectFieldAccessor(source); + source = accessor.getPropertyValue("executor"); + accessor = new DirectFieldAccessor(source); + boolean ignoreColumnMetaData = (Boolean) accessor.getPropertyValue("ignoreColumnMetaData"); + assertFalse(ignoreColumnMetaData); + } + + @Test + public void testIsIgnoreColumnMetaDataSet() throws Exception { + setUp("storedProcOutboundGatewayParserFunctionTest.xml", getClass()); + DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway); + Object source = accessor.getPropertyValue("handler"); + accessor = new DirectFieldAccessor(source); + source = accessor.getPropertyValue("executor"); + accessor = new DirectFieldAccessor(source); + boolean ignoreColumnMetaData = (Boolean) accessor.getPropertyValue("ignoreColumnMetaData"); + assertTrue(ignoreColumnMetaData); + } + @SuppressWarnings("unchecked") @Test public void testProcedurepParametersAreSet() throws Exception { diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParserTests.java index 9bff31f868..cbb86ca393 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcPollingChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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 @@ -14,6 +14,7 @@ package org.springframework.integration.jdbc.config; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -118,6 +119,18 @@ public class StoredProcPollingChannelAdapterParserTests { assertTrue("skipUndeclaredResults was not set and should default to 'true'", skipUndeclaredResults); } + @Test + public void testIsFunctionAttributeSet() throws Exception { + setUp("storedProcPollingChannelAdapterParserTest.xml", getClass()); + DirectFieldAccessor accessor = new DirectFieldAccessor(this.pollingAdapter); + Object source = accessor.getPropertyValue("source"); + accessor = new DirectFieldAccessor(source); + source = accessor.getPropertyValue("executor"); + accessor = new DirectFieldAccessor(source); + boolean isFunction = (Boolean) accessor.getPropertyValue("isFunction"); + assertTrue(isFunction); + } + @SuppressWarnings("unchecked") @Test public void testProcedurepParametersAreSet() throws Exception { @@ -235,6 +248,7 @@ public class StoredProcPollingChannelAdapterParserTests { MessageChannel autoChannel = context.getBean("autoChannel", MessageChannel.class); SourcePollingChannelAdapter autoChannelAdapter = context.getBean("autoChannel.adapter", SourcePollingChannelAdapter.class); assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel")); + assertFalse(TestUtils.getPropertyValue(autoChannelAdapter, "source.executor.isFunction", Boolean.class)); } @After diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcOutboundGatewayParserFunctionTest.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcOutboundGatewayParserFunctionTest.xml new file mode 100644 index 0000000000..44f4c5465a --- /dev/null +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcOutboundGatewayParserFunctionTest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcPollingChannelAdapterParserTest.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcPollingChannelAdapterParserTest.xml index b7fffe2f6e..b8cab1896f 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcPollingChannelAdapterParserTest.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/storedProcPollingChannelAdapterParserTest.xml @@ -15,7 +15,7 @@ + is-function="true">