Commit Graph

202 Commits

Author SHA1 Message Date
Gary Russell
78199dca9b Avoid throws Exception where possible - Phase III 2019-03-07 17:59:53 -05:00
Artem Bilan
1d54f9663a GH-2760: use assertThatExceptionOfType in tests
Fixes https://github.com/spring-projects/spring-integration/issues/2760

* The `assertThatExceptionOfType()` is more convenient,
than `assertThatThrownBy`, so, replace all the usages accordingly
* Fix JavaDoc typo in the `AbstractScriptExecutingMessageProcessor`
* Fix Sonar smells for `throws Exception` in `AbstractScriptExecutingMessageProcessor`
hierarchy and some code polishing for them
2019-02-22 13:54:36 -05:00
Artem Bilan
221393e02f MessageHandlingException consistency
* Use `IntegrationUtils.wrapInHandlingExceptionIfNecessary()` whenever
it is possible to avoid double wrapping into the `MessageHandlingException`
* Some code polishing for affected classes `@Nullable`, streams, diamonds etc.
2019-02-22 09:43:59 -05:00
Artem Bilan
7e3b56939e Fix XSDs for actual core schema version 2019-02-21 12:43:21 -05:00
Artem Bilan
622d42c71a Migrate tests to AssertJ
Mostly thanks to IDEA's plugin: https://plugins.jetbrains.com/plugin/10345-assertions2assertj
There is still a lot of work to do when complex and composite matchers are used.

* Add `awaitility` dependency and deprecate `EventuallyMatcher` in favor
of `awaitility`
* Remove Hamcrest from dependencies and disable JUnit & Hamcrest
static imports to encourage to use only AssertJ
* Migrate JUnit assumptions in rules to AssertJ's assumptions
* Deprecate some custom matchers in favor of existing in Hamcrest
after upgrading the last to version `2.1`
* Replace `ExpectedException` rules with `assertThatThrownBy()`
* Mention `MessagePredicate` in the `testing.adoc`
2019-02-21 10:20:45 -05:00
Gary Russell
520ebbbd2c Move master to 5.2 2019-02-15 12:01:24 -05:00
Artem Bilan
a283ad60fb GH-2723: Handle unsupported XML properties
Fixes spring-projects/spring-integration#2723

Not all XML components support all the configuration properties.
For example Saxon HE doesn't support `XMLConstants.ACCESS_EXTERNAL_DTD`
and end up with an exception like:
`IllegalArgumentException: Unknown configuration property http://javax.xml.XMLConstants/property/accessExternalDTD`

* Change `XsltPayloadTransformer` to re-use `TransformerFactoryUtils`
from spring-ws as a centralized source of `TransformerFactory`
configuration.
* Wrap `XMLConstants.ACCESS_EXTERNAL_STYLESHEET` to the `try..catch`
and log INFO about not supported property

