Cleanup and format code

This commit is contained in:
Phillip Webb
2017-03-06 16:44:31 -08:00
parent c7b46e4d1c
commit d8f827d224
649 changed files with 1922 additions and 2003 deletions

View File

@@ -167,7 +167,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void liveReloadDisabled() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.livereload.enabled", false);
this.context = initializeAndRun(Config.class, properties);
this.thrown.expect(NoSuchBeanDefinitionException.class);
@@ -202,7 +202,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void restartDisabled() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.enabled", false);
this.context = initializeAndRun(Config.class, properties);
this.thrown.expect(NoSuchBeanDefinitionException.class);
@@ -211,7 +211,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void restartWithTriggerFile() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.trigger-file", "somefile.txt");
this.context = initializeAndRun(Config.class, properties);
ClassPathFileSystemWatcher classPathWatcher = this.context
@@ -224,7 +224,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void watchingAdditionalPaths() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.additional-paths",
"src/main/java,src/test/java");
this.context = initializeAndRun(Config.class, properties);
@@ -268,7 +268,7 @@ public class LocalDevToolsAutoConfigurationTests {
private Map<String, Object> getDefaultProperties(
Map<String, Object> specifiedProperties) {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.thymeleaf.check-template-location", false);
properties.put("spring.devtools.livereload.port", this.liveReloadPort);
properties.put("server.port", 0);
@@ -307,7 +307,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Bean
public RedisTemplate<Object, Object> sessionRedisTemplate() {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<Object, Object>();
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(mock(RedisConnectionFactory.class));
return redisTemplate;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -48,7 +48,7 @@ public class ClassPathChangedEventTests {
@Test
public void getChangeSet() throws Exception {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this.source, changeSet,
false);
assertThat(event.getChangeSet()).isSameAs(changeSet);
@@ -56,7 +56,7 @@ public class ClassPathChangedEventTests {
@Test
public void getRestartRequired() throws Exception {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
ClassPathChangedEvent event;
event = new ClassPathChangedEvent(this.source, changeSet, false);
assertThat(event.isRestartRequired()).isFalse();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -103,7 +103,7 @@ public class ClassPathFileChangeListenerTests {
File file = new File("f1");
ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
Set<ChangedFile> files = new LinkedHashSet<>();
files.add(file1);
files.add(file2);
ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -67,9 +67,9 @@ public class ClassPathFileSystemWatcherTests {
@Test
public void configuredWithRestartStrategy() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
File folder = this.temp.newFolder();
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
urls.add(new URL("http://spring.io"));
urls.add(folder.toURI().toURL());
properties.put("urls", urls);
@@ -132,7 +132,7 @@ public class ClassPathFileSystemWatcherTests {
public static class Listener implements ApplicationListener<ClassPathChangedEvent> {
private List<ClassPathChangedEvent> events = new ArrayList<ClassPathChangedEvent>();
private List<ClassPathChangedEvent> events = new ArrayList<>();
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {

View File

@@ -219,7 +219,7 @@ public class FileSystemWatcherTests {
@Test
public void multipleListeners() throws Exception {
File folder = this.temp.newFolder();
final Set<ChangedFiles> listener2Changes = new LinkedHashSet<ChangedFiles>();
final Set<ChangedFiles> listener2Changes = new LinkedHashSet<>();
this.watcher.addSourceFolder(folder);
this.watcher.addListener(new FileChangeListener() {
@Override
@@ -249,7 +249,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles();
Set<ChangedFile> actual = changedFiles.getFiles();
Set<ChangedFile> expected = new HashSet<ChangedFile>();
Set<ChangedFile> expected = new HashSet<>();
expected.add(new ChangedFile(folder, modify, Type.MODIFY));
expected.add(new ChangedFile(folder, delete, Type.DELETE));
expected.add(new ChangedFile(folder, add, Type.ADD));
@@ -278,7 +278,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles();
Set<ChangedFile> actual = changedFiles.getFiles();
Set<ChangedFile> expected = new HashSet<ChangedFile>();
Set<ChangedFile> expected = new HashSet<>();
expected.add(new ChangedFile(folder, file, Type.MODIFY));
assertThat(actual).isEqualTo(expected);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -156,7 +156,7 @@ public class LiveReloadServerTests {
*/
private static class MonitoredLiveReloadServer extends LiveReloadServer {
private final List<ConnectionClosedException> closedExceptions = new ArrayList<ConnectionClosedException>();
private final List<ConnectionClosedException> closedExceptions = new ArrayList<>();
private final Object monitor = new Object();
@@ -172,7 +172,7 @@ public class LiveReloadServerTests {
public List<ConnectionClosedException> getClosedExceptions() {
synchronized (this.monitor) {
return new ArrayList<ConnectionClosedException>(this.closedExceptions);
return new ArrayList<>(this.closedExceptions);
}
}
@@ -207,7 +207,7 @@ public class LiveReloadServerTests {
private final CountDownLatch helloLatch = new CountDownLatch(2);
private final List<String> messages = new ArrayList<String>();
private final List<String> messages = new ArrayList<>();
private int pongCount;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -145,14 +145,14 @@ public class ClassPathChangeUploaderTests {
private ClassPathChangedEvent createClassPathChangedEvent(File sourceFolder)
throws IOException {
Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
Set<ChangedFile> files = new LinkedHashSet<>();
File file1 = createFile(sourceFolder, "File1");
File file2 = createFile(sourceFolder, "File2");
File file3 = createFile(sourceFolder, "File3");
files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
changeSet.add(new ChangedFiles(sourceFolder, files));
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
return event;

View File

@@ -112,7 +112,7 @@ public class RemoteClientConfigurationTests {
@Test
public void liveReloadOnClassPathChanged() throws Exception {
configure();
Set<ChangedFiles> changeSet = new HashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new HashSet<>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
this.context.publishEvent(event);
LiveReloadConfiguration configuration = this.context

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -37,7 +37,7 @@ public class MainMethodTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private static ThreadLocal<MainMethod> mainMethod = new ThreadLocal<MainMethod>();
private static ThreadLocal<MainMethod> mainMethod = new ThreadLocal<>();
private Method actualMain;

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
*/
public class MockRestarter implements TestRule {
private Map<String, Object> attributes = new HashMap<String, Object>();
private Map<String, Object> attributes = new HashMap<>();
private Restarter mock = mock(Restarter.class);

View File

@@ -214,7 +214,7 @@ public class RestartClassLoaderTests {
}
private <T> List<T> toList(Enumeration<T> enumeration) {
List<T> list = new ArrayList<T>();
List<T> list = new ArrayList<>();
if (enumeration != null) {
while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -38,7 +38,7 @@ public class DefaultSourceFolderUrlFilterTests {
private static final List<String> COMMON_POSTFIXES;
static {
List<String> postfixes = new ArrayList<String>();
List<String> postfixes = new ArrayList<>();
postfixes.add(".jar");
postfixes.add("-1.3.0.jar");
postfixes.add("-1.3.0-SNAPSHOT.jar");
@@ -105,7 +105,7 @@ public class DefaultSourceFolderUrlFilterTests {
}
private List<URL> getUrls(String name) throws MalformedURLException {
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
urls.add(new URL("file:/some/path/" + name));
urls.add(new URL("file:/some/path/" + name + "!/"));
for (String postfix : COMMON_POSTFIXES) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -73,7 +73,7 @@ public class RestartServerTests {
files.addFile("my/module-a", "ClassA.class", fileA);
files.addFile("my/module-c", "ClassB.class", fileB);
server.updateAndRestart(files);
Set<URL> expectedUrls = new LinkedHashSet<URL>(Arrays.asList(url1, url3));
Set<URL> expectedUrls = new LinkedHashSet<>(Arrays.asList(url1, url3));
assertThat(server.restartUrls).isEqualTo(expectedUrls);
assertThat(server.restartFiles).isEqualTo(files);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -43,9 +43,9 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory {
private AtomicLong seq = new AtomicLong();
private Deque<Object> responses = new ArrayDeque<Object>();
private Deque<Object> responses = new ArrayDeque<>();
private List<MockClientHttpRequest> executedRequests = new ArrayList<MockClientHttpRequest>();
private List<MockClientHttpRequest> executedRequests = new ArrayList<>();
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)

View File

@@ -345,7 +345,7 @@ public class HttpTunnelServerTests {
private int timeout;
private BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<ByteBuffer>();
private BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<>();
private ByteArrayOutputStream written = new ByteArrayOutputStream();