Skip to content

Commit 7bee5f6

Browse files
author
eugenp
committed
rest template work for digest auth and early work on gson
1 parent 1222077 commit 7bee5f6

File tree

8 files changed

+295
-170
lines changed

8 files changed

+295
-170
lines changed

jackson/pom.xml

Lines changed: 155 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,157 @@
1-
<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">
2-
<modelVersion>4.0.0</modelVersion>
3-
<groupId>org.baeldung</groupId>
4-
<artifactId>jackson</artifactId>
5-
<version>0.1-SNAPSHOT</version>
6-
7-
<name>jackson</name>
8-
9-
<dependencies>
10-
11-
<!-- utils -->
12-
13-
<dependency>
14-
<groupId>com.google.guava</groupId>
15-
<artifactId>guava</artifactId>
16-
<version>16.0.1</version>
17-
</dependency>
18-
<dependency>
19-
<groupId>commons-io</groupId>
20-
<artifactId>commons-io</artifactId>
21-
<version>2.4</version>
22-
</dependency>
23-
24-
<dependency>
25-
<groupId>org.apache.commons</groupId>
26-
<artifactId>commons-collections4</artifactId>
27-
<version>4.0</version>
28-
</dependency>
29-
30-
<dependency>
31-
<groupId>org.apache.commons</groupId>
32-
<artifactId>commons-lang3</artifactId>
33-
<version>${commons-lang3.version}</version>
34-
</dependency>
35-
36-
<!-- web -->
37-
38-
<!-- marshalling -->
39-
40-
<dependency>
41-
<groupId>com.fasterxml.jackson.core</groupId>
42-
<artifactId>jackson-databind</artifactId>
43-
<version>${jackson.version}</version>
44-
</dependency>
45-
46-
<!-- test scoped -->
47-
48-
<dependency>
49-
<groupId>junit</groupId>
50-
<artifactId>junit-dep</artifactId>
51-
<version>${junit.version}</version>
52-
<scope>test</scope>
53-
</dependency>
54-
55-
<dependency>
56-
<groupId>org.hamcrest</groupId>
57-
<artifactId>hamcrest-core</artifactId>
58-
<version>${org.hamcrest.version}</version>
59-
<scope>test</scope>
60-
</dependency>
61-
<dependency>
62-
<groupId>org.hamcrest</groupId>
63-
<artifactId>hamcrest-library</artifactId>
64-
<version>${org.hamcrest.version}</version>
65-
<scope>test</scope>
66-
</dependency>
67-
68-
<dependency>
69-
<groupId>org.mockito</groupId>
70-
<artifactId>mockito-core</artifactId>
71-
<version>${mockito.version}</version>
72-
<scope>test</scope>
73-
</dependency>
74-
75-
</dependencies>
76-
77-
<build>
78-
<finalName>jackson</finalName>
79-
<resources>
80-
<resource>
81-
<directory>src/main/resources</directory>
82-
<filtering>true</filtering>
83-
</resource>
84-
</resources>
85-
86-
<plugins>
87-
88-
<plugin>
89-
<groupId>org.apache.maven.plugins</groupId>
90-
<artifactId>maven-compiler-plugin</artifactId>
91-
<version>${maven-compiler-plugin.version}</version>
92-
<configuration>
93-
<source>1.7</source>
94-
<target>1.7</target>
95-
</configuration>
96-
</plugin>
97-
98-
<plugin>
99-
<groupId>org.apache.maven.plugins</groupId>
100-
<artifactId>maven-surefire-plugin</artifactId>
101-
<version>${maven-surefire-plugin.version}</version>
102-
</plugin>
103-
104-
</plugins>
105-
106-
</build>
107-
108-
<properties>
109-
<!-- Spring -->
110-
<org.springframework.version>4.0.6.RELEASE</org.springframework.version>
111-
<org.springframework.security.version>3.2.4.RELEASE</org.springframework.security.version>
112-
113-
<!-- persistence -->
114-
<hibernate.version>4.3.6.Final</hibernate.version>
115-
<mysql-connector-java.version>5.1.31</mysql-connector-java.version>
116-
117-
<!-- marshalling -->
118-
<jackson.version>2.4.1</jackson.version>
119-
120-
<!-- logging -->
121-
<org.slf4j.version>1.7.7</org.slf4j.version>
122-
<logback.version>1.1.2</logback.version>
123-
124-
<!-- various -->
125-
<hibernate-validator.version>5.1.2.Final</hibernate-validator.version>
126-
127-
<!-- util -->
128-
<guava.version>17.0</guava.version>
129-
<commons-lang3.version>3.3.2</commons-lang3.version>
130-
131-
<!-- testing -->
132-
<org.hamcrest.version>1.3</org.hamcrest.version>
133-
<junit.version>4.11</junit.version>
134-
<mockito.version>1.9.5</mockito.version>
135-
136-
<httpcore.version>4.3.2</httpcore.version>
137-
<httpclient.version>4.3.5</httpclient.version>
138-
139-
<rest-assured.version>2.3.2</rest-assured.version>
140-
141-
<!-- maven plugins -->
142-
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
143-
<maven-war-plugin.version>2.4</maven-war-plugin.version>
144-
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
145-
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
146-
<cargo-maven2-plugin.version>1.4.8</cargo-maven2-plugin.version>
147-
148-
</properties>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.baeldung</groupId>
5+
<artifactId>jackson</artifactId>
6+
<version>0.1-SNAPSHOT</version>
7+
8+
<name>jackson</name>
9+
10+
<dependencies>
11+
12+
<!-- utils -->
13+
14+
<dependency>
15+
<groupId>com.google.guava</groupId>
16+
<artifactId>guava</artifactId>
17+
<version>17.0</version>
18+
</dependency>
19+
<dependency>
20+
<groupId>commons-io</groupId>
21+
<artifactId>commons-io</artifactId>
22+
<version>2.4</version>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.apache.commons</groupId>
27+
<artifactId>commons-collections4</artifactId>
28+
<version>4.0</version>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.apache.commons</groupId>
33+
<artifactId>commons-lang3</artifactId>
34+
<version>${commons-lang3.version}</version>
35+
</dependency>
36+
37+
<!-- web -->
38+
39+
<!-- marshalling -->
40+
41+
<dependency>
42+
<groupId>com.fasterxml.jackson.core</groupId>
43+
<artifactId>jackson-databind</artifactId>
44+
<version>${jackson.version}</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.code.gson</groupId>
49+
<artifactId>gson</artifactId>
50+
<version>2.3</version>
51+
</dependency>
52+
53+
<!-- test scoped -->
54+
55+
<dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit-dep</artifactId>
58+
<version>${junit.version}</version>
59+
<scope>test</scope>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>org.hamcrest</groupId>
64+
<artifactId>hamcrest-core</artifactId>
65+
<version>${org.hamcrest.version}</version>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.hamcrest</groupId>
70+
<artifactId>hamcrest-library</artifactId>
71+
<version>${org.hamcrest.version}</version>
72+
<scope>test</scope>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>org.mockito</groupId>
77+
<artifactId>mockito-core</artifactId>
78+
<version>${mockito.version}</version>
79+
<scope>test</scope>
80+
</dependency>
81+
82+
</dependencies>
83+
84+
<build>
85+
<finalName>jackson</finalName>
86+
<resources>
87+
<resource>
88+
<directory>src/main/resources</directory>
89+
<filtering>true</filtering>
90+
</resource>
91+
</resources>
92+
93+
<plugins>
94+
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-compiler-plugin</artifactId>
98+
<version>${maven-compiler-plugin.version}</version>
99+
<configuration>
100+
<source>1.7</source>
101+
<target>1.7</target>
102+
</configuration>
103+
</plugin>
104+
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-surefire-plugin</artifactId>
108+
<version>${maven-surefire-plugin.version}</version>
109+
</plugin>
110+
111+
</plugins>
112+
113+
</build>
114+
115+
<properties>
116+
<!-- Spring -->
117+
<org.springframework.version>4.0.6.RELEASE</org.springframework.version>
118+
<org.springframework.security.version>3.2.4.RELEASE</org.springframework.security.version>
119+
120+
<!-- persistence -->
121+
<hibernate.version>4.3.6.Final</hibernate.version>
122+
<mysql-connector-java.version>5.1.31</mysql-connector-java.version>
123+
124+
<!-- marshalling -->
125+
<jackson.version>2.4.1</jackson.version>
126+
127+
<!-- logging -->
128+
<org.slf4j.version>1.7.7</org.slf4j.version>
129+
<logback.version>1.1.2</logback.version>
130+
131+
<!-- various -->
132+
<hibernate-validator.version>5.1.2.Final</hibernate-validator.version>
133+
134+
<!-- util -->
135+
<guava.version>17.0</guava.version>
136+
<commons-lang3.version>3.3.2</commons-lang3.version>
137+
138+
<!-- testing -->
139+
<org.hamcrest.version>1.3</org.hamcrest.version>
140+
<junit.version>4.11</junit.version>
141+
<mockito.version>1.9.5</mockito.version>
142+
143+
<httpcore.version>4.3.2</httpcore.version>
144+
<httpclient.version>4.3.5</httpclient.version>
145+
146+
<rest-assured.version>2.3.2</rest-assured.version>
147+
148+
<!-- maven plugins -->
149+
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
150+
<maven-war-plugin.version>2.4</maven-war-plugin.version>
151+
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
152+
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
153+
<cargo-maven2-plugin.version>1.4.8</cargo-maven2-plugin.version>
154+
155+
</properties>
149156

