Introduce 'app.version' property and remove hardcoded version

This commit is contained in:
Chris Beams 2014-11-11 22:33:32 +01:00
parent 15a6d8a295
commit 9adc41e23f
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
4 changed files with 27 additions and 3 deletions

View file

@ -17,15 +17,18 @@
package io.bitsquare.app;
import io.bitsquare.btc.UserAgent;
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.mock.env.MockPropertySource;
import static io.bitsquare.app.BitsquareEnvironment.*;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.springframework.core.env.PropertySource.named;
import static org.springframework.core.env.StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME;
@ -58,4 +61,15 @@ public class BitsquareEnvironmentTests {
assertThat(env.getProperty("key.x"), equalTo("x.commandline")); // commandline value wins due to precedence
assertThat(env.getProperty("key.y"), equalTo("y.env")); // env value wins because it's the only one available
}
@Test
public void bitsquareVersionShouldBeAvailable() {
// we cannot actually test for the value because (a) it requires Gradle's
// processResources task filtering (which does not happen within IDEA) and
// (b) because we do not know the specific version to test for. Instead just
// test that the property has been made available.
Environment env = new BitsquareEnvironment(new MockPropertySource());
assertThat(env.containsProperty(APP_VERSION_KEY), is(true));
assertThat(env.getProperty(UserAgent.VERSION_KEY), equalTo(env.getProperty(APP_VERSION_KEY)));
}
}