Skip to content

Commit

Permalink
Merge pull request spring-projects#9544 from htynkn:feature/use-getUs…
Browse files Browse the repository at this point in the history
…ableSpace-in-DiskSpaceHealthIndicator

* pr/9544:
  Polish "Use getUsableSpace() in DiskSpaceHealthIndicator"
  Use getUsableSpace() in DiskSpaceHealthIndicator
  • Loading branch information
snicoll committed Jun 20, 2017
2 parents 3ead213 + 3f70638 commit fc57a0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DiskSpaceHealthIndicator(DiskSpaceHealthIndicatorProperties properties) {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
File path = this.properties.getPath();
long diskFreeInBytes = path.getFreeSpace();
long diskFreeInBytes = path.getUsableSpace();
if (diskFreeInBytes >= this.properties.getThreshold()) {
builder.up();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -56,7 +56,7 @@ public void setUp() throws Exception {

@Test
public void diskSpaceIsUp() throws Exception {
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES + 10);
given(this.fileMock.getUsableSpace()).willReturn(THRESHOLD_BYTES + 10);
given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10);
Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
Expand All @@ -67,7 +67,7 @@ public void diskSpaceIsUp() throws Exception {

@Test
public void diskSpaceIsDown() throws Exception {
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10);
given(this.fileMock.getUsableSpace()).willReturn(THRESHOLD_BYTES - 10);
given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10);
Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
Expand Down

0 comments on commit fc57a0e

Please sign in to comment.