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
ba67e162
Commit
ba67e162
authored
Dec 03, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
50920190
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
19 deletions
+25
-19
ExpressionTree.java
...figurationprocessor/fieldvalues/javac/ExpressionTree.java
+2
-1
JavaCompilerFieldValuesParser.java
...ssor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
+2
-1
AbstractFieldValuesProcessorTests.java
...cessor/fieldvalues/AbstractFieldValuesProcessorTests.java
+7
-4
JsonMarshallerTests.java
.../configurationprocessor/metadata/JsonMarshallerTests.java
+10
-9
FieldValues.java
...ork/boot/configurationsample/fieldvalues/FieldValues.java
+4
-4
No files found.
spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/ExpressionTree.java
View file @
ba67e162
...
...
@@ -34,7 +34,8 @@ class ExpressionTree extends ReflectionWrapper {
private
final
Class
<?>
newArrayTreeType
=
findClass
(
"com.sun.source.tree.NewArrayTree"
);
private
final
Method
arrayValueMethod
=
findMethod
(
this
.
newArrayTreeType
,
"getInitializers"
);
private
final
Method
arrayValueMethod
=
findMethod
(
this
.
newArrayTreeType
,
"getInitializers"
);
public
ExpressionTree
(
Object
instance
)
{
super
(
instance
);
...
...
spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
View file @
ba67e162
...
...
@@ -115,7 +115,8 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
return
defaultValue
;
}
private
Object
getValue
(
ExpressionTree
expression
,
Object
defaultValue
)
throws
Exception
{
private
Object
getValue
(
ExpressionTree
expression
,
Object
defaultValue
)
throws
Exception
{
Object
literalValue
=
expression
.
getLiteralValue
();
if
(
literalValue
!=
null
)
{
return
literalValue
;
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java
View file @
ba67e162
...
...
@@ -78,12 +78,15 @@ public abstract class AbstractFieldValuesProcessorTests {
assertThat
(
values
.
get
(
"objectNone"
),
nullValue
());
assertThat
(
values
.
get
(
"objectConst"
),
equalToObject
(
"c"
));
assertThat
(
values
.
get
(
"objectInstance"
),
nullValue
());
assertThat
(
values
.
get
(
"stringArray"
),
equalToObject
(
new
Object
[]
{
"FOO"
,
"BAR"
}));
assertThat
(
values
.
get
(
"stringArray"
),
equalToObject
(
new
Object
[]
{
"FOO"
,
"BAR"
}));
assertThat
(
values
.
get
(
"stringArrayNone"
),
nullValue
());
assertThat
(
values
.
get
(
"stringEmptyArray"
),
equalToObject
(
new
Object
[
0
]));
assertThat
(
values
.
get
(
"stringArrayConst"
),
equalToObject
(
new
Object
[]{
"OK"
,
"KO"
}));
assertThat
(
values
.
get
(
"stringArrayConstElements"
),
equalToObject
(
new
Object
[]
{
"c"
}));
assertThat
(
values
.
get
(
"integerArray"
),
equalToObject
(
new
Object
[]
{
42
,
24
}));
assertThat
(
values
.
get
(
"stringArrayConst"
),
equalToObject
(
new
Object
[]
{
"OK"
,
"KO"
}));
assertThat
(
values
.
get
(
"stringArrayConstElements"
),
equalToObject
(
new
Object
[]
{
"c"
}));
assertThat
(
values
.
get
(
"integerArray"
),
equalToObject
(
new
Object
[]
{
42
,
24
}));
assertThat
(
values
.
get
(
"unknownArray"
),
nullValue
());
}
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshallerTests.java
View file @
ba67e162
...
...
@@ -23,9 +23,7 @@ import java.io.InputStream;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
array
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
springframework
.
boot
.
configurationprocessor
.
ConfigurationMetadataMatchers
.
containsGroup
;
import
static
org
.
springframework
.
boot
.
configurationprocessor
.
ConfigurationMetadataMatchers
.
containsProperty
;
...
...
@@ -49,10 +47,10 @@ public class JsonMarshallerTests {
false
));
metadata
.
add
(
ItemMetadata
.
newProperty
(
"d"
,
null
,
null
,
null
,
null
,
null
,
true
,
false
));
metadata
.
add
(
ItemMetadata
.
newProperty
(
"e"
,
null
,
null
,
null
,
null
,
null
,
new
String
[]{
"y"
,
"n"
},
false
));
metadata
.
add
(
ItemMetadata
.
newProperty
(
"f"
,
null
,
null
,
null
,
null
,
null
,
new
Boolean
[]{
true
,
false
},
false
));
metadata
.
add
(
ItemMetadata
.
newProperty
(
"e"
,
null
,
null
,
null
,
null
,
null
,
new
String
[]
{
"y"
,
"n"
},
false
));
metadata
.
add
(
ItemMetadata
.
newProperty
(
"f"
,
null
,
null
,
null
,
null
,
null
,
new
Boolean
[]
{
true
,
false
},
false
));
metadata
.
add
(
ItemMetadata
.
newGroup
(
"d"
,
null
,
null
,
null
));
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
JsonMarshaller
marshaller
=
new
JsonMarshaller
();
...
...
@@ -61,12 +59,15 @@ public class JsonMarshallerTests {
outputStream
.
toByteArray
()));
assertThat
(
read
,
containsProperty
(
"a.b"
,
StringBuffer
.
class
).
fromSource
(
InputStream
.
class
)
.
withDescription
(
"desc"
).
withDefaultValue
(
is
(
"x"
)).
withDeprecated
());
.
withDescription
(
"desc"
).
withDefaultValue
(
is
(
"x"
))
.
withDeprecated
());
assertThat
(
read
,
containsProperty
(
"b.c.d"
));
assertThat
(
read
,
containsProperty
(
"c"
).
withDefaultValue
(
is
(
123
)));
assertThat
(
read
,
containsProperty
(
"d"
).
withDefaultValue
(
is
(
true
)));
assertThat
(
read
,
containsProperty
(
"e"
).
withDefaultValue
(
is
(
array
(
equalTo
(
"y"
),
equalTo
(
"n"
)))));
assertThat
(
read
,
containsProperty
(
"f"
).
withDefaultValue
(
is
(
array
(
equalTo
(
true
),
equalTo
(
false
)))));
assertThat
(
read
,
containsProperty
(
"e"
).
withDefaultValue
(
is
(
new
String
[]
{
"y"
,
"n"
})));
assertThat
(
read
,
containsProperty
(
"f"
).
withDefaultValue
(
is
(
new
boolean
[]
{
true
,
false
})));
assertThat
(
read
,
containsGroup
(
"d"
));
}
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.java
View file @
ba67e162
...
...
@@ -38,7 +38,7 @@ public class FieldValues {
private
static
final
Integer
INTEGER_OBJ_CONST
=
4
;
private
static
final
String
[]
STRING_ARRAY_CONST
=
new
String
[]
{
"OK"
,
"KO"
};
private
static
final
String
[]
STRING_ARRAY_CONST
=
new
String
[]
{
"OK"
,
"KO"
};
private
String
string
=
"1"
;
...
...
@@ -78,7 +78,7 @@ public class FieldValues {
private
Object
objectInstance
=
new
StringBuffer
();
private
String
[]
stringArray
=
new
String
[]
{
"FOO"
,
"BAR"
};
private
String
[]
stringArray
=
new
String
[]
{
"FOO"
,
"BAR"
};
private
String
[]
stringArrayNone
;
...
...
@@ -88,8 +88,8 @@ public class FieldValues {
private
String
[]
stringArrayConstElements
=
new
String
[]
{
STRING_CONST
};
private
Integer
[]
integerArray
=
new
Integer
[]
{
42
,
24
};
private
Integer
[]
integerArray
=
new
Integer
[]
{
42
,
24
};
private
FieldValues
[]
unknownArray
=
new
FieldValues
[]
{
new
FieldValues
()
};
private
FieldValues
[]
unknownArray
=
new
FieldValues
[]
{
new
FieldValues
()
};
}
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