From 3402ae52bdc7fc2cd1fa48f7e3571c13803a931d Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 20 Mar 2015 15:28:37 +0000 Subject: [PATCH] Add plain @EnableZuulServer sample --- noweb/pom.xml | 2 +- pom.xml | 1 + zuul/README.md | 1 + zuul/pom.xml | 83 +++++++++++++++++++ zuul/src/main/java/demo/ZuulApplication.java | 14 ++++ .../src/main/resources/application.properties | 4 + .../test/java/demo/ZuulApplicationTests.java | 30 +++++++ zuul/src/test/resources/file.txt | 14 ++++ zuul/src/test/resources/ui.properties | 3 + 9 files changed, 151 insertions(+), 1 deletion(-) create mode 100755 zuul/README.md create mode 100644 zuul/pom.xml create mode 100644 zuul/src/main/java/demo/ZuulApplication.java create mode 100644 zuul/src/main/resources/application.properties create mode 100644 zuul/src/test/java/demo/ZuulApplicationTests.java create mode 100644 zuul/src/test/resources/file.txt create mode 100644 zuul/src/test/resources/ui.properties diff --git a/noweb/pom.xml b/noweb/pom.xml index b978b13..64445e6 100644 --- a/noweb/pom.xml +++ b/noweb/pom.xml @@ -38,7 +38,7 @@ org.springframework.cloud - spring-cloud-starter + spring-cloud-starter-config org.springframework.boot diff --git a/pom.xml b/pom.xml index b14d75f..7fdde5f 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ oauth2-ribbon ribbon-eureka turbine + zuul zuul-config-discovery zuul-proxy zuul-proxy-eureka diff --git a/zuul/README.md b/zuul/README.md new file mode 100755 index 0000000..7c781b8 --- /dev/null +++ b/zuul/README.md @@ -0,0 +1 @@ +Test with zuul server only. No proxy and no eureka. diff --git a/zuul/pom.xml b/zuul/pom.xml new file mode 100644 index 0000000..0e1b3cc --- /dev/null +++ b/zuul/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-sample-zuul + 1.0.1.BUILD-SNAPSHOT + jar + + spring-cloud-sample-zuul + Demo project for Spring Cloud + + + org.springframework.boot + spring-boot-starter-parent + 1.2.1.RELEASE + + + + + UTF-8 + demo.DemoApplication + 1.7 + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 1.0.1.BUILD-SNAPSHOT + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-netflix-core + + + com.netflix.zuul + zuul-core + + + org.springframework.cloud + spring-cloud-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + maven-deploy-plugin + + true + + + + + + diff --git a/zuul/src/main/java/demo/ZuulApplication.java b/zuul/src/main/java/demo/ZuulApplication.java new file mode 100644 index 0000000..ed27844 --- /dev/null +++ b/zuul/src/main/java/demo/ZuulApplication.java @@ -0,0 +1,14 @@ +package demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.zuul.EnableZuulServer; + +@SpringBootApplication +@EnableZuulServer +public class ZuulApplication { + + public static void main(String[] args) { + SpringApplication.run(ZuulApplication.class, args); + } +} diff --git a/zuul/src/main/resources/application.properties b/zuul/src/main/resources/application.properties new file mode 100644 index 0000000..1b1354d --- /dev/null +++ b/zuul/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.application.name: zuulproxy +server.port: 9900 +zuul.routes.ui.path: /ui/** +zuul.routes.ui.url: http://localhost:8080 \ No newline at end of file diff --git a/zuul/src/test/java/demo/ZuulApplicationTests.java b/zuul/src/test/java/demo/ZuulApplicationTests.java new file mode 100644 index 0000000..4deaba5 --- /dev/null +++ b/zuul/src/test/java/demo/ZuulApplicationTests.java @@ -0,0 +1,30 @@ +package demo; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = ZuulApplication.class) +@DirtiesContext +public class ZuulApplicationTests { + + @Autowired + DiscoveryClient discoveryClient; + + @Test + public void contextLoads() { + } + + @Test + public void discoveryClientIsNoop() { + assertTrue("discoveryClient is wrong type", discoveryClient instanceof NoopDiscoveryClient); + } +} diff --git a/zuul/src/test/resources/file.txt b/zuul/src/test/resources/file.txt new file mode 100644 index 0000000..44ea73f --- /dev/null +++ b/zuul/src/test/resources/file.txt @@ -0,0 +1,14 @@ +--FOO +Content-Disposition: form-data; name="file"; filename="foo.txt" +Content-Type: text/plain + +POST this file to the proxy to test multipart file data: + +$ curl -v -H "Content-Type: multipart/form-data; boundary=FOO" --data-binary @thisfile + + +--FOO +Content-Disposition: form-data; name="name" + +Dave +--FOO-- diff --git a/zuul/src/test/resources/ui.properties b/zuul/src/test/resources/ui.properties new file mode 100644 index 0000000..04b145f --- /dev/null +++ b/zuul/src/test/resources/ui.properties @@ -0,0 +1,3 @@ +spring.application.name: ui +multipart.maxFileSize: 128KB +multipart.maxRequestSize: 128KB \ No newline at end of file