Formatting
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package demo;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +22,7 @@ public class StandaloneClientApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertNotNull(this.locator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package demo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -20,13 +21,14 @@ public class BootstrapDecryptionClientApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private ConfigClientProperties config;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ConfigServicePropertySourceLocator locator;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertEquals("http://localhost:8888", config.getUri());
|
||||
assertEquals("http://localhost:8888", this.config.getUri());
|
||||
assertNotNull(this.locator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package demo;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +22,7 @@ public class StandaloneClientApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertNotNull(this.locator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
@EnableEurekaClient
|
||||
public class ConfigServerEurekaApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigServerEurekaApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigServerEurekaApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package demo;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +22,7 @@ public class EurekaClientApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertNotNull(this.client);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
@EnableDiscoveryClient
|
||||
public class EurekaFirstApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EurekaFirstApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EurekaFirstApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,25 +17,25 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
public class HystrixApplication {
|
||||
|
||||
@Bean
|
||||
public MyService myService() {
|
||||
return new MyService();
|
||||
}
|
||||
@Bean
|
||||
public MyService myService() {
|
||||
return new MyService();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private MyService myService;
|
||||
@Autowired
|
||||
private MyService myService;
|
||||
|
||||
@RequestMapping("/")
|
||||
public String ok() {
|
||||
return myService.ok();
|
||||
}
|
||||
@RequestMapping("/")
|
||||
public String ok() {
|
||||
return this.myService.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/fail")
|
||||
public String fail() {
|
||||
return myService.fail();
|
||||
}
|
||||
@RequestMapping("/fail")
|
||||
public String fail() {
|
||||
return this.myService.fail();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(HystrixApplication.class, args);
|
||||
}
|
||||
SpringApplication.run(HystrixApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.cloud.netflix.sidecar.EnableSidecar;
|
||||
@EnableSidecar
|
||||
public class SidecarApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SidecarApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SidecarApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class RibbonClientApplication {
|
||||
|
||||
@LoadBalanced
|
||||
@Bean
|
||||
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(
|
||||
OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context) {
|
||||
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(OAuth2ProtectedResourceDetails resource,
|
||||
OAuth2ClientContext context) {
|
||||
return new OAuth2RestTemplate(resource, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ public class MyDefaultRibbonConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServerListSubsetFilter serverListFilter() {
|
||||
ServerListSubsetFilter filter = new ServerListSubsetFilter();
|
||||
public ServerListSubsetFilter<Server> serverListFilter() {
|
||||
ServerListSubsetFilter<Server> filter = new ServerListSubsetFilter<Server>();
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
||||
public static class BazServiceList extends ConfigurationBasedServerList {
|
||||
public BazServiceList(IClientConfig config) {
|
||||
super.initWithNiwsConfig(config);
|
||||
|
||||
@@ -20,15 +20,12 @@ import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
|
||||
* @author brenuart
|
||||
*/
|
||||
@ComponentScan(
|
||||
// Exclude @Configuration classes that should be included only in sub contexts created
|
||||
// by Ribbon's SpringClientFactory.
|
||||
excludeFilters={
|
||||
@ComponentScan.Filter(type=FilterType.REGEX, pattern=".*RibbonConfig")
|
||||
}
|
||||
)
|
||||
// Exclude @Configuration classes that should be included only in sub contexts created
|
||||
// by Ribbon's SpringClientFactory.
|
||||
excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*RibbonConfig") })
|
||||
|
||||
@SpringBootApplication
|
||||
@RibbonClients(defaultConfiguration=MyDefaultRibbonConfig.class)
|
||||
@RibbonClients(defaultConfiguration = MyDefaultRibbonConfig.class)
|
||||
@Configuration
|
||||
public class RibbonDefaultConfigApplication {
|
||||
|
||||
@@ -36,28 +33,26 @@ public class RibbonDefaultConfigApplication {
|
||||
private SpringClientFactory clientFactory;
|
||||
|
||||
/**
|
||||
* Throws exception if the SpringClientFactory doesn't return a balancer with a server list
|
||||
* of the expected type.
|
||||
* Throws exception if the SpringClientFactory doesn't return a balancer with a server
|
||||
* list of the expected type.
|
||||
*
|
||||
*/
|
||||
@PostConstruct
|
||||
public void test() throws Exception {
|
||||
ZoneAwareLoadBalancer<Server> lb = (ZoneAwareLoadBalancer<Server>)clientFactory.getLoadBalancer("baz");
|
||||
@PostConstruct
|
||||
public void test() throws Exception {
|
||||
@SuppressWarnings("unchecked")
|
||||
ZoneAwareLoadBalancer<Server> lb = (ZoneAwareLoadBalancer<Server>) this.clientFactory.getLoadBalancer("baz");
|
||||
|
||||
ServerList<Server> serverList= lb.getServerListImpl();
|
||||
if( !(serverList instanceof MyDefaultRibbonConfig.BazServiceList) ) {
|
||||
throw new Exception("wrong server list type");
|
||||
}
|
||||
}
|
||||
ServerList<Server> serverList = lb.getServerListImpl();
|
||||
if (!(serverList instanceof MyDefaultRibbonConfig.BazServiceList)) {
|
||||
throw new Exception("wrong server list type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplicationBuilder(RibbonDefaultConfigApplication.class).build();
|
||||
app.run(args);
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplicationBuilder(RibbonDefaultConfigApplication.class).build();
|
||||
app.run(args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,22 @@
|
||||
package demo;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = RibbonDefaultConfigApplication.class)
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest("server.port=0")
|
||||
@DirtiesContext
|
||||
public class RibbonDefaultConfigApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
SpringApplication app = new SpringApplicationBuilder(RibbonDefaultConfigApplication.class).build();
|
||||
app.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@ import org.springframework.web.client.RestTemplate;
|
||||
@EnableDiscoveryClient
|
||||
@RestController
|
||||
public class HelloClientApplication {
|
||||
|
||||
@Autowired
|
||||
RestTemplate client;
|
||||
private RestTemplate client;
|
||||
|
||||
@RequestMapping("/")
|
||||
public String hello() {
|
||||
return client.getForObject("http://simple/", String.class);
|
||||
return this.client.getForObject("http://simple/", String.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -28,14 +28,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@EnableDiscoveryClient
|
||||
@RestController
|
||||
public class SimpleApplication {
|
||||
|
||||
|
||||
@RequestMapping("/")
|
||||
public String hello() {
|
||||
return "Hello";
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(SimpleApplication.class).properties(
|
||||
"spring.config.name:simple").run(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
@EnableZuulProxy
|
||||
public class ZuulConfigDiscoveryApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(ZuulConfigDiscoveryApplication.class).web(true).run(args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(ZuulConfigDiscoveryApplication.class).web(true).run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
@EnableZuulProxy
|
||||
public class ZuulProxyEurekaApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZuulProxyEurekaApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZuulProxyEurekaApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user