testing work
This commit is contained in:
		
							parent
							
								
									33fee76a32
								
							
						
					
					
						commit
						c7ce725cf6
					
				| @ -1,301 +1,307 @@ | |||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <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"> | ||||||
| 	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> | ||||||
| 	<modelVersion>4.0.0</modelVersion> |     <groupId>org.baeldung</groupId> | ||||||
| 	<groupId>org.baeldung</groupId> |     <artifactId>spring-security-rest-full</artifactId> | ||||||
| 	<artifactId>spring-security-rest-full</artifactId> |     <version>0.1-SNAPSHOT</version> | ||||||
| 	<version>0.1-SNAPSHOT</version> |  | ||||||
| 
 | 
 | ||||||
| 	<name>spring-security-rest-full</name> |     <name>spring-security-rest-full</name> | ||||||
| 	<packaging>war</packaging> |     <packaging>war</packaging> | ||||||
| 
 | 
 | ||||||
| 	<dependencies> |     <dependencies> | ||||||
| 
 | 
 | ||||||
| 		<!-- Spring Security --> |         <!-- Spring Security --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.security</groupId> |             <groupId>org.springframework.security</groupId> | ||||||
| 			<artifactId>spring-security-web</artifactId> |             <artifactId>spring-security-web</artifactId> | ||||||
| 			<version>${org.springframework.security.version}</version> |             <version>${org.springframework.security.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.security</groupId> |             <groupId>org.springframework.security</groupId> | ||||||
| 			<artifactId>spring-security-config</artifactId> |             <artifactId>spring-security-config</artifactId> | ||||||
| 			<version>${org.springframework.security.version}</version> |             <version>${org.springframework.security.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- Spring --> |         <!-- Spring --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-core</artifactId> |             <artifactId>spring-core</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-context</artifactId> |             <artifactId>spring-context</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-jdbc</artifactId> |             <artifactId>spring-jdbc</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-beans</artifactId> |             <artifactId>spring-beans</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-aop</artifactId> |             <artifactId>spring-aop</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-tx</artifactId> |             <artifactId>spring-tx</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-expression</artifactId> |             <artifactId>spring-expression</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-web</artifactId> |             <artifactId>spring-web</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-webmvc</artifactId> |             <artifactId>spring-webmvc</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- persistence --> |         <!-- persistence --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-orm</artifactId> |             <artifactId>spring-orm</artifactId> | ||||||
| 			<version>${org.springframework.version}</version> |             <version>${org.springframework.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.data</groupId> |             <groupId>org.springframework.data</groupId> | ||||||
| 			<artifactId>spring-data-jpa</artifactId> |             <artifactId>spring-data-jpa</artifactId> | ||||||
| 			<version>${spring-data-jpa.version}</version> |             <version>${spring-data-jpa.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.hibernate</groupId> |             <groupId>org.hibernate</groupId> | ||||||
| 			<artifactId>hibernate-entitymanager</artifactId> |             <artifactId>hibernate-entitymanager</artifactId> | ||||||
| 			<version>${hibernate.version}</version> |             <version>${hibernate.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.javassist</groupId> |             <groupId>org.javassist</groupId> | ||||||
| 			<artifactId>javassist</artifactId> |             <artifactId>javassist</artifactId> | ||||||
| 			<version>3.18.0-GA</version> |             <version>3.18.0-GA</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>mysql</groupId> |             <groupId>mysql</groupId> | ||||||
| 			<artifactId>mysql-connector-java</artifactId> |             <artifactId>mysql-connector-java</artifactId> | ||||||
| 			<version>${mysql-connector-java.version}</version> |             <version>${mysql-connector-java.version}</version> | ||||||
| 			<scope>runtime</scope> |             <scope>runtime</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- web --> |         <!-- web --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>javax.servlet</groupId> |             <groupId>javax.servlet</groupId> | ||||||
| 			<artifactId>javax.servlet-api</artifactId> |             <artifactId>javax.servlet-api</artifactId> | ||||||
| 			<version>3.0.1</version> |             <version>3.0.1</version> | ||||||
| 			<scope>provided</scope> |             <scope>provided</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>javax.servlet</groupId> |             <groupId>javax.servlet</groupId> | ||||||
| 			<artifactId>jstl</artifactId> |             <artifactId>jstl</artifactId> | ||||||
| 			<version>1.2</version> |             <version>1.2</version> | ||||||
| 			<scope>runtime</scope> |             <scope>runtime</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- marshalling --> |         <!-- marshalling --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>com.fasterxml.jackson.core</groupId> |             <groupId>com.fasterxml.jackson.core</groupId> | ||||||
| 			<artifactId>jackson-databind</artifactId> |             <artifactId>jackson-databind</artifactId> | ||||||
| 			<version>${jackson.version}</version> |             <version>${jackson.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- util --> |         <!-- util --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>com.google.guava</groupId> |             <groupId>com.google.guava</groupId> | ||||||
| 			<artifactId>guava</artifactId> |             <artifactId>guava</artifactId> | ||||||
| 			<version>${guava.version}</version> |             <version>${guava.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- logging --> |         <!-- logging --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.slf4j</groupId> |             <groupId>org.slf4j</groupId> | ||||||
| 			<artifactId>slf4j-api</artifactId> |             <artifactId>slf4j-api</artifactId> | ||||||
| 			<version>${org.slf4j.version}</version> |             <version>${org.slf4j.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>ch.qos.logback</groupId> |             <groupId>ch.qos.logback</groupId> | ||||||
| 			<artifactId>logback-classic</artifactId> |             <artifactId>logback-classic</artifactId> | ||||||
| 			<version>${logback.version}</version> |             <version>${logback.version}</version> | ||||||
| 			<!-- <scope>runtime</scope> --> |             <!-- <scope>runtime</scope> --> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.slf4j</groupId> |             <groupId>org.slf4j</groupId> | ||||||
| 			<artifactId>jcl-over-slf4j</artifactId> |             <artifactId>jcl-over-slf4j</artifactId> | ||||||
| 			<version>${org.slf4j.version}</version> |             <version>${org.slf4j.version}</version> | ||||||
| 			<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl --> |             <!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl --> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly --> |         <dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly --> | ||||||
| 			<groupId>org.slf4j</groupId> |             <groupId>org.slf4j</groupId> | ||||||
| 			<artifactId>log4j-over-slf4j</artifactId> |             <artifactId>log4j-over-slf4j</artifactId> | ||||||
| 			<version>${org.slf4j.version}</version> |             <version>${org.slf4j.version}</version> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- test scoped --> |         <!-- test scoped --> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>junit</groupId> |             <groupId>junit</groupId> | ||||||
| 			<artifactId>junit-dep</artifactId> |             <artifactId>junit-dep</artifactId> | ||||||
| 			<version>${junit.version}</version> |             <version>${junit.version}</version> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.hamcrest</groupId> |             <groupId>org.hamcrest</groupId> | ||||||
| 			<artifactId>hamcrest-core</artifactId> |             <artifactId>hamcrest-core</artifactId> | ||||||
| 			<version>${org.hamcrest.version}</version> |             <version>${org.hamcrest.version}</version> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.hamcrest</groupId> |             <groupId>org.hamcrest</groupId> | ||||||
| 			<artifactId>hamcrest-library</artifactId> |             <artifactId>hamcrest-library</artifactId> | ||||||
| 			<version>${org.hamcrest.version}</version> |             <version>${org.hamcrest.version}</version> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.mockito</groupId> |             <groupId>org.mockito</groupId> | ||||||
| 			<artifactId>mockito-core</artifactId> |             <artifactId>mockito-core</artifactId> | ||||||
| 			<version>${mockito.version}</version> |             <version>${mockito.version}</version> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 	</dependencies> |         <dependency> | ||||||
|  |             <groupId>com.jayway.restassured</groupId> | ||||||
|  |             <artifactId>rest-assured</artifactId> | ||||||
|  |             <version>2.1.0</version> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
| 
 | 
 | ||||||
| 	<build> |     </dependencies> | ||||||
| 		<finalName>spring-security-rest-full</finalName> |  | ||||||
| 		<resources> |  | ||||||
| 			<resource> |  | ||||||
| 				<directory>src/main/resources</directory> |  | ||||||
| 				<filtering>true</filtering> |  | ||||||
| 			</resource> |  | ||||||
| 		</resources> |  | ||||||
| 
 | 
 | ||||||
| 		<plugins> |     <build> | ||||||
|  |         <finalName>spring-security-rest-full</finalName> | ||||||
|  |         <resources> | ||||||
|  |             <resource> | ||||||
|  |                 <directory>src/main/resources</directory> | ||||||
|  |                 <filtering>true</filtering> | ||||||
|  |             </resource> | ||||||
|  |         </resources> | ||||||
| 
 | 
 | ||||||
| 			<plugin> |         <plugins> | ||||||
| 				<groupId>org.apache.maven.plugins</groupId> |  | ||||||
| 				<artifactId>maven-compiler-plugin</artifactId> |  | ||||||
| 				<version>3.1</version> |  | ||||||
| 				<configuration> |  | ||||||
| 					<source>1.7</source> |  | ||||||
| 					<target>1.7</target> |  | ||||||
| 				</configuration> |  | ||||||
| 			</plugin> |  | ||||||
| 
 | 
 | ||||||
| 			<plugin> |             <plugin> | ||||||
| 				<groupId>org.apache.maven.plugins</groupId> |                 <groupId>org.apache.maven.plugins</groupId> | ||||||
| 				<artifactId>maven-war-plugin</artifactId> |                 <artifactId>maven-compiler-plugin</artifactId> | ||||||
| 				<version>${maven-war-plugin.version}</version> |                 <version>3.1</version> | ||||||
| 			</plugin> |                 <configuration> | ||||||
|  |                     <source>1.7</source> | ||||||
|  |                     <target>1.7</target> | ||||||
|  |                 </configuration> | ||||||
|  |             </plugin> | ||||||
| 
 | 
 | ||||||
| 			<plugin> |             <plugin> | ||||||
| 				<groupId>org.apache.maven.plugins</groupId> |                 <groupId>org.apache.maven.plugins</groupId> | ||||||
| 				<artifactId>maven-surefire-plugin</artifactId> |                 <artifactId>maven-war-plugin</artifactId> | ||||||
| 				<version>${maven-surefire-plugin.version}</version> |                 <version>${maven-war-plugin.version}</version> | ||||||
| 				<configuration> |             </plugin> | ||||||
| 					<excludes> |  | ||||||
| 						<!-- <exclude>**/*ProductionTest.java</exclude> --> |  | ||||||
| 					</excludes> |  | ||||||
| 					<systemPropertyVariables> |  | ||||||
| 						<!-- <provPersistenceTarget>h2</provPersistenceTarget> --> |  | ||||||
| 					</systemPropertyVariables> |  | ||||||
| 				</configuration> |  | ||||||
| 			</plugin> |  | ||||||
| 
 | 
 | ||||||
| 			<plugin> |             <plugin> | ||||||
| 				<groupId>org.codehaus.cargo</groupId> |                 <groupId>org.apache.maven.plugins</groupId> | ||||||
| 				<artifactId>cargo-maven2-plugin</artifactId> |                 <artifactId>maven-surefire-plugin</artifactId> | ||||||
| 				<version>${cargo-maven2-plugin.version}</version> |                 <version>${maven-surefire-plugin.version}</version> | ||||||
| 				<configuration> |                 <configuration> | ||||||
| 					<wait>true</wait> |                     <excludes> | ||||||
| 					<container> |                         <!-- <exclude>**/*ProductionTest.java</exclude> --> | ||||||
| 						<containerId>jetty8x</containerId> |                     </excludes> | ||||||
| 						<type>embedded</type> |                     <systemPropertyVariables> | ||||||
| 						<systemProperties> |                         <!-- <provPersistenceTarget>h2</provPersistenceTarget> --> | ||||||
| 							<!-- <provPersistenceTarget>cargo</provPersistenceTarget> --> |                     </systemPropertyVariables> | ||||||
| 						</systemProperties> |                 </configuration> | ||||||
| 					</container> |             </plugin> | ||||||
| 					<configuration> |  | ||||||
| 						<properties> |  | ||||||
| 							<cargo.servlet.port>8082</cargo.servlet.port> |  | ||||||
| 						</properties> |  | ||||||
| 					</configuration> |  | ||||||
| 				</configuration> |  | ||||||
| 			</plugin> |  | ||||||
| 
 | 
 | ||||||
| 		</plugins> |             <plugin> | ||||||
|  |                 <groupId>org.codehaus.cargo</groupId> | ||||||
|  |                 <artifactId>cargo-maven2-plugin</artifactId> | ||||||
|  |                 <version>${cargo-maven2-plugin.version}</version> | ||||||
|  |                 <configuration> | ||||||
|  |                     <wait>true</wait> | ||||||
|  |                     <container> | ||||||
|  |                         <containerId>jetty8x</containerId> | ||||||
|  |                         <type>embedded</type> | ||||||
|  |                         <systemProperties> | ||||||
|  |                             <!-- <provPersistenceTarget>cargo</provPersistenceTarget> --> | ||||||
|  |                         </systemProperties> | ||||||
|  |                     </container> | ||||||
|  |                     <configuration> | ||||||
|  |                         <properties> | ||||||
|  |                             <cargo.servlet.port>8082</cargo.servlet.port> | ||||||
|  |                         </properties> | ||||||
|  |                     </configuration> | ||||||
|  |                 </configuration> | ||||||
|  |             </plugin> | ||||||
| 
 | 
 | ||||||
| 	</build> |         </plugins> | ||||||
| 
 | 
 | ||||||
| 	<properties> |     </build> | ||||||
| 		<!-- Spring --> |  | ||||||
| 		<org.springframework.version>4.0.0.RELEASE</org.springframework.version> |  | ||||||
| 		<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version> |  | ||||||
| 
 | 
 | ||||||
| 		<!-- persistence --> |     <properties> | ||||||
| 		<hibernate.version>4.3.0.Final</hibernate.version> |         <!-- Spring --> | ||||||
| 		<mysql-connector-java.version>5.1.27</mysql-connector-java.version> |         <org.springframework.version>4.0.0.RELEASE</org.springframework.version> | ||||||
| 		<spring-data-jpa.version>1.4.3.RELEASE</spring-data-jpa.version> |         <org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version> | ||||||
| 
 | 
 | ||||||
| 		<!-- marshalling --> |         <!-- persistence --> | ||||||
|  |         <hibernate.version>4.3.0.Final</hibernate.version> | ||||||
|  |         <mysql-connector-java.version>5.1.27</mysql-connector-java.version> | ||||||
|  |         <spring-data-jpa.version>1.4.3.RELEASE</spring-data-jpa.version> | ||||||
| 
 | 
 | ||||||
| 		<jackson.version>2.2.3</jackson.version> |         <!-- marshalling --> | ||||||
| 
 | 
 | ||||||
| 		<!-- logging --> |         <jackson.version>2.2.3</jackson.version> | ||||||
| 		<org.slf4j.version>1.7.5</org.slf4j.version> |  | ||||||
| 		<logback.version>1.0.11</logback.version> |  | ||||||
| 
 | 
 | ||||||
| 		<!-- various --> |         <!-- logging --> | ||||||
| 		<hibernate-validator.version>5.0.1.Final</hibernate-validator.version> |         <org.slf4j.version>1.7.5</org.slf4j.version> | ||||||
|  |         <logback.version>1.0.11</logback.version> | ||||||
| 
 | 
 | ||||||
| 		<!-- util --> |         <!-- various --> | ||||||
| 		<guava.version>15.0</guava.version> |         <hibernate-validator.version>5.0.1.Final</hibernate-validator.version> | ||||||
| 		<commons-lang3.version>3.1</commons-lang3.version> |  | ||||||
| 
 | 
 | ||||||
| 		<!-- testing --> |         <!-- util --> | ||||||
| 		<org.hamcrest.version>1.3</org.hamcrest.version> |         <guava.version>15.0</guava.version> | ||||||
| 		<junit.version>4.11</junit.version> |         <commons-lang3.version>3.1</commons-lang3.version> | ||||||
| 		<mockito.version>1.9.5</mockito.version> |  | ||||||
| 
 | 
 | ||||||
| 		<httpcore.version>4.3</httpcore.version> |         <!-- testing --> | ||||||
| 		<httpclient.version>4.3.1</httpclient.version> |         <org.hamcrest.version>1.3</org.hamcrest.version> | ||||||
|  |         <junit.version>4.11</junit.version> | ||||||
|  |         <mockito.version>1.9.5</mockito.version> | ||||||
| 
 | 
 | ||||||
| 		<rest-assured.version>2.1.0</rest-assured.version> |         <httpcore.version>4.3</httpcore.version> | ||||||
|  |         <httpclient.version>4.3.1</httpclient.version> | ||||||
| 
 | 
 | ||||||
| 		<!-- Maven plugins --> |         <rest-assured.version>2.1.0</rest-assured.version> | ||||||
| 		<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> |  | ||||||
| 		<maven-war-plugin.version>2.4</maven-war-plugin.version> |  | ||||||
| 		<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version> |  | ||||||
| 		<cargo-maven2-plugin.version>1.4.5</cargo-maven2-plugin.version> |  | ||||||
| 
 | 
 | ||||||
| 	</properties> |         <!-- Maven plugins --> | ||||||
|  |         <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> | ||||||
|  |         <maven-war-plugin.version>2.4</maven-war-plugin.version> | ||||||
|  |         <maven-surefire-plugin.version>2.16</maven-surefire-plugin.version> | ||||||
|  |         <cargo-maven2-plugin.version>1.4.5</cargo-maven2-plugin.version> | ||||||
|  | 
 | ||||||
|  |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -68,7 +68,6 @@ public class FooController { | |||||||
|     @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) |     @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) | ||||||
|     @ResponseBody |     @ResponseBody | ||||||
|     public List<Foo> findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { |     public List<Foo> findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { | ||||||
| 
 |  | ||||||
|         final Page<Foo> resultPage = service.findPaginated(page, size); |         final Page<Foo> resultPage = service.findPaginated(page, size); | ||||||
|         if (page > resultPage.getTotalPages()) { |         if (page > resultPage.getTotalPages()) { | ||||||
|             throw new MyResourceNotFoundException(); |             throw new MyResourceNotFoundException(); | ||||||
|  | |||||||
| @ -0,0 +1,72 @@ | |||||||
|  | package org.baeldung.common.web; | ||||||
|  | 
 | ||||||
|  | import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; | ||||||
|  | import static org.hamcrest.Matchers.is; | ||||||
|  | import static org.junit.Assert.assertFalse; | ||||||
|  | import static org.junit.Assert.assertThat; | ||||||
|  | 
 | ||||||
|  | import java.io.Serializable; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import org.junit.Test; | ||||||
|  | 
 | ||||||
|  | import com.google.common.base.Preconditions; | ||||||
|  | import com.jayway.restassured.RestAssured; | ||||||
|  | import com.jayway.restassured.response.Response; | ||||||
|  | import com.jayway.restassured.specification.RequestSpecification; | ||||||
|  | 
 | ||||||
|  | public abstract class AbstractLiveTest<T extends Serializable> { | ||||||
|  | 
 | ||||||
|  |     protected final Class<T> clazz; | ||||||
|  | 
 | ||||||
|  |     public AbstractLiveTest(final Class<T> clazzToSet) { | ||||||
|  |         super(); | ||||||
|  | 
 | ||||||
|  |         Preconditions.checkNotNull(clazzToSet); | ||||||
|  |         clazz = clazzToSet; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // tests | ||||||
|  | 
 | ||||||
|  |     // find - one | ||||||
|  | 
 | ||||||
|  |     // find - all | ||||||
|  | 
 | ||||||
|  |     // find - all - paginated | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void whenResourcesAreRetrievedPaged_then200IsReceived() { | ||||||
|  |         final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); | ||||||
|  | 
 | ||||||
|  |         assertThat(response.getStatusCode(), is(200)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { | ||||||
|  |         final Response response = givenAuth().get(getFooURL() + "?page=" + randomNumeric(5) + "&size=10"); | ||||||
|  | 
 | ||||||
|  |         assertThat(response.getStatusCode(), is(404)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { | ||||||
|  |         // restTemplate.createResource(); | ||||||
|  | 
 | ||||||
|  |         final Response response = givenAuth().get(getFooURL() + "?page=1&size=10"); | ||||||
|  | 
 | ||||||
|  |         assertFalse(response.body().as(List.class).isEmpty()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // count | ||||||
|  | 
 | ||||||
|  |     // template method | ||||||
|  | 
 | ||||||
|  |     private String getFooURL() { | ||||||
|  |         return "http://localhost:8080/spring-security-rest-full/foos"; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     protected final RequestSpecification givenAuth() { | ||||||
|  |         return RestAssured.given().auth().preemptive().basic("user1", "user1Pass"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,12 @@ | |||||||
|  | package org.baeldung.web; | ||||||
|  | 
 | ||||||
|  | import org.baeldung.common.web.AbstractLiveTest; | ||||||
|  | import org.baeldung.persistence.model.Foo; | ||||||
|  | 
 | ||||||
|  | public class FooLiveTest extends AbstractLiveTest<Foo> { | ||||||
|  | 
 | ||||||
|  |     public FooLiveTest() { | ||||||
|  |         super(Foo.class); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user