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
fc7823bc
Commit
fc7823bc
authored
Aug 19, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
baec9f50
7685d18e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
10 deletions
+53
-10
DefaultCounterService.java
...rk/boot/actuate/metrics/writer/DefaultCounterService.java
+1
-1
DefaultCounterServiceTests.java
...ot/actuate/metrics/writer/DefaultCounterServiceTests.java
+19
-9
pom.xml
spring-boot-integration-tests/pom.xml
+33
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java
View file @
fc7823bc
...
@@ -47,7 +47,7 @@ public class DefaultCounterService implements CounterService {
...
@@ -47,7 +47,7 @@ public class DefaultCounterService implements CounterService {
@Override
@Override
public
void
reset
(
String
metricName
)
{
public
void
reset
(
String
metricName
)
{
this
.
writer
.
increment
(
new
Delta
<
Long
>(
wrap
(
metricName
),
0L
));
this
.
writer
.
reset
(
wrap
(
metricName
));
}
}
private
String
wrap
(
String
metricName
)
{
private
String
wrap
(
String
metricName
)
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterServiceTests.java
View file @
fc7823bc
...
@@ -17,7 +17,10 @@
...
@@ -17,7 +17,10 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
writer
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
writer
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Captor
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
@@ -26,6 +29,7 @@ import static org.mockito.Mockito.verify;
...
@@ -26,6 +29,7 @@ import static org.mockito.Mockito.verify;
/**
/**
* Tests for {@link DefaultCounterService}.
* Tests for {@link DefaultCounterService}.
*/
*/
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
DefaultCounterServiceTests
{
public
class
DefaultCounterServiceTests
{
private
final
MetricWriter
repository
=
mock
(
MetricWriter
.
class
);
private
final
MetricWriter
repository
=
mock
(
MetricWriter
.
class
);
...
@@ -33,22 +37,28 @@ public class DefaultCounterServiceTests {
...
@@ -33,22 +37,28 @@ public class DefaultCounterServiceTests {
private
final
DefaultCounterService
service
=
new
DefaultCounterService
(
private
final
DefaultCounterService
service
=
new
DefaultCounterService
(
this
.
repository
);
this
.
repository
);
@Captor
private
ArgumentCaptor
<
Delta
<
Number
>>
captor
;
@Test
@Test
public
void
incrementPrependsCounter
()
{
public
void
incrementPrependsCounter
()
{
this
.
service
.
increment
(
"foo"
);
this
.
service
.
increment
(
"foo"
);
@SuppressWarnings
(
"rawtypes"
)
verify
(
this
.
repository
).
increment
(
this
.
captor
.
capture
());
ArgumentCaptor
<
Delta
>
captor
=
ArgumentCaptor
.
forClass
(
Delta
.
class
);
assertEquals
(
"counter.foo"
,
this
.
captor
.
getValue
().
getName
());
verify
(
this
.
repository
).
increment
(
captor
.
capture
());
assertEquals
(
1L
,
this
.
captor
.
getValue
().
getValue
());
assertEquals
(
"counter.foo"
,
captor
.
getValue
().
getName
());
}
}
@Test
@Test
public
void
decrementPrependsCounter
()
{
public
void
decrementPrependsCounter
()
{
this
.
service
.
decrement
(
"foo"
);
this
.
service
.
decrement
(
"foo"
);
@SuppressWarnings
(
"rawtypes"
)
verify
(
this
.
repository
).
increment
(
this
.
captor
.
capture
());
ArgumentCaptor
<
Delta
>
captor
=
ArgumentCaptor
.
forClass
(
Delta
.
class
);
assertEquals
(
"counter.foo"
,
this
.
captor
.
getValue
().
getName
());
verify
(
this
.
repository
).
increment
(
captor
.
capture
());
assertEquals
(-
1L
,
this
.
captor
.
getValue
().
getValue
());
assertEquals
(
"counter.foo"
,
captor
.
getValue
().
getName
());
}
assertEquals
(-
1L
,
captor
.
getValue
().
getValue
());
@Test
public
void
resetResetsCounter
()
throws
Exception
{
this
.
service
.
reset
(
"foo"
);
verify
(
this
.
repository
).
reset
(
"counter.foo"
);
}
}
}
}
spring-boot-integration-tests/pom.xml
View file @
fc7823bc
...
@@ -63,6 +63,39 @@
...
@@ -63,6 +63,39 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<executions>
<execution>
<id>
clean-samples
</id>
<phase>
clean
</phase>
<goals>
<goal>
run
</goal>
</goals>
<configuration>
<target>
<delete
includeemptydirs=
"true"
>
<fileset
dir=
"${main.basedir}/spring-boot-samples"
includes=
"**/target/"
/>
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-clean-plugin
</artifactId>
<executions>
<execution>
<id>
clean-samples
</id>
<phase>
clean
</phase>
<goals>
<goal>
clean
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</build>
</profile>
</profile>
...
...
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