150157
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.baeldung.gson;
2+
3+
public class GenericSourceClass {
4+
int intField;
5+
6+
public GenericSourceClass(final int i) {
7+
intField = i;
8+
}
9+
10+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.baeldung.gson;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import com.google.gson.Gson;
7+
import com.google.gson.reflect.TypeToken;
8+
9+
public class GsonDeserializationUnitTest {
10+
11+
private Gson gson;
12+
13+
@Before
14+
public final void before() {
15+
gson = new Gson();
16+
}
17+
18+
// tests
19+
20+
@Test
21+
public void givenUsingGson_whenDeserializingGeneric_thenCorrect() {
22+
final java.lang.reflect.Type genericSourceClassType = new TypeToken<GenericSourceClass>() {
23+
}.getType();
24+
final GenericSourceClass sourceObject = new GenericSourceClass(1);
25+
final String serializedSourceObject = gson.toJson(sourceObject, genericSourceClassType);
26+
27+
final GenericSourceClass targetObject = gson.fromJson(serializedSourceObject, genericSourceClassType);
28+
29+
System.out.println(targetObject);
30+
}
31+
32+
}

spring-security-rest-digest-auth/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<dependency>
9090
<groupId>com.fasterxml.jackson.core</groupId>
9191
<artifactId>jackson-databind</artifactId>
92-
<version>2.2.2</version>
92+
<version>${jackson.version}</version>
9393
</dependency>
9494

9595
<!-- http -->
@@ -227,13 +227,13 @@
227227
<debuglevel>source</debuglevel>
228228
</configuration>
229229
</plugin>
230-
230+
231231
<plugin>
232232
<groupId>org.apache.maven.plugins</groupId>
233233
<artifactId>maven-war-plugin</artifactId>
234234
<version>${maven-war-plugin.version}</version>
235235
</plugin>
236-
236+
237237
<plugin>
238238
<groupId>org.apache.maven.plugins</groupId>
239239
<artifactId>maven-surefire-plugin</artifactId>
@@ -290,6 +290,9 @@
290290
<org.slf4j.version>1.7.7</org.slf4j.version>
291291
<logback.version>1.1.2</logback.version> <!-- do not upgrade - see http://jira.qos.ch/browse/LOGBACK-851 -->
292292

293+
<!-- marshalling -->
294+
<jackson.version>2.4.2</jackson.version>
295+
293296
<!-- various -->
294297
<hibernate-validator.version>5.1.2.Final</hibernate-validator.version>
295298

@@ -308,7 +311,7 @@
308311
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
309312
<maven-war-plugin.version>2.4</maven-war-plugin.version>
310313
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
311-
<cargo-maven2-plugin.version>1.4.8</cargo-maven2-plugin.version>
314+
<cargo-maven2-plugin.version>1.4.9</cargo-maven2-plugin.version>
312315

313316
</properties>
314317

0 commit comments

Comments
 (0)