use of org.springframework.core.env.Environment in project nakadi by zalando.
the class HashPartitionStrategyCrutchTest method whenAdjustPartitionIndexThenOk.
@Test
public void whenAdjustPartitionIndexThenOk() {
final Environment env = mock(Environment.class);
when(env.getProperty("nakadi.hashPartitioning.overrideOrder.p3", List.class)).thenReturn(ImmutableList.of("1", "2", "0"));
when(env.getProperty("nakadi.hashPartitioning.overrideOrder.p4", List.class)).thenReturn(ImmutableList.of("2", "0", "1", "3"));
when(env.getProperty("nakadi.hashPartitioning.overrideOrder.p5", List.class)).thenReturn(ImmutableList.of("4", "3", "0", "2", "1"));
final HashPartitionStrategyCrutch hashStrategyCrutch = new HashPartitionStrategyCrutch(env, 4);
// expect no adjustment as we haven't specified any order for 2-partitions case
assertThat(hashStrategyCrutch.adjustPartitionIndex(1, 2), equalTo(1));
// expect adjustment
assertThat(hashStrategyCrutch.adjustPartitionIndex(1, 3), equalTo(2));
// expect adjustment
assertThat(hashStrategyCrutch.adjustPartitionIndex(2, 4), equalTo(1));
// expect no adjustment as the maxPartitionNum we specified is 3,
// so our predefined order for 5-partitions should be ignored
assertThat(hashStrategyCrutch.adjustPartitionIndex(0, 5), equalTo(0));
}
use of org.springframework.core.env.Environment in project nakadi by zalando.
the class HashPartitionStrategyCrutchTest method whenPartitionIndexIsWrongThenIllegalArgumentException.
@Test(expected = IllegalArgumentException.class)
public void whenPartitionIndexIsWrongThenIllegalArgumentException() {
final Environment env = mock(Environment.class);
when(env.getProperty("nakadi.hashPartitioning.overrideOrder.p3", List.class)).thenReturn(ImmutableList.of("1", "0", "3"));
new HashPartitionStrategyCrutch(env, 4);
}
use of org.springframework.core.env.Environment in project dubion by valsamiq.
the class DubionApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(DubionApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles());
}
use of org.springframework.core.env.Environment in project ArTEMiS by ls1intum.
the class ArTEMiSApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(ArTEMiSApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles());
}
use of org.springframework.core.env.Environment in project jhipster-sample-app-cassandra by jhipster.
the class JhipsterCassandraSampleApplicationApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(JhipsterCassandraSampleApplicationApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, hostAddress, env.getProperty("server.port"), env.getActiveProfiles());
}
Aggregations