diff --git a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java index dca2a15db3..f6926fc1f0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -77,7 +77,7 @@ public class BeanFactoryTypeConverterTests { @Test public void testEmptyCollectionConversion() { BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(); - List sourceObject = new ArrayList(); + List sourceObject = new ArrayList<>(); ArrayList convertedCollection = (ArrayList) typeConverter.convertValue(sourceObject, TypeDescriptor.forObject(sourceObject), @@ -101,7 +101,7 @@ public class BeanFactoryTypeConverterTests { @SuppressWarnings("unchecked") Collection converted = (Collection) typeConverter.convertValue(1234, TypeDescriptor.valueOf(Integer.class), - TypeDescriptor.forObject(new ArrayList(Arrays.asList(1)))); + TypeDescriptor.forObject(new ArrayList<>(Arrays.asList(1)))); assertEquals(Arrays.asList(1234), converted); } @@ -109,7 +109,7 @@ public class BeanFactoryTypeConverterTests { public void testMessageHeadersNotConverted() { BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(); typeConverter.setBeanFactory(new DefaultListableBeanFactory()); - MessageHeaders headers = new GenericMessage("foo").getHeaders(); + MessageHeaders headers = new GenericMessage<>("foo").getHeaders(); assertSame(headers, typeConverter.convertValue(headers, TypeDescriptor.valueOf(MessageHeaders.class), TypeDescriptor.valueOf(MessageHeaders.class))); } @@ -118,7 +118,7 @@ public class BeanFactoryTypeConverterTests { public void testMessageHistoryNotConverted() { BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(); typeConverter.setBeanFactory(new DefaultListableBeanFactory()); - Message message = new GenericMessage("foo"); + Message message = new GenericMessage<>("foo"); message = MessageHistory.write(message, new NamedComponent() { @Override public String getComponentName() { @@ -172,7 +172,7 @@ public class BeanFactoryTypeConverterTests { public void testMapOfMapOfCollectionIsConverted() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); DefaultConversionService conversionService = new DefaultConversionService(); - conversionService.addConverter(new Converter() { + conversionService.addConverter(new Converter() { // Must be explicit type with generics @Override public Bar convert(Foo source) { return new Bar(); @@ -189,11 +189,11 @@ public class BeanFactoryTypeConverterTests { TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.collection(Set.class, TypeDescriptor.valueOf(Bar.class)))); - Set fooSet = new HashSet(); + Set fooSet = new HashSet<>(); fooSet.add(new Foo()); Map> fooMap = new HashMap>(); fooMap.put("foo", fooSet); - foos = new HashMap>>(); + foos = new HashMap<>(); foos.put("foo", fooMap); bars = (Map>>) typeConverter.convertValue(foos, sourceType, targetType); @@ -206,7 +206,7 @@ public class BeanFactoryTypeConverterTests { ServiceActivatingHandler handler = new ServiceActivatingHandler(processor); QueueChannel replyChannel = new QueueChannel(); handler.setOutputChannel(replyChannel); - handler.handleMessage(new GenericMessage>>>(foos)); + handler.handleMessage(new GenericMessage<>(foos)); Message message = replyChannel.receive(0); assertNotNull(message); assertEquals("bar", message.getPayload()); @@ -216,7 +216,7 @@ public class BeanFactoryTypeConverterTests { public void testCollectionIsConverted() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); DefaultConversionService conversionService = new DefaultConversionService(); - conversionService.addConverter(new Converter() { + conversionService.addConverter(new Converter() { // Must be explicit type with generics @Override public Bar convert(Foo source) { return new Bar(); @@ -271,7 +271,7 @@ public class BeanFactoryTypeConverterTests { public void testEditorWithTargetFoo() { DefaultConversionService conversionService = new DefaultConversionService(); final Foo foo = new Foo(); - conversionService.addConverter(new Converter() { + conversionService.addConverter(new Converter() { // Must be explicit type with generics @Override public Foo convert(String source) { return foo; @@ -306,9 +306,9 @@ public class BeanFactoryTypeConverterTests { final AtomicInteger count = new AtomicInteger(); doAnswer(invocation -> { count.incrementAndGet(); - Thread.sleep(500); + Thread.sleep(100); concurrentlyInGetDefaultEditor.set(inGetDefaultEditor.getAndSet(true)); - Thread.sleep(500); + Thread.sleep(100); inGetDefaultEditor.set(false); return invocation.callRealMethod(); }).when(typeConverter).getDefaultEditor(UUID.class); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/util/CallerBlocksPolicyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/util/CallerBlocksPolicyTests.java index 582811688c..8785d62e33 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/util/CallerBlocksPolicyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/util/CallerBlocksPolicyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 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. @@ -35,6 +35,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; /** * @author Gary Russell * @author Artem Bilan + * * @since 3.0.3 * */ @@ -46,9 +47,9 @@ public class CallerBlocksPolicyTests { te.setCorePoolSize(1); te.setMaxPoolSize(1); te.setQueueCapacity(0); - te.setRejectedExecutionHandler(new CallerBlocksPolicy(1000)); + te.setRejectedExecutionHandler(new CallerBlocksPolicy(10)); te.initialize(); - final AtomicReference e = new AtomicReference(); + final AtomicReference e = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); Runnable task = new Runnable() { @@ -82,19 +83,15 @@ public class CallerBlocksPolicyTests { final CountDownLatch latch = new CountDownLatch(3); te.execute(() -> { try { - Runnable foo = new Runnable() { - - @Override - public void run() { - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(); - } - latch.countDown(); + Runnable foo = () -> { + try { + Thread.sleep(10); } + catch (InterruptedException e1) { + Thread.currentThread().interrupt(); + throw new RuntimeException(); + } + latch.countDown(); }; te.execute(foo); te.execute(foo); // this one will be queued