Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
032d5488
Commit
032d5488
authored
Jul 02, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tolerate non-existent source folders in DevTools
Closes gh-13620
parent
fddc9e9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
19 deletions
+29
-19
FileSystemWatcher.java
...gframework/boot/devtools/filewatch/FileSystemWatcher.java
+1
-2
FolderSnapshot.java
...ringframework/boot/devtools/filewatch/FolderSnapshot.java
+1
-1
FileSystemWatcherTests.java
...ework/boot/devtools/filewatch/FileSystemWatcherTests.java
+16
-13
FolderSnapshotTests.java
...ramework/boot/devtools/filewatch/FolderSnapshotTests.java
+11
-3
No files found.
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java
View file @
032d5488
...
...
@@ -125,8 +125,7 @@ public class FileSystemWatcher {
*/
public
void
addSourceFolder
(
File
folder
)
{
Assert
.
notNull
(
folder
,
"Folder must not be null"
);
Assert
.
isTrue
(
folder
.
isDirectory
(),
"Folder '"
+
folder
+
"' must exist and must"
+
" be a directory"
);
Assert
.
isTrue
(!
folder
.
isFile
(),
"Folder '"
+
folder
+
"' must not be a file"
);
synchronized
(
this
.
monitor
)
{
checkNotStarted
();
this
.
folders
.
put
(
folder
,
null
);
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java
View file @
032d5488
...
...
@@ -52,7 +52,7 @@ class FolderSnapshot {
*/
FolderSnapshot
(
File
folder
)
{
Assert
.
notNull
(
folder
,
"Folder must not be null"
);
Assert
.
isTrue
(
folder
.
isDirectory
(),
"Folder
must not be a file"
);
Assert
.
isTrue
(
!
folder
.
isFile
(),
"Folder '"
+
folder
+
"'
must not be a file"
);
this
.
folder
=
folder
;
this
.
time
=
new
Date
();
Set
<
FileSnapshot
>
files
=
new
LinkedHashSet
<>();
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/filewatch/FileSystemWatcherTests.java
View file @
032d5488
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -106,21 +106,11 @@ public class FileSystemWatcherTests {
}
@Test
public
void
sourceFolderMustExist
()
{
File
folder
=
new
File
(
"does/not/exist"
);
assertThat
(
folder
.
exists
()).
isFalse
();
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Folder '"
+
folder
+
"' must exist and must be a directory"
);
this
.
watcher
.
addSourceFolder
(
folder
);
}
@Test
public
void
sourceFolderMustBeADirectory
()
{
public
void
sourceFolderMustNotBeAFile
()
{
File
folder
=
new
File
(
"pom.xml"
);
assertThat
(
folder
.
isFile
()).
isTrue
();
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Folder 'pom.xml' must
exist and must be a directory
"
);
this
.
thrown
.
expectMessage
(
"Folder 'pom.xml' must
not be a file
"
);
this
.
watcher
.
addSourceFolder
(
new
File
(
"pom.xml"
));
}
...
...
@@ -152,6 +142,19 @@ public class FileSystemWatcherTests {
assertThat
(
changedFiles
.
getFiles
()).
contains
(
expected
);
}
@Test
public
void
createSourceFolderAndAddFile
()
throws
IOException
{
File
folder
=
new
File
(
this
.
temp
.
getRoot
(),
"does/not/exist"
);
assertThat
(
folder
.
exists
()).
isFalse
();
this
.
watcher
.
addSourceFolder
(
folder
);
this
.
watcher
.
start
();
folder
.
mkdirs
();
touch
(
new
File
(
folder
,
"text.txt"
));
this
.
watcher
.
stopAfter
(
1
);
ChangedFiles
changedFiles
=
getSingleChangedFiles
();
System
.
out
.
println
(
changedFiles
);
}
@Test
public
void
waitsForPollingInterval
()
throws
Exception
{
setupWatcher
(
10
,
1
);
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/filewatch/FolderSnapshotTests.java
View file @
032d5488
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -62,9 +62,17 @@ public class FolderSnapshotTests {
@Test
public
void
folderMustNotBeFile
()
throws
Exception
{
File
file
=
this
.
temporaryFolder
.
newFile
();
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Folder must not be a file"
);
new
FolderSnapshot
(
this
.
temporaryFolder
.
newFile
());
this
.
thrown
.
expectMessage
(
"Folder '"
+
file
+
"' must not be a file"
);
new
FolderSnapshot
(
file
);
}
@Test
public
void
folderDoesNotHaveToExist
()
throws
Exception
{
File
file
=
new
File
(
this
.
temporaryFolder
.
getRoot
(),
"does/not/exist"
);
FolderSnapshot
snapshot
=
new
FolderSnapshot
(
file
);
assertThat
(
snapshot
).
isEqualTo
(
new
FolderSnapshot
(
file
));
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment