-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include a service to display the current version
- Loading branch information
Showing
8 changed files
with
154 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
buildNumber=DEV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
flights-web-service/src/main/java/flyinghigh/services/flights/web/AboutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package flyinghigh.services.flights.web; | ||
|
||
import flyinghigh.services.flights.domain.Airport; | ||
import flyinghigh.services.flights.repositories.AirportRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
@RestController | ||
public class AboutController { | ||
|
||
@RequestMapping("/about") | ||
public String displayVersionDetails() throws IOException { | ||
final Properties properties = new Properties(); | ||
properties.load(this.getClass().getResourceAsStream("/application.properties")); | ||
String version = properties.getProperty("application.version"); | ||
StringBuilder about = new StringBuilder(); | ||
about.append("FLIGHTS WEB SERVICE VERSION "); | ||
about.append(version); | ||
|
||
return about.toString(); | ||
} | ||
|
||
} |
11 changes: 2 additions & 9 deletions
11
flights-web-service/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
server.port=8090 | ||
|
||
#mongodb.host=ds039020.mongolab.com | ||
#mongodb.port=39020 | ||
#mongodb.database=flyinghigh-integration | ||
#mongodb.username=flyinghigh | ||
#mongodb.password=flyinghigh | ||
application.version=@application.version@-@build.number@ | ||
|
||
mongodb.host=localhost | ||
mongodb.port=27017 | ||
mongodb.database=flyinghigh | ||
mongodb.username= | ||
mongodb.password= | ||
|
||
-Pmongodb.host=ds039020.mongolab.com -Pmongodb.port=39020 -Pmongodb.database=flyinghigh-integration -Pmongodb.username=flyinghigh -Pmongodb.password=flyinghigh | ||
mongodb.password= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...eb-service/src/test/java/flyinghigh/services/flights/CheckingTheApplicationVersionIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package flyinghigh.services.flights; | ||
|
||
import flyinghigh.services.flights.domain.Airport; | ||
import flyinghigh.services.flights.repositories.AirportRepository; | ||
import flyinghigh.services.flights.services.DatabaseSetup; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext; | ||
import org.springframework.boot.test.IntegrationTest; | ||
import org.springframework.boot.test.SpringApplicationConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.List; | ||
|
||
import static org.fest.assertions.api.Assertions.assertThat; | ||
|
||
// | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringApplicationConfiguration(classes = FlightsApp.class) | ||
@WebAppConfiguration | ||
@IntegrationTest({"server.port=0", "management.port=0"}) | ||
public class CheckingTheApplicationVersionIT { | ||
|
||
@Autowired | ||
private EmbeddedWebApplicationContext server; | ||
|
||
@Value("${local.server.port}") | ||
private int port; | ||
|
||
private RestTemplate restTemplate = new RestTemplate(); | ||
|
||
private String baseUrl; | ||
|
||
@Before | ||
public void configureBaseUrl() { | ||
baseUrl = "http://localhost:" + port; | ||
restTemplate = new RestTemplate(); | ||
} | ||
|
||
@Test | ||
public void should_display_the_current_application_version() { | ||
String about = restTemplate.getForObject(baseUrl + "/about", String.class); | ||
assertThat(about).contains("FLIGHTS WEB SERVICE VERSION"); | ||
} | ||
|
||
} |