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
cc2f6f4b
Commit
cc2f6f4b
authored
Mar 08, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
9bbde5b3
a83dae0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
3 deletions
+81
-3
RawConfigurationMetadata.java
.../boot/configurationmetadata/RawConfigurationMetadata.java
+9
-3
ConfigurationMetadataRepositoryJsonBuilderTests.java
...data/ConfigurationMetadataRepositoryJsonBuilderTests.java
+30
-0
JsonReaderTests.java
...framework/boot/configurationmetadata/JsonReaderTests.java
+12
-0
configuration-metadata-empty-groups.json
...sources/metadata/configuration-metadata-empty-groups.json
+30
-0
No files found.
spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/RawConfigurationMetadata.java
View file @
cc2f6f4b
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -78,11 +78,17 @@ class RawConfigurationMetadata {
ConfigurationMetadataSource
source
=
getSource
(
item
.
getSourceType
());
if
(
source
!=
null
)
{
String
groupId
=
source
.
getGroupId
();
String
dottedPrefix
=
groupId
+
"."
;
String
id
=
item
.
getId
();
if
(
id
.
startsWith
(
groupId
))
{
// match
String
name
=
id
.
substring
(
groupId
.
length
()
+
1
,
id
.
length
());
// "."
if
(
hasLength
(
groupId
)
&&
id
.
startsWith
(
dottedPrefix
))
{
String
name
=
id
.
substring
(
dottedPrefix
.
length
(),
id
.
length
());
item
.
setName
(
name
);
}
}
}
private
static
boolean
hasLength
(
String
s
)
{
return
(
s
!=
null
&&
s
.
length
()
>
0
);
}
}
spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java
View file @
cc2f6f4b
...
...
@@ -138,6 +138,22 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
}
}
@Test
public
void
emptyGroups
()
throws
IOException
{
InputStream
in
=
getInputStreamFor
(
"empty-groups"
);
try
{
ConfigurationMetadataRepository
repo
=
ConfigurationMetadataRepositoryJsonBuilder
.
create
(
in
).
build
();
validateEmptyGroup
(
repo
);
assertThat
(
repo
.
getAllGroups
()).
hasSize
(
1
);
contains
(
repo
.
getAllProperties
(),
"name"
,
"title"
);
assertThat
(
repo
.
getAllProperties
()).
hasSize
(
2
);
}
finally
{
in
.
close
();
}
}
@Test
public
void
builderInstancesAreIsolated
()
throws
IOException
{
InputStream
foo
=
getInputStreamFor
(
"foo"
);
...
...
@@ -241,6 +257,20 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
.
get
(
"target"
)).
isEqualTo
(
"java.lang.Integer"
);
}
private
void
validateEmptyGroup
(
ConfigurationMetadataRepository
repo
)
{
ConfigurationMetadataGroup
group
=
repo
.
getAllGroups
().
get
(
""
);
contains
(
group
.
getSources
(),
"org.acme.Foo"
,
"org.acme.Bar"
);
ConfigurationMetadataSource
source
=
group
.
getSources
().
get
(
"org.acme.Foo"
);
contains
(
source
.
getProperties
(),
"name"
);
assertThat
(
source
.
getProperties
()).
hasSize
(
1
);
ConfigurationMetadataSource
source2
=
group
.
getSources
()
.
get
(
"org.acme.Bar"
);
contains
(
source2
.
getProperties
(),
"title"
);
assertThat
(
source2
.
getProperties
()).
hasSize
(
1
);
validatePropertyHints
(
repo
.
getAllProperties
().
get
(
"name"
),
0
,
0
);
validatePropertyHints
(
repo
.
getAllProperties
().
get
(
"title"
),
0
,
0
);
}
private
void
validatePropertyHints
(
ConfigurationMetadataProperty
property
,
int
valueHints
,
int
valueProviders
)
{
assertThat
(
property
.
getHints
().
getValueHints
().
size
()).
isEqualTo
(
valueHints
);
...
...
spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/JsonReaderTests.java
View file @
cc2f6f4b
...
...
@@ -49,6 +49,18 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
readFor
(
"invalid"
);
}
@Test
public
void
emptyGroupName
()
throws
IOException
{
RawConfigurationMetadata
rawMetadata
=
readFor
(
"empty-groups"
);
List
<
ConfigurationMetadataItem
>
items
=
rawMetadata
.
getItems
();
assertThat
(
items
).
hasSize
(
2
);
ConfigurationMetadataItem
name
=
items
.
get
(
0
);
assertProperty
(
name
,
"name"
,
"name"
,
String
.
class
,
null
);
ConfigurationMetadataItem
dotTitle
=
items
.
get
(
1
);
assertProperty
(
dotTitle
,
"title"
,
"title"
,
String
.
class
,
null
);
}
@Test
public
void
simpleMetadata
()
throws
IOException
{
RawConfigurationMetadata
rawMetadata
=
readFor
(
"foo"
);
...
...
spring-boot-tools/spring-boot-configuration-metadata/src/test/resources/metadata/configuration-metadata-empty-groups.json
0 → 100644
View file @
cc2f6f4b
{
"groups"
:
[
{
"name"
:
""
,
"type"
:
"org.acme.Foo"
,
"sourceType"
:
"org.acme.config.FooApp"
,
"sourceMethod"
:
"foo()"
,
"description"
:
"This is Foo."
},
{
"name"
:
""
,
"type"
:
"org.acme.Bar"
,
"sourceType"
:
"org.acme.config.FooApp"
,
"sourceMethod"
:
"bar()"
,
"description"
:
"This is Bar."
}
],
"properties"
:
[
{
"name"
:
"name"
,
"type"
:
"java.lang.String"
,
"sourceType"
:
"org.acme.Foo"
},
{
"name"
:
"title"
,
"type"
:
"java.lang.String"
,
"sourceType"
:
"org.acme.Bar"
}
]
}
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