**Cherry-pick to 5.0.x & 4.3.x**
2019-01-29 12:27:05 -05:00
Artem Bilan
eed16f02ca Fix BeanFactory propagation for MMInvokerHelper (#2694)
* Fix BeanFactory propagation for MMInvokerHelper

* Remove check for `null` in the
`MessagingMethodInvokerHelper.isProvidedMessageHandlerFactoryBean()`
* Fix `RecipientListRouter` for `BeanFactory` propagation to the
`Recipient.selector`
* Fix tests for `BeanFactory` population and propagation
* Add `errorChannel` into the `TestUtils.createTestApplicationContext()`
* Fix some Sonar smell, including new reported

* * Restore NPE check for the `BeanFactory` in the
`MessagingMethodInvokerHelper` to avoid breaking changes in the current
point release
* Some other polishing and optimizations in the
`MessagingMethodInvokerHelper`
2019-01-15 15:16:33 -05:00
Artem Bilan
59c69ed40d Allow XML components injection
**Cherry-pick to 5.0.x & 4.3.x**

* Polishing after rebase
* Copyright to 2019

* Rebase and update according upstream deps
2019-01-10 14:43:06 -05:00
Gary Russell
2766707547 Sonar fixes
- remaining hidden fields

* Fix copyright
2019-01-09 13:30:08 -05:00
Gary Russell
1bafe89d49 Sonar Fixes
- avoid parameter assignments
2019-01-07 11:35:58 -05:00
Gary Russell
e8df546b04 Sonar Fixes - Javadoc-only imports 2019-01-02 12:26:22 -05:00
Gary Russell
113a371f2c Remove Exception from IOS.onInit() 2018-12-22 17:25:56 -05:00
Artem Bilan
0d09bdccd4 Replace xmlunit dependecy with AssertJ methods 2018-12-21 09:10:23 -05:00
Artem Bilan
93d7c58b64 Enable ModifierOrderCheck Checkstyle rule (#2673)
* Enable ModifierOrderCheck Checkstyle rule

* Fix violations for `static` and `abstract` modifier
* Remove redundant code in the `TcpNioConnection`
* Mark `connectionFactoryName` as `@Nullable` in the `TcpConnectionSupport`
ctor and its inheritors
* Fix some smells according IDEA suggestions in the affected classes
* This should fix some Sonar smells as well

* * Fix `HeaderMapperTests`

* * Polishing `TcpConnection` code style and fix Javdocs
2018-12-20 19:19:47 -05:00
Artem Bilan
648aeb8e96 Unable ImportOrder Checkstyle rule for tests
* Fix wrong import order in tests
* Polishing for not closed application contexts
* Use diamonds
* Use proper assertion operators
* Remove redundant classes
* Improve performance in JPA tests
* Fix typos
2018-11-07 15:32:31 -05:00
Artem Bilan
674d5adfc0 INT-4114: Add missed <poller> to XSDs
JIRA: https://jira.spring.io/browse/INT-4114
2018-10-26 13:51:18 -04:00
Gary Russell
bebde260db INT-4506: Splitter: close stream and Closeables
JIRA: https://jira.spring.io/browse/INT-4506

Capture the actual splitter result in the `FunctionIterator and close it if necessary.

**cherry-pick to 5.0.x**

Add Closeable to proxy in test; remove AutoCloseable check.

Closeable extends AutoCloseable.

Fix javadocs; test for AutoCloseable instead of Closeable

Polishing - PR comments; tighten up API.

A `CloseableIterator` is now an `AutoCloseable` with an overridden
`close()`` (no exception) to avoid lint problem.

* Polishing omissions, code style and `@author`

**Cherry-pick to 5.0.x**
2018-07-25 13:16:48 -04:00
Gary Russell
549ef87a8e INT-4469: XML Unmarshaller support byte[] payloads
JIRA: https://jira.spring.io/browse/INT-4469
2018-05-16 14:35:14 -04:00
Artem Bilan
027021d6e4 Move XSDs to version 5.1
* Upgrade to Spring AMQP-2.1 and fix compatibility
2018-03-17 09:58:40 -04:00
Artem Bilan
30450c48be INT-4376: Upgage to Log4J 2 (#2321)
* INT-4376: Upgage to Log4J 2

JIRA: https://jira.spring.io/browse/INT-4376

* Deprecate Log4J 1.x components in favor of newly added
a `Log4j2LevelAdjuster` JUnit `@Rule`
* Update all the logging configuration to Log4J 2

* Polishing after testing
2018-01-11 10:59:55 -05:00
Artem Bilan
784d891fa5 Fix Checkstyle violations 2017-07-24 14:05:53 -04:00
Artem Bilan
d79e70c6df GH-2197: Rely on the Document creation for Source
Resolves https://github.com/spring-projects/spring-integration/issues/2197

Sometime we would like to avoid some XML definition features (e.g. loading of the DTD).
The `XmlValidatingMessageSelector` doesn't allow to do that easily because it doesn't
rely on the `Document` creation via `DocumentBuilderFactory`, but directly
manipulates with `Source`

* Change `DefaultXmlPayloadConverter.convertToSource()` to fallback to the `convertToDocument()`
for non-Document payloads.
This way we can configure `DefaultXmlPayloadConverter` with custom `DocumentBuilderFactory` and
bypass DTD loading, for example
* Expose `xml-converter` option for the `<int-xml:validating-filter>`  component
2017-07-06 12:04:16 -04:00
Artem Bilan
f112ecbb7e INT-4269: Add Stream & Flux Support for Splitter
JIRA: https://jira.spring.io/browse/INT-4269

* Check if `outputChannel` is `ReactiveStreamsSubscribableChannel`
to let back-pressure splitting
* Build `Flux` or `Iterator` depending in the `reactive` state
* Allow to get a size of the `iterator` if it is possible,
for example `XPathMessageSplitter`

Add tests

Fix raw type and unused import

* Add JavaDocs to the `AbstractMessageSplitter#obtainSizeIfPossible()`
* Add asserts for the `sequenceSize` populataiton in the `XPathMessageSplitter`
* Document `Stream` & `Flux` support in the splitter

Minor doc polishing
2017-05-31 14:28:28 -04:00
Gary Russell
572467b1c4 INT-4260: MessagePublishingErrorHandler Orig. Msg
JIRA: https://jira.spring.io/browse/INT-4260

MPEH: Populate the `ErrorMessage.originalMessage`,
if available and not the same as the `failedMessage`.

Polishing - rename exception to `MessagingExceptionWrapper`;
 make `MPEH` a subclass of `ErrorMessagePublisher`

PR Comments

Polishing - PR Comments
2017-05-03 16:32:49 -04:00
Gary Russell
37683f1b80 INT-4219: Test Polishing
JIRA: https://jira.spring.io/browse/INT-4219

- Use `AdditionalAnswers.returnFirstArgument` instead of lambda to return first arg
- Enable CheckStyle `AvoidStaticImport` for tests
- Fix static import violations in tests
2017-03-06 11:13:39 -05:00
Artem Bilan
1e07551294 INT-1800: Add MTOM Support for WS
JIRA: https://jira.spring.io/browse/INT-1800

The Simple WebService Inbound and Outbound Gateways can operate with `WebServiceMessage`s directly.
This allows to create those messages manually and add attachments to them.
Or, on the other hand, process incoming messages with attachments manually.

For this purpose the `SimpleWebServiceOutboundGateway` is supplied with new `extractPayload` property.
Also the `UnmarshallingTransformer` can now process `MimeMessage` as payload to unmarshal it into object graph with attachments if that
2017-03-01 12:15:45 -05:00
Artem Bilan
2659baa821 Checkstyle ImportOrder for main and fixes 2017-01-23 12:58:36 -05:00
Gary Russell
67d6cd0c89 Lambdas for Remaining Modules JPA -> ZK
Polishing - PR Comments and Closeable Warnings

Eclipse emits bogus warnings with exceptions in lambdas.
Even though the lambda might run on another thread, elipse thinks it could
cause the context to not be closed.

SPR-14854: MessageChannel is now a @FunctionalInterface

* Additional Lambda polishing and some code style fixes
2016-10-28 16:06:11 -04:00
Artem Bilan
12fb590b95 Mainly Checkstyle Violation Fixes
* Upgrade to Checkstyle `7.1`
* Relax `RequireThis` rule a bit. Right now it does the effort only in case of overlapping. See https://github.com/checkstyle/checkstyle/issues/2362 for more info
* Enable some annotation rules and provide fixes for violations
* Enable `tabs indents` rule. This was the biggest fix in this PR
* Resolve `TODO` in the `MessagingMethodInvokerHelper` and fix tests to meet `IllegalStateException` now

Remain Checkstyle version `6.16.1` and reinstate `RequireThis` rule

The latest Checkstyle has a bug with local scope variables if they have the same names as property.

Revert some literals splitting

Fix some line length exceeding and code style
2016-09-22 13:23:51 -04:00
Artem Bilan
370be4853d Apply Some Java 8 Code Changes
* Make most functional interfaces as `@FunctionalInterface`
* Convert some abstract classes to `@FunctionalInterface` with `default` methods
* Apply Lambda style implementation in some places
* Remove `Function` in favor of similar in Java 8

*  Remove redundant code from `DefaultAmqpHeaderMapper` since we are already on Spring AMQP-2.0
* Add several ctors to the `ExpressionEvaluatingMessageListProcessor`
* Populate explicit `Boolean.class` `expectedType` from the `ExpressionEvaluatingReleaseStrategy`
2016-08-29 09:14:31 -04:00
Gary Russell
04a42f54be Rename Schemas to 5.0
Fix Schema Imports

spring.schemas
2016-08-18 14:40:38 -04:00
Artem Bilan
7124136091 Some Fixes and Improvements
* Fix several typos in log messages. And some test on the matter as well
* Add comment to `AbstractPersistentAcceptOnceFileListFilter.rollback()` to clarify the reason of `rollingBack` variable
* Make `RemoteFileTemplate.StreamHolder` as `static` to avoid extra internal variable to outer class instance
* Replace `MessagingException` with `AbstractInboundFileSynchronizingMessageSource` in `init()` method of some components. It isn't Messaging yet in that phase
* Fix `SubscribableRedisChannel.MessageListenerDelegate` to handle `Object` not `String`, because with the `serializer` injection there is no guaranty that incoming is always `String`
* Move `JSch.setLogger(new JschLogger());` in the `DefaultSftpSessionFactory` to `static` block. It really should be done only once
* Remove `Assert.isTrue(this.port >= 0)` from the `DefaultSftpSessionFactory`. The subsequant `initJschSession()` convert it to default `22` port
* Change in the `JschProxyFactoryBean` `UnsupportedOperationException` to `IllegalArgumentException`. Wrong enum is wrong argument. That isn't a problem of operation
* Simplify `stop()` in the `CuratorFrameworkFactoryBean` and mark it as a `this.running = false`. Otherwise it wasn't able to be restarted
* Expose `leaderEventPublisher` in the `LeaderInitiatorFactoryBean`  and fix `stop(Runnable callback)` with propagation `callback` to delegate.

Fix `SubscribableRedisChannelTests` for new `handleMessage(Object)` signature
2016-08-12 12:47:32 -04:00
Artem Bilan
f74ddc2aa6 INT-4063: Extend Types for DefXmlPayloadConverter
JIRA: https://jira.spring.io/browse/INT-4063

Since `DefaultXmlPayloadConverter` is used from many out-of-the-box components by default,
make it more flexible with the supported input types which can be converted into `Document`

Improve `xml.adoc` about this types and also fix a lot of typos there as well

Address PR comments
2016-07-22 13:38:10 -04:00
Gary Russell
90e5457260 File Cleanup - ws to xmpp 2016-06-04 12:50:39 -04:00
Gary Russell
57f96bb759 checkstyle Misc Rules
checkstyle Nesting

checkstyle GenericWhitespace

checkstyle MethodParamPad

checkstyle NoWhiteSpace

checkstyle ParenPad Script

checkstyle ParenPad
2016-04-05 17:21:29 -04:00
Gary Russell
05cc7be644 checkstyle WhiteAround
WhiteAroundCheck script
2016-04-05 13:50:11 -04:00
Gary Russell
842aded9a4 checkstyle MutableException
checkstyle EmptyBlock

checkstyle fixRightCurly Script

checkstyle EmptyStatement

checkstyle RightCurly

checkstyle TailingWhite

checkstyle NeedBraces

Fix the line separator in the `fixRightCurly.gradle`
2016-04-05 13:10:33 -04:00
Gary Russell
4ac3a79df7 checkstyle FinalClassCheck
fixes

fixModifiers after fixFinal

Revert CachingSessionFactory

Class is spied in tests.

checkstyle - Import Rules

checkstyle InterfaceIsType

checkstyle InnerTypeLast

checkstyle OneStatementPerLine

CovariantEquals
OneTopLevelClass

* Revert `'\n'` -> `System.lineSeparator()` in the Gradle scripts to meet Git `autocrlf = true` on Windows
* Fix timing issue with the `LastModifiedFileListFilterTests`, when the `age = 1` might not be enough for the file object when we have some delay before checking
2016-04-04 13:49:56 -04:00
Gary Russell
43af472c3a checkstyle HideUtilityClassConstructor
https://sonar.spring.io/issues/search#componentRoots=org.springframework.integration%3Aspring-integration|createdAt=2016-04-01T10%3A00%3A36%2B0000|sort=UPDATE_DATE|asc=false
2016-04-01 16:18:28 -04:00
Artem Bilan
2b0598291c RequireThis rule and fixThis Gradle task
* `gradlew clean check -x test --parallel --continue` - to collect reports
* `gradlew fixThis --parallel` - to fix all possible vulnerabilities. With `-Dfile.encoding=UTF-8` on Windows

Since the `RequireThisCheck` doesn't see parents for anonymous classes (e.g. `Runnable` callback), its report doesn't contains the outer class name with `this.`,
therefore we still have to fix those cases manually.
Thanks to the wrong `replacer` just with `this.` we have uncompilable code enough easy to find problems.
Not so easy to fix for good readability though...

* Upgrade to Grade 2.12
* Upgrade to SonarQube native plugin

The fix contains at about 300 files. So, will be done on merge.

Fix `fixThis.gradle` according PR comments

Apply `fixThis` and also `fixModifiers` for test classes.
 Fix some `this.` inner issues manually.
 Make code polishing for long lines after `fixThis`

Fix conflicts and vulnerabilities after the rebase
2016-03-22 20:18:27 -04:00
Artem Bilan
66cd92a6e7 INT-3964: More @EnableIntegration Documentation
JIRA: https://jira.spring.io/browse/INT-3964

Doc Polish

XSD: document classes for element implementations

Fix Redis XSD typo for CDATA
2016-03-22 10:41:07 -04:00
Artem Bilan
c2954881ad Enable RedundantModifier checkstyle, add fixer
Add `fixModifiers.gradle` to run after `check` task.

The `RedundantModifierChecker` doesn't catch all errors at once.
We need run `check -> fixModifiers` pair several times to reach `SUCCESSFUL`.

The `fixThis` has been ported from the SA, but without applying.

* Polishing for `fixModifiers.gradle`
* Fix all redundant modifier with the `fixModifiers.gradle`

NOTE: Since all these task modify files on Windows we have to run them with the `-Dfile.encoding=UTF-8`.
Otherwise they are read and write with the Windows default `cp1251` making them incompatible with Unix system.
2016-03-17 13:10:05 -04:00
Artem Bilan
ef40a939cf Add check header rule and fixHeaders task
Add "new line" in the header end

* Optimization for the `fixHeaders.gradle`
* Apply the `fixHeaders` for the affected classes
2016-03-07 15:08:51 -05:00
Gary Russell
d684dc4d0e INT-3902: XML: SmartLifecycle, Order Attributes
JIRA: https://jira.spring.io/browse/INT-3902

Polishing

Polishing - PR Comments

Introduce `RouterFactoryBean.setSendTimeout` and deprecate `setTimeout`
2016-01-07 14:08:32 -05:00
Artem Bilan
cf528c0b5d INT-3665: Remove Deprecations and Resolve Issues
https://jira.spring.io/browse/INT-3665

Fixes according Travis report

Introduce `...ExpressionString(String)` setter

Some further fixes and polishing

Address PR comments
2015-12-08 16:48:29 -05:00
Gary Russell
d16cd9748c INT-799: Remove Core Deps from s-i-test
JIRA: https://jira.spring.io/browse/INT-799

Some test classes (e.g. `TestUtils`) were duplicated in core to avoid cyclic
dependency.

Now that core messaging has been moved to spring-messaging, it is possible
to remove the dependencies on `spring-integration-core` from `spring-integration-test`.

A few minor test cases have been moved to `spring-integration-core`.

The simple polishing to the `build.gradle` and `ServiceActivatorOnMockitoMockTests`
2015-12-07 20:39:00 -05:00
Gary Russell
255247ca9a Code Polishing (Sonar)
- remove redundant modifiers
- overridable methods called from ctors

Polishing - PR Comments
2015-12-07 15:39:13 -05:00
Gary Russell
051b393ed0 Prepare Master for 4.3
Reference to 4.3

Refactor `what's new` for 4.3
2015-11-17 12:12:49 -05:00
Artem Bilan
256ff4c46f INT-3599/INT-2042: Improve XPathMessageSplitter
JIRA: https://jira.spring.io/browse/INT-2042,
https://jira.spring.io/browse/INT-3599

* Expose `outputProperties` for the `XPathMessageSplitter`
* Add `iterator` mode for the `XPathMessageSplitter`

Address PR comments

Doc Polishing
2015-05-06 15:25:35 +01:00