Add plain @EnableZuulServer sample

This commit is contained in:
Dave Syer
2015-03-20 15:28:37 +00:00
parent c7c445ce00
commit 3402ae52bd
9 changed files with 151 additions and 1 deletions

View File

@@ -38,7 +38,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -29,6 +29,7 @@
<module>oauth2-ribbon</module>
<module>ribbon-eureka</module>
<module>turbine</module>
<module>zuul</module>
<module>zuul-config-discovery</module>
<module>zuul-proxy</module>
<module>zuul-proxy-eureka</module>

1
zuul/README.md Executable file
View File

@@ -0,0 +1 @@
Test with zuul server only. No proxy and no eureka.

83
zuul/pom.xml Normal file
View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sample-zuul</artifactId>
<version>1.0.1.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-cloud-sample-zuul</name>
<description>Demo project for Spring Cloud</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.DemoApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>1.0.1.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-core</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.zuul</groupId>
<artifactId>zuul-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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);
}
}

View File

@@ -0,0 +1,4 @@
spring.application.name: zuulproxy
server.port: 9900
zuul.routes.ui.path: /ui/**
zuul.routes.ui.url: http://localhost:8080

View File

@@ -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);
}
}

View File

@@ -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--

View File

@@ -0,0 +1,3 @@
spring.application.name: ui
multipart.maxFileSize: 128KB
multipart.maxRequestSize: 128KB