From fe8262f2f545b92fd35d994708b8948eb887d1d4 Mon Sep 17 00:00:00 2001 From: sameira Date: Wed, 9 Dec 2015 16:11:46 +0530 Subject: [PATCH 001/626] adding Cassandra Templates and CQL Queries tutorial code samples --- .../repository/CQLQueriesIntegrationTest.java | 115 +++++++++++++++ .../CassandraTemplateIntegrationTest.java | 138 ++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java create mode 100644 spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java new file mode 100644 index 000000000000..1835df31f955 --- /dev/null +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java @@ -0,0 +1,115 @@ +package org.baeldung.spring.data.cassandra.repository; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.Insert; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; +import org.apache.cassandra.exceptions.ConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.thrift.transport.TTransportException; +import org.baeldung.spring.data.cassandra.config.CassandraConfig; +import org.baeldung.spring.data.cassandra.model.Book; +import org.cassandraunit.utils.EmbeddedCassandraServerHelper; +import org.junit.*; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.core.cql.CqlIdentifier; +import org.springframework.data.cassandra.core.CassandraAdminOperations; +import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import static junit.framework.TestCase.assertEquals; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = CassandraConfig.class) +public class CQLQueriesIntegrationTest { + + private static final Log LOGGER = LogFactory.getLog(CQLQueriesIntegrationTest.class); + + public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; + + public static final String KEYSPACE_ACTIVATE_QUERY = "USE testKeySpace;"; + + public static final String DATA_TABLE_NAME = "book"; + + @Autowired + private CassandraAdminOperations adminTemplate; + + @Autowired + private CassandraOperations cassandraTemplate; + + @BeforeClass + public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { + EmbeddedCassandraServerHelper.startEmbeddedCassandra(); + Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); + LOGGER.info("Server Started at 127.0.0.1:9142... "); + Session session = cluster.connect(); + session.execute(KEYSPACE_CREATION_QUERY); + session.execute(KEYSPACE_ACTIVATE_QUERY); + Thread.sleep(1000); + LOGGER.info("KeySpace created and activated."); + } + + @Before + public void createTable() throws InterruptedException, TTransportException, ConfigurationException, IOException { + adminTemplate.createTable(true, CqlIdentifier.cqlId(DATA_TABLE_NAME), Book.class, new HashMap()); + } + + @Test + public void whenSavingBook_thenAvailableOnRetrieval_usingQueryBuilder() { + UUID uuid = UUIDs.timeBased(); + Insert insert = QueryBuilder.insertInto(DATA_TABLE_NAME).value("isbn", uuid).value("title", "Head First Java").value("publisher", "OReilly Media").value("tags", ImmutableSet.of("Software")); + cassandraTemplate.execute(insert); + Select select = QueryBuilder.select().from("book").limit(10); + Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + assertEquals(uuid, retrievedBook.getId()); + } + + @Test + public void whenSavingBook_thenAvailableOnRetrieval_usingCQLStatements() { + UUID uuid = UUIDs.timeBased(); + String insertCql = "insert into book (isbn, title, publisher, tags) values " + "(" + uuid + ", 'Head First Java', 'OReilly Media', {'Software'})"; + cassandraTemplate.execute(insertCql); + Select select = QueryBuilder.select().from("book").limit(10); + Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + assertEquals(uuid, retrievedBook.getId()); + } + + @Test + public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() { + UUID uuid = UUIDs.timeBased(); + String insertPreparedCql = "insert into book (isbn, title, publisher, tags) values (?, ?, ?, ?)"; + List bookList = new ArrayList<>(); + List> bookListOfList = new ArrayList<>(); + bookList.add(uuid); + bookList.add("Head First Java"); + bookList.add("OReilly Media"); + bookList.add(ImmutableSet.of("Software")); + bookList.add(bookList); + cassandraTemplate.ingest(insertPreparedCql, bookListOfList); + Select select = QueryBuilder.select().from("book").limit(10); + Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + assertEquals(uuid, retrievedBook.getId()); + } + + @After + public void dropTable() { + adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME)); + } + + @AfterClass + public static void stopCassandraEmbedded() { + EmbeddedCassandraServerHelper.cleanEmbeddedCassandra(); + } +} diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java new file mode 100644 index 000000000000..69b965f8c500 --- /dev/null +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java @@ -0,0 +1,138 @@ +package org.baeldung.spring.data.cassandra.repository; + +import static junit.framework.TestCase.assertNull; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +import org.apache.cassandra.exceptions.ConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.thrift.transport.TTransportException; +import org.baeldung.spring.data.cassandra.config.CassandraConfig; +import org.baeldung.spring.data.cassandra.model.Book; +import org.cassandraunit.utils.EmbeddedCassandraServerHelper; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.core.cql.CqlIdentifier; +import org.springframework.data.cassandra.core.CassandraAdminOperations; +import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = CassandraConfig.class) +public class CassandraTemplateIntegrationTest { + + private static final Log LOGGER = LogFactory.getLog(CassandraTemplateIntegrationTest.class); + + public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; + + public static final String KEYSPACE_ACTIVATE_QUERY = "USE testKeySpace;"; + + public static final String DATA_TABLE_NAME = "book"; + + @Autowired + private CassandraAdminOperations adminTemplate; + + @Autowired + private CassandraOperations cassandraTemplate; + + @BeforeClass + public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { + EmbeddedCassandraServerHelper.startEmbeddedCassandra(); + Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); + LOGGER.info("Server Started at 127.0.0.1:9142... "); + Session session = cluster.connect(); + session.execute(KEYSPACE_CREATION_QUERY); + session.execute(KEYSPACE_ACTIVATE_QUERY); + Thread.sleep(5000); + LOGGER.info("KeySpace created and activated."); + } + + @Before + public void createTable() throws InterruptedException, TTransportException, ConfigurationException, IOException { + adminTemplate.createTable(true, CqlIdentifier.cqlId(DATA_TABLE_NAME), Book.class, new HashMap()); + } + + @Test + public void whenSavingBook_thenAvailableOnRetrieval() { + Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + cassandraTemplate.insert(javaBook); + Select select = QueryBuilder.select().from("book").where(QueryBuilder.eq("title", "Head First Java")).and(QueryBuilder.eq("publisher", "O'Reilly Media")).limit(10); + Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + assertEquals(javaBook.getId(), retrievedBook.getId()); + } + + @Test + public void whenSavingBooks_thenAllAvailableOnRetrieval() { + Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + cassandraTemplate.insert(javaBook); + cassandraTemplate.insert(dPatternBook); + + Select select = QueryBuilder.select().from("book").limit(10); + List retrievedBooks = cassandraTemplate.select(select, Book.class); + assertThat(retrievedBooks.size(), is(2)); + assertEquals(javaBook.getId(), retrievedBooks.get(0).getId()); + assertEquals(dPatternBook.getId(), retrievedBooks.get(1).getId()); + } + + @Test + public void whenUpdatingBook_thenShouldUpdatedOnRetrieval() { + Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + cassandraTemplate.insert(javaBook); + Select select = QueryBuilder.select().from("book").limit(10); + Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + retrievedBook.setTags(ImmutableSet.of("Computer", "Software", "Java")); + cassandraTemplate.update(retrievedBook); + Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); + assertEquals(retrievedBook.getTags(), retrievedUpdatedBook.getTags()); + } + + @Test + public void whenDeletingExistingBooks_thenNotAvailableOnRetrieval() { + Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + Book insertedBook = cassandraTemplate.insert(javaBook); + cassandraTemplate.deleteAll(Book.class); + Select select = QueryBuilder.select().from("book").limit(10); + Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); + assertNull(retrievedUpdatedBook); + } + + @Test + public void whenAddingBooks_thenCountShouldBeCorrectOnRetrieval() { + Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + cassandraTemplate.insert(javaBook); + cassandraTemplate.insert(dPatternBook); + long bookCount = cassandraTemplate.count(Book.class); + assertEquals(2, bookCount); + } + + @After + public void dropTable() { + adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME)); + } + + @AfterClass + public static void stopCassandraEmbedded() { + EmbeddedCassandraServerHelper.cleanEmbeddedCassandra(); + } +} From ee5fe4a41f91a06e214fc5404577ebfd5c24a68e Mon Sep 17 00:00:00 2001 From: sameira Date: Wed, 9 Dec 2015 16:20:30 +0530 Subject: [PATCH 002/626] Adding test cases for Cassandra Templates and CQL Queries --- .../repository/CQLQueriesIntegrationTest.java | 4 +- .../CassandraTemplateIntegrationTest.java | 37 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java index 1835df31f955..fd60b9a7f910 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java @@ -57,7 +57,7 @@ public static void startCassandraEmbedded() throws InterruptedException, TTransp Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); - Thread.sleep(1000); + Thread.sleep(2000); LOGGER.info("KeySpace created and activated."); } @@ -96,7 +96,7 @@ public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() { bookList.add("Head First Java"); bookList.add("OReilly Media"); bookList.add(ImmutableSet.of("Software")); - bookList.add(bookList); + bookListOfList.add(bookList); cassandraTemplate.ingest(insertPreparedCql, bookListOfList); Select select = QueryBuilder.select().from("book").limit(10); Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java index 69b965f8c500..fae24e8f21ae 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java @@ -1,14 +1,11 @@ package org.baeldung.spring.data.cassandra.repository; -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; - +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -16,11 +13,7 @@ import org.baeldung.spring.data.cassandra.config.CassandraConfig; import org.baeldung.spring.data.cassandra.model.Book; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cassandra.core.cql.CqlIdentifier; @@ -29,12 +22,14 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; -import com.datastax.driver.core.utils.UUIDs; -import com.google.common.collect.ImmutableSet; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +import static junit.framework.TestCase.assertNull; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) @@ -62,7 +57,7 @@ public static void startCassandraEmbedded() throws InterruptedException, TTransp Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); - Thread.sleep(5000); + Thread.sleep(2000); LOGGER.info("KeySpace created and activated."); } From 53ea3c63f06dc804aa23fecce28b52e85ed61bbc Mon Sep 17 00:00:00 2001 From: sameira Date: Wed, 9 Dec 2015 17:15:15 +0530 Subject: [PATCH 003/626] Updated data insertion using an array list --- .../repository/CassandraTemplateIntegrationTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java index fae24e8f21ae..3108658c0e02 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java @@ -23,6 +23,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -79,8 +80,10 @@ public void whenSavingBook_thenAvailableOnRetrieval() { public void whenSavingBooks_thenAllAvailableOnRetrieval() { Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - cassandraTemplate.insert(javaBook); - cassandraTemplate.insert(dPatternBook); + List bookList = new ArrayList<>(); + bookList.add(javaBook); + bookList.add(dPatternBook); + cassandraTemplate.insert(bookList); Select select = QueryBuilder.select().from("book").limit(10); List retrievedBooks = cassandraTemplate.select(select, Book.class); From 0c8f855ff76c2445e80af0fa1eb19c1214ed5637 Mon Sep 17 00:00:00 2001 From: gmaipady Date: Wed, 9 Dec 2015 17:42:35 +0530 Subject: [PATCH 004/626] Added spring-thymeleaf initial version --- spring-thymeleaf/.classpath | 32 +++++ spring-thymeleaf/.project | 42 ++++++ spring-thymeleaf/pom.xml | 128 ++++++++++++++++++ .../thymeleaf/controller/HomeController.java | 27 ++++ .../controller/StudentController.java | 65 +++++++++ .../thymeleaf/formatter/NameFormatter.java | 30 ++++ .../org/baeldung/thymeleaf/model/Student.java | 40 ++++++ .../src/main/resources/logback.xml | 20 +++ .../main/resources/messages_en_US.properties | 4 + .../WEB-INF/appServlet/servlet-context.xml | 53 ++++++++ .../src/main/webapp/WEB-INF/root-context.xml | 8 ++ .../main/webapp/WEB-INF/views/addStudent.html | 30 ++++ .../src/main/webapp/WEB-INF/views/home.html | 15 ++ .../webapp/WEB-INF/views/listStudents.html | 24 ++++ .../src/main/webapp/WEB-INF/web.xml | 34 +++++ 15 files changed, 552 insertions(+) create mode 100644 spring-thymeleaf/.classpath create mode 100644 spring-thymeleaf/.project create mode 100644 spring-thymeleaf/pom.xml create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java create mode 100644 spring-thymeleaf/src/main/resources/logback.xml create mode 100644 spring-thymeleaf/src/main/resources/messages_en_US.properties create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/web.xml diff --git a/spring-thymeleaf/.classpath b/spring-thymeleaf/.classpath new file mode 100644 index 000000000000..28e4a52cd44a --- /dev/null +++ b/spring-thymeleaf/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-thymeleaf/.project b/spring-thymeleaf/.project new file mode 100644 index 000000000000..3c898c7e84c3 --- /dev/null +++ b/spring-thymeleaf/.project @@ -0,0 +1,42 @@ + + + spring-thymeleaf + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml new file mode 100644 index 000000000000..770f67d59c73 --- /dev/null +++ b/spring-thymeleaf/pom.xml @@ -0,0 +1,128 @@ + + 4.0.0 + org.baeldung + spring-thymeleaf + 0.1-SNAPSHOT + war + + 1.7 + + 4.1.8.RELEASE + 3.0.1 + + 1.7.12 + 1.1.3 + + 2.1.4.RELEASE + + 1.1.0.Final + 5.1.2.Final + + 3.3 + 2.6 + 2.18.1 + + + + + org.springframework + spring-context + ${org.springframework-version} + + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + + org.thymeleaf + thymeleaf + ${org.thymeleaf-version} + + + org.thymeleaf + thymeleaf-spring4 + ${org.thymeleaf-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + javax.servlet + javax.servlet-api + ${javax.servlet-version} + provided + + + + javax.validation + validation-api + ${javax.validation-version} + + + org.hibernate + hibernate-validator + ${org.hibernate-version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${java-version} + ${java-version} + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java new file mode 100644 index 000000000000..505dc8303b9f --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java @@ -0,0 +1,27 @@ +package org.baeldung.thymeleaf.controller; + +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * Handles requests for the application home page. + * + */ +@Controller +public class HomeController { + + @RequestMapping(value = "/", method = RequestMethod.GET) + public String getHome(Model model) { + + DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault()); + model.addAttribute("serverTime", dateFormat.format(new Date())); + return "home"; + } + +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java new file mode 100644 index 000000000000..fb7f52f85384 --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java @@ -0,0 +1,65 @@ +package org.baeldung.thymeleaf.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.validation.Valid; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import org.baeldung.thymeleaf.model.Student; + +/** + * Handles requests for the student model. + * + */ +@Controller +public class StudentController { + + @RequestMapping(value = "/saveStudent", method = RequestMethod.POST) + public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) { + if (!errors.hasErrors()) { + // get mock objects + List students = buildStudents(); + // add current student + students.add(student); + model.addAttribute("students", students); + } + return ((errors.hasErrors()) ? "addStudent" : "listStudents"); + } + + @RequestMapping(value = "/addStudent", method = RequestMethod.GET) + public String addStudent(Model model) { + model.addAttribute("student", new Student()); + return "addStudent"; + } + + @RequestMapping(value = "/listStudents", method = RequestMethod.GET) + public String listStudent(Model model) { + + model.addAttribute("students", buildStudents()); + + return "listStudents"; + } + + private List buildStudents() { + List students = new ArrayList(); + + Student student1 = new Student(); + student1.setId(1001); + student1.setName("John Smith"); + students.add(student1); + + Student student2 = new Student(); + student2.setId(1002); + student2.setName("Jane Williams"); + students.add(student2); + + return students; + } +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java new file mode 100644 index 000000000000..9c07ef8d145f --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java @@ -0,0 +1,30 @@ +package org.baeldung.thymeleaf.formatter; + +import java.text.ParseException; +import java.util.Locale; + +import org.springframework.format.Formatter; +import org.thymeleaf.util.StringUtils; + +/** + * + * Name formatter class that implements the Spring Formatter interface. + * Formats a name(String) and return the value with spaces replaced by commas. + * + */ +public class NameFormatter implements Formatter { + + @Override + public String print(String input, Locale locale) { + return formatName(input, locale); + } + + @Override + public String parse(String input, Locale locale) throws ParseException { + return formatName(input, locale); + } + + private String formatName(String input, Locale locale) { + return StringUtils.replace(input, " ", ","); + } +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java new file mode 100644 index 000000000000..d34af3961ecb --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java @@ -0,0 +1,40 @@ +package org.baeldung.thymeleaf.model; + +import java.io.Serializable; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * + * Simple student POJO with two fields - id and name + * + */ +public class Student implements Serializable { + + private static final long serialVersionUID = -8582553475226281591L; + + @NotNull(message = "Student ID is required.") + @Min(value = 1000, message = "Student ID must be atleast 4 digits.") + private Integer id; + + @NotNull(message = "Student Name is required.") + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/spring-thymeleaf/src/main/resources/logback.xml b/spring-thymeleaf/src/main/resources/logback.xml new file mode 100644 index 000000000000..1146dade632e --- /dev/null +++ b/spring-thymeleaf/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-thymeleaf/src/main/resources/messages_en_US.properties b/spring-thymeleaf/src/main/resources/messages_en_US.properties new file mode 100644 index 000000000000..0cfe16cd8471 --- /dev/null +++ b/spring-thymeleaf/src/main/resources/messages_en_US.properties @@ -0,0 +1,4 @@ +msg.id=ID +msg.name=Name +welcome.message=Welcome Student !!! + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml new file mode 100644 index 000000000000..38a4233c64b2 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml new file mode 100644 index 000000000000..5cb2a94d7367 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html new file mode 100644 index 000000000000..9358c991e920 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html @@ -0,0 +1,30 @@ + + + +Add Student + + +

Add Student

+
+
    +
  • +
  • +
+ + + + + + + + + + + + +
+
+ + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html new file mode 100644 index 000000000000..7d9d5852e4a6 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html @@ -0,0 +1,15 @@ + + + +Home + + +

+ +

+

+ Current time is +

+ + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html new file mode 100644 index 000000000000..e35082be50c5 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html @@ -0,0 +1,24 @@ + + + +Student List + + +

Student List

+ + + + + + + + + + + + + +
+ + diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..275a482c6f02 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + + + + contextConfigLocation + /WEB-INF/root-context.xml + + + + + org.springframework.web.context.ContextLoaderListener + + + + + appServlet + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + /WEB-INF/appServlet/servlet-context.xml + + 1 + + + + appServlet + / + + \ No newline at end of file From cd4d7beb86665560fa4f47f44ae5ec27f0d27523 Mon Sep 17 00:00:00 2001 From: gmaipady Date: Wed, 9 Dec 2015 18:13:30 +0530 Subject: [PATCH 005/626] Updated README file --- spring-thymeleaf/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spring-thymeleaf/README.md diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md new file mode 100644 index 000000000000..ef86ae055a3b --- /dev/null +++ b/spring-thymeleaf/README.md @@ -0,0 +1,17 @@ +========= + +## Spring Thymeleaf Example Project + + +### Relevant Articles: + + +### Build the Project +``` +mvn clean install +``` + +Access sample pages using the URLs: +http://localhost:8080/spring-thymeleaf/ +http://localhost:8080/spring-thymeleaf/addStudent/ +http://localhost:8080/spring-thymeleaf/listStudents/ From 9b2b856661948c6bec5bfee2c8191d203c8cf191 Mon Sep 17 00:00:00 2001 From: Devendra Desale Date: Fri, 11 Dec 2015 15:16:48 +0800 Subject: [PATCH 006/626] Adding spring batch project --- spring-batch-intro/.classpath | 27 ++++++++ spring-batch-intro/.project | 23 +++++++ spring-batch-intro/pom.xml | 45 ++++++++++++++ .../org/baeldung/spring_batch_intro/App.java | 28 +++++++++ .../spring_batch_intro/model/Transaction.java | 54 ++++++++++++++++ .../service/CustomItemProcessor.java | 14 +++++ .../service/RecordFieldSetMapper.java | 33 ++++++++++ .../src/main/resources/input/record.csv | 3 + .../src/main/resources/spring-batch-intro.xml | 61 +++++++++++++++++++ .../src/main/resources/spring.xml | 44 +++++++++++++ spring-batch-intro/xml/output.xml | 1 + 11 files changed, 333 insertions(+) create mode 100644 spring-batch-intro/.classpath create mode 100644 spring-batch-intro/.project create mode 100644 spring-batch-intro/pom.xml create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java create mode 100644 spring-batch-intro/src/main/resources/input/record.csv create mode 100644 spring-batch-intro/src/main/resources/spring-batch-intro.xml create mode 100644 spring-batch-intro/src/main/resources/spring.xml create mode 100644 spring-batch-intro/xml/output.xml diff --git a/spring-batch-intro/.classpath b/spring-batch-intro/.classpath new file mode 100644 index 000000000000..395dbde027f6 --- /dev/null +++ b/spring-batch-intro/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-intro/.project b/spring-batch-intro/.project new file mode 100644 index 000000000000..032f8a95417f --- /dev/null +++ b/spring-batch-intro/.project @@ -0,0 +1,23 @@ + + + spring-batch-intro + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/spring-batch-intro/pom.xml b/spring-batch-intro/pom.xml new file mode 100644 index 000000000000..c68608d4ae7e --- /dev/null +++ b/spring-batch-intro/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + + org.baeldung + spring-batch-intro + 0.1-SNAPSHOT + jar + + spring-batch-intro + http://maven.apache.org + + + UTF-8 + 4.0.2.RELEASE + 3.0.5.RELEASE + 3.8.11.2 + + + + + + org.xerial + sqlite-jdbc + ${sqlite.version} + + + org.springframework + spring-oxm + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + + org.springframework.batch + spring-batch-core + ${spring.batch.version} + + + + diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java new file mode 100644 index 000000000000..7e6b08085173 --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java @@ -0,0 +1,28 @@ +package org.baeldung.spring_batch_intro; + +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class App { + public static void main(String[] args) { + + ApplicationContext context = new ClassPathXmlApplicationContext( + "/spring-batch-intro.xml"); + + JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); + Job job = (Job) context.getBean("firstBatchJob"); + System.out.println("Starting the batch job"); + try { + JobExecution execution = jobLauncher.run(job, new JobParameters()); + System.out.println("Job Status : " + execution.getStatus()); + System.out.println("Job completed"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Job failed"); + } + } +} \ No newline at end of file diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java new file mode 100644 index 000000000000..815af78cd44b --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java @@ -0,0 +1,54 @@ +package org.baeldung.spring_batch_intro.model; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlRootElement; + +@SuppressWarnings("restriction") +@XmlRootElement(name = "transactionRecord") +public class Transaction { + private String username; + private int userId; + private Date transactionDate; + private double amount; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public Date getTransactionDate() { + return transactionDate; + } + + public void setTransactionDate(Date transactionDate) { + this.transactionDate = transactionDate; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + @Override + public String toString() { + return "Transaction [username=" + username + ", userId=" + userId + + ", transactionDate=" + transactionDate + ", amount=" + amount + + "]"; + } + +} diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java new file mode 100644 index 000000000000..be1127c5e77b --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java @@ -0,0 +1,14 @@ +package org.baeldung.spring_batch_intro.service; + + +import org.baeldung.spring_batch_intro.model.Transaction; +import org.springframework.batch.item.ItemProcessor; + +public class CustomItemProcessor implements ItemProcessor { + + public Transaction process(Transaction item) throws Exception { + + System.out.println("Processing..." + item); + return item; + } +} \ No newline at end of file diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java new file mode 100644 index 000000000000..2b8f897e2a84 --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java @@ -0,0 +1,33 @@ +package org.baeldung.spring_batch_intro.service; + +import java.text.ParseException; +import java.text.SimpleDateFormat; + +import org.baeldung.spring_batch_intro.model.Transaction; +import org.springframework.batch.item.file.mapping.FieldSetMapper; +import org.springframework.batch.item.file.transform.FieldSet; +import org.springframework.validation.BindException; + +public class RecordFieldSetMapper implements FieldSetMapper { + + public Transaction mapFieldSet(FieldSet fieldSet) throws BindException { + + SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Transaction transaction = new Transaction(); + + transaction.setUsername(fieldSet.readString("username")); + transaction.setUserId(fieldSet.readInt(1)); + transaction.setAmount(fieldSet.readDouble(3)); + //Converting the date + String dateString = fieldSet.readString(2); + try { + transaction.setTransactionDate(dateFormat.parse(dateString)); + } catch (ParseException e) { + e.printStackTrace(); + } + + return transaction; + + } + +} diff --git a/spring-batch-intro/src/main/resources/input/record.csv b/spring-batch-intro/src/main/resources/input/record.csv new file mode 100644 index 000000000000..3a1437eed5f1 --- /dev/null +++ b/spring-batch-intro/src/main/resources/input/record.csv @@ -0,0 +1,3 @@ +devendra, 1234, 31/10/2015, 10000 +john, 2134, 3/12/2015, 12321 +robin, 2134, 2/02/2015, 23411 \ No newline at end of file diff --git a/spring-batch-intro/src/main/resources/spring-batch-intro.xml b/spring-batch-intro/src/main/resources/spring-batch-intro.xml new file mode 100644 index 000000000000..06918d87548a --- /dev/null +++ b/spring-batch-intro/src/main/resources/spring-batch-intro.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.baeldung.spring_batch_intro.model.Transaction + + + + + + + + + + + + + + diff --git a/spring-batch-intro/src/main/resources/spring.xml b/spring-batch-intro/src/main/resources/spring.xml new file mode 100644 index 000000000000..d286662002e1 --- /dev/null +++ b/spring-batch-intro/src/main/resources/spring.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-batch-intro/xml/output.xml b/spring-batch-intro/xml/output.xml new file mode 100644 index 000000000000..9e57fa38f207 --- /dev/null +++ b/spring-batch-intro/xml/output.xml @@ -0,0 +1 @@ +10000.02015-10-31T00:00:00+08:001234devendra12321.02015-12-03T00:00:00+08:002134john23411.02015-02-02T00:00:00+08:002134robin \ No newline at end of file From 57b27f6c9c952a96aed157935873d54dd814bd4e Mon Sep 17 00:00:00 2001 From: Devendra Desale Date: Sun, 13 Dec 2015 22:12:09 +0800 Subject: [PATCH 007/626] adding java based spring batch configuration --- spring-batch-intro/pom.xml | 75 ++++++------ .../org/baeldung/spring_batch_intro/App.java | 42 ++++--- .../spring_batch_intro/SpringBatchConfig.java | 92 ++++++++++++++ .../spring_batch_intro/SpringConfig.java | 75 ++++++++++++ .../spring_batch_intro/model/Transaction.java | 86 ++++++------- .../service/CustomItemProcessor.java | 13 +- .../service/RecordFieldSetMapper.java | 38 +++--- .../src/main/resources/spring-batch-intro.xml | 115 +++++++++--------- .../src/main/resources/spring.xml | 67 +++++----- 9 files changed, 392 insertions(+), 211 deletions(-) create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java create mode 100644 spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java diff --git a/spring-batch-intro/pom.xml b/spring-batch-intro/pom.xml index c68608d4ae7e..28d48c594e3c 100644 --- a/spring-batch-intro/pom.xml +++ b/spring-batch-intro/pom.xml @@ -1,45 +1,44 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.baeldung - spring-batch-intro - 0.1-SNAPSHOT - jar + org.baeldung + spring-batch-intro + 0.1-SNAPSHOT + jar - spring-batch-intro - http://maven.apache.org + spring-batch-intro + http://maven.apache.org - - UTF-8 - 4.0.2.RELEASE - 3.0.5.RELEASE - 3.8.11.2 - + + UTF-8 + 4.2.0.RELEASE + 3.0.5.RELEASE + 3.8.11.2 + - - - - org.xerial - sqlite-jdbc - ${sqlite.version} - - - org.springframework - spring-oxm - ${spring.version} - - - org.springframework - spring-jdbc - ${spring.version} - - - - org.springframework.batch - spring-batch-core - ${spring.batch.version} - - + + + + org.xerial + sqlite-jdbc + ${sqlite.version} + + + org.springframework + spring-oxm + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + org.springframework.batch + spring-batch-core + ${spring.batch.version} + + diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java index 7e6b08085173..a2f8f38e0f19 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java @@ -1,28 +1,38 @@ package org.baeldung.spring_batch_intro; +import javax.swing.Spring; + import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { - public static void main(String[] args) { + public static void main(String[] args) { + // Spring Java config + AnnotationConfigApplicationContext context = new + AnnotationConfigApplicationContext(); + context.register(SpringConfig.class); + context.register(SpringBatchConfig.class); + context.refresh(); + + // Spring xml config +// ApplicationContext context = new ClassPathXmlApplicationContext( +// "spring-batch-intro.xml"); - ApplicationContext context = new ClassPathXmlApplicationContext( - "/spring-batch-intro.xml"); - - JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); - Job job = (Job) context.getBean("firstBatchJob"); - System.out.println("Starting the batch job"); - try { - JobExecution execution = jobLauncher.run(job, new JobParameters()); - System.out.println("Job Status : " + execution.getStatus()); - System.out.println("Job completed"); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Job failed"); - } - } + JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); + Job job = (Job) context.getBean("firstBatchJob"); + System.out.println("Starting the batch job"); + try { + JobExecution execution = jobLauncher.run(job, new JobParameters()); + System.out.println("Job Status : " + execution.getStatus()); + System.out.println("Job completed"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Job failed"); + } + } } \ No newline at end of file diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java new file mode 100644 index 000000000000..c892e24fd8b4 --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java @@ -0,0 +1,92 @@ +package org.baeldung.spring_batch_intro; + +import java.net.MalformedURLException; +import java.text.ParseException; + +import org.baeldung.spring_batch_intro.model.Transaction; +import org.baeldung.spring_batch_intro.service.CustomItemProcessor; +import org.baeldung.spring_batch_intro.service.RecordFieldSetMapper; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.batch.item.file.FlatFileItemReader; +import org.springframework.batch.item.file.mapping.DefaultLineMapper; +import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; +import org.springframework.batch.item.xml.StaxEventItemWriter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.oxm.Marshaller; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +public class SpringBatchConfig { + @Autowired + private JobBuilderFactory jobs; + + @Autowired + private StepBuilderFactory steps; + + @Value("input/record.csv") + private Resource inputCsv; + + @Value("file:xml/output.xml") + private Resource outputXml; + + @Bean + public ItemReader itemReader() + throws UnexpectedInputException, ParseException, Exception { + FlatFileItemReader reader = new FlatFileItemReader(); + DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(); + String[] tokens = { "username", "userid", "transactiondate", "amount" }; + tokenizer.setNames(tokens); + reader.setResource(inputCsv); + DefaultLineMapper lineMapper = new DefaultLineMapper(); + lineMapper.setLineTokenizer(tokenizer); + lineMapper.setFieldSetMapper(new RecordFieldSetMapper()); + reader.setLineMapper(lineMapper); + return reader; + } + + @Bean + public ItemProcessor itemProcessor() { + return new CustomItemProcessor(); + } + + @Bean + public ItemWriter itemWriter(Marshaller marshaller) + throws MalformedURLException { + StaxEventItemWriter itemWriter = new StaxEventItemWriter(); + itemWriter.setMarshaller(marshaller); + itemWriter.setRootTagName("transactionRecord"); + itemWriter.setResource(outputXml); + return itemWriter; + } + + @Bean + public Marshaller marshaller() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(new Class[] { Transaction.class }); + return marshaller; + } + + @Bean + protected Step step1(ItemReader reader, + ItemProcessor processor, + ItemWriter writer) { + return steps.get("step1"). chunk(10) + .reader(reader).processor(processor).writer(writer).build(); + } + + @Bean(name = "firstBatchJob") + public Job job(@Qualifier("step1") Step step1) { + return jobs.get("firstBatchJob").start(step1).build(); + } + +} diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java new file mode 100644 index 000000000000..79676fbe4eb9 --- /dev/null +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java @@ -0,0 +1,75 @@ +package org.baeldung.spring_batch_intro; + +import java.net.MalformedURLException; + +import javax.sql.DataSource; + +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; +import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.jdbc.datasource.init.DataSourceInitializer; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; +import org.springframework.transaction.PlatformTransactionManager; + +@Configuration +@EnableBatchProcessing +public class SpringConfig { + + @Value("org/springframework/batch/core/schema-drop-sqlite.sql") + private Resource dropReopsitoryTables; + + @Value("org/springframework/batch/core/schema-sqlite.sql") + private Resource dataReopsitorySchema; + + @Bean + public DataSource dataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("org.sqlite.JDBC"); + dataSource.setUrl("jdbc:sqlite:repository.sqlite"); + return dataSource; + } + + @Bean + public DataSourceInitializer dataSourceInitializer(DataSource dataSource) + throws MalformedURLException { + ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); + + databasePopulator.addScript(dropReopsitoryTables); + databasePopulator.addScript(dataReopsitorySchema); + databasePopulator.setIgnoreFailedDrops(true); + + DataSourceInitializer initializer = new DataSourceInitializer(); + initializer.setDataSource(dataSource); + initializer.setDatabasePopulator(databasePopulator); + + return initializer; + } + + private JobRepository getJobRepository() throws Exception { + JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); + factory.setDataSource(dataSource()); + factory.setTransactionManager(getTransactionManager()); + factory.afterPropertiesSet(); + return (JobRepository) factory.getObject(); + } + + private PlatformTransactionManager getTransactionManager() { + return new ResourcelessTransactionManager(); + } + + public JobLauncher getJobLauncher() throws Exception { + SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + jobLauncher.setJobRepository(getJobRepository()); + jobLauncher.afterPropertiesSet(); + return jobLauncher; + } + +} \ No newline at end of file diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java index 815af78cd44b..0108dcf50111 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java @@ -7,48 +7,48 @@ @SuppressWarnings("restriction") @XmlRootElement(name = "transactionRecord") public class Transaction { - private String username; - private int userId; - private Date transactionDate; - private double amount; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public int getUserId() { - return userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public Date getTransactionDate() { - return transactionDate; - } - - public void setTransactionDate(Date transactionDate) { - this.transactionDate = transactionDate; - } - - public double getAmount() { - return amount; - } - - public void setAmount(double amount) { - this.amount = amount; - } - - @Override - public String toString() { - return "Transaction [username=" + username + ", userId=" + userId - + ", transactionDate=" + transactionDate + ", amount=" + amount - + "]"; - } + private String username; + private int userId; + private Date transactionDate; + private double amount; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public Date getTransactionDate() { + return transactionDate; + } + + public void setTransactionDate(Date transactionDate) { + this.transactionDate = transactionDate; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + @Override + public String toString() { + return "Transaction [username=" + username + ", userId=" + userId + + ", transactionDate=" + transactionDate + ", amount=" + amount + + "]"; + } } diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java index be1127c5e77b..487dbb5efbb7 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java @@ -1,14 +1,13 @@ package org.baeldung.spring_batch_intro.service; - import org.baeldung.spring_batch_intro.model.Transaction; import org.springframework.batch.item.ItemProcessor; -public class CustomItemProcessor implements ItemProcessor { +public class CustomItemProcessor implements + ItemProcessor { - public Transaction process(Transaction item) throws Exception { - - System.out.println("Processing..." + item); - return item; - } + public Transaction process(Transaction item) throws Exception { + System.out.println("Processing..." + item); + return item; + } } \ No newline at end of file diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java index 2b8f897e2a84..0955b57c768b 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java @@ -10,24 +10,24 @@ public class RecordFieldSetMapper implements FieldSetMapper { - public Transaction mapFieldSet(FieldSet fieldSet) throws BindException { - - SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); - Transaction transaction = new Transaction(); - - transaction.setUsername(fieldSet.readString("username")); - transaction.setUserId(fieldSet.readInt(1)); - transaction.setAmount(fieldSet.readDouble(3)); - //Converting the date - String dateString = fieldSet.readString(2); - try { - transaction.setTransactionDate(dateFormat.parse(dateString)); - } catch (ParseException e) { - e.printStackTrace(); - } - - return transaction; - - } + public Transaction mapFieldSet(FieldSet fieldSet) throws BindException { + + SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Transaction transaction = new Transaction(); + + transaction.setUsername(fieldSet.readString("username")); + transaction.setUserId(fieldSet.readInt(1)); + transaction.setAmount(fieldSet.readDouble(3)); + // Converting the date + String dateString = fieldSet.readString(2); + try { + transaction.setTransactionDate(dateFormat.parse(dateString)); + } catch (ParseException e) { + e.printStackTrace(); + } + + return transaction; + + } } diff --git a/spring-batch-intro/src/main/resources/spring-batch-intro.xml b/spring-batch-intro/src/main/resources/spring-batch-intro.xml index 06918d87548a..6daa0358d994 100644 --- a/spring-batch-intro/src/main/resources/spring-batch-intro.xml +++ b/spring-batch-intro/src/main/resources/spring-batch-intro.xml @@ -1,61 +1,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.baeldung.spring_batch_intro.model.Transaction - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.baeldung.spring_batch_intro.model.Transaction + + + + + + + + + + + + + + diff --git a/spring-batch-intro/src/main/resources/spring.xml b/spring-batch-intro/src/main/resources/spring.xml index d286662002e1..dea261c5e612 100644 --- a/spring-batch-intro/src/main/resources/spring.xml +++ b/spring-batch-intro/src/main/resources/spring.xml @@ -1,44 +1,45 @@ + http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd"> - - - - - - - + + + + + + + - - - - - + + + + + - - + + - - - - - - + + + + + + - + - - - + + + \ No newline at end of file From 09bc7399ddddd88c744b37afad6bbf321a36c4e0 Mon Sep 17 00:00:00 2001 From: Devendra Desale Date: Mon, 14 Dec 2015 14:35:09 +0800 Subject: [PATCH 008/626] updating generic Exception and linewrappings. --- .../org/baeldung/spring_batch_intro/App.java | 16 +++++++--------- .../spring_batch_intro/SpringBatchConfig.java | 10 +++++----- .../spring_batch_intro/SpringConfig.java | 6 +++++- .../spring_batch_intro/model/Transaction.java | 6 ++++-- .../service/CustomItemProcessor.java | 4 ++-- .../service/RecordFieldSetMapper.java | 6 ++++-- .../src/main/resources/spring-batch-intro.xml | 2 -- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java index a2f8f38e0f19..db963fff2058 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java @@ -1,7 +1,5 @@ package org.baeldung.spring_batch_intro; -import javax.swing.Spring; - import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; @@ -10,18 +8,18 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; + public class App { public static void main(String[] args) { // Spring Java config - AnnotationConfigApplicationContext context = new - AnnotationConfigApplicationContext(); - context.register(SpringConfig.class); - context.register(SpringBatchConfig.class); - context.refresh(); + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + context.register(SpringConfig.class); + context.register(SpringBatchConfig.class); + context.refresh(); // Spring xml config -// ApplicationContext context = new ClassPathXmlApplicationContext( -// "spring-batch-intro.xml"); + // ApplicationContext context = new ClassPathXmlApplicationContext( + // "spring-batch-intro.xml"); JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); Job job = (Job) context.getBean("firstBatchJob"); diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java index c892e24fd8b4..f0e3b364b66a 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java @@ -41,7 +41,7 @@ public class SpringBatchConfig { @Bean public ItemReader itemReader() - throws UnexpectedInputException, ParseException, Exception { + throws UnexpectedInputException, ParseException { FlatFileItemReader reader = new FlatFileItemReader(); DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(); String[] tokens = { "username", "userid", "transactiondate", "amount" }; @@ -61,7 +61,7 @@ public ItemProcessor itemProcessor() { @Bean public ItemWriter itemWriter(Marshaller marshaller) - throws MalformedURLException { + throws MalformedURLException { StaxEventItemWriter itemWriter = new StaxEventItemWriter(); itemWriter.setMarshaller(marshaller); itemWriter.setRootTagName("transactionRecord"); @@ -78,10 +78,10 @@ public Marshaller marshaller() { @Bean protected Step step1(ItemReader reader, - ItemProcessor processor, - ItemWriter writer) { + ItemProcessor processor, + ItemWriter writer) { return steps.get("step1"). chunk(10) - .reader(reader).processor(processor).writer(writer).build(); + .reader(reader).processor(processor).writer(writer).build(); } @Bean(name = "firstBatchJob") diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java index 79676fbe4eb9..91366d872163 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java @@ -39,7 +39,7 @@ public DataSource dataSource() { @Bean public DataSourceInitializer dataSourceInitializer(DataSource dataSource) - throws MalformedURLException { + throws MalformedURLException { ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); databasePopulator.addScript(dropReopsitoryTables); @@ -57,6 +57,8 @@ private JobRepository getJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource()); factory.setTransactionManager(getTransactionManager()); + // JobRepositoryFactoryBean's methods Throws Generic Exception, + // it would have been better to have a specific one factory.afterPropertiesSet(); return (JobRepository) factory.getObject(); } @@ -67,6 +69,8 @@ private PlatformTransactionManager getTransactionManager() { public JobLauncher getJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + // SimpleJobLauncher's methods Throws Generic Exception, + // it would have been better to have a specific one jobLauncher.setJobRepository(getJobRepository()); jobLauncher.afterPropertiesSet(); return jobLauncher; diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java index 0108dcf50111..6e80298ff0d7 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java @@ -12,6 +12,8 @@ public class Transaction { private Date transactionDate; private double amount; + /* getters and setters for the attributes */ + public String getUsername() { return username; } @@ -47,8 +49,8 @@ public void setAmount(double amount) { @Override public String toString() { return "Transaction [username=" + username + ", userId=" + userId - + ", transactionDate=" + transactionDate + ", amount=" + amount - + "]"; + + ", transactionDate=" + transactionDate + ", amount=" + amount + + "]"; } } diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java index 487dbb5efbb7..baabe794097b 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java @@ -4,9 +4,9 @@ import org.springframework.batch.item.ItemProcessor; public class CustomItemProcessor implements - ItemProcessor { + ItemProcessor { - public Transaction process(Transaction item) throws Exception { + public Transaction process(Transaction item) { System.out.println("Processing..." + item); return item; } diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java index 0955b57c768b..94f9e7d94e9f 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java @@ -14,9 +14,11 @@ public Transaction mapFieldSet(FieldSet fieldSet) throws BindException { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Transaction transaction = new Transaction(); - + // you can either use the indices or custom names + // I personally prefer the custom names easy for debugging and + // validating the pipelines transaction.setUsername(fieldSet.readString("username")); - transaction.setUserId(fieldSet.readInt(1)); + transaction.setUserId(fieldSet.readInt("userid")); transaction.setAmount(fieldSet.readDouble(3)); // Converting the date String dateString = fieldSet.readString(2); diff --git a/spring-batch-intro/src/main/resources/spring-batch-intro.xml b/spring-batch-intro/src/main/resources/spring-batch-intro.xml index 6daa0358d994..3b1f11521f92 100644 --- a/spring-batch-intro/src/main/resources/spring-batch-intro.xml +++ b/spring-batch-intro/src/main/resources/spring-batch-intro.xml @@ -8,8 +8,6 @@ - - From 06ded372a4a2cd38e8f391d2f3362ef3b221515b Mon Sep 17 00:00:00 2001 From: gmaipady Date: Tue, 15 Dec 2015 15:52:52 +0530 Subject: [PATCH 009/626] Minor changes --- .../controller/StudentController.java | 71 ++++++++++--------- .../org/baeldung/thymeleaf/model/Student.java | 58 ++++++++++----- .../main/resources/messages_en_US.properties | 5 ++ .../WEB-INF/appServlet/servlet-context.xml | 6 +- .../main/webapp/WEB-INF/views/addStudent.html | 17 ++++- .../src/main/webapp/WEB-INF/views/home.html | 16 +++-- .../webapp/WEB-INF/views/listStudents.html | 20 ++++-- 7 files changed, 128 insertions(+), 65 deletions(-) diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java index fb7f52f85384..3bef22cdae3f 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java @@ -21,45 +21,50 @@ @Controller public class StudentController { - @RequestMapping(value = "/saveStudent", method = RequestMethod.POST) - public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) { - if (!errors.hasErrors()) { - // get mock objects - List students = buildStudents(); - // add current student - students.add(student); - model.addAttribute("students", students); - } - return ((errors.hasErrors()) ? "addStudent" : "listStudents"); - } + @RequestMapping(value = "/saveStudent", method = RequestMethod.POST) + public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) { + if (!errors.hasErrors()) { + // get mock objects + List students = buildStudents(); + // add current student + students.add(student); + model.addAttribute("students", students); + } + return ((errors.hasErrors()) ? "addStudent" : "listStudents"); + } - @RequestMapping(value = "/addStudent", method = RequestMethod.GET) - public String addStudent(Model model) { - model.addAttribute("student", new Student()); - return "addStudent"; - } + @RequestMapping(value = "/addStudent", method = RequestMethod.GET) + public String addStudent(Model model) { + model.addAttribute("student", new Student()); + return "addStudent"; + } - @RequestMapping(value = "/listStudents", method = RequestMethod.GET) - public String listStudent(Model model) { + @RequestMapping(value = "/listStudents", method = RequestMethod.GET) + public String listStudent(Model model) { - model.addAttribute("students", buildStudents()); + model.addAttribute("students", buildStudents()); - return "listStudents"; - } + return "listStudents"; + } - private List buildStudents() { - List students = new ArrayList(); + private List buildStudents() { + List students = new ArrayList(); - Student student1 = new Student(); - student1.setId(1001); - student1.setName("John Smith"); - students.add(student1); + Student student1 = new Student(); + student1.setId(1001); + student1.setName("John Smith"); + student1.setGender('M'); + student1.setPercentage(Float.valueOf("80.45")); - Student student2 = new Student(); - student2.setId(1002); - student2.setName("Jane Williams"); - students.add(student2); + students.add(student1); - return students; - } + Student student2 = new Student(); + student2.setId(1002); + student2.setName("Jane Williams"); + student2.setGender('F'); + student2.setPercentage(Float.valueOf("60.25")); + + students.add(student2); + return students; + } } diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java index d34af3961ecb..d4d8ea1d6c4d 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java @@ -7,34 +7,54 @@ /** * - * Simple student POJO with two fields - id and name + * Simple student POJO with few fields * */ public class Student implements Serializable { - private static final long serialVersionUID = -8582553475226281591L; + private static final long serialVersionUID = -8582553475226281591L; - @NotNull(message = "Student ID is required.") - @Min(value = 1000, message = "Student ID must be atleast 4 digits.") - private Integer id; + @NotNull(message = "Student ID is required.") + @Min(value = 1000, message = "Student ID must be atleast 4 digits.") + private Integer id; - @NotNull(message = "Student Name is required.") - private String name; + @NotNull(message = "Student name is required.") + private String name; - public Integer getId() { - return id; - } + @NotNull(message = "Student gender is required.") + private Character gender; - public void setId(Integer id) { - this.id = id; - } + private Float percentage; - public String getName() { - return name; - } + public Integer getId() { + return id; + } - public void setName(String name) { - this.name = name; - } + public void setId(Integer id) { + this.id = id; + } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Character getGender() { + return gender; + } + + public void setGender(Character gender) { + this.gender = gender; + } + + public Float getPercentage() { + return percentage; + } + + public void setPercentage(Float percentage) { + this.percentage = percentage; + } } diff --git a/spring-thymeleaf/src/main/resources/messages_en_US.properties b/spring-thymeleaf/src/main/resources/messages_en_US.properties index 0cfe16cd8471..33295968e079 100644 --- a/spring-thymeleaf/src/main/resources/messages_en_US.properties +++ b/spring-thymeleaf/src/main/resources/messages_en_US.properties @@ -1,4 +1,9 @@ msg.id=ID msg.name=Name +msg.gender=Gender +msg.percent=Percentage welcome.message=Welcome Student !!! +msg.AddStudent=Add Student +msg.ListStudents=List Students +msg.Home=Home diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml index 38a4233c64b2..ef42557429f2 100644 --- a/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml @@ -26,7 +26,7 @@ - + - org.springframework spring-web @@ -21,64 +18,53 @@ spring-webmvc ${org.springframework.version} - - javax.servlet javax.servlet-api 3.0.1 provided - javax.servlet jstl 1.2 runtime - org.springframework spring-aop ${org.springframework.version} - org.aspectj aspectjrt ${aspectj.version} - org.aspectj aspectjweaver ${aspectj.version} - org.slf4j slf4j-api ${org.slf4j.version} - org.slf4j slf4j-log4j12 ${org.slf4j.version} - - junit junit-dep ${junit.version} test - org.hamcrest hamcrest-core @@ -91,23 +77,30 @@ ${org.hamcrest.version} test - org.mockito mockito-core ${mockito.version} test - org.springframework spring-test ${org.springframework.version} test - + + + org.thymeleaf + thymeleaf-spring4 + ${thymeleaf.version} + + + org.thymeleaf + thymeleaf + ${thymeleaf.version} + - spring-mvc-java @@ -116,9 +109,7 @@ true - - org.apache.maven.plugins maven-compiler-plugin @@ -128,7 +119,10 @@ 1.8 - + + maven-resources-plugin + 2.7 + org.apache.maven.plugins maven-war-plugin @@ -137,7 +131,6 @@ false - org.apache.maven.plugins maven-surefire-plugin @@ -151,7 +144,6 @@ - org.codehaus.cargo cargo-maven2-plugin @@ -172,50 +164,46 @@ - + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + / + + - - 4.2.2.RELEASE 4.0.2.RELEASE - + 2.1.4.RELEASE 4.3.11.Final 5.1.36 - 1.7.12 1.1.3 - 5.2.1.Final - 18.0 3.4 - 1.3 4.11 1.10.19 - 4.4.1 4.5 - 2.4.1 - 3.3 2.6 2.18.1 2.7 1.4.15 - 1.8.7 - \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java b/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java new file mode 100644 index 000000000000..3203296a1743 --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java @@ -0,0 +1,31 @@ +package org.baeldung.controller; + +import org.baeldung.model.UserDetails; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +@RequestMapping("/") +public class UserController { + + @RequestMapping(value = "/", method = RequestMethod.GET) + public String showForm(final Model model) { + final UserDetails user = new UserDetails(); + user.setFirstname("John"); + user.setLastname("Roy"); + user.setEmailId("John.Roy@gmail.com"); + model.addAttribute("user", user); + return "index"; + } + + @RequestMapping(value = "/processForm", method = RequestMethod.POST) + public String processForm(@ModelAttribute(value = "user") final UserDetails user, final Model model) { + // Insert userDetails into DB + model.addAttribute("name", user.getFirstname() + " " + user.getLastname()); + return "hello"; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/dialect/CustomDialect.java b/spring-mvc-java/src/main/java/org/baeldung/dialect/CustomDialect.java new file mode 100644 index 000000000000..e6d1ad6b746d --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/dialect/CustomDialect.java @@ -0,0 +1,24 @@ +package org.baeldung.dialect; + +import java.util.HashSet; +import java.util.Set; + +import org.baeldung.processor.NameProcessor; +import org.thymeleaf.dialect.AbstractDialect; +import org.thymeleaf.processor.IProcessor; + +public class CustomDialect extends AbstractDialect { + + @Override + public String getPrefix() { + return "custom"; + } + + @Override + public Set getProcessors() { + final Set processors = new HashSet(); + processors.add(new NameProcessor()); + return processors; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java b/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java new file mode 100644 index 000000000000..d0b37fae8a1f --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java @@ -0,0 +1,32 @@ +package org.baeldung.model; + +public class UserDetails { + private String firstname; + private String lastname; + private String emailId; + + public String getFirstname() { + return firstname; + } + + public void setFirstname(final String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(final String lastname) { + this.lastname = lastname; + } + + public String getEmailId() { + return emailId; + } + + public void setEmailId(final String emailId) { + this.emailId = emailId; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/processor/NameProcessor.java b/spring-mvc-java/src/main/java/org/baeldung/processor/NameProcessor.java new file mode 100644 index 000000000000..df9a4da7f09b --- /dev/null +++ b/spring-mvc-java/src/main/java/org/baeldung/processor/NameProcessor.java @@ -0,0 +1,23 @@ +package org.baeldung.processor; + +import org.thymeleaf.Arguments; +import org.thymeleaf.dom.Element; +import org.thymeleaf.processor.attr.AbstractTextChildModifierAttrProcessor; + +public class NameProcessor extends AbstractTextChildModifierAttrProcessor { + + public NameProcessor() { + super("name"); + } + + @Override + protected String getText(final Arguments arguements, final Element elements, final String attributeName) { + return "Hello, " + elements.getAttributeValue(attributeName) + "!"; + } + + @Override + public int getPrecedence() { + return 1000; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 945c1794fba9..50681e88f628 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -1,16 +1,28 @@ package org.baeldung.spring.web.config; +import java.util.HashSet; +import java.util.Set; + +import org.baeldung.dialect.CustomDialect; +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; +import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; +import org.thymeleaf.dialect.IDialect; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.view.ThymeleafViewResolver; +import org.thymeleaf.templateresolver.ServletContextTemplateResolver; @EnableWebMvc @Configuration +@ComponentScan("org.baeldung.controller") public class ClientWebConfig extends WebMvcConfigurerAdapter { public ClientWebConfig() { @@ -28,12 +40,49 @@ public void addViewControllers(final ViewControllerRegistry registry) { @Bean public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - + /*final InternalResourceViewResolver bean = new InternalResourceViewResolver(); bean.setViewClass(JstlView.class); bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + bean.setSuffix(".jsp");*/ + + final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); + viewResolver.setTemplateEngine(templateEngine()); + + return viewResolver; + } + + @Bean + @Description("Thymeleaf template resolver serving HTML 5") + public ServletContextTemplateResolver templateResolver() { + final ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); + templateResolver.setPrefix("/WEB-INF/templates/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML5"); + return templateResolver; + } - return bean; + @Bean + @Description("Thymeleaf template engine with Spring integration") + public SpringTemplateEngine templateEngine() { + final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + final Set dialects = new HashSet<>(); + dialects.add(new CustomDialect()); + templateEngine.setAdditionalDialects(dialects); + return templateEngine; + } + + @Bean + @Description("Spring message resolver") + public MessageSource messageSource() { + final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("messages"); + return messageSource; } + + @Override + public void addResourceHandlers(final ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); + } + } \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html b/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html new file mode 100644 index 000000000000..f72d55330382 --- /dev/null +++ b/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html @@ -0,0 +1,6 @@ + + + +
© 2013 Footer
+ + \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html b/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html new file mode 100644 index 000000000000..1eddd85166a9 --- /dev/null +++ b/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html @@ -0,0 +1,14 @@ + + + + + + + Hi + John ! + Test +
© 2013 The Static + Templates
+ + \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html b/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html new file mode 100644 index 000000000000..9b4159c19316 --- /dev/null +++ b/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html @@ -0,0 +1,36 @@ + + + + +Thymeleaf Spring Example + + + Hello John! +

+
Please confirm your details
+

+
+ + + + + + + + + + + + + + + + +
Firstname :
Lastname :
EmailId :
+
+ + \ No newline at end of file From 1e91b46d1e28b0c4899afa8ac00504b1a35ae4b5 Mon Sep 17 00:00:00 2001 From: vkadapa Date: Fri, 18 Dec 2015 06:46:29 +0530 Subject: [PATCH 012/626] Missed messages.properties --- spring-mvc-java/src/main/resources/messages_en.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 spring-mvc-java/src/main/resources/messages_en.properties diff --git a/spring-mvc-java/src/main/resources/messages_en.properties b/spring-mvc-java/src/main/resources/messages_en.properties new file mode 100644 index 000000000000..549024372b67 --- /dev/null +++ b/spring-mvc-java/src/main/resources/messages_en.properties @@ -0,0 +1 @@ +welcome.text=Hello \ No newline at end of file From 7fef26916994c488de0b515f5e3f930e846eaa4f Mon Sep 17 00:00:00 2001 From: vkadapa Date: Fri, 18 Dec 2015 07:14:51 +0530 Subject: [PATCH 013/626] Modified code to support both thymeleaf and existing viewResolvers --- .../spring/web/config/ClientWebConfig.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index 50681e88f628..fe31e3581eee 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -15,6 +15,8 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; import org.thymeleaf.dialect.IDialect; import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.view.ThymeleafViewResolver; @@ -39,18 +41,23 @@ public void addViewControllers(final ViewControllerRegistry registry) { } @Bean - public ViewResolver viewResolver() { - /*final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp");*/ - + public ViewResolver thymeleafViewResolver() { final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); viewResolver.setTemplateEngine(templateEngine()); - + viewResolver.setOrder(1); return viewResolver; } + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + bean.setOrder(0); + return bean; + } + @Bean @Description("Thymeleaf template resolver serving HTML 5") public ServletContextTemplateResolver templateResolver() { From 5aaeb7308a3618c2f8a372c1035ac3b0d411f4a5 Mon Sep 17 00:00:00 2001 From: vkadapa Date: Fri, 18 Dec 2015 15:51:12 +0530 Subject: [PATCH 014/626] Removed Tomcat Plugin from pom.xml, rename Userdetails to User and moved the controller to web --- spring-mvc-java/pom.xml | 8 --- .../model/{UserDetails.java => User.java} | 64 +++++++++---------- .../spring/web/config/ClientWebConfig.java | 2 - .../{ => web}/controller/UserController.java | 63 +++++++++--------- 4 files changed, 64 insertions(+), 73 deletions(-) rename spring-mvc-java/src/main/java/org/baeldung/model/{UserDetails.java => User.java} (92%) rename spring-mvc-java/src/main/java/org/baeldung/{ => web}/controller/UserController.java (54%) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index a9bbf71ba3ce..56054b0c47b0 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -164,14 +164,6 @@ - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - / - - diff --git a/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java b/spring-mvc-java/src/main/java/org/baeldung/model/User.java similarity index 92% rename from spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java rename to spring-mvc-java/src/main/java/org/baeldung/model/User.java index d0b37fae8a1f..df549cd21dcb 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java +++ b/spring-mvc-java/src/main/java/org/baeldung/model/User.java @@ -1,32 +1,32 @@ -package org.baeldung.model; - -public class UserDetails { - private String firstname; - private String lastname; - private String emailId; - - public String getFirstname() { - return firstname; - } - - public void setFirstname(final String firstname) { - this.firstname = firstname; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(final String lastname) { - this.lastname = lastname; - } - - public String getEmailId() { - return emailId; - } - - public void setEmailId(final String emailId) { - this.emailId = emailId; - } - -} +package org.baeldung.model; + +public class User { + private String firstname; + private String lastname; + private String emailId; + + public String getFirstname() { + return firstname; + } + + public void setFirstname(final String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(final String lastname) { + this.lastname = lastname; + } + + public String getEmailId() { + return emailId; + } + + public void setEmailId(final String emailId) { + this.emailId = emailId; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index fe31e3581eee..db57b4716b9c 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -6,7 +6,6 @@ import org.baeldung.dialect.CustomDialect; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Description; import org.springframework.context.support.ResourceBundleMessageSource; @@ -24,7 +23,6 @@ @EnableWebMvc @Configuration -@ComponentScan("org.baeldung.controller") public class ClientWebConfig extends WebMvcConfigurerAdapter { public ClientWebConfig() { diff --git a/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java similarity index 54% rename from spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java rename to spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java index 3203296a1743..731424c33679 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java +++ b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java @@ -1,31 +1,32 @@ -package org.baeldung.controller; - -import org.baeldung.model.UserDetails; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping("/") -public class UserController { - - @RequestMapping(value = "/", method = RequestMethod.GET) - public String showForm(final Model model) { - final UserDetails user = new UserDetails(); - user.setFirstname("John"); - user.setLastname("Roy"); - user.setEmailId("John.Roy@gmail.com"); - model.addAttribute("user", user); - return "index"; - } - - @RequestMapping(value = "/processForm", method = RequestMethod.POST) - public String processForm(@ModelAttribute(value = "user") final UserDetails user, final Model model) { - // Insert userDetails into DB - model.addAttribute("name", user.getFirstname() + " " + user.getLastname()); - return "hello"; - } - -} +package org.baeldung.web.controller; + +import org.baeldung.model.User; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +@RequestMapping("/") +public class UserController { + + @RequestMapping(value = "/", method = RequestMethod.GET) + public String showForm(final Model model) { + final User user = new User(); + user.setFirstname("John"); + user.setLastname("Roy"); + user.setEmailId("John.Roy@gmail.com"); + model.addAttribute("user", user); + return "index"; + } + + @RequestMapping(value = "/processForm", method = RequestMethod.POST) + public String processForm(@ModelAttribute(value = "user") final User user, + final Model model) { + // Insert User into DB + model.addAttribute("name", user.getFirstname() + " " + user.getLastname()); + return "hello"; + } + +} From 55b0827420ab29cafc6d0080703f02266e26a06f Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 18 Dec 2015 13:14:30 +0200 Subject: [PATCH 015/626] minor cleanup --- spring-mvc-java/pom.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 56054b0c47b0..1a462fabaa06 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -1,5 +1,4 @@ - + 4.0.0 org.baeldung spring-mvc-java @@ -101,6 +100,7 @@ ${thymeleaf.version} + spring-mvc-java @@ -109,6 +109,7 @@ true + org.apache.maven.plugins @@ -119,10 +120,12 @@ 1.8 + maven-resources-plugin 2.7 + org.apache.maven.plugins maven-war-plugin From 2ea5de304b19e47be4fb798cf26c53f36677be94 Mon Sep 17 00:00:00 2001 From: gmaipady Date: Sun, 20 Dec 2015 21:43:31 +0530 Subject: [PATCH 016/626] Fixed minor comments --- spring-thymeleaf/README.md | 18 +++++++++++------ spring-thymeleaf/pom.xml | 20 +++++++++++++++++++ .../org/baeldung/thymeleaf/model/Student.java | 2 +- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md index ef86ae055a3b..8cb1c2e982a5 100644 --- a/spring-thymeleaf/README.md +++ b/spring-thymeleaf/README.md @@ -7,11 +7,17 @@ ### Build the Project -``` + mvn clean install -``` -Access sample pages using the URLs: -http://localhost:8080/spring-thymeleaf/ -http://localhost:8080/spring-thymeleaf/addStudent/ -http://localhost:8080/spring-thymeleaf/listStudents/ +### Run the Project +mvn cargo:run +- **note**: starts on port '8082' + +Access the pages using the URLs: + +http://localhost:8082/spring-thymeleaf/ +http://localhost:8082/spring-thymeleaf/addStudent/ +http://localhost:8082/spring-thymeleaf/listStudents/ + +The first URL is the home page of the application. The home page has links to the other two pages. diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index 770f67d59c73..1a8dff671e58 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -22,6 +22,7 @@ 3.3 2.6 2.18.1 + 1.4.15 @@ -123,6 +124,25 @@ + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + 8082 + + + + diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java index d4d8ea1d6c4d..f21169dbcf3c 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java @@ -15,7 +15,7 @@ public class Student implements Serializable { private static final long serialVersionUID = -8582553475226281591L; @NotNull(message = "Student ID is required.") - @Min(value = 1000, message = "Student ID must be atleast 4 digits.") + @Min(value = 1000, message = "Student ID must be at least 4 digits.") private Integer id; @NotNull(message = "Student name is required.") From 2057015cd64bbf5e98283513589ca41686f2030c Mon Sep 17 00:00:00 2001 From: sameira Date: Sun, 20 Dec 2015 21:45:36 +0530 Subject: [PATCH 017/626] Updated test cases adding increased timeouts and sleeps to enhance the stability, updated Spring Data Cassandra Version. --- spring-data-cassandra/pom.xml | 2 +- .../cassandra/repository/CQLQueriesIntegrationTest.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-data-cassandra/pom.xml b/spring-data-cassandra/pom.xml index 13c5c18529c1..b2b649a4224a 100644 --- a/spring-data-cassandra/pom.xml +++ b/spring-data-cassandra/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 1.3.1.RELEASE + 1.3.2.RELEASE 4.2.2.RELEASE 4.11 1.7.12 diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java index f4354a66e227..031b5c0b6f1b 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java @@ -51,7 +51,7 @@ public class CQLQueriesIntegrationTest { @BeforeClass public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { - EmbeddedCassandraServerHelper.startEmbeddedCassandra(); + EmbeddedCassandraServerHelper.startEmbeddedCassandra(25000); Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); LOGGER.info("Server Started at 127.0.0.1:9142... "); Session session = cluster.connect(); @@ -87,7 +87,7 @@ public void whenSavingBook_thenAvailableOnRetrieval_usingCQLStatements() { } @Test - public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() { + public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() throws InterruptedException { UUID uuid = UUIDs.timeBased(); String insertPreparedCql = "insert into book (id, title, publisher, tags) values (?, ?, ?, ?)"; List singleBookArgsList = new ArrayList<>(); @@ -98,6 +98,8 @@ public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() { singleBookArgsList.add(ImmutableSet.of("Software")); bookList.add(singleBookArgsList); cassandraTemplate.ingest(insertPreparedCql, bookList); + //This may not be required, just added to avoid any transient issues + Thread.sleep(5000); Select select = QueryBuilder.select().from("book"); Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(uuid, retrievedBook.getId()); From d7d86a1df8bcdf0d79a1de891c0cc545990eb90e Mon Sep 17 00:00:00 2001 From: sameira Date: Sun, 20 Dec 2015 22:24:54 +0530 Subject: [PATCH 018/626] Adding README.md --- spring-data-cassandra/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 spring-data-cassandra/README.md diff --git a/spring-data-cassandra/README.md b/spring-data-cassandra/README.md new file mode 100644 index 000000000000..a245ff62a11b --- /dev/null +++ b/spring-data-cassandra/README.md @@ -0,0 +1,15 @@ +## Spring Data Cassandra + +### Relevant Articles: +- [Introduction to Spring Data Cassandra](http://www.baeldung.com/spring-data-cassandra-tutorial) + +### Build the Project with Tests Running +``` +mvn clean install +``` + +### Run Tests Directly +``` +mvn test +``` + From 8238c11c809e78f0c7b5dd0c91e51a14a36214b9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Dec 2015 11:34:42 +0200 Subject: [PATCH 019/626] maven upgrades --- apache-fop/pom.xml | 6 ++--- core-java-8/pom.xml | 4 ++-- core-java/pom.xml | 10 ++++---- gson/pom.xml | 8 +++---- guava/pom.xml | 8 +++---- handling-spring-static-resources/pom.xml | 8 +++---- httpclient/pom.xml | 8 +++---- jackson/pom.xml | 10 ++++---- mockito/pom.xml | 8 +++---- rest-testing/pom.xml | 10 ++++---- sandbox/pom.xml | 8 +++---- spring-all/pom.xml | 16 ++++++------- spring-exceptions/pom.xml | 16 ++++++------- spring-hibernate3/pom.xml | 16 ++++++------- spring-hibernate4/pom.xml | 16 ++++++------- spring-jpa/pom.xml | 14 +++++------ spring-mvc-java/pom.xml | 16 ++++++------- spring-mvc-no-xml/pom.xml | 8 +++---- spring-mvc-xml/pom.xml | 8 +++---- spring-rest/pom.xml | 18 +++++++------- spring-security-basic-auth/pom.xml | 16 ++++++------- .../pom.xml | 8 +++---- spring-security-mvc-custom/pom.xml | 16 ++++++------- spring-security-mvc-digest-auth/pom.xml | 16 ++++++------- spring-security-mvc-ldap/pom.xml | 14 +++++------ spring-security-mvc-login/pom.xml | 16 ++++++------- spring-security-mvc-session/pom.xml | 16 ++++++------- spring-security-rest-basic-auth/pom.xml | 22 ++++++++--------- spring-security-rest-custom/pom.xml | 16 ++++++------- spring-security-rest-digest-auth/pom.xml | 24 +++++++++---------- spring-security-rest-full/pom.xml | 18 +++++++------- spring-security-rest/pom.xml | 16 ++++++------- 32 files changed, 207 insertions(+), 207 deletions(-) diff --git a/apache-fop/pom.xml b/apache-fop/pom.xml index 13fc2257cf54..95505f9374d4 100644 --- a/apache-fop/pom.xml +++ b/apache-fop/pom.xml @@ -37,7 +37,7 @@ junit - junit-dep + junit ${junit.version} test @@ -151,7 +151,7 @@ 5.1.34 - 2.4.4 + 2.5.5 1.7.9 @@ -166,7 +166,7 @@ 1.3 - 4.11 + 4.12 1.10.19 4.4 diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index 9db2562fb43e..07d3bcd146b2 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -98,14 +98,14 @@ - 1.7.12 + 1.7.13 1.0.13 5.1.3.Final - 18.0 + 19.0 3.4 diff --git a/core-java/pom.xml b/core-java/pom.xml index c6f2b32cd86d..b439b41f22a1 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -79,7 +79,7 @@ junit - junit-dep + junit ${junit.version} test @@ -152,22 +152,22 @@ 5.1.35 - 2.4.4 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/gson/pom.xml b/gson/pom.xml index 500d14c40c93..c0640abcbf98 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -53,7 +53,7 @@ junit - junit-dep + junit ${junit.version} test @@ -124,19 +124,19 @@ 2.3 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/guava/pom.xml b/guava/pom.xml index 78c5a14e4124..2b07be71bfe3 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -34,7 +34,7 @@ junit - junit-dep + junit ${junit.version} test @@ -102,19 +102,19 @@ 5.1.35 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/handling-spring-static-resources/pom.xml b/handling-spring-static-resources/pom.xml index 67591e18447c..677d70593296 100644 --- a/handling-spring-static-resources/pom.xml +++ b/handling-spring-static-resources/pom.xml @@ -190,22 +190,22 @@ - 2.4.4 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/httpclient/pom.xml b/httpclient/pom.xml index a6df3842fd78..0098c40d522f 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -89,7 +89,7 @@ junit - junit-dep + junit ${junit.version} test @@ -157,19 +157,19 @@ 5.1.35 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/jackson/pom.xml b/jackson/pom.xml index b2c2465436f9..999633036138 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -72,7 +72,7 @@ junit - junit-dep + junit ${junit.version} test @@ -140,22 +140,22 @@ 5.1.35 - 2.4.4 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/mockito/pom.xml b/mockito/pom.xml index a97a017c5ce2..a73eea764703 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -28,7 +28,7 @@ junit - junit-dep + junit ${junit.version} test @@ -96,19 +96,19 @@ 5.1.35 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 488a8a3cdb83..b8fdc50a0199 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -78,7 +78,7 @@ junit - junit-dep + junit ${junit.version} test @@ -141,22 +141,22 @@ 4.1.5.RELEASE - 2.4.4 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 5.1.3.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 55cb9f11f229..95b2df2cb348 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -73,7 +73,7 @@ junit - junit-dep + junit ${junit.version} test @@ -141,10 +141,10 @@ 5.1.35 - 2.4.4 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 @@ -156,7 +156,7 @@ 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 0551abe5a5fd..16ff340d813c 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -127,7 +127,7 @@ junit - junit-dep + junit ${junit.version} test @@ -221,29 +221,29 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 3.20.0-GA 1.2 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index f4c0acec857a..324b7475b384 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -105,7 +105,7 @@ junit - junit-dep + junit ${junit.version} test @@ -203,30 +203,30 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 3.20.0-GA 1.2 4.3.11.Final - 5.1.36 + 5.1.37 7.0.42 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-hibernate3/pom.xml b/spring-hibernate3/pom.xml index 29682a97c398..d88358168fdd 100644 --- a/spring-hibernate3/pom.xml +++ b/spring-hibernate3/pom.xml @@ -73,7 +73,7 @@ junit - junit-dep + junit ${junit.version} test @@ -162,29 +162,29 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 3.20.0-GA 3.6.10.Final - 5.1.36 + 5.1.37 7.0.47 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 3b0e3b6a0073..c8ab1866e2d7 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -80,7 +80,7 @@ junit - junit-dep + junit ${junit.version} test @@ -169,29 +169,29 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 3.20.0-GA 4.3.11.Final - 5.1.36 + 5.1.37 7.0.42 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index f065fe1a81f9..63d97c337bb4 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -85,7 +85,7 @@ junit - junit-dep + junit ${junit.version} test @@ -174,29 +174,29 @@ - 4.2.2.RELEASE + 4.2.4.RELEASE 4.0.2.RELEASE 3.20.0-GA 4.3.11.Final - 5.1.36 + 5.1.37 1.7.2.RELEASE - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 1a462fabaa06..ef6ac59dd4c8 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -60,7 +60,7 @@ junit - junit-dep + junit ${junit.version} test @@ -171,23 +171,23 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 2.1.4.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 4.5 diff --git a/spring-mvc-no-xml/pom.xml b/spring-mvc-no-xml/pom.xml index ecb159f82e8c..da71a699dbde 100644 --- a/spring-mvc-no-xml/pom.xml +++ b/spring-mvc-no-xml/pom.xml @@ -67,7 +67,7 @@ junit - junit-dep + junit ${junit.version} test @@ -144,15 +144,15 @@ - 4.2.2.RELEASE + 4.2.4.RELEASE - 1.7.12 + 1.7.13 1.1.3 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml index 378d2be339bd..896d744e99d9 100644 --- a/spring-mvc-xml/pom.xml +++ b/spring-mvc-xml/pom.xml @@ -73,7 +73,7 @@ junit - junit-dep + junit ${junit.version} test @@ -146,15 +146,15 @@ - 4.2.2.RELEASE + 4.2.4.RELEASE - 1.7.12 + 1.7.13 1.1.3 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 7bc09055422f..e2cf9d7c3e1a 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -128,7 +128,7 @@ junit - junit-dep + junit ${junit.version} test @@ -229,27 +229,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 2.5.1 + 2.5.5 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 @@ -258,7 +258,7 @@ 2.4.1 - 1.7.12 + 1.7.13 1.1.3 diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 72914dd0d599..6abefbd7ecce 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -130,7 +130,7 @@ junit - junit-dep + junit ${junit.version} test @@ -225,27 +225,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-login-and-registration/pom.xml b/spring-security-login-and-registration/pom.xml index df7e6396604e..ffa8be484b81 100644 --- a/spring-security-login-and-registration/pom.xml +++ b/spring-security-login-and-registration/pom.xml @@ -235,10 +235,10 @@ 1.7 4.1.6.RELEASE - 4.0.2.RELEASE + 4.0.3.RELEASE - 1.7.12 + 1.7.13 1.1.3 @@ -251,10 +251,10 @@ 1.8.0.RELEASE - 18.0 + 19.0 - 1.4.16 + 1.4.17 3.3 2.6 2.18.1 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index d6ac323104cc..2e2d434fb288 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -135,7 +135,7 @@ junit - junit-dep + junit ${junit.version} test @@ -230,27 +230,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.5 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index f7ca0868812f..2dce2835f5d9 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -130,7 +130,7 @@ junit - junit-dep + junit ${junit.version} test @@ -225,27 +225,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index a11bc4c374a8..00165bd740c7 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -87,27 +87,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 1f824f50034f..3d76fcb22f47 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -127,7 +127,7 @@ junit - junit-dep + junit ${junit.version} test @@ -222,27 +222,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index f6cd575d57ad..c9a919e6843e 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -135,7 +135,7 @@ junit - junit-dep + junit ${junit.version} test @@ -230,27 +230,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.5 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index a6d5b363813e..1fbeeaa9a932 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -189,7 +189,7 @@ junit - junit-dep + junit ${junit.version} test @@ -287,40 +287,40 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 4.4.3 + 4.4.4 4.5.1 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 - 2.6.0 + 2.8.0 3.3 2.6 2.19 - 1.4.16 + 1.4.17 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index cfe3afbc54b7..20984ba6dd4e 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -140,7 +140,7 @@ junit - junit-dep + junit ${junit.version} test @@ -258,27 +258,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index 1bc107dda268..d20220ac3649 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -177,7 +177,7 @@ junit - junit-dep + junit ${junit.version} test @@ -274,43 +274,43 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 4.4.3 + 4.4.4 4.5.1 - 1.7.12 + 1.7.13 1.1.3 - 2.5.1 + 2.5.5 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 - 2.6.0 + 2.8.0 3.3 2.6 2.19 - 1.4.16 + 1.4.17 diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 04ade99195ca..bed716897b62 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -242,7 +242,7 @@ junit - junit-dep + junit ${junit.version} test @@ -426,32 +426,32 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 1.7.2.RELEASE - 2.5.1 + 2.5.5 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 4.4.1 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 4fd64b5289d4..42381bf607b7 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -142,7 +142,7 @@ junit - junit-dep + junit ${junit.version} test @@ -250,27 +250,27 @@ - 4.2.2.RELEASE - 4.0.2.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 4.3.11.Final - 5.1.36 + 5.1.37 - 1.7.12 + 1.7.13 1.1.3 - 5.2.1.Final + 5.2.2.Final - 18.0 + 19.0 3.4 1.3 - 4.11 + 4.12 1.10.19 From 30f53b76eecd399deff96e41bc932253406d19dc Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Dec 2015 11:37:37 +0200 Subject: [PATCH 020/626] new set test --- .../org/baeldung/guava/GuavaCollectionTypesTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java index 26d3fa90ca5f..2eb5141f8d0a 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java @@ -148,6 +148,15 @@ public void whenCalculatingSetIntersection_thenCorrect() { assertThat(intersection, containsInAnyOrder('b', 'c')); } + @Test + public void whenCalculatingSetSymetricDifference_thenCorrect() { + final Set first = ImmutableSet.of('a', 'b', 'c'); + final Set second = ImmutableSet.of('b', 'c', 'd'); + + final Set intersection = Sets.symmetricDifference(first, second); + assertThat(intersection, containsInAnyOrder('a', 'd')); + } + @Test public void whenCalculatingPowerSet_thenCorrect() { final Set chars = ImmutableSet.of('a', 'b'); From f0284f3fbaf43992afb5d66d9dc60784f70fa493 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 21 Dec 2015 11:53:17 +0200 Subject: [PATCH 021/626] fixes - spelling and security work --- .../org/baeldung/guava/GuavaCollectionTypesTest.java | 2 +- .../org/baeldung/security/MyUserDetailsService.java | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java index 2eb5141f8d0a..9c38afbcc2cf 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java +++ b/guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java @@ -149,7 +149,7 @@ public void whenCalculatingSetIntersection_thenCorrect() { } @Test - public void whenCalculatingSetSymetricDifference_thenCorrect() { + public void whenCalculatingSetSymmetricDifference_thenCorrect() { final Set first = ImmutableSet.of('a', 'b', 'c'); final Set second = ImmutableSet.of('b', 'c', 'd'); diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java index 567fa7717d85..d4b77878be33 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -1,13 +1,11 @@ package org.baeldung.security; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.baeldung.persistence.dao.RoleRepository; import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.model.Privilege; import org.baeldung.persistence.model.Role; @@ -28,9 +26,6 @@ public class MyUserDetailsService implements UserDetailsService { @Autowired private UserRepository userRepository; - @Autowired - private RoleRepository roleRepository; - @Autowired private LoginAttemptService loginAttemptService; @@ -53,7 +48,7 @@ public UserDetails loadUserByUsername(final String email) throws UsernameNotFoun try { final User user = userRepository.findByEmail(email); if (user == null) { - return new org.springframework.security.core.userdetails.User(" ", " ", true, true, true, true, getAuthorities(Arrays.asList(roleRepository.findByName("ROLE_USER")))); + throw new UsernameNotFoundException("No user found with username: " + email); } return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), user.isEnabled(), true, true, true, getAuthorities(user.getRoles())); @@ -90,8 +85,9 @@ private final List getGrantedAuthorities(final List pr private String getClientIP() { final String xfHeader = request.getHeader("X-Forwarded-For"); - if (xfHeader == null) + if (xfHeader == null) { return request.getRemoteAddr(); + } return xfHeader.split(",")[0]; } } From bb6166986e993a66172f73142057ed9dbed93aaf Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 22 Dec 2015 17:43:44 +0200 Subject: [PATCH 022/626] add some gson deserialization examples --- .../baeldung/gson/deserialization/Foo.java | 26 ++++++++++++------ .../deserialization/FooInstanceCreator.java | 14 ++++++++++ .../gson/deserialization/FooWithInner.java | 24 +++++++++++++++++ .../test/GsonDeserializationTest.java | 27 +++++++++++++++++++ 4 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java create mode 100644 gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java b/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java index 64720f63f988..84f8aaef1342 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java +++ b/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java @@ -9,6 +9,10 @@ public Foo(final int intValue, final String stringValue) { this.stringValue = stringValue; } + public Foo(final String stringValue) { + this.stringValue = stringValue; + } + public Foo() { super(); } @@ -19,27 +23,33 @@ public Foo() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + intValue; - result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode()); + result = (prime * result) + intValue; + result = (prime * result) + ((stringValue == null) ? 0 : stringValue.hashCode()); return result; } @Override public boolean equals(final Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } final Foo other = (Foo) obj; - if (intValue != other.intValue) + if (intValue != other.intValue) { return false; + } if (stringValue == null) { - if (other.stringValue != null) + if (other.stringValue != null) { return false; - } else if (!stringValue.equals(other.stringValue)) + } + } else if (!stringValue.equals(other.stringValue)) { return false; + } return true; } diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java b/gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java new file mode 100644 index 000000000000..4df3986ec3b4 --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java @@ -0,0 +1,14 @@ +package org.baeldung.gson.deserialization; + +import java.lang.reflect.Type; + +import com.google.gson.InstanceCreator; + +public class FooInstanceCreator implements InstanceCreator { + + @Override + public Foo createInstance(Type type) { + return new Foo("sample"); + } + +} diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java b/gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java new file mode 100644 index 000000000000..705e534e77a2 --- /dev/null +++ b/gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java @@ -0,0 +1,24 @@ +package org.baeldung.gson.deserialization; + +public class FooWithInner { + public int intValue; + public String stringValue; + public InnerFoo innerFoo; + + public FooWithInner(int intValue, String stringValue, String name) { + super(); + this.intValue = intValue; + this.stringValue = stringValue; + this.innerFoo = new InnerFoo(name); + } + + public class InnerFoo { + public String name; + + public InnerFoo(String name) { + super(); + this.name = name; + } + + } +} diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationTest.java b/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationTest.java index 342b3096d734..072a25e74964 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationTest.java +++ b/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationTest.java @@ -12,6 +12,8 @@ import org.baeldung.gson.deserialization.Foo; import org.baeldung.gson.deserialization.FooDeserializerFromJsonWithDifferentFields; +import org.baeldung.gson.deserialization.FooInstanceCreator; +import org.baeldung.gson.deserialization.FooWithInner; import org.baeldung.gson.deserialization.GenericFoo; import org.junit.Test; @@ -108,4 +110,29 @@ public void whenDeserializingJsonIntoElements_thenCorrect() { assertEquals(targetObject.stringValue, "seven"); } + // new examples + + @Test + public void whenDeserializingToNestedObjects_thenCorrect() { + final String json = "{\"intValue\":1,\"stringValue\":\"one\",\"innerFoo\":{\"name\":\"inner\"}}"; + + final FooWithInner targetObject = new Gson().fromJson(json, FooWithInner.class); + + assertEquals(targetObject.intValue, 1); + assertEquals(targetObject.stringValue, "one"); + assertEquals(targetObject.innerFoo.name, "inner"); + } + + @Test + public void whenDeserializingUsingInstanceCreator_thenCorrect() { + final String json = "{\"intValue\":1}"; + + final GsonBuilder gsonBldr = new GsonBuilder(); + gsonBldr.registerTypeAdapter(Foo.class, new FooInstanceCreator()); + final Foo targetObject = gsonBldr.create().fromJson(json, Foo.class); + + assertEquals(targetObject.intValue, 1); + assertEquals(targetObject.stringValue, "sample"); + } + } From b7bbd201557feeaa79e129c5284234e15687a71d Mon Sep 17 00:00:00 2001 From: Devendra Desale Date: Wed, 23 Dec 2015 14:17:31 +0530 Subject: [PATCH 023/626] updated header to csv --- .../org/baeldung/spring_batch_intro/App.java | 2 +- .../spring_batch_intro/SpringBatchConfig.java | 1 + .../src/main/resources/input/record.csv | 1 + .../src/main/resources/spring-batch-intro.xml | 31 +++++++------------ spring-batch-intro/xml/output.xml | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java index db963fff2058..d6af37595c74 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java @@ -27,7 +27,7 @@ public static void main(String[] args) { try { JobExecution execution = jobLauncher.run(job, new JobParameters()); System.out.println("Job Status : " + execution.getStatus()); - System.out.println("Job completed"); + System.out.println("Job succeeded"); } catch (Exception e) { e.printStackTrace(); System.out.println("Job failed"); diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java index f0e3b364b66a..a024cbc04e9f 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java +++ b/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java @@ -50,6 +50,7 @@ public ItemReader itemReader() DefaultLineMapper lineMapper = new DefaultLineMapper(); lineMapper.setLineTokenizer(tokenizer); lineMapper.setFieldSetMapper(new RecordFieldSetMapper()); + reader.setLinesToSkip(1); reader.setLineMapper(lineMapper); return reader; } diff --git a/spring-batch-intro/src/main/resources/input/record.csv b/spring-batch-intro/src/main/resources/input/record.csv index 3a1437eed5f1..e554becb2ab4 100644 --- a/spring-batch-intro/src/main/resources/input/record.csv +++ b/spring-batch-intro/src/main/resources/input/record.csv @@ -1,3 +1,4 @@ +username, user_id, transaction_date, transaction_amount devendra, 1234, 31/10/2015, 10000 john, 2134, 3/12/2015, 12321 robin, 2134, 2/02/2015, 23411 \ No newline at end of file diff --git a/spring-batch-intro/src/main/resources/spring-batch-intro.xml b/spring-batch-intro/src/main/resources/spring-batch-intro.xml index 3b1f11521f92..93606d232f54 100644 --- a/spring-batch-intro/src/main/resources/spring-batch-intro.xml +++ b/spring-batch-intro/src/main/resources/spring-batch-intro.xml @@ -1,18 +1,15 @@ - + http://www.springframework.org/schema/batch/spring-batch-3.0.xsd + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-4.2.xsd +"> - - + - @@ -20,23 +17,21 @@ + value="username,userid,transaction_date,transaction_amount" /> - + - + - + @@ -45,13 +40,11 @@ - org.baeldung.spring_batch_intro.model.Transaction - + org.baeldung.spring_batch_intro.model.Transaction - diff --git a/spring-batch-intro/xml/output.xml b/spring-batch-intro/xml/output.xml index 9e57fa38f207..acf4969341d0 100644 --- a/spring-batch-intro/xml/output.xml +++ b/spring-batch-intro/xml/output.xml @@ -1 +1 @@ -10000.02015-10-31T00:00:00+08:001234devendra12321.02015-12-03T00:00:00+08:002134john23411.02015-02-02T00:00:00+08:002134robin \ No newline at end of file +10000.02015-10-31T00:00:00+05:301234devendra12321.02015-12-03T00:00:00+05:302134john23411.02015-02-02T00:00:00+05:302134robin \ No newline at end of file From 62fd1e6eda38346f8a02481767953d0e52907767 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 24 Dec 2015 11:39:47 +0200 Subject: [PATCH 024/626] minor cleanup --- spring-data-cassandra/.classpath | 31 +++++++ spring-data-cassandra/.project | 29 ++++++ .../cassandra/config/CassandraConfig.java | 6 +- .../spring/data/cassandra/model/Book.java | 22 +++-- .../cassandra/repository/BookRepository.java | 2 + .../BookRepositoryIntegrationTest.java | 63 +++++++------ .../repository/CQLQueriesIntegrationTest.java | 73 ++++++++------- .../CassandraTemplateIntegrationTest.java | 88 ++++++++++--------- spring-data-mongodb/.classpath | 37 ++++++++ spring-data-mongodb/.project | 29 ++++++ spring-mvc-java/pom.xml | 4 +- 11 files changed, 269 insertions(+), 115 deletions(-) create mode 100644 spring-data-cassandra/.classpath create mode 100644 spring-data-cassandra/.project create mode 100644 spring-data-mongodb/.classpath create mode 100644 spring-data-mongodb/.project diff --git a/spring-data-cassandra/.classpath b/spring-data-cassandra/.classpath new file mode 100644 index 000000000000..698778fef337 --- /dev/null +++ b/spring-data-cassandra/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-data-cassandra/.project b/spring-data-cassandra/.project new file mode 100644 index 000000000000..239fa4f00275 --- /dev/null +++ b/spring-data-cassandra/.project @@ -0,0 +1,29 @@ + + + spring-data-cassandra + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/config/CassandraConfig.java b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/config/CassandraConfig.java index 5f2c4c6d477d..2edd5551a5a7 100644 --- a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/config/CassandraConfig.java +++ b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/config/CassandraConfig.java @@ -17,8 +17,8 @@ @PropertySource(value = { "classpath:cassandra.properties" }) @EnableCassandraRepositories(basePackages = "org.baeldung.spring.data.cassandra.repository") public class CassandraConfig extends AbstractCassandraConfiguration { - private static final Log LOGGER = LogFactory.getLog(CassandraConfig.class); + @Autowired private Environment environment; @@ -27,15 +27,17 @@ protected String getKeyspaceName() { return environment.getProperty("cassandra.keyspace"); } + @Override @Bean public CassandraClusterFactoryBean cluster() { - CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); + final CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); cluster.setContactPoints(environment.getProperty("cassandra.contactpoints")); cluster.setPort(Integer.parseInt(environment.getProperty("cassandra.port"))); LOGGER.info("Cluster created with contact points [" + environment.getProperty("cassandra.contactpoints") + "] " + "& port [" + Integer.parseInt(environment.getProperty("cassandra.port")) + "]."); return cluster; } + @Override @Bean public CassandraMappingContext cassandraMapping() throws ClassNotFoundException { return new BasicCassandraMappingContext(); diff --git a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/model/Book.java b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/model/Book.java index 6c099d99bc7b..a8ec81d6b583 100644 --- a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/model/Book.java +++ b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/model/Book.java @@ -1,28 +1,31 @@ package org.baeldung.spring.data.cassandra.model; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + import org.springframework.cassandra.core.Ordering; import org.springframework.cassandra.core.PrimaryKeyType; import org.springframework.data.cassandra.mapping.Column; import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.mapping.Table; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - @Table public class Book { + @PrimaryKeyColumn(name = "id", ordinal = 0, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING) private UUID id; + @PrimaryKeyColumn(name = "title", ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String title; @PrimaryKeyColumn(name = "publisher", ordinal = 2, type = PrimaryKeyType.PARTITIONED) private String publisher; + @Column private Set tags = new HashSet<>(); - public Book(UUID id, String title, String publisher, Set tags) { + public Book(final UUID id, final String title, final String publisher, final Set tags) { this.id = id; this.title = title; this.publisher = publisher; @@ -45,19 +48,20 @@ public Set getTags() { return tags; } - public void setId(UUID id) { + public void setId(final UUID id) { this.id = id; } - public void setTitle(String title) { + public void setTitle(final String title) { this.title = title; } - public void setPublisher(String publisher) { + public void setPublisher(final String publisher) { this.publisher = publisher; } - public void setTags(Set tags) { + public void setTags(final Set tags) { this.tags = tags; } + } diff --git a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/repository/BookRepository.java b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/repository/BookRepository.java index e37ae78b595b..66d656ac3a0f 100644 --- a/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/repository/BookRepository.java +++ b/spring-data-cassandra/src/main/java/org/baeldung/spring/data/cassandra/repository/BookRepository.java @@ -7,6 +7,8 @@ @Repository public interface BookRepository extends CassandraRepository { + @Query("select * from book where title = ?0 and publisher=?1") Iterable findByTitleAndPublisher(String title, String publisher); + } diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/BookRepositoryIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/BookRepositoryIntegrationTest.java index e5a723714531..8cbcdc3195ac 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/BookRepositoryIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/BookRepositoryIntegrationTest.java @@ -1,9 +1,11 @@ package org.baeldung.spring.data.cassandra.repository; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.utils.UUIDs; -import com.google.common.collect.ImmutableSet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.io.IOException; +import java.util.HashMap; + import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -11,7 +13,11 @@ import org.baeldung.spring.data.cassandra.config.CassandraConfig; import org.baeldung.spring.data.cassandra.model.Book; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cassandra.core.cql.CqlIdentifier; @@ -19,16 +25,14 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.io.IOException; -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) public class BookRepositoryIntegrationTest { - private static final Log LOGGER = LogFactory.getLog(BookRepositoryIntegrationTest.class); public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; @@ -43,13 +47,14 @@ public class BookRepositoryIntegrationTest { @Autowired private CassandraAdminOperations adminTemplate; + // + @BeforeClass public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(); - Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1") - .withPort(9142).build(); + final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); LOGGER.info("Server Started at 127.0.0.1:9142... "); - Session session = cluster.connect(); + final Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); LOGGER.info("KeySpace created and activated."); @@ -63,54 +68,54 @@ public void createTable() throws InterruptedException, TTransportException, Conf @Test public void whenSavingBook_thenAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", - "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); bookRepository.save(ImmutableSet.of(javaBook)); - Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); + final Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); assertEquals(javaBook.getId(), books.iterator().next().getId()); } @Test public void whenUpdatingBooks_thenAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); bookRepository.save(ImmutableSet.of(javaBook)); - Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); + final Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); javaBook.setTitle("Head First Java Second Edition"); bookRepository.save(ImmutableSet.of(javaBook)); - Iterable updateBooks = bookRepository.findByTitleAndPublisher("Head First Java Second Edition", "O'Reilly Media"); + final Iterable updateBooks = bookRepository.findByTitleAndPublisher("Head First Java Second Edition", "O'Reilly Media"); assertEquals(javaBook.getTitle(), updateBooks.iterator().next().getTitle()); } @Test(expected = java.util.NoSuchElementException.class) public void whenDeletingExistingBooks_thenNotAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); bookRepository.save(ImmutableSet.of(javaBook)); bookRepository.delete(javaBook); - Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); + final Iterable books = bookRepository.findByTitleAndPublisher("Head First Java", "O'Reilly Media"); assertNotEquals(javaBook.getId(), books.iterator().next().getId()); } @Test public void whenSavingBooks_thenAllShouldAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", - "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", - "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); bookRepository.save(ImmutableSet.of(javaBook)); bookRepository.save(ImmutableSet.of(dPatternBook)); - Iterable books = bookRepository.findAll(); + final Iterable books = bookRepository.findAll(); int bookCount = 0; - for (Book book : books) bookCount++; + for (final Book book : books) { + bookCount++; + } assertEquals(bookCount, 2); } @After public void dropTable() { - adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME)); + adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME)); } @AfterClass public static void stopCassandraEmbedded() { EmbeddedCassandraServerHelper.cleanEmbeddedCassandra(); } + } diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java index 031b5c0b6f1b..584d5f868b5c 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java @@ -1,12 +1,13 @@ package org.baeldung.spring.data.cassandra.repository; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.querybuilder.Insert; -import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; -import com.datastax.driver.core.utils.UUIDs; -import com.google.common.collect.ImmutableSet; +import static junit.framework.TestCase.assertEquals; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -14,7 +15,11 @@ import org.baeldung.spring.data.cassandra.config.CassandraConfig; import org.baeldung.spring.data.cassandra.model.Book; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cassandra.core.cql.CqlIdentifier; @@ -23,18 +28,17 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; - -import static junit.framework.TestCase.assertEquals; +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.Insert; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) public class CQLQueriesIntegrationTest { - private static final Log LOGGER = LogFactory.getLog(CQLQueriesIntegrationTest.class); public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; @@ -49,12 +53,14 @@ public class CQLQueriesIntegrationTest { @Autowired private CassandraOperations cassandraTemplate; + // + @BeforeClass public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(25000); - Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); + final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); LOGGER.info("Server Started at 127.0.0.1:9142... "); - Session session = cluster.connect(); + final Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); LOGGER.info("KeySpace created and activated."); @@ -68,40 +74,40 @@ public void createTable() throws InterruptedException, TTransportException, Conf @Test public void whenSavingBook_thenAvailableOnRetrieval_usingQueryBuilder() { - UUID uuid = UUIDs.timeBased(); - Insert insert = QueryBuilder.insertInto(DATA_TABLE_NAME).value("id", uuid).value("title", "Head First Java").value("publisher", "OReilly Media").value("tags", ImmutableSet.of("Software")); + final UUID uuid = UUIDs.timeBased(); + final Insert insert = QueryBuilder.insertInto(DATA_TABLE_NAME).value("id", uuid).value("title", "Head First Java").value("publisher", "OReilly Media").value("tags", ImmutableSet.of("Software")); cassandraTemplate.execute(insert); - Select select = QueryBuilder.select().from("book").limit(10); - Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(uuid, retrievedBook.getId()); } @Test public void whenSavingBook_thenAvailableOnRetrieval_usingCQLStatements() { - UUID uuid = UUIDs.timeBased(); - String insertCql = "insert into book (id, title, publisher, tags) values " + "(" + uuid + ", 'Head First Java', 'OReilly Media', {'Software'})"; + final UUID uuid = UUIDs.timeBased(); + final String insertCql = "insert into book (id, title, publisher, tags) values " + "(" + uuid + ", 'Head First Java', 'OReilly Media', {'Software'})"; cassandraTemplate.execute(insertCql); - Select select = QueryBuilder.select().from("book").limit(10); - Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(uuid, retrievedBook.getId()); } @Test public void whenSavingBook_thenAvailableOnRetrieval_usingPreparedStatements() throws InterruptedException { - UUID uuid = UUIDs.timeBased(); - String insertPreparedCql = "insert into book (id, title, publisher, tags) values (?, ?, ?, ?)"; - List singleBookArgsList = new ArrayList<>(); - List> bookList = new ArrayList<>(); + final UUID uuid = UUIDs.timeBased(); + final String insertPreparedCql = "insert into book (id, title, publisher, tags) values (?, ?, ?, ?)"; + final List singleBookArgsList = new ArrayList<>(); + final List> bookList = new ArrayList<>(); singleBookArgsList.add(uuid); singleBookArgsList.add("Head First Java"); singleBookArgsList.add("OReilly Media"); singleBookArgsList.add(ImmutableSet.of("Software")); bookList.add(singleBookArgsList); cassandraTemplate.ingest(insertPreparedCql, bookList); - //This may not be required, just added to avoid any transient issues + // This may not be required, just added to avoid any transient issues Thread.sleep(5000); - Select select = QueryBuilder.select().from("book"); - Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book"); + final Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(uuid, retrievedBook.getId()); } @@ -114,4 +120,5 @@ public void dropTable() { public static void stopCassandraEmbedded() { EmbeddedCassandraServerHelper.cleanEmbeddedCassandra(); } + } diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java index 35de50864197..e331ac3cd409 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java @@ -1,11 +1,15 @@ package org.baeldung.spring.data.cassandra.repository; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; -import com.datastax.driver.core.utils.UUIDs; -import com.google.common.collect.ImmutableSet; +import static junit.framework.TestCase.assertNull; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -13,7 +17,11 @@ import org.baeldung.spring.data.cassandra.config.CassandraConfig; import org.baeldung.spring.data.cassandra.model.Book; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cassandra.core.cql.CqlIdentifier; @@ -22,20 +30,16 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) public class CassandraTemplateIntegrationTest { - private static final Log LOGGER = LogFactory.getLog(CassandraTemplateIntegrationTest.class); public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; @@ -50,12 +54,14 @@ public class CassandraTemplateIntegrationTest { @Autowired private CassandraOperations cassandraTemplate; + // + @BeforeClass public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(); - Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); + final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); LOGGER.info("Server Started at 127.0.0.1:9142... "); - Session session = cluster.connect(); + final Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); LOGGER.info("KeySpace created and activated."); @@ -69,24 +75,24 @@ public void createTable() throws InterruptedException, TTransportException, Conf @Test public void whenSavingBook_thenAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); cassandraTemplate.insert(javaBook); - Select select = QueryBuilder.select().from("book").where(QueryBuilder.eq("title", "Head First Java")).and(QueryBuilder.eq("publisher", "O'Reilly Media")).limit(10); - Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").where(QueryBuilder.eq("title", "Head First Java")).and(QueryBuilder.eq("publisher", "O'Reilly Media")).limit(10); + final Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(javaBook.getId(), retrievedBook.getId()); } @Test public void whenSavingBooks_thenAllAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - List bookList = new ArrayList<>(); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final List bookList = new ArrayList<>(); bookList.add(javaBook); bookList.add(dPatternBook); cassandraTemplate.insert(bookList); - Select select = QueryBuilder.select().from("book").limit(10); - List retrievedBooks = cassandraTemplate.select(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final List retrievedBooks = cassandraTemplate.select(select, Book.class); assertThat(retrievedBooks.size(), is(2)); assertEquals(javaBook.getId(), retrievedBooks.get(0).getId()); assertEquals(dPatternBook.getId(), retrievedBooks.get(1).getId()); @@ -94,45 +100,45 @@ public void whenSavingBooks_thenAllAvailableOnRetrieval() { @Test public void whenUpdatingBook_thenShouldUpdatedOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); cassandraTemplate.insert(javaBook); - Select select = QueryBuilder.select().from("book").limit(10); - Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); retrievedBook.setTags(ImmutableSet.of("Java", "Programming")); cassandraTemplate.update(retrievedBook); - Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); + final Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); assertEquals(retrievedBook.getTags(), retrievedUpdatedBook.getTags()); } @Test public void whenDeletingASelectedBook_thenNotAvailableOnRetrieval() throws InterruptedException { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "OReilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "OReilly Media", ImmutableSet.of("Computer", "Software")); cassandraTemplate.insert(javaBook); cassandraTemplate.delete(javaBook); - Select select = QueryBuilder.select().from("book").limit(10); - Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); assertNull(retrievedUpdatedBook); } @Test public void whenDeletingAllBooks_thenNotAvailableOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); cassandraTemplate.insert(javaBook); cassandraTemplate.insert(dPatternBook); cassandraTemplate.deleteAll(Book.class); - Select select = QueryBuilder.select().from("book").limit(10); - Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); + final Select select = QueryBuilder.select().from("book").limit(10); + final Book retrievedUpdatedBook = cassandraTemplate.selectOne(select, Book.class); assertNull(retrievedUpdatedBook); } @Test public void whenAddingBooks_thenCountShouldBeCorrectOnRetrieval() { - Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); - Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book javaBook = new Book(UUIDs.timeBased(), "Head First Java", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); + final Book dPatternBook = new Book(UUIDs.timeBased(), "Head Design Patterns", "O'Reilly Media", ImmutableSet.of("Computer", "Software")); cassandraTemplate.insert(javaBook); cassandraTemplate.insert(dPatternBook); - long bookCount = cassandraTemplate.count(Book.class); + final long bookCount = cassandraTemplate.count(Book.class); assertEquals(2, bookCount); } diff --git a/spring-data-mongodb/.classpath b/spring-data-mongodb/.classpath new file mode 100644 index 000000000000..baf7c981310c --- /dev/null +++ b/spring-data-mongodb/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-data-mongodb/.project b/spring-data-mongodb/.project new file mode 100644 index 000000000000..e3d768757313 --- /dev/null +++ b/spring-data-mongodb/.project @@ -0,0 +1,29 @@ + + + spring-data-mongodb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index ef6ac59dd4c8..d9a578cb8ca3 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -169,6 +169,7 @@ + 4.2.4.RELEASE @@ -197,8 +198,9 @@ 2.6 2.18.1 2.7 - 1.4.15 + 1.4.17 1.8.7 + \ No newline at end of file From 1a0d627c19d246d6667065ec9a389075cc2ca051 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 24 Dec 2015 14:15:21 +0200 Subject: [PATCH 025/626] update xml configuration --- .../baeldung/spring/SecSecurityConfig.java | 1 + .../resources/webSecurityConfig-basic.xml | 41 +++++++++++++++++++ .../src/main/resources/webSecurityConfig.xml | 16 ++++++-- 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 spring-security-login-and-registration/src/main/resources/webSecurityConfig-basic.xml diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4863187bbadf..677ad514e56f 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -18,6 +18,7 @@ @Configuration @ComponentScan(basePackages = { "org.baeldung.security" }) +// @ImportResource({ "classpath:webSecurityConfig.xml" }) @EnableWebSecurity public class SecSecurityConfig extends WebSecurityConfigurerAdapter { diff --git a/spring-security-login-and-registration/src/main/resources/webSecurityConfig-basic.xml b/spring-security-login-and-registration/src/main/resources/webSecurityConfig-basic.xml new file mode 100644 index 000000000000..bf85a09b6215 --- /dev/null +++ b/spring-security-login-and-registration/src/main/resources/webSecurityConfig-basic.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml index 677b0864c440..3141b19142a2 100644 --- a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml @@ -1,9 +1,10 @@ @@ -36,5 +37,14 @@ + + + + + + + + + \ No newline at end of file From d52ab2212ae46b66fe7b1fa534bfe1d32e263c04 Mon Sep 17 00:00:00 2001 From: dasvipin5585 Date: Fri, 25 Dec 2015 23:02:13 +0530 Subject: [PATCH 026/626] Java - Try with resources code commit --- .../java8/JavaTryWithResourcesTest.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java diff --git a/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java b/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java new file mode 100644 index 000000000000..ae56099e0d0e --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java @@ -0,0 +1,94 @@ +package org.baeldung.java8; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.Scanner; + +import org.junit.Assert; +import org.junit.Test; + +public class JavaTryWithResourcesTest { + + private static final String TEST_STRING_HELLO_WORLD = "Hello World"; + private Date resource1Date, resource2Date; + + /* + * Example for using Try_with_resources + */ + @Test + public void whenWritingToStringWriter_thenCorrectlyWritten() { + + StringWriter sw = new StringWriter(); + try (PrintWriter pw = new PrintWriter(sw, true)) { + pw.print(TEST_STRING_HELLO_WORLD); + } + + Assert.assertEquals(sw.getBuffer().toString(), TEST_STRING_HELLO_WORLD); + } + + /* + * Example for using multiple resources + */ + @Test + public void givenStringToScanner_whenWritingToStringWriter_thenCorrectlyWritten() { + + StringWriter sw = new StringWriter(); + try (Scanner sc = new Scanner(TEST_STRING_HELLO_WORLD); PrintWriter pw = new PrintWriter(sw, true)) { + while (sc.hasNext()) { + pw.print(sc.nextLine()); + } + } + + Assert.assertEquals(sw.getBuffer().toString(), TEST_STRING_HELLO_WORLD); + } + + /* + * Example to show order in which the resources are closed + */ + @Test + public void whenFirstAutoClosableResourceIsinitializedFirst_thenFirstAutoClosableResourceIsReleasedFirst() throws Exception { + + try (AutoCloseableResourcesFirst af = new AutoCloseableResourcesFirst(); AutoCloseableResourcesSecond as = new AutoCloseableResourcesSecond()) { + af.doSomething(); + as.doSomething(); + } + Assert.assertTrue(resource1Date.after(resource2Date)); + } + + class AutoCloseableResourcesFirst implements AutoCloseable { + + public AutoCloseableResourcesFirst() { + System.out.println("Constructor -> AutoCloseableResources_First"); + } + + public void doSomething() { + System.out.println("Something -> AutoCloseableResources_First"); + } + + @Override + public void close() throws Exception { + System.out.println("Closed AutoCloseableResources_First"); + resource1Date = new Date(); + + } + } + + class AutoCloseableResourcesSecond implements AutoCloseable { + + public AutoCloseableResourcesSecond() { + System.out.println("Constructor -> AutoCloseableResources_Second"); + } + + public void doSomething() { + System.out.println("Something -> AutoCloseableResources_Second"); + } + + @Override + public void close() throws Exception { + System.out.println("Closed AutoCloseableResources_Second"); + resource2Date = new Date(); + Thread.sleep(10000); + } + } +} From 8b75f3da06e5f88427864e1a0254c1c5f843e350 Mon Sep 17 00:00:00 2001 From: sameira Date: Fri, 25 Dec 2015 23:37:49 +0530 Subject: [PATCH 027/626] Adding Spring Data Redis Examples --- spring-data-radis/pom.xml | 78 ++++++++++++++++++ .../spring/data/radis/model/Student.java | 64 ++++++++++++++ .../data/radis/repo/StudentRepository.java | 17 ++++ .../radis/repo/StudentRepositoryImpl.java | 37 +++++++++ .../src/main/resources/logback.xml | 20 +++++ .../src/main/resources/spring-config.xml | 19 +++++ spring-data-radis/src/main/resources/test.png | Bin 0 -> 855 bytes .../radis/repo/StudentRepositoryTest.java | 58 +++++++++++++ 8 files changed, 293 insertions(+) create mode 100644 spring-data-radis/pom.xml create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java create mode 100644 spring-data-radis/src/main/resources/logback.xml create mode 100644 spring-data-radis/src/main/resources/spring-config.xml create mode 100644 spring-data-radis/src/main/resources/test.png create mode 100644 spring-data-radis/src/test/java/org/baeldung/spring/data/radis/repo/StudentRepositoryTest.java diff --git a/spring-data-radis/pom.xml b/spring-data-radis/pom.xml new file mode 100644 index 000000000000..4d3b467d7bd7 --- /dev/null +++ b/spring-data-radis/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + org.baeldung + sprint-data-radis + 0.0.1-SNAPSHOT + jar + + sprint-data-radis + + + UTF-8 + 4.2.2.RELEASE + 1.6.2.RELEASE + 0.8.0 + + + + + org.springframework.data + spring-data-redis + ${spring-data-redis} + + + + cglib + cglib-nodep + 2.2 + + + + log4j + log4j + 1.2.16 + + + + redis.clients + jedis + 2.5.1 + jar + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-context + ${spring.version} + + + + junit + junit + 4.12 + test + + + + org.springframework + spring-test + ${spring.version} + test + + + + com.lordofthejars + nosqlunit-redis + ${nosqlunit.version} + + + + diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java new file mode 100644 index 000000000000..4b8a90943ce3 --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java @@ -0,0 +1,64 @@ +package org.baeldung.spring.data.radis.model; + + +import java.io.Serializable; + +public class Student implements Serializable { + + private static final long serialVersionUID = -1907106213598514113L; + + public enum Gender{Male, Female} + private String id; + private String name; + private Gender gender; + private int grade; + + public Student(String id, String name, Gender gender, int grade) { + this.id = id; + this.name = name; + this.gender = gender; + this.grade = grade; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Gender getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender; + } + + public int getGrade() { + return grade; + } + + public void setGrade(int grade) { + this.grade = grade; + } + + @Override + public String toString() { + return "Student{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", gender=" + gender + + ", grade=" + grade + + '}'; + } +} \ No newline at end of file diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java new file mode 100644 index 000000000000..bc1201478ce2 --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.data.radis.repo; + +import org.baeldung.spring.data.radis.model.Student; + +import java.util.Map; + +public interface StudentRepository { + void saveStudent(Student person); + + void updateStudent(Student student); + + Student findStudent(String id); + + Map findAllStudents(); + + void deleteStudent(String id); +} diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java new file mode 100644 index 000000000000..3033020c2496 --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java @@ -0,0 +1,37 @@ +package org.baeldung.spring.data.radis.repo; + +import org.baeldung.spring.data.radis.model.Student; +import org.springframework.data.redis.core.RedisTemplate; + +import java.util.Map; + +public class StudentRepositoryImpl implements StudentRepository { + + private static final String KEY = "Student"; + + private RedisTemplate redisTemplate; + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + public void saveStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public void updateStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public Student findStudent(final String id) { + return (Student)this.redisTemplate.opsForHash().get(KEY, id); + } + + public Map findAllStudents() { + return this.redisTemplate.opsForHash().entries(KEY); + } + + public void deleteStudent(final String id) { + this.redisTemplate.opsForHash().delete(KEY,id); + } +} diff --git a/spring-data-radis/src/main/resources/logback.xml b/spring-data-radis/src/main/resources/logback.xml new file mode 100644 index 000000000000..215eeede64ee --- /dev/null +++ b/spring-data-radis/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/spring-config.xml b/spring-data-radis/src/main/resources/spring-config.xml new file mode 100644 index 000000000000..950cd9a6fdbc --- /dev/null +++ b/spring-data-radis/src/main/resources/spring-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/test.png b/spring-data-radis/src/main/resources/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086 GIT binary patch literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); + assertEquals(retrievedStudent.size(), 2); + } + + @Test + public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); + studentRepository.saveStudent(student); + studentRepository.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); + assertNull(retrievedStudent); + } +} \ No newline at end of file From 31b5d9ff16dc3322a7f6a9f11ef7206d014fe2e1 Mon Sep 17 00:00:00 2001 From: sameira Date: Fri, 25 Dec 2015 23:54:54 +0530 Subject: [PATCH 028/626] Adding Spring Data Redis Examples --- spring-data-redis/pom.xml | 78 ++++++++++++++++++ .../spring/data/redis/model/Student.java | 64 ++++++++++++++ .../data/redis/repo/StudentRepository.java | 17 ++++ .../redis/repo/StudentRepositoryImpl.java | 37 +++++++++ .../src/main/resources/logback.xml | 20 +++++ .../src/main/resources/spring-config.xml | 19 +++++ spring-data-redis/src/main/resources/test.png | Bin 0 -> 855 bytes .../redis/repo/StudentRepositoryTest.java | 58 +++++++++++++ 8 files changed, 293 insertions(+) create mode 100644 spring-data-redis/pom.xml create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java create mode 100644 spring-data-redis/src/main/resources/logback.xml create mode 100644 spring-data-redis/src/main/resources/spring-config.xml create mode 100644 spring-data-redis/src/main/resources/test.png create mode 100644 spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java diff --git a/spring-data-redis/pom.xml b/spring-data-redis/pom.xml new file mode 100644 index 000000000000..57bc76d5ff7a --- /dev/null +++ b/spring-data-redis/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + org.baeldung + sprint-data-redis + 0.0.1-SNAPSHOT + jar + + sprint-data-redis + + + UTF-8 + 4.2.2.RELEASE + 1.6.2.RELEASE + 0.8.0 + + + + + org.springframework.data + spring-data-redis + ${spring-data-redis} + + + + cglib + cglib-nodep + 2.2 + + + + log4j + log4j + 1.2.16 + + + + redis.clients + jedis + 2.5.1 + jar + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-context + ${spring.version} + + + + junit + junit + 4.12 + test + + + + org.springframework + spring-test + ${spring.version} + test + + + + com.lordofthejars + nosqlunit-redis + ${nosqlunit.version} + + + + diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java new file mode 100644 index 000000000000..4302edfab246 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -0,0 +1,64 @@ +package org.baeldung.spring.data.redis.model; + + +import java.io.Serializable; + +public class Student implements Serializable { + + private static final long serialVersionUID = -1907106213598514113L; + + public enum Gender{Male, Female} + private String id; + private String name; + private Gender gender; + private int grade; + + public Student(String id, String name, Gender gender, int grade) { + this.id = id; + this.name = name; + this.gender = gender; + this.grade = grade; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Gender getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender; + } + + public int getGrade() { + return grade; + } + + public void setGrade(int grade) { + this.grade = grade; + } + + @Override + public String toString() { + return "Student{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", gender=" + gender + + ", grade=" + grade + + '}'; + } +} \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java new file mode 100644 index 000000000000..ae7e63c88875 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.data.redis.repo; + +import org.baeldung.spring.data.redis.model.Student; + +import java.util.Map; + +public interface StudentRepository { + void saveStudent(Student person); + + void updateStudent(Student student); + + Student findStudent(String id); + + Map findAllStudents(); + + void deleteStudent(String id); +} diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java new file mode 100644 index 000000000000..6be8d7fd2097 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -0,0 +1,37 @@ +package org.baeldung.spring.data.redis.repo; + +import org.baeldung.spring.data.redis.model.Student; +import org.springframework.data.redis.core.RedisTemplate; + +import java.util.Map; + +public class StudentRepositoryImpl implements StudentRepository { + + private static final String KEY = "Student"; + + private RedisTemplate redisTemplate; + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + public void saveStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public void updateStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public Student findStudent(final String id) { + return (Student)this.redisTemplate.opsForHash().get(KEY, id); + } + + public Map findAllStudents() { + return this.redisTemplate.opsForHash().entries(KEY); + } + + public void deleteStudent(final String id) { + this.redisTemplate.opsForHash().delete(KEY,id); + } +} diff --git a/spring-data-redis/src/main/resources/logback.xml b/spring-data-redis/src/main/resources/logback.xml new file mode 100644 index 000000000000..215eeede64ee --- /dev/null +++ b/spring-data-redis/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-redis/src/main/resources/spring-config.xml b/spring-data-redis/src/main/resources/spring-config.xml new file mode 100644 index 000000000000..4ca240d3f106 --- /dev/null +++ b/spring-data-redis/src/main/resources/spring-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-redis/src/main/resources/test.png b/spring-data-redis/src/main/resources/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086 GIT binary patch literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); + assertEquals(retrievedStudent.size(), 2); + } + + @Test + public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); + studentRepository.saveStudent(student); + studentRepository.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); + assertNull(retrievedStudent); + } +} \ No newline at end of file From fa8427aa9d3ad82c3d2a00b7d73ec47315599ad7 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:01:31 +0530 Subject: [PATCH 029/626] Adding ReadMe File --- spring-data-redis/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 spring-data-redis/README.md diff --git a/spring-data-redis/README.md b/spring-data-redis/README.md new file mode 100644 index 000000000000..716d52a56374 --- /dev/null +++ b/spring-data-redis/README.md @@ -0,0 +1,15 @@ +## Spring Data Cassandra + +### Relevant Articles: +- [Introduction to Spring Data Redis] + +### Build the Project with Tests Running +``` +mvn clean install +``` + +### Run Tests Directly +``` +mvn test +``` + From be8feed4917b6d6bb7a4a97df116861e8dfc3a39 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:02:28 +0530 Subject: [PATCH 030/626] Updated README file --- spring-data-redis/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-redis/README.md b/spring-data-redis/README.md index 716d52a56374..b9b2e5d93d89 100644 --- a/spring-data-redis/README.md +++ b/spring-data-redis/README.md @@ -1,4 +1,4 @@ -## Spring Data Cassandra +## Spring Data Redis ### Relevant Articles: - [Introduction to Spring Data Redis] From eea69135f75df9ec7beec5dd5aff3fc5aecb6ac4 Mon Sep 17 00:00:00 2001 From: eugenp Date: Fri, 25 Dec 2015 20:45:45 +0200 Subject: [PATCH 031/626] general cleanup work --- .../java8/JavaTryWithResourcesTest.java | 24 +++++++------------ ...st.java => CqlQueriesIntegrationTest.java} | 4 ++-- 2 files changed, 10 insertions(+), 18 deletions(-) rename spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/{CQLQueriesIntegrationTest.java => CqlQueriesIntegrationTest.java} (98%) diff --git a/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java b/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java index ae56099e0d0e..a59682c5350c 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java @@ -13,13 +13,12 @@ public class JavaTryWithResourcesTest { private static final String TEST_STRING_HELLO_WORLD = "Hello World"; private Date resource1Date, resource2Date; - /* - * Example for using Try_with_resources - */ + // tests + + /* Example for using Try_with_resources */ @Test public void whenWritingToStringWriter_thenCorrectlyWritten() { - - StringWriter sw = new StringWriter(); + final StringWriter sw = new StringWriter(); try (PrintWriter pw = new PrintWriter(sw, true)) { pw.print(TEST_STRING_HELLO_WORLD); } @@ -27,13 +26,11 @@ public void whenWritingToStringWriter_thenCorrectlyWritten() { Assert.assertEquals(sw.getBuffer().toString(), TEST_STRING_HELLO_WORLD); } - /* - * Example for using multiple resources - */ + /* Example for using multiple resources */ @Test public void givenStringToScanner_whenWritingToStringWriter_thenCorrectlyWritten() { - StringWriter sw = new StringWriter(); + final StringWriter sw = new StringWriter(); try (Scanner sc = new Scanner(TEST_STRING_HELLO_WORLD); PrintWriter pw = new PrintWriter(sw, true)) { while (sc.hasNext()) { pw.print(sc.nextLine()); @@ -43,12 +40,9 @@ public void givenStringToScanner_whenWritingToStringWriter_thenCorrectlyWritten( Assert.assertEquals(sw.getBuffer().toString(), TEST_STRING_HELLO_WORLD); } - /* - * Example to show order in which the resources are closed - */ + /* Example to show order in which the resources are closed */ @Test public void whenFirstAutoClosableResourceIsinitializedFirst_thenFirstAutoClosableResourceIsReleasedFirst() throws Exception { - try (AutoCloseableResourcesFirst af = new AutoCloseableResourcesFirst(); AutoCloseableResourcesSecond as = new AutoCloseableResourcesSecond()) { af.doSomething(); as.doSomething(); @@ -57,7 +51,6 @@ public void whenFirstAutoClosableResourceIsinitializedFirst_thenFirstAutoClosabl } class AutoCloseableResourcesFirst implements AutoCloseable { - public AutoCloseableResourcesFirst() { System.out.println("Constructor -> AutoCloseableResources_First"); } @@ -70,12 +63,10 @@ public void doSomething() { public void close() throws Exception { System.out.println("Closed AutoCloseableResources_First"); resource1Date = new Date(); - } } class AutoCloseableResourcesSecond implements AutoCloseable { - public AutoCloseableResourcesSecond() { System.out.println("Constructor -> AutoCloseableResources_Second"); } @@ -91,4 +82,5 @@ public void close() throws Exception { Thread.sleep(10000); } } + } diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CqlQueriesIntegrationTest.java similarity index 98% rename from spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java rename to spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CqlQueriesIntegrationTest.java index 584d5f868b5c..f7e42ae23b21 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CqlQueriesIntegrationTest.java @@ -38,8 +38,8 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) -public class CQLQueriesIntegrationTest { - private static final Log LOGGER = LogFactory.getLog(CQLQueriesIntegrationTest.class); +public class CqlQueriesIntegrationTest { + private static final Log LOGGER = LogFactory.getLog(CqlQueriesIntegrationTest.class); public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };"; From 948a7279fcc2fe29c278def0c3fc4e0a5bc7d322 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:38:18 +0530 Subject: [PATCH 032/626] Adding eclipse formatting --- spring-data-redis/pom.xml | 2 -- .../baeldung/spring/data/redis/model/Student.java | 13 +++++-------- .../spring/data/redis/repo/StudentRepository.java | 3 ++- .../data/redis/repo/StudentRepositoryImpl.java | 4 ++-- .../data/redis/repo/StudentRepositoryTest.java | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/spring-data-redis/pom.xml b/spring-data-redis/pom.xml index 57bc76d5ff7a..98da69934c3f 100644 --- a/spring-data-redis/pom.xml +++ b/spring-data-redis/pom.xml @@ -7,8 +7,6 @@ 0.0.1-SNAPSHOT jar - sprint-data-redis - UTF-8 4.2.2.RELEASE diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java index 4302edfab246..a37ecb8dd9a1 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -1,13 +1,15 @@ package org.baeldung.spring.data.redis.model; - import java.io.Serializable; public class Student implements Serializable { private static final long serialVersionUID = -1907106213598514113L; - public enum Gender{Male, Female} + public enum Gender { + Male, Female + } + private String id; private String name; private Gender gender; @@ -54,11 +56,6 @@ public void setGrade(int grade) { @Override public String toString() { - return "Student{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", gender=" + gender + - ", grade=" + grade + - '}'; + return "Student{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", gender=" + gender + ", grade=" + grade + '}'; } } \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java index ae7e63c88875..59b3a4c5e8ce 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -5,8 +5,9 @@ import java.util.Map; public interface StudentRepository { + void saveStudent(Student person); - + void updateStudent(Student student); Student findStudent(String id); diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java index 6be8d7fd2097..d964b830d2cd 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -24,7 +24,7 @@ public void updateStudent(final Student student) { } public Student findStudent(final String id) { - return (Student)this.redisTemplate.opsForHash().get(KEY, id); + return (Student) this.redisTemplate.opsForHash().get(KEY, id); } public Map findAllStudents() { @@ -32,6 +32,6 @@ public Map findAllStudents() { } public void deleteStudent(final String id) { - this.redisTemplate.opsForHash().delete(KEY,id); + this.redisTemplate.opsForHash().delete(KEY, id); } } diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java index 19e59f69d1f6..a68d93c173e4 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertNull; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:/spring-config.xml"}) +@ContextConfiguration(locations = { "classpath:/spring-config.xml" }) public class StudentRepositoryTest { @Autowired From 97ca1980acc48dbe9051b95a338b089d019b124e Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:47:00 +0530 Subject: [PATCH 033/626] Removing invalid folder --- spring-data-radis/pom.xml | 78 ------------------ .../spring/data/radis/model/Student.java | 64 -------------- .../data/radis/repo/StudentRepository.java | 17 ---- .../radis/repo/StudentRepositoryImpl.java | 37 --------- .../src/main/resources/logback.xml | 20 ----- .../src/main/resources/spring-config.xml | 19 ----- spring-data-radis/src/main/resources/test.png | Bin 855 -> 0 bytes .../radis/repo/StudentRepositoryTest.java | 58 ------------- 8 files changed, 293 deletions(-) delete mode 100644 spring-data-radis/pom.xml delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java delete mode 100644 spring-data-radis/src/main/resources/logback.xml delete mode 100644 spring-data-radis/src/main/resources/spring-config.xml delete mode 100644 spring-data-radis/src/main/resources/test.png delete mode 100644 spring-data-radis/src/test/java/org/baeldung/spring/data/radis/repo/StudentRepositoryTest.java diff --git a/spring-data-radis/pom.xml b/spring-data-radis/pom.xml deleted file mode 100644 index 4d3b467d7bd7..000000000000 --- a/spring-data-radis/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - 4.0.0 - - org.baeldung - sprint-data-radis - 0.0.1-SNAPSHOT - jar - - sprint-data-radis - - - UTF-8 - 4.2.2.RELEASE - 1.6.2.RELEASE - 0.8.0 - - - - - org.springframework.data - spring-data-redis - ${spring-data-redis} - - - - cglib - cglib-nodep - 2.2 - - - - log4j - log4j - 1.2.16 - - - - redis.clients - jedis - 2.5.1 - jar - - - - org.springframework - spring-core - ${spring.version} - - - - org.springframework - spring-context - ${spring.version} - - - - junit - junit - 4.12 - test - - - - org.springframework - spring-test - ${spring.version} - test - - - - com.lordofthejars - nosqlunit-redis - ${nosqlunit.version} - - - - diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java deleted file mode 100644 index 4b8a90943ce3..000000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.baeldung.spring.data.radis.model; - - -import java.io.Serializable; - -public class Student implements Serializable { - - private static final long serialVersionUID = -1907106213598514113L; - - public enum Gender{Male, Female} - private String id; - private String name; - private Gender gender; - private int grade; - - public Student(String id, String name, Gender gender, int grade) { - this.id = id; - this.name = name; - this.gender = gender; - this.grade = grade; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Gender getGender() { - return gender; - } - - public void setGender(Gender gender) { - this.gender = gender; - } - - public int getGrade() { - return grade; - } - - public void setGrade(int grade) { - this.grade = grade; - } - - @Override - public String toString() { - return "Student{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", gender=" + gender + - ", grade=" + grade + - '}'; - } -} \ No newline at end of file diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java deleted file mode 100644 index bc1201478ce2..000000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring.data.radis.repo; - -import org.baeldung.spring.data.radis.model.Student; - -import java.util.Map; - -public interface StudentRepository { - void saveStudent(Student person); - - void updateStudent(Student student); - - Student findStudent(String id); - - Map findAllStudents(); - - void deleteStudent(String id); -} diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java deleted file mode 100644 index 3033020c2496..000000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.baeldung.spring.data.radis.repo; - -import org.baeldung.spring.data.radis.model.Student; -import org.springframework.data.redis.core.RedisTemplate; - -import java.util.Map; - -public class StudentRepositoryImpl implements StudentRepository { - - private static final String KEY = "Student"; - - private RedisTemplate redisTemplate; - - public void setRedisTemplate(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - - public void saveStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); - } - - public void updateStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); - } - - public Student findStudent(final String id) { - return (Student)this.redisTemplate.opsForHash().get(KEY, id); - } - - public Map findAllStudents() { - return this.redisTemplate.opsForHash().entries(KEY); - } - - public void deleteStudent(final String id) { - this.redisTemplate.opsForHash().delete(KEY,id); - } -} diff --git a/spring-data-radis/src/main/resources/logback.xml b/spring-data-radis/src/main/resources/logback.xml deleted file mode 100644 index 215eeede64ee..000000000000 --- a/spring-data-radis/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/spring-config.xml b/spring-data-radis/src/main/resources/spring-config.xml deleted file mode 100644 index 950cd9a6fdbc..000000000000 --- a/spring-data-radis/src/main/resources/spring-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/test.png b/spring-data-radis/src/main/resources/test.png deleted file mode 100644 index c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); - assertEquals(retrievedStudent.size(), 2); - } - - @Test - public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { - final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - studentRepository.saveStudent(student); - studentRepository.deleteStudent(student.getId()); - final Student retrievedStudent = studentRepository.findStudent(student.getId()); - assertNull(retrievedStudent); - } -} \ No newline at end of file From 93d6e3f67a4e218933950c22ee03f63f4fc18b20 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 27 Dec 2015 23:55:25 +0200 Subject: [PATCH 034/626] testing work --- spring-hibernate4/pom.xml | 5 +++++ spring-jpa/pom.xml | 5 +++++ .../baeldung/persistence/service/FooServiceSortingTests.java | 4 ---- .../{JPAMultipleDBTest.java => JpaMultipleDBTest.java} | 5 ++++- .../baeldung/persistence/service/PersistenceTestSuite.java | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) rename spring-jpa/src/test/java/org/baeldung/persistence/service/{JPAMultipleDBTest.java => JpaMultipleDBTest.java} (98%) diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index c8ab1866e2d7..8fabb56ab74c 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -53,6 +53,11 @@ hibernate-validator ${hibernate-validator.version} + + javax.el + javax.el-api + 2.2.5 + diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 63d97c337bb4..20be07ca5bb0 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -58,6 +58,11 @@ hibernate-validator ${hibernate-validator.version} + + javax.el + javax.el-api + 2.2.5 + diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java index c12dfda50c6a..319d36151e98 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/FooServiceSortingTests.java @@ -15,7 +15,6 @@ import org.baeldung.persistence.model.Foo; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; @@ -28,9 +27,6 @@ public class FooServiceSortingTests { @PersistenceContext private EntityManager entityManager; - @Autowired - private FooService service; - // tests @Test diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/JPAMultipleDBTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/JpaMultipleDBTest.java similarity index 98% rename from spring-jpa/src/test/java/org/baeldung/persistence/service/JPAMultipleDBTest.java rename to spring-jpa/src/test/java/org/baeldung/persistence/service/JpaMultipleDBTest.java index 4c6b02ec3d30..427e182d9ea7 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/JPAMultipleDBTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/JpaMultipleDBTest.java @@ -21,13 +21,16 @@ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { UserConfig.class, ProductConfig.class }) @TransactionConfiguration -public class JPAMultipleDBTest { +public class JpaMultipleDBTest { + @Autowired private UserRepository userRepository; @Autowired private ProductRepository productRepository; + // tests + @Test @Transactional("userTransactionManager") public void whenCreatingUser_thenCreated() { diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java index f6c41258d4d8..919171de9f25 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/PersistenceTestSuite.java @@ -8,6 +8,7 @@ FooPaginationPersistenceIntegrationTest.class ,FooServicePersistenceIntegrationTest.class ,FooServiceSortingTests.class + ,JpaMultipleDBTest.class // manual only // ,FooServiceSortingWitNullsManualTest.class }) // @formatter:on From c5eb1c570a7d9708d51c1420be5d9314cbd6cf94 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 28 Dec 2015 12:04:08 +0200 Subject: [PATCH 035/626] modify ldap configuration --- spring-security-mvc-ldap/pom.xml | 19 +--------- .../org/baeldung/SampleLDAPApplication.java | 4 +-- .../org/baeldung/security/SecurityConfig.java | 13 +++---- .../src/main/resources/templates/login.html | 2 +- .../src/main/resources/webSecurityConfig.xml | 36 +++++++++++++++++++ 5 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 00165bd740c7..5282f76a7e9b 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -35,29 +35,13 @@ spring-security-ldap - - org.springframework.ldap - spring-ldap-core - 2.0.3.RELEASE - - - org.springframework.ldap - spring-ldap-core-tiger - 2.0.3.RELEASE - - org.apache.directory.server apacheds-server-jndi 1.5.5 - - org.apache.mina - mina-core - 2.0.9 - - + @@ -74,7 +58,6 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} 1.8 1.8 diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java index 454e52d1d5f4..4bcb25504604 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java @@ -3,16 +3,14 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * Main Application Class - uses Spring Boot. Just run this as a normal Java * class to run up a Jetty Server (on http://localhost:8080) - * + * */ -@EnableScheduling @EnableAutoConfiguration @ComponentScan("org.baeldung") public class SampleLDAPApplication extends WebMvcConfigurerAdapter { diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java index c9bb5b74ae70..ee72ee7891e9 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java @@ -1,29 +1,26 @@ package org.baeldung.security; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.stereotype.Controller; /** * Security Configuration - LDAP and HTTP Authorizations. */ -@EnableAutoConfiguration -@ComponentScan -@Controller +@Configuration +// @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("member={0}").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif"); + auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("(member={0})").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif"); } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated(); - http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/"); + http.formLogin().loginPage("/login").permitAll().loginProcessingUrl("/j_spring_security_check").and().logout().logoutSuccessUrl("/"); } } diff --git a/spring-security-mvc-ldap/src/main/resources/templates/login.html b/spring-security-mvc-ldap/src/main/resources/templates/login.html index e3a18c2e486a..81f62fde1371 100644 --- a/spring-security-mvc-ldap/src/main/resources/templates/login.html +++ b/spring-security-mvc-ldap/src/main/resources/templates/login.html @@ -21,7 +21,7 @@

You have been logged out

There was an error, please try again

Login with Username and Password

-
+
diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml new file mode 100644 index 000000000000..6bd2c422d820 --- /dev/null +++ b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 3052a5305efc230836481eb036717fce990b7ed7 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 28 Dec 2015 18:23:13 +0200 Subject: [PATCH 036/626] spring batch work --- .../.classpath | 6 +++++- {spring-batch-intro => spring-batch}/.project | 8 +++++++- {spring-batch-intro => spring-batch}/pom.xml | 7 +++---- .../org/baeldung/spring_batch_intro/App.java | 18 +++++++----------- .../spring_batch_intro/SpringBatchConfig.java | 0 .../spring_batch_intro/SpringConfig.java | 0 .../spring_batch_intro/model/Transaction.java | 0 .../service/CustomItemProcessor.java | 0 .../service/RecordFieldSetMapper.java | 0 .../src/main/resources/input/record.csv | 0 .../src/main/resources/spring-batch-intro.xml | 0 .../src/main/resources/spring.xml | 0 .../xml/output.xml | 0 13 files changed, 22 insertions(+), 17 deletions(-) rename {spring-batch-intro => spring-batch}/.classpath (83%) rename {spring-batch-intro => spring-batch}/.project (69%) rename {spring-batch-intro => spring-batch}/pom.xml (85%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/App.java (60%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java (100%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java (100%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java (100%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java (100%) rename {spring-batch-intro => spring-batch}/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java (100%) rename {spring-batch-intro => spring-batch}/src/main/resources/input/record.csv (100%) rename {spring-batch-intro => spring-batch}/src/main/resources/spring-batch-intro.xml (100%) rename {spring-batch-intro => spring-batch}/src/main/resources/spring.xml (100%) rename {spring-batch-intro => spring-batch}/xml/output.xml (100%) diff --git a/spring-batch-intro/.classpath b/spring-batch/.classpath similarity index 83% rename from spring-batch-intro/.classpath rename to spring-batch/.classpath index 395dbde027f6..e7ac9faf1160 100644 --- a/spring-batch-intro/.classpath +++ b/spring-batch/.classpath @@ -12,7 +12,11 @@ - + + + + + diff --git a/spring-batch-intro/.project b/spring-batch/.project similarity index 69% rename from spring-batch-intro/.project rename to spring-batch/.project index 032f8a95417f..0159a7237c75 100644 --- a/spring-batch-intro/.project +++ b/spring-batch/.project @@ -1,6 +1,6 @@ - spring-batch-intro + spring-batch @@ -15,8 +15,14 @@ + + org.springframework.ide.eclipse.core.springbuilder + + + + org.springframework.ide.eclipse.core.springnature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature diff --git a/spring-batch-intro/pom.xml b/spring-batch/pom.xml similarity index 85% rename from spring-batch-intro/pom.xml rename to spring-batch/pom.xml index 28d48c594e3c..c85aeff6f3cc 100644 --- a/spring-batch-intro/pom.xml +++ b/spring-batch/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.baeldung - spring-batch-intro + spring-batch 0.1-SNAPSHOT jar - spring-batch-intro + spring-batch http://maven.apache.org diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/App.java similarity index 60% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/App.java index d6af37595c74..2ce4dae6e698 100644 --- a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/App.java +++ b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/App.java @@ -4,31 +4,27 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - public class App { - public static void main(String[] args) { + public static void main(final String[] args) { // Spring Java config - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(SpringConfig.class); context.register(SpringBatchConfig.class); context.refresh(); // Spring xml config - // ApplicationContext context = new ClassPathXmlApplicationContext( - // "spring-batch-intro.xml"); + // ApplicationContext context = new ClassPathXmlApplicationContext("spring-batch.xml"); - JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); - Job job = (Job) context.getBean("firstBatchJob"); + final JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); + final Job job = (Job) context.getBean("firstBatchJob"); System.out.println("Starting the batch job"); try { - JobExecution execution = jobLauncher.run(job, new JobParameters()); + final JobExecution execution = jobLauncher.run(job, new JobParameters()); System.out.println("Job Status : " + execution.getStatus()); System.out.println("Job succeeded"); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); System.out.println("Job failed"); } diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java similarity index 100% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java similarity index 100% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java similarity index 100% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java similarity index 100% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java diff --git a/spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java similarity index 100% rename from spring-batch-intro/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java rename to spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/RecordFieldSetMapper.java diff --git a/spring-batch-intro/src/main/resources/input/record.csv b/spring-batch/src/main/resources/input/record.csv similarity index 100% rename from spring-batch-intro/src/main/resources/input/record.csv rename to spring-batch/src/main/resources/input/record.csv diff --git a/spring-batch-intro/src/main/resources/spring-batch-intro.xml b/spring-batch/src/main/resources/spring-batch-intro.xml similarity index 100% rename from spring-batch-intro/src/main/resources/spring-batch-intro.xml rename to spring-batch/src/main/resources/spring-batch-intro.xml diff --git a/spring-batch-intro/src/main/resources/spring.xml b/spring-batch/src/main/resources/spring.xml similarity index 100% rename from spring-batch-intro/src/main/resources/spring.xml rename to spring-batch/src/main/resources/spring.xml diff --git a/spring-batch-intro/xml/output.xml b/spring-batch/xml/output.xml similarity index 100% rename from spring-batch-intro/xml/output.xml rename to spring-batch/xml/output.xml From a19854cceb9353a5eafcff737ef1b25a3c021648 Mon Sep 17 00:00:00 2001 From: Alexander Odinets Date: Wed, 30 Dec 2015 16:56:51 +0300 Subject: [PATCH 037/626] Audit with JPA callbacks, Hibernate Envers and Spring Data JPA --- spring-hibernate4/pom.xml | 80 ++++++++-- .../persistence/dao/IBarAuditableDao.java | 8 + .../persistence/dao/IBarCrudRepository.java | 10 ++ .../org/baeldung/persistence/dao/IBarDao.java | 8 + .../persistence/dao/IFooAuditableDao.java | 8 + .../persistence/dao/common/AbstractDao.java | 14 ++ .../common/AbstractHibernateAuditableDao.java | 37 +++++ .../dao/common/AbstractHibernateDao.java | 24 ++- .../dao/common/AbstractJpaDao.java | 56 +++++++ .../dao/common/IAuditOperations.java | 14 ++ .../persistence/dao/impl/BarAuditableDao.java | 28 ++++ .../baeldung/persistence/dao/impl/BarDao.java | 19 +++ .../persistence/dao/impl/BarJpaDao.java | 19 +++ .../persistence/dao/impl/FooAuditableDao.java | 17 +++ .../baeldung/persistence/dao/impl/FooDao.java | 2 +- .../org/baeldung/persistence/model/Bar.java | 138 ++++++++++++++++- .../org/baeldung/persistence/model/Foo.java | 4 + .../service/IBarAuditableService.java | 8 + .../persistence/service/IBarService.java | 8 + .../service/IFooAuditableService.java | 8 + .../AbstractHibernateAuditableService.java | 30 ++++ .../common/AbstractHibernateService.java | 42 ++++++ .../service/common/AbstractJpaService.java | 42 ++++++ .../service/common/AbstractService.java | 2 - .../common/AbstractSpringDataJpaService.java | 46 ++++++ .../service/impl/BarAuditableService.java | 41 +++++ .../service/impl/BarJpaService.java | 30 ++++ .../persistence/service/impl/BarService.java | 30 ++++ .../service/impl/BarSpringDataJpaService.java | 26 ++++ .../service/impl/ChildService.java | 4 +- .../service/impl/FooAuditableService.java | 41 +++++ .../persistence/service/impl/FooService.java | 6 +- .../service/impl/ParentService.java | 4 +- .../baeldung/spring/PersistenceConfig.java | 111 +++++++++++++- .../resources/persistence-mysql.properties | 3 + .../src/main/resources/webSecurityConfig.xml | 3 +- .../persistence/audit/AuditTestSuite.java | 14 ++ .../audit/EnversFooBarAuditTest.java | 142 ++++++++++++++++++ .../persistence/audit/JPABarAuditTest.java | 106 +++++++++++++ .../audit/SpringDataJPABarAuditTest.java | 76 ++++++++++ .../FooServicePersistenceIntegrationTest.java | 2 + 41 files changed, 1263 insertions(+), 48 deletions(-) create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarAuditableDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarCrudRepository.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooAuditableDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractJpaDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IAuditOperations.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarAuditableDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarJpaDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooAuditableDao.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarAuditableService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooAuditableService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateAuditableService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractJpaService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractSpringDataJpaService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarAuditableService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarJpaService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarSpringDataJpaService.java create mode 100644 spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooAuditableService.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/audit/AuditTestSuite.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/audit/EnversFooBarAuditTest.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/audit/JPABarAuditTest.java create mode 100644 spring-hibernate4/src/test/java/org/baeldung/persistence/audit/SpringDataJPABarAuditTest.java diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml index 3b0e3b6a0073..711f9b35335e 100644 --- a/spring-hibernate4/pom.xml +++ b/spring-hibernate4/pom.xml @@ -15,6 +15,16 @@ spring-context ${org.springframework.version} + + org.springframework + spring-aspects + ${org.springframework.version} + + + org.springframework.security + spring-security-core + ${org.springframework.security.version} + @@ -23,21 +33,35 @@ spring-orm ${org.springframework.version} + + org.springframework.data + spring-data-jpa + ${org.springframework.data.version} + org.hibernate hibernate-core ${hibernate.version} - org.javassist - javassist - ${javassist.version} + org.hibernate + hibernate-envers + ${hibernate-envers.version} + + + javax.transaction + jta + ${jta.version} + + + javax.el + javax.el-api + ${el-api.version} mysql mysql-connector-java ${mysql-connector-java.version} - runtime @@ -77,6 +101,13 @@ ${org.springframework.version} test + + + org.springframework.security + spring-security-test + ${org.springframework.security.version} + test + junit @@ -85,12 +116,6 @@ test - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - org.hamcrest hamcrest-library @@ -162,7 +187,28 @@ - + @@ -171,19 +217,22 @@ 4.2.2.RELEASE 4.0.2.RELEASE - 3.20.0-GA - + 1.9.2.RELEASE + 4.3.11.Final + ${hibernate.version} 5.1.36 7.0.42 + 1.1 + 2.2.4 1.7.12 1.1.3 - + - 5.2.1.Final + 4.3.2.Final 18.0 @@ -204,6 +253,7 @@ 2.18.1 2.7 1.4.15 + diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarAuditableDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarAuditableDao.java new file mode 100644 index 000000000000..060922942b6f --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarAuditableDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.model.Bar; + +public interface IBarAuditableDao extends IBarDao, IAuditOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarCrudRepository.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarCrudRepository.java new file mode 100644 index 000000000000..70fffd9d801f --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarCrudRepository.java @@ -0,0 +1,10 @@ +package org.baeldung.persistence.dao; + +import java.io.Serializable; + +import org.baeldung.persistence.model.Bar; +import org.springframework.data.repository.CrudRepository; + +public interface IBarCrudRepository extends CrudRepository { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarDao.java new file mode 100644 index 000000000000..02814b39b8aa --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IBarDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Bar; + +public interface IBarDao extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooAuditableDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooAuditableDao.java new file mode 100644 index 000000000000..ee0cc1fb8aa0 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/IFooAuditableDao.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooAuditableDao extends IFooDao, IAuditOperations { + // +} \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractDao.java new file mode 100644 index 000000000000..6a1790ad3e38 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractDao.java @@ -0,0 +1,14 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import com.google.common.base.Preconditions; + +public abstract class AbstractDao implements IOperations { + + protected Class clazz; + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java new file mode 100644 index 000000000000..f0886c612e93 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java @@ -0,0 +1,37 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.AuditReaderFactory; +import org.hibernate.envers.query.AuditQuery; + +@SuppressWarnings("unchecked") +public class AbstractHibernateAuditableDao extends AbstractHibernateDao implements IAuditOperations { + + @Override + public List getEntitiesAtRevision(final Number revision) { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forEntitiesAtRevision(clazz, revision); + final List resultList = query.getResultList(); + return resultList; + } + + @Override + public List getEntitiesModifiedAtRevision(final Number revision) { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forEntitiesModifiedAtRevision(clazz, revision); + final List resultList = query.getResultList(); + return resultList; + } + + @Override + public List getRevisions() { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, true, true); + final List resultList = query.getResultList(); + return resultList; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java index 65e57afcb3e5..dd22d94503f4 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -10,55 +10,49 @@ import com.google.common.base.Preconditions; @SuppressWarnings("unchecked") -public abstract class AbstractHibernateDao implements IOperations { - private Class clazz; +public abstract class AbstractHibernateDao extends AbstractDao implements IOperations { @Autowired - private SessionFactory sessionFactory; + protected SessionFactory sessionFactory; // API - protected final void setClazz(final Class clazzToSet) { - clazz = Preconditions.checkNotNull(clazzToSet); - } - @Override - public final T findOne(final long id) { + public T findOne(final long id) { return (T) getCurrentSession().get(clazz, id); } @Override - public final List findAll() { + public List findAll() { return getCurrentSession().createQuery("from " + clazz.getName()).list(); } @Override - public final void create(final T entity) { + public void create(final T entity) { Preconditions.checkNotNull(entity); - // getCurrentSession().persist(entity); getCurrentSession().saveOrUpdate(entity); } @Override - public final T update(final T entity) { + public T update(final T entity) { Preconditions.checkNotNull(entity); return (T) getCurrentSession().merge(entity); } @Override - public final void delete(final T entity) { + public void delete(final T entity) { Preconditions.checkNotNull(entity); getCurrentSession().delete(entity); } @Override - public final void deleteById(final long entityId) { + public void deleteById(final long entityId) { final T entity = findOne(entityId); Preconditions.checkState(entity != null); delete(entity); } - protected final Session getCurrentSession() { + protected Session getCurrentSession() { return sessionFactory.getCurrentSession(); } diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractJpaDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractJpaDao.java new file mode 100644 index 000000000000..7e08151beaa1 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/AbstractJpaDao.java @@ -0,0 +1,56 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +public class AbstractJpaDao extends AbstractDao implements IOperations { + + @PersistenceContext + private EntityManager em; + + // API + + @Override + public T findOne(final long id) { + return em.find(clazz, Long.valueOf(id).intValue()); + } + + @Override + public List findAll() { + final CriteriaBuilder cb = em.getCriteriaBuilder(); + final CriteriaQuery cq = cb.createQuery(clazz); + final Root rootEntry = cq.from(clazz); + final CriteriaQuery all = cq.select(rootEntry); + final TypedQuery allQuery = em.createQuery(all); + return allQuery.getResultList(); + } + + @Override + public void create(final T entity) { + em.persist(entity); + } + + @Override + public T update(final T entity) { + em.merge(entity); + return entity; + } + + @Override + public void delete(final T entity) { + em.remove(entity); + } + + @Override + public void deleteById(final long entityId) { + delete(findOne(entityId)); + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IAuditOperations.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IAuditOperations.java new file mode 100644 index 000000000000..bcc1059dbe45 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/common/IAuditOperations.java @@ -0,0 +1,14 @@ +package org.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IAuditOperations { + + List getEntitiesAtRevision(Number revision); + + List getEntitiesModifiedAtRevision(Number revision); + + List getRevisions(); + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarAuditableDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarAuditableDao.java new file mode 100644 index 000000000000..bddd98bcfbcf --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarAuditableDao.java @@ -0,0 +1,28 @@ +package org.baeldung.persistence.dao.impl; + +import java.util.List; + +import org.baeldung.persistence.dao.IBarAuditableDao; +import org.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; +import org.baeldung.persistence.model.Bar; + +public class BarAuditableDao extends AbstractHibernateAuditableDao implements IBarAuditableDao { + + public BarAuditableDao() { + super(); + + setClazz(Bar.class); + } + + // API + + @Override + public List getRevisions() { + final List resultList = super.getRevisions(); + for (final Bar bar : resultList) { + bar.getFooSet().size(); // force FooSet initialization + } + return resultList; + } + +} \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarDao.java new file mode 100644 index 000000000000..ba48581edb5b --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarDao.java @@ -0,0 +1,19 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.common.AbstractHibernateDao; +import org.baeldung.persistence.model.Bar; +import org.springframework.stereotype.Repository; + +@Repository +public class BarDao extends AbstractHibernateDao implements IBarDao { + + public BarDao() { + super(); + + setClazz(Bar.class); + } + + // API + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarJpaDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarJpaDao.java new file mode 100644 index 000000000000..cd167dd64fb1 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/BarJpaDao.java @@ -0,0 +1,19 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.common.AbstractJpaDao; +import org.baeldung.persistence.model.Bar; +import org.springframework.stereotype.Repository; + +@Repository +public class BarJpaDao extends AbstractJpaDao implements IBarDao { + + public BarJpaDao() { + super(); + + setClazz(Bar.class); + } + + // API + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooAuditableDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooAuditableDao.java new file mode 100644 index 000000000000..ee9cc639b55b --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooAuditableDao.java @@ -0,0 +1,17 @@ +package org.baeldung.persistence.dao.impl; + +import org.baeldung.persistence.dao.IFooAuditableDao; +import org.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; +import org.baeldung.persistence.model.Foo; + +public class FooAuditableDao extends AbstractHibernateAuditableDao implements IFooAuditableDao { + + public FooAuditableDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java index eb3a66126caa..b8360160dac4 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java @@ -6,7 +6,7 @@ import org.springframework.stereotype.Repository; @Repository -public class FooDao extends AbstractHibernateDaoimplements IFooDao { +public class FooDao extends AbstractHibernateDao implements IFooDao { public FooDao() { super(); diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java index 410ad79b025a..1d4ec697419b 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java @@ -1,26 +1,66 @@ package org.baeldung.persistence.model; import java.io.Serializable; +import java.util.Date; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EntityListeners; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; import org.hibernate.annotations.OrderBy; +import org.hibernate.envers.Audited; +import org.jboss.logging.Logger; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import com.google.common.collect.Sets; @Entity @NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") +@Audited +@EntityListeners(AuditingEntityListener.class) public class Bar implements Serializable { + private static Logger logger = Logger.getLogger(Bar.class); + + public enum OPERATION { + INSERT, UPDATE, DELETE; + private String value; + + OPERATION() { + value = toString(); + } + + public String getValue() { + return value; + } + + public static OPERATION parse(final String value) { + OPERATION operation = null; + for (final OPERATION op : OPERATION.values()) { + if (op.getValue().equals(value)) { + operation = op; + break; + } + } + return operation; + } + }; + @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") @@ -31,8 +71,31 @@ public class Bar implements Serializable { @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OrderBy(clause = "NAME DESC") + // @NotAudited private Set fooSet = Sets.newHashSet(); + @Column(name = "operation") + private String operation; + + @Column(name = "timestamp") + private long timestamp; + + @Column(name = "created_date") + @CreatedDate + private long createdDate; + + @Column(name = "modified_date") + @LastModifiedDate + private long modifiedDate; + + @Column(name = "created_by") + @CreatedBy + private String createdBy; + + @Column(name = "modified_by") + @LastModifiedBy + private String modifiedBy; + public Bar() { super(); } @@ -69,7 +132,57 @@ public void setName(final String name) { this.name = name; } - // + public OPERATION getOperation() { + return OPERATION.parse(operation); + } + + public void setOperation(final OPERATION operation) { + this.operation = operation.getValue(); + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(final long timestamp) { + this.timestamp = timestamp; + } + + public long getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(final long createdDate) { + this.createdDate = createdDate; + } + + public long getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(final long modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(final String createdBy) { + this.createdBy = createdBy; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(final String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public void setOperation(final String operation) { + this.operation = operation; + } @Override public int hashCode() { @@ -103,4 +216,27 @@ public String toString() { return builder.toString(); } + @PrePersist + public void onPrePersist() { + logger.info("@PrePersist"); + audit(OPERATION.INSERT); + } + + @PreUpdate + public void onPreUpdate() { + logger.info("@PreUpdate"); + audit(OPERATION.UPDATE); + } + + @PreRemove + public void onPreRemove() { + logger.info("@PreRemove"); + audit(OPERATION.DELETE); + } + + private void audit(final OPERATION operation) { + setOperation(operation); + setTimestamp((new Date()).getTime()); + } + } diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java index 974535e05801..9a96594cfea8 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java @@ -12,7 +12,11 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import org.hibernate.envers.Audited; + @Entity +@Audited +// @Proxy(lazy = false) public class Foo implements Serializable { @Id diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarAuditableService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarAuditableService.java new file mode 100644 index 000000000000..b481dfefeb6c --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarAuditableService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.model.Bar; + +public interface IBarAuditableService extends IBarService, IAuditOperations { + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarService.java new file mode 100644 index 000000000000..145a0d54db1b --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IBarService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Bar; + +public interface IBarService extends IOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooAuditableService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooAuditableService.java new file mode 100644 index 000000000000..2bd9ccb2082c --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/IFooAuditableService.java @@ -0,0 +1,8 @@ +package org.baeldung.persistence.service; + +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.model.Foo; + +public interface IFooAuditableService extends IFooService, IAuditOperations { + // +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateAuditableService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateAuditableService.java new file mode 100644 index 000000000000..f9b670360794 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateAuditableService.java @@ -0,0 +1,30 @@ +package org.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "hibernateTransactionManager") +public abstract class AbstractHibernateAuditableService extends AbstractHibernateService implements IOperations, IAuditOperations { + + @Override + public List getEntitiesAtRevision(final Number revision) { + return getAuditableDao().getEntitiesAtRevision(revision); + } + + @Override + public List getEntitiesModifiedAtRevision(final Number revision) { + return getAuditableDao().getEntitiesModifiedAtRevision(revision); + } + + @Override + public List getRevisions() { + return getAuditableDao().getRevisions(); + } + + abstract protected IAuditOperations getAuditableDao(); + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateService.java new file mode 100644 index 000000000000..3539a5689685 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractHibernateService.java @@ -0,0 +1,42 @@ +package org.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "hibernateTransactionManager") +public abstract class AbstractHibernateService extends AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return super.findOne(id); + } + + @Override + public List findAll() { + return super.findAll(); + } + + @Override + public void create(final T entity) { + super.create(entity); + } + + @Override + public T update(final T entity) { + return super.update(entity); + } + + @Override + public void delete(final T entity) { + super.delete(entity); + } + + @Override + public void deleteById(final long entityId) { + super.deleteById(entityId); + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractJpaService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractJpaService.java new file mode 100644 index 000000000000..2b41edda1205 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractJpaService.java @@ -0,0 +1,42 @@ +package org.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "jpaTransactionManager") +public abstract class AbstractJpaService extends AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return super.findOne(id); + } + + @Override + public List findAll() { + return super.findAll(); + } + + @Override + public void create(final T entity) { + super.create(entity); + } + + @Override + public T update(final T entity) { + return super.update(entity); + } + + @Override + public void delete(final T entity) { + super.delete(entity); + } + + @Override + public void deleteById(final long entityId) { + super.deleteById(entityId); + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 3b32bc3ebb59..530bc5e95665 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -4,9 +4,7 @@ import java.util.List; import org.baeldung.persistence.dao.common.IOperations; -import org.springframework.transaction.annotation.Transactional; -@Transactional public abstract class AbstractService implements IOperations { @Override diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractSpringDataJpaService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractSpringDataJpaService.java new file mode 100644 index 000000000000..dfb73204c2f6 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/common/AbstractSpringDataJpaService.java @@ -0,0 +1,46 @@ +package org.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import org.baeldung.persistence.dao.common.IOperations; +import org.springframework.data.repository.CrudRepository; +import org.springframework.transaction.annotation.Transactional; + +import com.google.common.collect.Lists; + +@Transactional(value = "jpaTransactionManager") +public abstract class AbstractSpringDataJpaService implements IOperations { + + @Override + public T findOne(final long id) { + return getDao().findOne(Long.valueOf(id)); + } + + @Override + public List findAll() { + return Lists.newArrayList(getDao().findAll()); + } + + @Override + public void create(final T entity) { + getDao().save(entity); + } + + @Override + public T update(final T entity) { + return getDao().save(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().delete(Long.valueOf(entityId)); + } + + protected abstract CrudRepository getDao(); +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarAuditableService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarAuditableService.java new file mode 100644 index 000000000000..9124a41a564e --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarAuditableService.java @@ -0,0 +1,41 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.dao.IBarAuditableDao; +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.service.IBarAuditableService; +import org.baeldung.persistence.service.common.AbstractHibernateAuditableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarAuditableService extends AbstractHibernateAuditableService implements IBarAuditableService { + + @Autowired + @Qualifier("barHibernateDao") + private IBarDao dao; + + @Autowired + @Qualifier("barHibernateAuditableDao") + private IBarAuditableDao auditDao; + + public BarAuditableService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + + @Override + protected IAuditOperations getAuditableDao() { + return auditDao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarJpaService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarJpaService.java new file mode 100644 index 000000000000..d78fbdd7c403 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarJpaService.java @@ -0,0 +1,30 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.persistence.service.common.AbstractJpaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarJpaService extends AbstractJpaService implements IBarService { + + @Autowired + @Qualifier("barJpaDao") + private IBarDao dao; + + public BarJpaService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} \ No newline at end of file diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarService.java new file mode 100644 index 000000000000..7fdd1b026d76 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarService.java @@ -0,0 +1,30 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.persistence.service.common.AbstractHibernateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarService extends AbstractHibernateService implements IBarService { + + @Autowired + @Qualifier("barHibernateDao") + private IBarDao dao; + + public BarService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarSpringDataJpaService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarSpringDataJpaService.java new file mode 100644 index 000000000000..65f665495a9d --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/BarSpringDataJpaService.java @@ -0,0 +1,26 @@ +package org.baeldung.persistence.service.impl; + +import java.io.Serializable; + +import org.baeldung.persistence.dao.IBarCrudRepository; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.persistence.service.common.AbstractSpringDataJpaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.CrudRepository; + +public class BarSpringDataJpaService extends AbstractSpringDataJpaService implements IBarService { + + @Autowired + private IBarCrudRepository dao; + + public BarSpringDataJpaService() { + super(); + } + + @Override + protected CrudRepository getDao() { + return dao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java index 71b1bc697ef9..17f5c36e4850 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ChildService.java @@ -4,12 +4,12 @@ import org.baeldung.persistence.dao.common.IOperations; import org.baeldung.persistence.model.Child; import org.baeldung.persistence.service.IChildService; -import org.baeldung.persistence.service.common.AbstractService; +import org.baeldung.persistence.service.common.AbstractHibernateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class ChildService extends AbstractServiceimplements IChildService { +public class ChildService extends AbstractHibernateServiceimplements IChildService { @Autowired private IChildDao dao; diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooAuditableService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooAuditableService.java new file mode 100644 index 000000000000..bef9ba5fad30 --- /dev/null +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooAuditableService.java @@ -0,0 +1,41 @@ +package org.baeldung.persistence.service.impl; + +import org.baeldung.persistence.dao.IFooAuditableDao; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.dao.common.IAuditOperations; +import org.baeldung.persistence.dao.common.IOperations; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IFooAuditableService; +import org.baeldung.persistence.service.common.AbstractHibernateAuditableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class FooAuditableService extends AbstractHibernateAuditableService implements IFooAuditableService { + + @Autowired + @Qualifier("fooHibernateDao") + private IFooDao dao; + + @Autowired + @Qualifier("fooHibernateAuditableDao") + private IFooAuditableDao auditDao; + + public FooAuditableService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + + @Override + protected IAuditOperations getAuditableDao() { + return auditDao; + } + +} diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java index 8a89153dd074..65b5cdec5c23 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -4,14 +4,16 @@ import org.baeldung.persistence.dao.common.IOperations; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; -import org.baeldung.persistence.service.common.AbstractService; +import org.baeldung.persistence.service.common.AbstractHibernateService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @Service -public class FooService extends AbstractServiceimplements IFooService { +public class FooService extends AbstractHibernateServiceimplements IFooService { @Autowired + @Qualifier("fooHibernateDao") private IFooDao dao; public FooService() { diff --git a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java index 1f9b602350b3..b78ae53264e7 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java +++ b/spring-hibernate4/src/main/java/org/baeldung/persistence/service/impl/ParentService.java @@ -4,12 +4,12 @@ import org.baeldung.persistence.dao.common.IOperations; import org.baeldung.persistence.model.Parent; import org.baeldung.persistence.service.IParentService; -import org.baeldung.persistence.service.common.AbstractService; +import org.baeldung.persistence.service.common.AbstractHibernateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class ParentService extends AbstractServiceimplements IParentService { +public class ParentService extends AbstractHibernateServiceimplements IParentService { @Autowired private IParentDao dao; diff --git a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java index 000c67d62573..ae7ecf343906 100644 --- a/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-hibernate4/src/main/java/org/baeldung/spring/PersistenceConfig.java @@ -5,7 +5,24 @@ import javax.sql.DataSource; import org.apache.tomcat.dbcp.dbcp.BasicDataSource; -import org.hibernate.SessionFactory; +import org.baeldung.persistence.dao.IBarAuditableDao; +import org.baeldung.persistence.dao.IBarDao; +import org.baeldung.persistence.dao.IFooAuditableDao; +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.dao.impl.BarAuditableDao; +import org.baeldung.persistence.dao.impl.BarDao; +import org.baeldung.persistence.dao.impl.BarJpaDao; +import org.baeldung.persistence.dao.impl.FooAuditableDao; +import org.baeldung.persistence.dao.impl.FooDao; +import org.baeldung.persistence.service.IBarAuditableService; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.persistence.service.IFooAuditableService; +import org.baeldung.persistence.service.IFooService; +import org.baeldung.persistence.service.impl.BarAuditableService; +import org.baeldung.persistence.service.impl.BarJpaService; +import org.baeldung.persistence.service.impl.BarSpringDataJpaService; +import org.baeldung.persistence.service.impl.FooAuditableService; +import org.baeldung.persistence.service.impl.FooService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -13,14 +30,23 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.hibernate4.HibernateTransactionManager; import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement +@EnableJpaRepositories(basePackages = { "org.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager") +@EnableJpaAuditing @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan({ "org.baeldung.persistence" }) public class PersistenceConfig { @@ -42,6 +68,19 @@ public LocalSessionFactoryBean sessionFactory() { return sessionFactory; } + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); + emf.setDataSource(restDataSource()); + emf.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + emf.setJpaVendorAdapter(vendorAdapter); + emf.setJpaProperties(hibernateProperties()); + + return emf; + } + @Bean public DataSource restDataSource() { final BasicDataSource dataSource = new BasicDataSource(); @@ -54,12 +93,17 @@ public DataSource restDataSource() { } @Bean - @Autowired - public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) { - final HibernateTransactionManager txManager = new HibernateTransactionManager(); - txManager.setSessionFactory(sessionFactory); + public PlatformTransactionManager hibernateTransactionManager() { + final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); + transactionManager.setSessionFactory(sessionFactory().getObject()); + return transactionManager; + } - return txManager; + @Bean + public PlatformTransactionManager jpaTransactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + return transactionManager; } @Bean @@ -67,7 +111,57 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { return new PersistenceExceptionTranslationPostProcessor(); } - final Properties hibernateProperties() { + @Bean + public IBarService barJpaService() { + return new BarJpaService(); + } + + @Bean + public IBarService barSpringDataJpaService() { + return new BarSpringDataJpaService(); + } + + @Bean + public IFooService fooHibernateService() { + return new FooService(); + } + + @Bean + public IBarAuditableService barHibernateAuditableService() { + return new BarAuditableService(); + } + + @Bean + public IFooAuditableService fooHibernateAuditableService() { + return new FooAuditableService(); + } + + @Bean + public IBarDao barJpaDao() { + return new BarJpaDao(); + } + + @Bean + public IBarDao barHibernateDao() { + return new BarDao(); + } + + @Bean + public IBarAuditableDao barHibernateAuditableDao() { + return new BarAuditableDao(); + } + + @Bean + public IFooDao fooHibernateDao() { + return new FooDao(); + } + + @Bean + public IFooAuditableDao fooHibernateAuditableDao() { + return new FooAuditableDao(); + } + + private final Properties hibernateProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); @@ -76,6 +170,9 @@ final Properties hibernateProperties() { // hibernateProperties.setProperty("hibernate.format_sql", "true"); // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + // Envers properties + hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); + return hibernateProperties; } diff --git a/spring-hibernate4/src/main/resources/persistence-mysql.properties b/spring-hibernate4/src/main/resources/persistence-mysql.properties index 8263b0d9accd..f6b6ab6fcaa9 100644 --- a/spring-hibernate4/src/main/resources/persistence-mysql.properties +++ b/spring-hibernate4/src/main/resources/persistence-mysql.properties @@ -8,3 +8,6 @@ jdbc.pass=tutorialmy5ql hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop + +# envers.X +envers.audit_table_suffix=_audit_log diff --git a/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/spring-hibernate4/src/main/resources/webSecurityConfig.xml index 88af78dabc9c..d9423d31e770 100644 --- a/spring-hibernate4/src/main/resources/webSecurityConfig.xml +++ b/spring-hibernate4/src/main/resources/webSecurityConfig.xml @@ -5,7 +5,8 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd" > - + + diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/AuditTestSuite.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/AuditTestSuite.java new file mode 100644 index 000000000000..d3a0ab9cb688 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/AuditTestSuite.java @@ -0,0 +1,14 @@ +package org.baeldung.persistence.audit; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ // @formatter:off + EnversFooBarAuditTest.class, + JPABarAuditTest.class, + SpringDataJPABarAuditTest.class +}) // @formatter:on +public class AuditTestSuite { + // +} \ No newline at end of file diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/EnversFooBarAuditTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/EnversFooBarAuditTest.java new file mode 100644 index 000000000000..77202532375a --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/EnversFooBarAuditTest.java @@ -0,0 +1,142 @@ +package org.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.List; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.baeldung.persistence.service.IBarAuditableService; +import org.baeldung.persistence.service.IFooAuditableService; +import org.baeldung.spring.PersistenceConfig; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class EnversFooBarAuditTest { + + private static Logger logger = LoggerFactory.getLogger(EnversFooBarAuditTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + @Autowired + @Qualifier("fooHibernateAuditableService") + private IFooAuditableService fooService; + + @Autowired + @Qualifier("barHibernateAuditableService") + private IBarAuditableService barService; + + @Autowired + private SessionFactory sessionFactory; + + private Session session; + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + makeRevisions(); + session = sessionFactory.openSession(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + session.close(); + } + + private void makeRevisions() { + final Bar bar = rev1(); + rev2(bar); + rev3(bar); + rev4(bar); + } + + // REV #1: insert BAR & FOO1 + private Bar rev1() { + final Bar bar = new Bar("BAR"); + final Foo foo1 = new Foo("FOO1"); + foo1.setBar(bar); + fooService.create(foo1); + return bar; + } + + // REV #2: insert FOO2 & update BAR + private void rev2(final Bar bar) { + final Foo foo2 = new Foo("FOO2"); + foo2.setBar(bar); + fooService.create(foo2); + } + + // REV #3: update BAR + private void rev3(final Bar bar) { + + bar.setName("BAR1"); + barService.update(bar); + } + + // REV #4: insert FOO3 & update BAR + private void rev4(final Bar bar) { + + final Foo foo3 = new Foo("FOO3"); + foo3.setBar(bar); + fooService.create(foo3); + } + + @Test + public final void whenFooBarsModified_thenFooBarsAudited() { + + List barRevisionList; + List fooRevisionList; + + // test Bar revisions + + barRevisionList = barService.getRevisions(); + + assertNotNull(barRevisionList); + assertEquals(4, barRevisionList.size()); + + assertEquals("BAR", barRevisionList.get(0).getName()); + assertEquals("BAR", barRevisionList.get(1).getName()); + assertEquals("BAR1", barRevisionList.get(2).getName()); + assertEquals("BAR1", barRevisionList.get(3).getName()); + + assertEquals(1, barRevisionList.get(0).getFooSet().size()); + assertEquals(2, barRevisionList.get(1).getFooSet().size()); + assertEquals(2, barRevisionList.get(2).getFooSet().size()); + assertEquals(3, barRevisionList.get(3).getFooSet().size()); + + // test Foo revisions + + fooRevisionList = fooService.getRevisions(); + assertNotNull(fooRevisionList); + assertEquals(3, fooRevisionList.size()); + assertEquals("FOO1", fooRevisionList.get(0).getName()); + assertEquals("FOO2", fooRevisionList.get(1).getName()); + assertEquals("FOO3", fooRevisionList.get(2).getName()); + } + +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/JPABarAuditTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/JPABarAuditTest.java new file mode 100644 index 000000000000..3f1353ba8cfd --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/JPABarAuditTest.java @@ -0,0 +1,106 @@ +package org.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Bar.OPERATION; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.spring.PersistenceConfig; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class JPABarAuditTest { + + private static Logger logger = LoggerFactory.getLogger(JPABarAuditTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + + @Autowired + @Qualifier("barJpaService") + private IBarService barService; + + @Autowired + private EntityManagerFactory entityManagerFactory; + + private EntityManager em; + + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + em = entityManagerFactory.createEntityManager(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + em.close(); + } + + + @Test + public final void whenBarsModified_thenBarsAudited() { + + // insert BAR1 + Bar bar1 = new Bar("BAR1"); + barService.create(bar1); + + // update BAR1 + bar1.setName("BAR1a"); + barService.update(bar1); + + // insert BAR2 + Bar bar2 = new Bar("BAR2"); + barService.create(bar2); + + // update BAR1 + bar1.setName("BAR1b"); + barService.update(bar1); + + + // get BAR1 and BAR2 from the DB and check the audit values + // detach instances from persistence context to make sure we fire db + em.detach(bar1); + em.detach(bar2); + bar1 = barService.findOne(bar1.getId()); + bar2 = barService.findOne(bar2.getId()); + + assertNotNull(bar1); + assertNotNull(bar2); + assertEquals(OPERATION.UPDATE, bar1.getOperation()); + assertEquals(OPERATION.INSERT, bar2.getOperation()); + assertTrue(bar1.getTimestamp() > bar2.getTimestamp()); + + barService.deleteById(bar1.getId()); + barService.deleteById(bar2.getId()); + + } + +} \ No newline at end of file diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/SpringDataJPABarAuditTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/SpringDataJPABarAuditTest.java new file mode 100644 index 000000000000..bddaac401184 --- /dev/null +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/audit/SpringDataJPABarAuditTest.java @@ -0,0 +1,76 @@ +package org.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.service.IBarService; +import org.baeldung.spring.PersistenceConfig; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class SpringDataJPABarAuditTest { + + private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + @Autowired + @Qualifier("barSpringDataJpaService") + private IBarService barService; + + @Autowired + private EntityManagerFactory entityManagerFactory; + + private EntityManager em; + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + em = entityManagerFactory.createEntityManager(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + em.close(); + } + + @Test + @WithMockUser(username = "tutorialuser") + public final void whenBarsModified_thenBarsAudited() { + Bar bar = new Bar("BAR1"); + barService.create(bar); + assertEquals(bar.getCreatedDate(), bar.getModifiedDate()); + assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); + bar.setName("BAR2"); + bar = barService.update(bar); + assertTrue(bar.getCreatedDate() < bar.getModifiedDate()); + assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); + } +} diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 07c6ba338205..37781aeb2203 100644 --- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -8,6 +8,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -20,6 +21,7 @@ public class FooServicePersistenceIntegrationTest { @Autowired + @Qualifier("fooHibernateService") private IFooService service; // tests From b6ba166e723a7ec888d19059c433b487c082d8e1 Mon Sep 17 00:00:00 2001 From: gmaipady Date: Wed, 30 Dec 2015 21:17:31 +0530 Subject: [PATCH 038/626] Moved from XML config to Java config --- spring-thymeleaf/.classpath | 10 ++-- spring-thymeleaf/pom.xml | 3 ++ .../WEB-INF/appServlet/servlet-context.xml | 53 ------------------- .../src/main/webapp/WEB-INF/root-context.xml | 8 --- .../src/main/webapp/WEB-INF/web.xml | 34 ------------ 5 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml delete mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml delete mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/web.xml diff --git a/spring-thymeleaf/.classpath b/spring-thymeleaf/.classpath index 28e4a52cd44a..81999ab71733 100644 --- a/spring-thymeleaf/.classpath +++ b/spring-thymeleaf/.classpath @@ -11,21 +11,21 @@ - + - - + + - + + - diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index 1a8dff671e58..ae7451a74e38 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -112,6 +112,9 @@ org.apache.maven.plugins maven-war-plugin ${maven-war-plugin.version} + + false + org.apache.maven.plugins diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml deleted file mode 100644 index ef42557429f2..000000000000 --- a/spring-thymeleaf/src/main/webapp/WEB-INF/appServlet/servlet-context.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml deleted file mode 100644 index 5cb2a94d7367..000000000000 --- a/spring-thymeleaf/src/main/webapp/WEB-INF/root-context.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml b/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 275a482c6f02..000000000000 --- a/spring-thymeleaf/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - contextConfigLocation - /WEB-INF/root-context.xml - - - - - org.springframework.web.context.ContextLoaderListener - - - - - appServlet - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - /WEB-INF/appServlet/servlet-context.xml - - 1 - - - - appServlet - / - - \ No newline at end of file From 02740211b07ecaadc6428ee5d9e29b8bdb14df9b Mon Sep 17 00:00:00 2001 From: gmaipady Date: Wed, 30 Dec 2015 21:21:21 +0530 Subject: [PATCH 039/626] Moved from XML config to Java config --- .../org/baeldung/thymeleaf/config/WebApp.java | 36 +++++++++ .../thymeleaf/config/WebMVCConfig.java | 73 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java create mode 100644 spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java new file mode 100644 index 000000000000..45752a6269d5 --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java @@ -0,0 +1,36 @@ +package org.baeldung.thymeleaf.config; + +import javax.servlet.ServletRegistration.Dynamic; + +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +/** + * Java configuration file that is used for web application initialization + */ +public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer { + + public WebApp() { + super(); + } + + @Override + protected Class[] getRootConfigClasses() { + return null; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[] { WebMVCConfig.class }; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + + @Override + protected void customizeRegistration(final Dynamic registration) { + super.customizeRegistration(registration); + } + +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java new file mode 100644 index 000000000000..c5bd460eee9d --- /dev/null +++ b/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java @@ -0,0 +1,73 @@ +package org.baeldung.thymeleaf.config; + +import org.baeldung.thymeleaf.formatter.NameFormatter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.view.ThymeleafViewResolver; +import org.thymeleaf.templateresolver.ServletContextTemplateResolver; + +@Configuration +@EnableWebMvc +@ComponentScan({ "org.baeldung.thymeleaf" }) +/** + * Java configuration file that is used for Spring MVC and Thymeleaf + * configurations + */ +public class WebMVCConfig extends WebMvcConfigurerAdapter { + + @Bean + @Description("Thymeleaf Template Resolver") + public ServletContextTemplateResolver templateResolver() { + ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); + templateResolver.setPrefix("/WEB-INF/views/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML5"); + + return templateResolver; + } + + @Bean + @Description("Thymeleaf Template Engine") + public SpringTemplateEngine templateEngine() { + SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + + return templateEngine; + } + + @Bean + @Description("Thymeleaf View Resolver") + public ThymeleafViewResolver viewResolver() { + ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); + viewResolver.setTemplateEngine(templateEngine()); + viewResolver.setOrder(1); + return viewResolver; + } + + @Bean + @Description("Spring Message Resolver") + public ResourceBundleMessageSource messageSource() { + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("messages"); + return messageSource; + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/"); + } + + @Override + @Description("Custom Conversion Service") + public void addFormatters(FormatterRegistry registry) { + registry.addFormatter(new NameFormatter()); + } +} From 4a6c23cac65b50769c4f7a289aa1e456f23eb510 Mon Sep 17 00:00:00 2001 From: Alex V Date: Thu, 31 Dec 2015 05:14:39 +0200 Subject: [PATCH 040/626] Code for "Lambda Expressions and Functional Interfaces. Best Practices and Tips" article --- .../src/main/java/org/baeldung/Adder.java | 12 +++ .../src/main/java/org/baeldung/AdderImpl.java | 16 +++ .../src/main/java/org/baeldung/Bar.java | 12 +++ .../src/main/java/org/baeldung/Baz.java | 11 ++ .../src/main/java/org/baeldung/Foo.java | 9 ++ .../main/java/org/baeldung/FooExtended.java | 11 ++ .../src/main/java/org/baeldung/UseFoo.java | 39 +++++++ .../Java8FunctionalInteracesLambdasTest.java | 101 ++++++++++++++++++ .../baeldung/java8/JavaFolderSizeTest.java | 21 ++-- 9 files changed, 226 insertions(+), 6 deletions(-) create mode 100644 core-java-8/src/main/java/org/baeldung/Adder.java create mode 100644 core-java-8/src/main/java/org/baeldung/AdderImpl.java create mode 100644 core-java-8/src/main/java/org/baeldung/Bar.java create mode 100644 core-java-8/src/main/java/org/baeldung/Baz.java create mode 100644 core-java-8/src/main/java/org/baeldung/Foo.java create mode 100644 core-java-8/src/main/java/org/baeldung/FooExtended.java create mode 100644 core-java-8/src/main/java/org/baeldung/UseFoo.java create mode 100644 core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java diff --git a/core-java-8/src/main/java/org/baeldung/Adder.java b/core-java-8/src/main/java/org/baeldung/Adder.java new file mode 100644 index 000000000000..4578990de7c5 --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/Adder.java @@ -0,0 +1,12 @@ +package org.baeldung; + +import java.util.function.Consumer; +import java.util.function.Function; + +public interface Adder { + + String addWithFunction(Function f); + + void addWithConsumer(Consumer f); + +} diff --git a/core-java-8/src/main/java/org/baeldung/AdderImpl.java b/core-java-8/src/main/java/org/baeldung/AdderImpl.java new file mode 100644 index 000000000000..a62c0cd4fb9d --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/AdderImpl.java @@ -0,0 +1,16 @@ +package org.baeldung; + +import java.util.function.Consumer; +import java.util.function.Function; + +public class AdderImpl implements Adder { + + @Override + public String addWithFunction(Function f) { + return f.apply("Something "); + } + + @Override + public void addWithConsumer(Consumer f) {} + +} diff --git a/core-java-8/src/main/java/org/baeldung/Bar.java b/core-java-8/src/main/java/org/baeldung/Bar.java new file mode 100644 index 000000000000..0dd7df6be2eb --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/Bar.java @@ -0,0 +1,12 @@ +package org.baeldung; + +@FunctionalInterface +public interface Bar { + + String method(String string); + + default String defaultMethod() { + return "String from Bar"; + } + +} diff --git a/core-java-8/src/main/java/org/baeldung/Baz.java b/core-java-8/src/main/java/org/baeldung/Baz.java new file mode 100644 index 000000000000..bcc46af6e746 --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/Baz.java @@ -0,0 +1,11 @@ +package org.baeldung; + +@FunctionalInterface +public interface Baz { + + String method(String string); + + default String defaultMethod() { + return "String from Baz"; + } +} diff --git a/core-java-8/src/main/java/org/baeldung/Foo.java b/core-java-8/src/main/java/org/baeldung/Foo.java new file mode 100644 index 000000000000..a10e45a8f58e --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/Foo.java @@ -0,0 +1,9 @@ +package org.baeldung; + +@FunctionalInterface +public interface Foo { + + String method(String string); + + default void defaultMethod() {} +} diff --git a/core-java-8/src/main/java/org/baeldung/FooExtended.java b/core-java-8/src/main/java/org/baeldung/FooExtended.java new file mode 100644 index 000000000000..39c3a0765f8f --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/FooExtended.java @@ -0,0 +1,11 @@ +package org.baeldung; + +@FunctionalInterface +public interface FooExtended extends Baz, Bar { + + @Override + default String defaultMethod() { + return Bar.super.defaultMethod(); + } + +} diff --git a/core-java-8/src/main/java/org/baeldung/UseFoo.java b/core-java-8/src/main/java/org/baeldung/UseFoo.java new file mode 100644 index 000000000000..a29c5631ace3 --- /dev/null +++ b/core-java-8/src/main/java/org/baeldung/UseFoo.java @@ -0,0 +1,39 @@ +package org.baeldung; + +import java.util.function.Function; + +public class UseFoo { + + private String value = "Enclosing scope value"; + + public String add(String string, Foo foo) { + return foo.method(string); + } + + public String addWithStandardFI(String string, Function fn) { + return fn.apply(string); + } + + public String scopeExperiment() { + Foo fooIC = new Foo() { + String value = "Inner class value"; + + @Override + public String method(String string) { + return this.value; + } + }; + String resultIC = fooIC.method(""); + + Foo fooLambda = parameter -> { + String value = "Lambda value"; + return this.value; + }; + String resultLambda = fooLambda.method(""); + + return "Results: resultIC = " + resultIC + + ", resultLambda = " + resultLambda; + } + + +} diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java b/core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java new file mode 100644 index 000000000000..3845d6ba8452 --- /dev/null +++ b/core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java @@ -0,0 +1,101 @@ +package org.baeldung.java8; + +import org.baeldung.Foo; +import org.baeldung.FooExtended; +import org.baeldung.UseFoo; +import org.junit.Before; +import org.junit.Test; + +import java.util.function.Function; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +public class Java8FunctionalInteracesLambdasTest { + + private UseFoo useFoo; + + @Before + public void init() { + useFoo = new UseFoo(); + } + + @Test + public void functionalInterfaceInstantiation_whenReturnDefiniteString_thenCorrect() { + + Foo foo = parameter -> parameter + "from lambda"; + String result = useFoo.add("Message ", foo); + + assertEquals("Message from lambda", result); + } + + @Test + public void standardFIParameter_whenReturnDefiniteString_thenCorrect() { + + Function fn = parameter -> parameter + "from lambda"; + String result = useFoo.addWithStandardFI("Message ", fn); + + assertEquals("Message from lambda", result); + } + + @Test + public void defaultMethodFromExtendedInterface_whenReturnDefiniteString_thenCorrect() { + + FooExtended fooExtended = string -> string; + String result = fooExtended.defaultMethod(); + + assertEquals("String from Bar", result); + } + + @Test + public void lambdaAndInnerClassInstantiation_whenReturnSameString_thenCorrect() { + + Foo foo = parameter -> parameter + "from Foo"; + + Foo fooByIC = new Foo() { + @Override + public String method(String string) { + return string + "from Foo"; + } + }; + + assertEquals(foo.method("Something "), fooByIC.method("Something ")); + } + + @Test + public void accessVariablesFromDifferentScopes_whenReturnPredefinedString_thenCorrect() { + + assertEquals("Results: resultIC = Inner class value, resultLambda = Enclosing scope value", + useFoo.scopeExperiment()); + } + + @Test + public void shorteningLambdas_whenReturnEqualsResults_thenCorrect() { + + Foo foo = parameter -> buildString(parameter); + + Foo fooHuge = parameter -> { String result = "Something " + parameter; + //many lines of code + return result; + }; + + assertEquals(foo.method("Something"), fooHuge.method("Something")); + } + + private String buildString(String parameter) { + String result = "Something " + parameter; + //many lines of code + return result; + } + + @Test + public void mutatingOfEffectivelyFinalVariable_whenNotEquals_thenCorrect() { + + int[] total = new int[1]; + Runnable r = () -> total[0]++; + r.run(); + + assertNotEquals(0, total[0]); + } + +} diff --git a/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java b/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java index baa41511de00..a65971bb913f 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java @@ -15,15 +15,24 @@ import java.util.stream.StreamSupport; import org.apache.commons.io.FileUtils; +import org.junit.Before; import org.junit.Test; public class JavaFolderSizeTest { + private String path; + + @Before + public void init() { + final String separator = File.separator; + path = "src" + separator + "test" + separator + "resources"; + } + @Test public void whenGetFolderSizeRecursive_thenCorrect() { final long expectedSize = 136; - final File folder = new File("src/test/resources"); + final File folder = new File(path); final long size = getFolderSize(folder); assertEquals(expectedSize, size); @@ -34,7 +43,7 @@ public void whenGetFolderSizeUsingJava7_thenCorrect() throws IOException { final long expectedSize = 136; final AtomicLong size = new AtomicLong(0); - final Path folder = Paths.get("src/test/resources"); + final Path folder = Paths.get(path); Files.walkFileTree(folder, new SimpleFileVisitor() { @Override @@ -51,7 +60,7 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr public void whenGetFolderSizeUsingJava8_thenCorrect() throws IOException { final long expectedSize = 136; - final Path folder = Paths.get("src/test/resources"); + final Path folder = Paths.get(path); final long size = Files.walk(folder).filter(p -> p.toFile().isFile()).mapToLong(p -> p.toFile().length()).sum(); assertEquals(expectedSize, size); @@ -61,7 +70,7 @@ public void whenGetFolderSizeUsingJava8_thenCorrect() throws IOException { public void whenGetFolderSizeUsingApacheCommonsIO_thenCorrect() { final long expectedSize = 136; - final File folder = new File("src/test/resources"); + final File folder = new File(path); final long size = FileUtils.sizeOfDirectory(folder); assertEquals(expectedSize, size); @@ -71,7 +80,7 @@ public void whenGetFolderSizeUsingApacheCommonsIO_thenCorrect() { public void whenGetFolderSizeUsingGuava_thenCorrect() { final long expectedSize = 136; - final File folder = new File("src/test/resources"); + final File folder = new File(path); final Iterable files = com.google.common.io.Files.fileTreeTraverser().breadthFirstTraversal(folder); final long size = StreamSupport.stream(files.spliterator(), false).filter(f -> f.isFile()).mapToLong(File::length).sum(); @@ -81,7 +90,7 @@ public void whenGetFolderSizeUsingGuava_thenCorrect() { @Test public void whenGetReadableSize_thenCorrect() { - final File folder = new File("src/test/resources"); + final File folder = new File(path); final long size = getFolderSize(folder); final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; From f921036f4f5d4d18fd93917b59a7cc54eeffbe7d Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 31 Dec 2015 13:02:15 +0200 Subject: [PATCH 041/626] Handling accessDenied --- .../baeldung/spring/SecSecurityConfig.java | 48 +++++++++++++++++-- .../web/controller/RootController.java | 15 ++++-- .../web/error/CustomAccessDeniedHandler.java | 22 +++++++++ .../RestResponseEntityExceptionHandler.java | 7 +++ .../src/main/resources/webSecurityConfig.xml | 7 ++- 5 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java index acf5ff6be54e..75daacbb0466 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,16 +1,58 @@ package org.baeldung.spring; +import org.baeldung.web.error.CustomAccessDeniedHandler; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration @EnableAutoConfiguration -@ImportResource({ "classpath:webSecurityConfig.xml" }) -public class SecSecurityConfig { +// +@EnableWebSecurity +@EnableGlobalMethodSecurity(prePostEnabled = true) +// @ImportResource({ "classpath:webSecurityConfig.xml" }) +public class SecSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private CustomAccessDeniedHandler accessDeniedHandler; public SecSecurityConfig() { super(); } + // java config + + @Override + protected void configure(final AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication().withUser("user1").password("user1Pass").authorities("ROLE_USER").and().withUser("admin").password("adminPass").authorities("ROLE_ADMIN"); + } + + @Override + public void configure(final WebSecurity web) throws Exception { + web.ignoring().antMatchers("/resources/**"); + } + + @Override + protected void configure(final HttpSecurity http) throws Exception { + // @formatter:off + http + .csrf().disable() + .authorizeRequests() + .antMatchers("/admin/*").hasAnyRole("ROLE_ADMIN") + .anyRequest().authenticated() + .and() + .httpBasic() + .and() + // .exceptionHandling().accessDeniedPage("/my-error-page") + .exceptionHandling().accessDeniedHandler(accessDeniedHandler) + ; + // @formatter:on + } + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java index 42fc78f6117b..e83b8cf5baff 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java @@ -11,6 +11,7 @@ import org.baeldung.web.util.LinkUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -51,6 +52,7 @@ public Map getMetric() { return metricService.getFullMetric(); } + @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/status-metric", method = RequestMethod.GET) @ResponseBody public Map getStatusMetric() { @@ -67,9 +69,16 @@ public Object[][] drawMetric() { return result; } - @RequestMapping(value = "/metric-graph-data", method = RequestMethod.GET) + @RequestMapping(value = "/admin/x", method = RequestMethod.GET) @ResponseBody - public Object[][] getActuatorMetricData() { - return actMetricService.getGraphData(); + public String sampleAdminPage() { + return "Hello"; } + + @RequestMapping(value = "/my-error-page", method = RequestMethod.GET) + @ResponseBody + public String sampleErrorPage() { + return "Error Occurred"; + } + } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java new file mode 100644 index 000000000000..ae7340ef88a1 --- /dev/null +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java @@ -0,0 +1,22 @@ +package org.baeldung.web.error; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.stereotype.Component; + +@Component +public class CustomAccessDeniedHandler implements AccessDeniedHandler { + + @Override + public void handle(final HttpServletRequest request, final HttpServletResponse response, final AccessDeniedException ex) throws IOException, ServletException { + response.getOutputStream().print("Error Message Goes Here"); + // response.sendRedirect("/my-error-page"); + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java index a465a82d75f1..e9d34aa9cfb2 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -11,11 +11,13 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.security.access.AccessDeniedException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +//import org.springframework.security.access.AccessDeniedException; @ControllerAdvice public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { @@ -54,6 +56,11 @@ protected ResponseEntity handleMethodArgumentNotValid(final MethodArgume } // 403 + @ExceptionHandler({ AccessDeniedException.class }) + public ResponseEntity handleAccessDeniedException(final Exception ex, final WebRequest request) { + System.out.println("request" + request.getUserPrincipal()); + return new ResponseEntity("Access denied message here", new HttpHeaders(), HttpStatus.FORBIDDEN); + } // 404 diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index 915460bd44c9..a60033b71a20 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -9,19 +9,24 @@ - + + + + + + From 2435e66439c95c2dd36baf0ad89e2bcc07671b92 Mon Sep 17 00:00:00 2001 From: sghosh Date: Mon, 4 Jan 2016 00:15:43 +0530 Subject: [PATCH 042/626] Source code for Intro to QueryDSL article. --- querydsl/pom.xml | 187 ++++++++++++++++++ .../main/java/org/baeldung/dao/PersonDao.java | 12 ++ .../java/org/baeldung/dao/PersonDaoImpl.java | 30 +++ .../main/java/org/baeldung/entity/Person.java | 50 +++++ .../main/resources/META-INF/persistence.xml | 19 ++ querydsl/src/main/resources/log4j.xml | 42 ++++ .../java/org/baeldung/dao/PersonDaoTest.java | 33 ++++ querydsl/src/test/resources/db.properties | 6 + querydsl/src/test/resources/test-context.xml | 20 ++ querydsl/src/test/resources/test-db.xml | 49 +++++ 10 files changed, 448 insertions(+) create mode 100644 querydsl/pom.xml create mode 100644 querydsl/src/main/java/org/baeldung/dao/PersonDao.java create mode 100644 querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java create mode 100644 querydsl/src/main/java/org/baeldung/entity/Person.java create mode 100644 querydsl/src/main/resources/META-INF/persistence.xml create mode 100644 querydsl/src/main/resources/log4j.xml create mode 100644 querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java create mode 100644 querydsl/src/test/resources/db.properties create mode 100644 querydsl/src/test/resources/test-context.xml create mode 100644 querydsl/src/test/resources/test-db.xml diff --git a/querydsl/pom.xml b/querydsl/pom.xml new file mode 100644 index 000000000000..4efb5dcb8b93 --- /dev/null +++ b/querydsl/pom.xml @@ -0,0 +1,187 @@ + + + 4.0.0 + + org.baeldung + querydsl + 0.1-SNAPSHOT + jar + + querydsl + http://maven.apache.org + + + UTF-8 + 1.6 + 4.10 + 3.1.0.RELEASE + 4.1.1.Final + 2.5.0 + 1.5.10 + + + + + + com.mysema.querydsl + querydsl-core + ${querydsl.version} + + + + com.mysema.querydsl + querydsl-jpa + ${querydsl.version} + + + + com.mysema.querydsl + querydsl-apt + ${querydsl.version} + provided + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + compile + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + 1.0.0.Final + compile + + + + commons-dbcp + commons-dbcp + 1.4 + jar + compile + + + + commons-pool + commons-pool + 1.5.5 + jar + compile + + + + + org.hsqldb + hsqldb-j5 + 2.2.4 + + + + + org.springframework + spring-context + ${spring.version} + + + + org.springframework + spring-webmvc + ${spring.version} + + + + org.springframework + spring-orm + ${spring.version} + jar + compile + + + + org.springframework + spring-aop + ${spring.version} + + + + org.springframework + spring-test + ${spring.version} + jar + test + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + runtime + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + runtime + + + log4j + log4j + 1.2.16 + + + + + junit + junit + ${junit.version} + test + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + ${java.version} + ${java.version} + -proc:none + + + + + + com.mysema.maven + maven-apt-plugin + 1.0.3 + + + + process + + + target/metamodel + com.mysema.query.apt.jpa.JPAAnnotationProcessor + + + + + + + \ No newline at end of file diff --git a/querydsl/src/main/java/org/baeldung/dao/PersonDao.java b/querydsl/src/main/java/org/baeldung/dao/PersonDao.java new file mode 100644 index 000000000000..cc193de44b34 --- /dev/null +++ b/querydsl/src/main/java/org/baeldung/dao/PersonDao.java @@ -0,0 +1,12 @@ +package org.baeldung.dao; + +import org.baeldung.entity.Person; + +import java.util.List; + +public interface PersonDao { + + public Person save(Person person); + + public List findPersonsByFirstnameQueryDSL(String firstname); +} \ No newline at end of file diff --git a/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java b/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java new file mode 100644 index 000000000000..82ee4c16cd0d --- /dev/null +++ b/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java @@ -0,0 +1,30 @@ +package org.baeldung.dao; + +import com.mysema.query.jpa.impl.JPAQuery; +import org.baeldung.entity.Person; +import org.baeldung.entity.QPerson; +import org.springframework.stereotype.Repository; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import java.util.List; + +@Repository +public class PersonDaoImpl implements PersonDao { + + @PersistenceContext + private EntityManager em; + + public Person save(Person person) { + em.persist(person); + return person; + } + + public List findPersonsByFirstnameQueryDSL(String firstname) { + JPAQuery query = new JPAQuery(em); + QPerson person = QPerson.person; + + return query.from(person).where(person.firstname.eq(firstname)).list(person); + } + +} \ No newline at end of file diff --git a/querydsl/src/main/java/org/baeldung/entity/Person.java b/querydsl/src/main/java/org/baeldung/entity/Person.java new file mode 100644 index 000000000000..d9b0a5a97d0d --- /dev/null +++ b/querydsl/src/main/java/org/baeldung/entity/Person.java @@ -0,0 +1,50 @@ +package org.baeldung.entity; + +import javax.persistence.*; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column + private String firstname; + + @Column + private String surname; + + Person() { + } + + public Person(String firstname, String surname) { + this.firstname = firstname; + this.surname = surname; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + +} \ No newline at end of file diff --git a/querydsl/src/main/resources/META-INF/persistence.xml b/querydsl/src/main/resources/META-INF/persistence.xml new file mode 100644 index 000000000000..111d7933c314 --- /dev/null +++ b/querydsl/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/querydsl/src/main/resources/log4j.xml b/querydsl/src/main/resources/log4j.xml new file mode 100644 index 000000000000..a7f96b38a4ea --- /dev/null +++ b/querydsl/src/main/resources/log4j.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java b/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java new file mode 100644 index 000000000000..29d4dd98e926 --- /dev/null +++ b/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java @@ -0,0 +1,33 @@ +package org.baeldung.dao; + +import junit.framework.Assert; +import org.baeldung.entity.Person; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.transaction.TransactionConfiguration; +import org.springframework.transaction.annotation.Transactional; + + +@ContextConfiguration("/test-context.xml") +@RunWith(SpringJUnit4ClassRunner.class) +@Transactional +@TransactionConfiguration(defaultRollback=true) +public class PersonDaoTest { + + @Autowired + private PersonDao personDao; + + @Test + public void testCreation() { + personDao.save(new Person("Erich", "Gamma")); + Person person = new Person("Kent", "Beck"); + personDao.save(person); + personDao.save(new Person("Ralph", "Johnson")); + + Person personFromDb = personDao.findPersonsByFirstnameQueryDSL("Kent").get(0); + Assert.assertEquals(person.getId(), personFromDb.getId()); + } +} \ No newline at end of file diff --git a/querydsl/src/test/resources/db.properties b/querydsl/src/test/resources/db.properties new file mode 100644 index 000000000000..efee3669ce31 --- /dev/null +++ b/querydsl/src/test/resources/db.properties @@ -0,0 +1,6 @@ +#In memory db +db.username=sa +db.password= +db.driver=org.hsqldb.jdbcDriver +db.url=jdbc:hsqldb:mem:app-db +db.dialect=org.hibernate.dialect.HSQLDialect \ No newline at end of file diff --git a/querydsl/src/test/resources/test-context.xml b/querydsl/src/test/resources/test-context.xml new file mode 100644 index 000000000000..13d823a8574b --- /dev/null +++ b/querydsl/src/test/resources/test-context.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/querydsl/src/test/resources/test-db.xml b/querydsl/src/test/resources/test-db.xml new file mode 100644 index 000000000000..7f85630b6b9e --- /dev/null +++ b/querydsl/src/test/resources/test-db.xml @@ -0,0 +1,49 @@ + + + + + + + classpath:db.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From bfdcb18a3a083b4ee39d435e9c9a6993a9ab39e8 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 4 Jan 2016 00:55:58 +0200 Subject: [PATCH 043/626] cleanup work --- .../.settings/org.eclipse.wst.common.project.facet.core.xml | 2 +- .../src/main/resources/webSecurityConfig.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml index f5888c141165..8a1c18941956 100644 --- a/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/spring-security-rest-digest-auth/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml index 695efa8047a4..42a59abff024 100644 --- a/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-digest-auth/src/main/resources/webSecurityConfig.xml @@ -2,9 +2,9 @@ From 4a029959af84de55bdee134b40fa164bab94c5a9 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 4 Jan 2016 01:01:27 +0200 Subject: [PATCH 044/626] minor cleanup --- .../main/java/org/baeldung/web/metric/MetricFilter.java | 2 +- .../src/main/resources/springDataPersistenceConfig.xml | 7 +++++-- .../src/main/resources/webSecurityConfig.xml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java b/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java index d77aec791954..6c2fb0cb3963 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java @@ -26,7 +26,7 @@ public class MetricFilter implements Filter { public void init(final FilterConfig config) throws ServletException { if (metricService == null || actMetricService == null) { metricService = (IMetricService) WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean("metricService"); - actMetricService = (ICustomActuatorMetricService) WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean("actuatorMetricService"); + actMetricService = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean(CustomActuatorMetricService.class); } } diff --git a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml index 5c971d975d0f..d6d0ec6e4753 100644 --- a/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml +++ b/spring-security-rest-full/src/main/resources/springDataPersistenceConfig.xml @@ -1,7 +1,10 @@ diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml index a60033b71a20..d6ba952dfd0a 100644 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-4.2.xsd" + http://www.springframework.org/schema/beans/spring-beans.xsd" > From 6b10b326a2b39737a4ffd5daa40fa884d1db9cac Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 5 Jan 2016 19:55:11 +0200 Subject: [PATCH 045/626] cleanup and upgrade --- spring-all/pom.xml | 4 -- spring-katharsis/pom.xml | 6 ++- spring-security-mvc-ldap/pom.xml | 42 ++----------------- .../org/baeldung/security/SecurityConfig.java | 4 +- .../src/main/resources/templates/login.html | 2 +- .../src/main/resources/webSecurityConfig.xml | 5 +-- spring-security-rest-full/pom.xml | 26 ++++++------ spring-security-rest/pom.xml | 18 ++++---- .../baeldung/spring/SecurityJavaConfig.java | 7 +--- .../src/main/resources/webSecurityConfig.xml | 4 +- 10 files changed, 42 insertions(+), 76 deletions(-) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 16ff340d813c..6ce8ad7196da 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -128,7 +128,6 @@ junit junit - ${junit.version} test @@ -164,7 +163,6 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} 1.8 1.8 @@ -174,7 +172,6 @@ org.apache.maven.plugins maven-war-plugin - ${maven-war-plugin.version} false @@ -183,7 +180,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} diff --git a/spring-katharsis/pom.xml b/spring-katharsis/pom.xml index 554ff4e656b4..892aaf24f1f1 100644 --- a/spring-katharsis/pom.xml +++ b/spring-katharsis/pom.xml @@ -31,7 +31,7 @@ io.katharsis katharsis-servlet - 1.0.0 + ${katharsis.version} @@ -45,7 +45,7 @@ com.jayway.restassured rest-assured - 2.4.0 + ${restassured.version} test @@ -60,6 +60,8 @@ 1.8 + 1.0.0 + 2.4.0 diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 5282f76a7e9b..3f9b9ad1ede7 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.2.4.RELEASE + 1.3.1.RELEASE @@ -39,7 +39,7 @@ org.apache.directory.server apacheds-server-jndi - 1.5.5 + ${apacheds.version} @@ -68,42 +68,8 @@ - - - 4.2.4.RELEASE - 4.0.3.RELEASE - - - 4.3.11.Final - 5.1.37 - - - 1.7.13 - 1.1.3 - - - 5.2.2.Final - - - 19.0 - 3.4 - - - 1.3 - 4.12 - 1.10.19 - - 4.4.1 - 4.5 - - 2.4.1 - - - 3.3 - 2.6 - 2.18.1 - 1.4.15 - + + 1.5.5 diff --git a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java index ee72ee7891e9..0d444e36ffe8 100644 --- a/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java +++ b/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java @@ -9,7 +9,7 @@ * Security Configuration - LDAP and HTTP Authorizations. */ @Configuration -// @ImportResource({ "classpath:webSecurityConfig.xml" }) +// @ImportResource({ "classpath:webSecurityConfig.xml" }) //=> uncomment to use equivalent xml config public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override @@ -20,7 +20,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated(); - http.formLogin().loginPage("/login").permitAll().loginProcessingUrl("/j_spring_security_check").and().logout().logoutSuccessUrl("/"); + http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/"); } } diff --git a/spring-security-mvc-ldap/src/main/resources/templates/login.html b/spring-security-mvc-ldap/src/main/resources/templates/login.html index 81f62fde1371..e21ea21e6927 100644 --- a/spring-security-mvc-ldap/src/main/resources/templates/login.html +++ b/spring-security-mvc-ldap/src/main/resources/templates/login.html @@ -21,7 +21,7 @@

You have been logged out

There was an error, please try again

Login with Username and Password

- +
diff --git a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml index 6bd2c422d820..c13f65de5ef4 100644 --- a/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml @@ -13,10 +13,7 @@ - + diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index bed716897b62..cbcc3fca64b9 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.0.RELEASE + 1.3.1.RELEASE @@ -113,12 +113,12 @@ com.mysema.querydsl querydsl-apt - 3.6.2 + ${querydsl.version} com.mysema.querydsl querydsl-jpa - 3.6.2 + ${querydsl.version} @@ -126,7 +126,7 @@ cz.jirutka.rsql rsql-parser - 2.0.0 + ${rsql.version} @@ -144,7 +144,6 @@ org.apache.httpcomponents httpcore - ${httpcore.version} @@ -164,7 +163,7 @@ xml-apis xml-apis - 1.4.01 + ${xml-apis.version} org.javassist @@ -200,7 +199,7 @@ com.thoughtworks.xstream xstream - 1.4.8 + ${xstream.version} @@ -243,7 +242,6 @@ junit junit - ${junit.version} test @@ -267,7 +265,7 @@ com.jayway.restassured rest-assured - 2.4.0 + ${rest-assured.version} test @@ -344,7 +342,7 @@ com.mysema.maven apt-maven-plugin - 1.1.3 + ${apt-maven-plugin.version} @@ -434,9 +432,12 @@ 5.1.37 1.7.2.RELEASE + 2.0.0 + 3.6.2 + - 2.5.5 + 1.4.01 1.7.13 @@ -444,6 +445,7 @@ 5.2.2.Final + 1.4.8 19.0 @@ -464,7 +466,7 @@ 2.6 2.18.1 1.4.15 - + 1.1.3 \ No newline at end of file diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 42381bf607b7..2046b3881010 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -82,14 +82,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet-api.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -98,7 +98,7 @@ com.fasterxml.jackson.core jackson-databind - 2.2.2 + ${jackson.version} @@ -111,7 +111,7 @@ org.apache.commons commons-lang3 - 3.1 + ${commons-lang3.version} @@ -171,13 +171,13 @@ io.springfox springfox-swagger2 - 2.2.2 + ${springfox.version} io.springfox springfox-swagger-ui - 2.2.2 + ${springfox.version} @@ -263,7 +263,11 @@ 5.2.2.Final - + 3.0.1 + 1.2 + 2.2.2 + 2.2.2 + 19.0 3.4 diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java index ca882909f002..5b88fefdb22b 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java @@ -35,19 +35,16 @@ protected void configure(final AuthenticationManagerBuilder auth) throws Excepti } @Override - protected void configure(final HttpSecurity http) throws Exception { // @formatter:off + protected void configure(final HttpSecurity http) throws Exception {// @formatter:off http .csrf().disable() .exceptionHandling() .authenticationEntryPoint(restAuthenticationEntryPoint) .and() .authorizeRequests() - .antMatchers("/api/foos").authenticated() + .antMatchers("/api/**").authenticated() .and() .formLogin() - .loginProcessingUrl("/j_spring_security_check") - .usernameParameter("j_username") - .passwordParameter("j_password") .successHandler(authenticationSuccessHandler) .failureHandler(new SimpleUrlAuthenticationFailureHandler()) .and() diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index 20651c458cbf..619b53fb7e1f 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -11,7 +11,9 @@ - + + + From d0a80fc0c431da4569de65fc7473748c969b9bb9 Mon Sep 17 00:00:00 2001 From: David Morley Date: Tue, 5 Jan 2016 21:37:15 -0600 Subject: [PATCH 046/626] Remove Eclipse-specific metadata files --- spring-thymeleaf/.classpath | 32 ---------------------------- spring-thymeleaf/.project | 42 ------------------------------------- 2 files changed, 74 deletions(-) delete mode 100644 spring-thymeleaf/.classpath delete mode 100644 spring-thymeleaf/.project diff --git a/spring-thymeleaf/.classpath b/spring-thymeleaf/.classpath deleted file mode 100644 index 81999ab71733..000000000000 --- a/spring-thymeleaf/.classpath +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-thymeleaf/.project b/spring-thymeleaf/.project deleted file mode 100644 index 3c898c7e84c3..000000000000 --- a/spring-thymeleaf/.project +++ /dev/null @@ -1,42 +0,0 @@ - - - spring-thymeleaf - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - - From a937aef25e991a25650caf63c8d4f7c668a20804 Mon Sep 17 00:00:00 2001 From: David Morley Date: Tue, 5 Jan 2016 21:37:48 -0600 Subject: [PATCH 047/626] Rename package to conform with site name --- spring-thymeleaf/pom.xml | 2 +- .../baeldung/thymeleaf/config/WebApp.java | 72 ++++----- .../thymeleaf/config/WebMVCConfig.java | 146 +++++++++--------- .../thymeleaf/controller/HomeController.java | 2 +- .../controller/StudentController.java | 139 +++++++++-------- .../thymeleaf/formatter/NameFormatter.java | 60 +++---- .../baeldung/thymeleaf/model/Student.java | 120 +++++++------- 7 files changed, 270 insertions(+), 271 deletions(-) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/config/WebApp.java (91%) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/config/WebMVCConfig.java (92%) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/controller/HomeController.java (94%) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/controller/StudentController.java (92%) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/formatter/NameFormatter.java (91%) rename spring-thymeleaf/src/main/java/{org => com}/baeldung/thymeleaf/model/Student.java (91%) diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index ae7451a74e38..16e6849f932b 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - org.baeldung + com.baeldung spring-thymeleaf 0.1-SNAPSHOT war diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java similarity index 91% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java index 45752a6269d5..89ad7e601ec2 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebApp.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java @@ -1,36 +1,36 @@ -package org.baeldung.thymeleaf.config; - -import javax.servlet.ServletRegistration.Dynamic; - -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -/** - * Java configuration file that is used for web application initialization - */ -public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer { - - public WebApp() { - super(); - } - - @Override - protected Class[] getRootConfigClasses() { - return null; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { WebMVCConfig.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } - - @Override - protected void customizeRegistration(final Dynamic registration) { - super.customizeRegistration(registration); - } - -} +package com.baeldung.thymeleaf.config; + +import javax.servlet.ServletRegistration.Dynamic; + +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +/** + * Java configuration file that is used for web application initialization + */ +public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer { + + public WebApp() { + super(); + } + + @Override + protected Class[] getRootConfigClasses() { + return null; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[] { WebMVCConfig.class }; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + + @Override + protected void customizeRegistration(final Dynamic registration) { + super.customizeRegistration(registration); + } + +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java similarity index 92% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java index c5bd460eee9d..51c60247a109 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/config/WebMVCConfig.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java @@ -1,73 +1,73 @@ -package org.baeldung.thymeleaf.config; - -import org.baeldung.thymeleaf.formatter.NameFormatter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Description; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.format.FormatterRegistry; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.thymeleaf.spring4.SpringTemplateEngine; -import org.thymeleaf.spring4.view.ThymeleafViewResolver; -import org.thymeleaf.templateresolver.ServletContextTemplateResolver; - -@Configuration -@EnableWebMvc -@ComponentScan({ "org.baeldung.thymeleaf" }) -/** - * Java configuration file that is used for Spring MVC and Thymeleaf - * configurations - */ -public class WebMVCConfig extends WebMvcConfigurerAdapter { - - @Bean - @Description("Thymeleaf Template Resolver") - public ServletContextTemplateResolver templateResolver() { - ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); - templateResolver.setPrefix("/WEB-INF/views/"); - templateResolver.setSuffix(".html"); - templateResolver.setTemplateMode("HTML5"); - - return templateResolver; - } - - @Bean - @Description("Thymeleaf Template Engine") - public SpringTemplateEngine templateEngine() { - SpringTemplateEngine templateEngine = new SpringTemplateEngine(); - templateEngine.setTemplateResolver(templateResolver()); - - return templateEngine; - } - - @Bean - @Description("Thymeleaf View Resolver") - public ThymeleafViewResolver viewResolver() { - ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); - viewResolver.setTemplateEngine(templateEngine()); - viewResolver.setOrder(1); - return viewResolver; - } - - @Bean - @Description("Spring Message Resolver") - public ResourceBundleMessageSource messageSource() { - ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename("messages"); - return messageSource; - } - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/"); - } - - @Override - @Description("Custom Conversion Service") - public void addFormatters(FormatterRegistry registry) { - registry.addFormatter(new NameFormatter()); - } -} +package com.baeldung.thymeleaf.config; + +import com.baeldung.thymeleaf.formatter.NameFormatter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.view.ThymeleafViewResolver; +import org.thymeleaf.templateresolver.ServletContextTemplateResolver; + +@Configuration +@EnableWebMvc +@ComponentScan({ "com.baeldung.thymeleaf" }) +/** + * Java configuration file that is used for Spring MVC and Thymeleaf + * configurations + */ +public class WebMVCConfig extends WebMvcConfigurerAdapter { + + @Bean + @Description("Thymeleaf Template Resolver") + public ServletContextTemplateResolver templateResolver() { + ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); + templateResolver.setPrefix("/WEB-INF/views/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML5"); + + return templateResolver; + } + + @Bean + @Description("Thymeleaf Template Engine") + public SpringTemplateEngine templateEngine() { + SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + + return templateEngine; + } + + @Bean + @Description("Thymeleaf View Resolver") + public ThymeleafViewResolver viewResolver() { + ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); + viewResolver.setTemplateEngine(templateEngine()); + viewResolver.setOrder(1); + return viewResolver; + } + + @Bean + @Description("Spring Message Resolver") + public ResourceBundleMessageSource messageSource() { + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("messages"); + return messageSource; + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/"); + } + + @Override + @Description("Custom Conversion Service") + public void addFormatters(FormatterRegistry registry) { + registry.addFormatter(new NameFormatter()); + } +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java similarity index 94% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java index 505dc8303b9f..a28d059acc03 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/HomeController.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java @@ -1,4 +1,4 @@ -package org.baeldung.thymeleaf.controller; +package com.baeldung.thymeleaf.controller; import java.text.DateFormat; import java.util.Date; diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java similarity index 92% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java index 3bef22cdae3f..912eb521f48b 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/controller/StudentController.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java @@ -1,70 +1,69 @@ -package org.baeldung.thymeleaf.controller; - -import java.util.ArrayList; -import java.util.List; - -import javax.validation.Valid; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import org.baeldung.thymeleaf.model.Student; - -/** - * Handles requests for the student model. - * - */ -@Controller -public class StudentController { - - @RequestMapping(value = "/saveStudent", method = RequestMethod.POST) - public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) { - if (!errors.hasErrors()) { - // get mock objects - List students = buildStudents(); - // add current student - students.add(student); - model.addAttribute("students", students); - } - return ((errors.hasErrors()) ? "addStudent" : "listStudents"); - } - - @RequestMapping(value = "/addStudent", method = RequestMethod.GET) - public String addStudent(Model model) { - model.addAttribute("student", new Student()); - return "addStudent"; - } - - @RequestMapping(value = "/listStudents", method = RequestMethod.GET) - public String listStudent(Model model) { - - model.addAttribute("students", buildStudents()); - - return "listStudents"; - } - - private List buildStudents() { - List students = new ArrayList(); - - Student student1 = new Student(); - student1.setId(1001); - student1.setName("John Smith"); - student1.setGender('M'); - student1.setPercentage(Float.valueOf("80.45")); - - students.add(student1); - - Student student2 = new Student(); - student2.setId(1002); - student2.setName("Jane Williams"); - student2.setGender('F'); - student2.setPercentage(Float.valueOf("60.25")); - - students.add(student2); - return students; - } -} +package com.baeldung.thymeleaf.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.validation.Valid; + +import com.baeldung.thymeleaf.model.Student; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * Handles requests for the student model. + * + */ +@Controller +public class StudentController { + + @RequestMapping(value = "/saveStudent", method = RequestMethod.POST) + public String saveStudent(@Valid @ModelAttribute Student student, BindingResult errors, Model model) { + if (!errors.hasErrors()) { + // get mock objects + List students = buildStudents(); + // add current student + students.add(student); + model.addAttribute("students", students); + } + return ((errors.hasErrors()) ? "addStudent" : "listStudents"); + } + + @RequestMapping(value = "/addStudent", method = RequestMethod.GET) + public String addStudent(Model model) { + model.addAttribute("student", new Student()); + return "addStudent"; + } + + @RequestMapping(value = "/listStudents", method = RequestMethod.GET) + public String listStudent(Model model) { + + model.addAttribute("students", buildStudents()); + + return "listStudents"; + } + + private List buildStudents() { + List students = new ArrayList(); + + Student student1 = new Student(); + student1.setId(1001); + student1.setName("John Smith"); + student1.setGender('M'); + student1.setPercentage(Float.valueOf("80.45")); + + students.add(student1); + + Student student2 = new Student(); + student2.setId(1002); + student2.setName("Jane Williams"); + student2.setGender('F'); + student2.setPercentage(Float.valueOf("60.25")); + + students.add(student2); + return students; + } +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java similarity index 91% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java index 9c07ef8d145f..a5d2366390c2 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/formatter/NameFormatter.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java @@ -1,30 +1,30 @@ -package org.baeldung.thymeleaf.formatter; - -import java.text.ParseException; -import java.util.Locale; - -import org.springframework.format.Formatter; -import org.thymeleaf.util.StringUtils; - -/** - * - * Name formatter class that implements the Spring Formatter interface. - * Formats a name(String) and return the value with spaces replaced by commas. - * - */ -public class NameFormatter implements Formatter { - - @Override - public String print(String input, Locale locale) { - return formatName(input, locale); - } - - @Override - public String parse(String input, Locale locale) throws ParseException { - return formatName(input, locale); - } - - private String formatName(String input, Locale locale) { - return StringUtils.replace(input, " ", ","); - } -} +package com.baeldung.thymeleaf.formatter; + +import java.text.ParseException; +import java.util.Locale; + +import org.springframework.format.Formatter; +import org.thymeleaf.util.StringUtils; + +/** + * + * Name formatter class that implements the Spring Formatter interface. + * Formats a name(String) and return the value with spaces replaced by commas. + * + */ +public class NameFormatter implements Formatter { + + @Override + public String print(String input, Locale locale) { + return formatName(input, locale); + } + + @Override + public String parse(String input, Locale locale) throws ParseException { + return formatName(input, locale); + } + + private String formatName(String input, Locale locale) { + return StringUtils.replace(input, " ", ","); + } +} diff --git a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java similarity index 91% rename from spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java rename to spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java index f21169dbcf3c..bce99f286cd6 100644 --- a/spring-thymeleaf/src/main/java/org/baeldung/thymeleaf/model/Student.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java @@ -1,60 +1,60 @@ -package org.baeldung.thymeleaf.model; - -import java.io.Serializable; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -/** - * - * Simple student POJO with few fields - * - */ -public class Student implements Serializable { - - private static final long serialVersionUID = -8582553475226281591L; - - @NotNull(message = "Student ID is required.") - @Min(value = 1000, message = "Student ID must be at least 4 digits.") - private Integer id; - - @NotNull(message = "Student name is required.") - private String name; - - @NotNull(message = "Student gender is required.") - private Character gender; - - private Float percentage; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Character getGender() { - return gender; - } - - public void setGender(Character gender) { - this.gender = gender; - } - - public Float getPercentage() { - return percentage; - } - - public void setPercentage(Float percentage) { - this.percentage = percentage; - } -} +package com.baeldung.thymeleaf.model; + +import java.io.Serializable; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * + * Simple student POJO with few fields + * + */ +public class Student implements Serializable { + + private static final long serialVersionUID = -8582553475226281591L; + + @NotNull(message = "Student ID is required.") + @Min(value = 1000, message = "Student ID must be at least 4 digits.") + private Integer id; + + @NotNull(message = "Student name is required.") + private String name; + + @NotNull(message = "Student gender is required.") + private Character gender; + + private Float percentage; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Character getGender() { + return gender; + } + + public void setGender(Character gender) { + this.gender = gender; + } + + public Float getPercentage() { + return percentage; + } + + public void setPercentage(Float percentage) { + this.percentage = percentage; + } +} From 671bfc1635419937d3ea4cf3d11ce65600e586f0 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 6 Jan 2016 13:26:07 +0200 Subject: [PATCH 048/626] cleanup and upgrade --- spring-security-basic-auth/pom.xml | 10 ++++++---- spring-security-mvc-custom/pom.xml | 8 +++++--- .../src/main/resources/webSecurityConfig.xml | 2 ++ .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 8 ++++---- spring-security-mvc-digest-auth/pom.xml | 8 +++++--- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/spring-security-basic-auth/pom.xml b/spring-security-basic-auth/pom.xml index 6abefbd7ecce..1e15cd5b53f1 100644 --- a/spring-security-basic-auth/pom.xml +++ b/spring-security-basic-auth/pom.xml @@ -82,14 +82,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -98,7 +98,7 @@ com.google.guava guava - 14.0.1 + ${guava.version} @@ -238,7 +238,9 @@ 5.2.2.Final - + 1.2 + 3.0.1 + 19.0 3.4 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 2e2d434fb288..b5f71847f5b6 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -87,14 +87,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -243,7 +243,9 @@ 5.2.2.Final - + 3.0.1 + 1.2 + 19.0 3.4 diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index bbb22c11cb11..603ded74fed6 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -12,6 +12,8 @@ + + diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp index d18b59a10caf..5a58d8892fae 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/console.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp index afd2c6da594f..2568adec669c 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/homepage.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp index 0eb857c62aee..762218e40fe1 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -4,20 +4,20 @@

Login

- + - + - + - + diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 2dce2835f5d9..dc2c4d80a50c 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -82,14 +82,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -238,7 +238,9 @@ 5.2.2.Final - + 1.2 + 3.0.1 + 19.03.4 From cb45b176f59d7e94be6a46b05b72d1836d3ded16 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 6 Jan 2016 19:38:25 +0200 Subject: [PATCH 049/626] cleanup and upgrade --- spring-security-mvc-login/pom.xml | 6 ++++-- .../src/main/resources/webSecurityConfig.xml | 2 ++ .../src/main/webapp/WEB-INF/view/login.jsp | 4 ++-- spring-security-rest-basic-auth/pom.xml | 11 +++++++---- spring-security-rest-custom/pom.xml | 6 +----- spring-security-rest-digest-auth/pom.xml | 6 ++++-- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 3d76fcb22f47..ee6b37743be2 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -87,14 +87,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -235,6 +235,8 @@ 5.2.2.Final + 3.0.1 + 1.2 19.0 diff --git a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml index 2bac3024c72a..ec4cf60eb54e 100644 --- a/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml @@ -12,6 +12,8 @@ + + diff --git a/spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp index 013ceccb4e4d..95930c139dae 100644 --- a/spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-login/src/main/webapp/WEB-INF/view/login.jsp @@ -9,11 +9,11 @@
User:
Password:
Remember Me:
- + - + diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 1fbeeaa9a932..767edb77780a 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -88,7 +88,7 @@ com.fasterxml.jackson.core jackson-databind - 2.2.3 + ${jackson.version} @@ -134,14 +134,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -304,7 +304,10 @@ 5.2.2.Final - + 1.2 + 3.0.1 + 2.2.3 + 19.03.4 diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index 20984ba6dd4e..a112fdcd4307 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.2.4.RELEASE + 1.3.1.RELEASE @@ -141,7 +141,6 @@ junit junit - ${junit.version} test @@ -199,7 +198,6 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} 1.8 1.8 @@ -211,7 +209,6 @@ org.apache.maven.plugins maven-war-plugin - ${maven-war-plugin.version} false @@ -220,7 +217,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml index d20220ac3649..88e760458b08 100644 --- a/spring-security-rest-digest-auth/pom.xml +++ b/spring-security-rest-digest-auth/pom.xml @@ -122,14 +122,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -294,6 +294,8 @@ 5.2.2.Final + 3.0.1 + 1.2 19.0 From 6fd951d7959294eae940df8e8cf6c5f275fc7a11 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 6 Jan 2016 20:01:17 +0200 Subject: [PATCH 050/626] cleanup and upgrade --- spring-security-mvc-session/pom.xml | 11 +++++++---- .../src/main/resources/webSecurityConfig.xml | 3 ++- .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 8 ++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index c9a919e6843e..fd90be6cc878 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -87,14 +87,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -103,7 +103,7 @@ com.codahale.metrics metrics-core - 3.0.1 + ${codahale.metrics.version} @@ -243,7 +243,10 @@ 5.2.2.Final - + 3.0.1 + 1.2 + 3.0.1 + 19.0 3.4 diff --git a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml index a9b0019fbd0f..02b74b0933a5 100644 --- a/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-session/src/main/resources/webSecurityConfig.xml @@ -12,10 +12,11 @@ + + - diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp index d18b59a10caf..5a58d8892fae 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/console.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp index afd2c6da594f..2568adec669c 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/homepage.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp index 0eb857c62aee..762218e40fe1 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp @@ -4,20 +4,20 @@

Login

- +
User:
Password:
- + - + - + From 70be232c5a58672138138583ccb78bc3ccc626f4 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 7 Jan 2016 15:17:26 +0200 Subject: [PATCH 051/626] cleanup and upgrade --- .../src/main/webapp/WEB-INF/view/login.jsp | 2 +- .../pom.xml | 23 +++++++++++-------- .../src/main/resources/webSecurityConfig.xml | 14 +++++------ .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 8 +++---- .../src/main/webapp/WEB-INF/view/login.jsp | 2 +- spring-security-oauth/pom.xml | 2 +- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp index 762218e40fe1..eb41cc79a81f 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/login.jsp @@ -17,7 +17,7 @@ - + diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml index 37f271f66d60..1691f10f4351 100644 --- a/spring-security-mvc-persisted-remember-me/pom.xml +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -93,14 +93,14 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -109,13 +109,13 @@ com.h2database h2 - 1.4.178 + ${h2.version} postgresql postgresql - 9.1-901.jdbc4 + ${postgresql.version} runtime @@ -260,12 +260,15 @@ - 4.1.4.RELEASE - 3.2.5.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE - 4.3.10.Final - 5.1.35 + 4.3.11.Final + 5.1.37 + 1.4.190 + 9.1-901.jdbc4 + 1.7.12 @@ -273,9 +276,11 @@ 5.1.3.Final + 3.0.1 + 1.2 - 18.0 + 19.0 3.4 diff --git a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml index 0fa077db00fb..a11f13c9ab1f 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-persisted-remember-me/src/main/resources/webSecurityConfig.xml @@ -7,11 +7,11 @@ xmlns:util="http://www.springframework.org/schema/util" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd - http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd"> @@ -35,9 +35,9 @@ - - - + + + diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp index d18b59a10caf..5a58d8892fae 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/console.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp index afd2c6da594f..2568adec669c 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/homepage.jsp @@ -16,7 +16,7 @@
- ">Logout + ">Logout \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp index 5697d1544a69..7636cd5e6159 100644 --- a/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-persisted-remember-me/src/main/webapp/WEB-INF/view/login.jsp @@ -17,20 +17,20 @@

Login

- +
User:
Password:
Remember Me:
Remember Me:
- + - + - + diff --git a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp index 762218e40fe1..eb41cc79a81f 100644 --- a/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-mvc-session/src/main/webapp/WEB-INF/view/login.jsp @@ -17,7 +17,7 @@ - + diff --git a/spring-security-oauth/pom.xml b/spring-security-oauth/pom.xml index 473a4e5c352f..7bb7aa86c84b 100644 --- a/spring-security-oauth/pom.xml +++ b/spring-security-oauth/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.2.7.RELEASE + 1.3.1.RELEASE From a10967217275f62614ffeb3f7f0f8eb2e8ae8e0f Mon Sep 17 00:00:00 2001 From: David Morley Date: Thu, 7 Jan 2016 20:28:55 -0600 Subject: [PATCH 052/626] Rename package org.baeldung -> com.baeldung --- .../src/main/java/{org => com}/baeldung/Adder.java | 2 +- .../src/main/java/{org => com}/baeldung/AdderImpl.java | 2 +- core-java-8/src/main/java/{org => com}/baeldung/Bar.java | 2 +- core-java-8/src/main/java/{org => com}/baeldung/Baz.java | 2 +- core-java-8/src/main/java/{org => com}/baeldung/Foo.java | 2 +- .../src/main/java/{org => com}/baeldung/FooExtended.java | 2 +- .../src/main/java/{org => com}/baeldung/UseFoo.java | 2 +- .../baeldung/java8/Java8CollectionCleanupUnitTest.java | 2 +- .../java8/Java8FunctionalInteracesLambdasTest.java | 8 ++++---- .../{org => com}/baeldung/java8/Java8SortUnitTest.java | 4 ++-- .../{org => com}/baeldung/java8/JavaFolderSizeTest.java | 2 +- .../baeldung/java8/JavaTryWithResourcesTest.java | 2 +- .../java8/base64/ApacheCommonsEncodeDecodeTest.java | 2 +- .../baeldung/java8/base64/Java8EncodeDecodeTest.java | 2 +- .../java/{org => com}/baeldung/java8/entity/Human.java | 2 +- 15 files changed, 19 insertions(+), 19 deletions(-) rename core-java-8/src/main/java/{org => com}/baeldung/Adder.java (90%) rename core-java-8/src/main/java/{org => com}/baeldung/AdderImpl.java (93%) rename core-java-8/src/main/java/{org => com}/baeldung/Bar.java (87%) rename core-java-8/src/main/java/{org => com}/baeldung/Baz.java (87%) rename core-java-8/src/main/java/{org => com}/baeldung/Foo.java (84%) rename core-java-8/src/main/java/{org => com}/baeldung/FooExtended.java (88%) rename core-java-8/src/main/java/{org => com}/baeldung/UseFoo.java (97%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/Java8CollectionCleanupUnitTest.java (97%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/Java8FunctionalInteracesLambdasTest.java (95%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/Java8SortUnitTest.java (98%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/JavaFolderSizeTest.java (99%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/JavaTryWithResourcesTest.java (99%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java (98%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/base64/Java8EncodeDecodeTest.java (99%) rename core-java-8/src/test/java/{org => com}/baeldung/java8/entity/Human.java (98%) diff --git a/core-java-8/src/main/java/org/baeldung/Adder.java b/core-java-8/src/main/java/com/baeldung/Adder.java similarity index 90% rename from core-java-8/src/main/java/org/baeldung/Adder.java rename to core-java-8/src/main/java/com/baeldung/Adder.java index 4578990de7c5..e3e100f121ae 100644 --- a/core-java-8/src/main/java/org/baeldung/Adder.java +++ b/core-java-8/src/main/java/com/baeldung/Adder.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import java.util.function.Consumer; import java.util.function.Function; diff --git a/core-java-8/src/main/java/org/baeldung/AdderImpl.java b/core-java-8/src/main/java/com/baeldung/AdderImpl.java similarity index 93% rename from core-java-8/src/main/java/org/baeldung/AdderImpl.java rename to core-java-8/src/main/java/com/baeldung/AdderImpl.java index a62c0cd4fb9d..55cf84c378c4 100644 --- a/core-java-8/src/main/java/org/baeldung/AdderImpl.java +++ b/core-java-8/src/main/java/com/baeldung/AdderImpl.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import java.util.function.Consumer; import java.util.function.Function; diff --git a/core-java-8/src/main/java/org/baeldung/Bar.java b/core-java-8/src/main/java/com/baeldung/Bar.java similarity index 87% rename from core-java-8/src/main/java/org/baeldung/Bar.java rename to core-java-8/src/main/java/com/baeldung/Bar.java index 0dd7df6be2eb..f9b6f2773e9a 100644 --- a/core-java-8/src/main/java/org/baeldung/Bar.java +++ b/core-java-8/src/main/java/com/baeldung/Bar.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; @FunctionalInterface public interface Bar { diff --git a/core-java-8/src/main/java/org/baeldung/Baz.java b/core-java-8/src/main/java/com/baeldung/Baz.java similarity index 87% rename from core-java-8/src/main/java/org/baeldung/Baz.java rename to core-java-8/src/main/java/com/baeldung/Baz.java index bcc46af6e746..6d03f74198fa 100644 --- a/core-java-8/src/main/java/org/baeldung/Baz.java +++ b/core-java-8/src/main/java/com/baeldung/Baz.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; @FunctionalInterface public interface Baz { diff --git a/core-java-8/src/main/java/org/baeldung/Foo.java b/core-java-8/src/main/java/com/baeldung/Foo.java similarity index 84% rename from core-java-8/src/main/java/org/baeldung/Foo.java rename to core-java-8/src/main/java/com/baeldung/Foo.java index a10e45a8f58e..c42ec86f8b3a 100644 --- a/core-java-8/src/main/java/org/baeldung/Foo.java +++ b/core-java-8/src/main/java/com/baeldung/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; @FunctionalInterface public interface Foo { diff --git a/core-java-8/src/main/java/org/baeldung/FooExtended.java b/core-java-8/src/main/java/com/baeldung/FooExtended.java similarity index 88% rename from core-java-8/src/main/java/org/baeldung/FooExtended.java rename to core-java-8/src/main/java/com/baeldung/FooExtended.java index 39c3a0765f8f..c8ed0c35ddc5 100644 --- a/core-java-8/src/main/java/org/baeldung/FooExtended.java +++ b/core-java-8/src/main/java/com/baeldung/FooExtended.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; @FunctionalInterface public interface FooExtended extends Baz, Bar { diff --git a/core-java-8/src/main/java/org/baeldung/UseFoo.java b/core-java-8/src/main/java/com/baeldung/UseFoo.java similarity index 97% rename from core-java-8/src/main/java/org/baeldung/UseFoo.java rename to core-java-8/src/main/java/com/baeldung/UseFoo.java index a29c5631ace3..bfa7a2f2c08d 100644 --- a/core-java-8/src/main/java/org/baeldung/UseFoo.java +++ b/core-java-8/src/main/java/com/baeldung/UseFoo.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import java.util.function.Function; diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java similarity index 97% rename from core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java rename to core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java index acca829b7864..7329a2dc9731 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8CollectionCleanupUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8; +package com.baeldung.java8; import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java similarity index 95% rename from core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java rename to core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java index 3845d6ba8452..0620ebd35aee 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8FunctionalInteracesLambdasTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java @@ -1,8 +1,8 @@ -package org.baeldung.java8; +package com.baeldung.java8; -import org.baeldung.Foo; -import org.baeldung.FooExtended; -import org.baeldung.UseFoo; +import com.baeldung.Foo; +import com.baeldung.FooExtended; +import com.baeldung.UseFoo; import org.junit.Before; import org.junit.Test; diff --git a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java similarity index 98% rename from core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java rename to core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java index 8ed7828de029..e0e10b293e2e 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8; +package com.baeldung.java8; import static org.hamcrest.Matchers.equalTo; @@ -6,7 +6,7 @@ import java.util.Comparator; import java.util.List; -import org.baeldung.java8.entity.Human; +import com.baeldung.java8.entity.Human; import org.junit.Assert; import org.junit.Test; diff --git a/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java b/core-java-8/src/test/java/com/baeldung/java8/JavaFolderSizeTest.java similarity index 99% rename from core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java rename to core-java-8/src/test/java/com/baeldung/java8/JavaFolderSizeTest.java index a65971bb913f..2ac16b5d1dc6 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/JavaFolderSizeTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/JavaFolderSizeTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8; +package com.baeldung.java8; import static org.junit.Assert.assertEquals; diff --git a/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java b/core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesTest.java similarity index 99% rename from core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java rename to core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesTest.java index a59682c5350c..18110b181d67 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/JavaTryWithResourcesTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8; +package com.baeldung.java8; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/core-java-8/src/test/java/org/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java b/core-java-8/src/test/java/com/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java similarity index 98% rename from core-java-8/src/test/java/org/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java rename to core-java-8/src/test/java/com/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java index 9745655d8a42..07380cdd0142 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/base64/ApacheCommonsEncodeDecodeTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8.base64; +package com.baeldung.java8.base64; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; diff --git a/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java b/core-java-8/src/test/java/com/baeldung/java8/base64/Java8EncodeDecodeTest.java similarity index 99% rename from core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java rename to core-java-8/src/test/java/com/baeldung/java8/base64/Java8EncodeDecodeTest.java index 7b7a0be26a63..3c504edbf351 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/base64/Java8EncodeDecodeTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java8.base64; +package com.baeldung.java8.base64; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; diff --git a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java b/core-java-8/src/test/java/com/baeldung/java8/entity/Human.java similarity index 98% rename from core-java-8/src/test/java/org/baeldung/java8/entity/Human.java rename to core-java-8/src/test/java/com/baeldung/java8/entity/Human.java index ac58b301b7f3..cab8546129f6 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/entity/Human.java +++ b/core-java-8/src/test/java/com/baeldung/java8/entity/Human.java @@ -1,4 +1,4 @@ -package org.baeldung.java8.entity; +package com.baeldung.java8.entity; public class Human { private String name; From 959eb4320f908414497b647e183fd0499bf6b2ef Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 9 Jan 2016 01:34:39 +0200 Subject: [PATCH 053/626] minor cleanup work --- .../.settings/org.eclipse.jdt.core.prefs | 9 ++- .../src/main/java/com/baeldung/AdderImpl.java | 5 +- .../src/main/java/com/baeldung/Foo.java | 3 +- .../src/main/java/com/baeldung/UseFoo.java | 22 ++++--- .../Java8FunctionalInteracesLambdasTest.java | 60 +++++++++---------- .../com/baeldung/java8/Java8SortUnitTest.java | 2 +- 6 files changed, 50 insertions(+), 51 deletions(-) diff --git a/core-java-8/.settings/org.eclipse.jdt.core.prefs b/core-java-8/.settings/org.eclipse.jdt.core.prefs index c57289fc0970..c38ccc12948e 100644 --- a/core-java-8/.settings/org.eclipse.jdt.core.prefs +++ b/core-java-8/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault @@ -26,7 +27,7 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=error +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning @@ -35,7 +36,7 @@ org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=error +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore @@ -48,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error @@ -68,6 +70,7 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled @@ -82,6 +85,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning @@ -91,6 +95,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference= org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 diff --git a/core-java-8/src/main/java/com/baeldung/AdderImpl.java b/core-java-8/src/main/java/com/baeldung/AdderImpl.java index 55cf84c378c4..5109f3aaba4c 100644 --- a/core-java-8/src/main/java/com/baeldung/AdderImpl.java +++ b/core-java-8/src/main/java/com/baeldung/AdderImpl.java @@ -6,11 +6,12 @@ public class AdderImpl implements Adder { @Override - public String addWithFunction(Function f) { + public String addWithFunction(Function f) { return f.apply("Something "); } @Override - public void addWithConsumer(Consumer f) {} + public void addWithConsumer(Consumer f) { + } } diff --git a/core-java-8/src/main/java/com/baeldung/Foo.java b/core-java-8/src/main/java/com/baeldung/Foo.java index c42ec86f8b3a..90ebdfeed391 100644 --- a/core-java-8/src/main/java/com/baeldung/Foo.java +++ b/core-java-8/src/main/java/com/baeldung/Foo.java @@ -5,5 +5,6 @@ public interface Foo { String method(String string); - default void defaultMethod() {} + default void defaultMethod() { + } } diff --git a/core-java-8/src/main/java/com/baeldung/UseFoo.java b/core-java-8/src/main/java/com/baeldung/UseFoo.java index bfa7a2f2c08d..a91404ebafca 100644 --- a/core-java-8/src/main/java/com/baeldung/UseFoo.java +++ b/core-java-8/src/main/java/com/baeldung/UseFoo.java @@ -6,34 +6,32 @@ public class UseFoo { private String value = "Enclosing scope value"; - public String add(String string, Foo foo) { + public String add(final String string, final Foo foo) { return foo.method(string); } - public String addWithStandardFI(String string, Function fn) { + public String addWithStandardFI(final String string, final Function fn) { return fn.apply(string); } public String scopeExperiment() { - Foo fooIC = new Foo() { + final Foo fooIC = new Foo() { String value = "Inner class value"; @Override - public String method(String string) { - return this.value; + public String method(final String string) { + return value; } }; - String resultIC = fooIC.method(""); + final String resultIC = fooIC.method(""); - Foo fooLambda = parameter -> { - String value = "Lambda value"; + final Foo fooLambda = parameter -> { + final String value = "Lambda value"; return this.value; }; - String resultLambda = fooLambda.method(""); + final String resultLambda = fooLambda.method(""); - return "Results: resultIC = " + resultIC + - ", resultLambda = " + resultLambda; + return "Results: resultIC = " + resultIC + ", resultLambda = " + resultLambda; } - } diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java index 0620ebd35aee..94448fcc8351 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8FunctionalInteracesLambdasTest.java @@ -1,15 +1,16 @@ package com.baeldung.java8; -import com.baeldung.Foo; -import com.baeldung.FooExtended; -import com.baeldung.UseFoo; -import org.junit.Before; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import java.util.function.Function; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.Foo; +import com.baeldung.FooExtended; +import com.baeldung.UseFoo; public class Java8FunctionalInteracesLambdasTest { @@ -22,39 +23,35 @@ public void init() { @Test public void functionalInterfaceInstantiation_whenReturnDefiniteString_thenCorrect() { - - Foo foo = parameter -> parameter + "from lambda"; - String result = useFoo.add("Message ", foo); + final Foo foo = parameter -> parameter + "from lambda"; + final String result = useFoo.add("Message ", foo); assertEquals("Message from lambda", result); } @Test public void standardFIParameter_whenReturnDefiniteString_thenCorrect() { - - Function fn = parameter -> parameter + "from lambda"; - String result = useFoo.addWithStandardFI("Message ", fn); + final Function fn = parameter -> parameter + "from lambda"; + final String result = useFoo.addWithStandardFI("Message ", fn); assertEquals("Message from lambda", result); } @Test public void defaultMethodFromExtendedInterface_whenReturnDefiniteString_thenCorrect() { - - FooExtended fooExtended = string -> string; - String result = fooExtended.defaultMethod(); + final FooExtended fooExtended = string -> string; + final String result = fooExtended.defaultMethod(); assertEquals("String from Bar", result); } @Test public void lambdaAndInnerClassInstantiation_whenReturnSameString_thenCorrect() { + final Foo foo = parameter -> parameter + "from Foo"; - Foo foo = parameter -> parameter + "from Foo"; - - Foo fooByIC = new Foo() { + final Foo fooByIC = new Foo() { @Override - public String method(String string) { + public String method(final String string) { return string + "from Foo"; } }; @@ -64,35 +61,32 @@ public String method(String string) { @Test public void accessVariablesFromDifferentScopes_whenReturnPredefinedString_thenCorrect() { - - assertEquals("Results: resultIC = Inner class value, resultLambda = Enclosing scope value", - useFoo.scopeExperiment()); + assertEquals("Results: resultIC = Inner class value, resultLambda = Enclosing scope value", useFoo.scopeExperiment()); } @Test public void shorteningLambdas_whenReturnEqualsResults_thenCorrect() { + final Foo foo = parameter -> buildString(parameter); - Foo foo = parameter -> buildString(parameter); - - Foo fooHuge = parameter -> { String result = "Something " + parameter; - //many lines of code + final Foo fooHuge = parameter -> { + final String result = "Something " + parameter; + // many lines of code return result; }; assertEquals(foo.method("Something"), fooHuge.method("Something")); } - private String buildString(String parameter) { - String result = "Something " + parameter; - //many lines of code + private String buildString(final String parameter) { + final String result = "Something " + parameter; + // many lines of code return result; } @Test public void mutatingOfEffectivelyFinalVariable_whenNotEquals_thenCorrect() { - - int[] total = new int[1]; - Runnable r = () -> total[0]++; + final int[] total = new int[1]; + final Runnable r = () -> total[0]++; r.run(); assertNotEquals(0, total[0]); diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java index e0e10b293e2e..2ba9e417d616 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java @@ -6,10 +6,10 @@ import java.util.Comparator; import java.util.List; -import com.baeldung.java8.entity.Human; import org.junit.Assert; import org.junit.Test; +import com.baeldung.java8.entity.Human; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; From 5154c5ba888d3708b1b905915ba0aa969ccc85d7 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 9 Jan 2016 13:01:30 +0200 Subject: [PATCH 054/626] cleanup and upgrade --- handling-spring-static-resources/.classpath | 4 +- handling-spring-static-resources/pom.xml | 20 +- .../src/main/resources/webSecurityConfig.xml | 8 +- .../src/main/webapp/WEB-INF/view/login.jsp | 6 +- .../.classpath | 2 +- .../pom.xml | 203 +++++++++++++----- .../CustomAuthenticationFailureHandler.java | 2 +- .../java/org/baeldung/spring/MvcConfig.java | 2 +- .../baeldung/spring/SecSecurityConfig.java | 10 +- .../src/main/resources/webSecurityConfig.xml | 17 +- .../src/main/webapp/WEB-INF/view/admin.jsp | 2 +- .../webapp/WEB-INF/view/changePassword.jsp | 2 +- .../src/main/webapp/WEB-INF/view/console.jsp | 2 +- .../src/main/webapp/WEB-INF/view/home.jsp | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 2 +- .../src/main/webapp/WEB-INF/view/login.jsp | 11 +- .../src/main/webapp/WEB-INF/view/logout.jsp | 2 +- .../baeldung/test/ChangePasswordLiveTest.java | 2 +- 18 files changed, 193 insertions(+), 106 deletions(-) diff --git a/handling-spring-static-resources/.classpath b/handling-spring-static-resources/.classpath index 88536687a565..71a1c1e0b57d 100644 --- a/handling-spring-static-resources/.classpath +++ b/handling-spring-static-resources/.classpath @@ -19,9 +19,9 @@ - + - + diff --git a/handling-spring-static-resources/pom.xml b/handling-spring-static-resources/pom.xml index 677d70593296..8efacc4b28fe 100644 --- a/handling-spring-static-resources/pom.xml +++ b/handling-spring-static-resources/pom.xml @@ -171,33 +171,29 @@ - 1.7 + 1.8 - 4.1.5.RELEASE - 3.2.5.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 1.8.1 2.3.2-b01 - - 4.1.5.RELEASE - 3.2.5.RELEASE - - 4.3.10.Final - 5.1.35 - 1.7.2.RELEASE + 4.3.11.Final + 5.1.37 + 1.9.2.RELEASE - 2.5.5 + 2.6.4 1.7.13 1.1.3 - 5.1.3.Final + 5.2.2.Final 19.0 diff --git a/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml index 56d7f9c11321..76b5015e7bca 100644 --- a/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml +++ b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml @@ -2,10 +2,10 @@ @@ -21,7 +21,7 @@ - + diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp index 1b09f7c634da..8c9f46c027c5 100644 --- a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp @@ -41,15 +41,15 @@

- +
User:
Password:
Remember Me:
Remember Me:
- + - + diff --git a/spring-security-login-and-registration/.classpath b/spring-security-login-and-registration/.classpath index 91f27076bead..26981b6dd763 100644 --- a/spring-security-login-and-registration/.classpath +++ b/spring-security-login-and-registration/.classpath @@ -23,7 +23,7 @@ - + diff --git a/spring-security-login-and-registration/pom.xml b/spring-security-login-and-registration/pom.xml index ffa8be484b81..9e0f15688fd2 100644 --- a/spring-security-login-and-registration/pom.xml +++ b/spring-security-login-and-registration/pom.xml @@ -9,67 +9,108 @@ spring-security-login-and-registration war - - org.springframework.boot - spring-boot-starter-parent - 1.2.6.RELEASE - + + + + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} + + + + + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + + - org.springframework.boot - spring-boot-starter-web + org.springframework + spring-context + ${org.springframework.version} org.springframework spring-context-support + ${org.springframework.version} - org.springframework.security - spring-security-config + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} - - org.springframework.boot - spring-boot-starter-tomcat - provided + org.springframework + spring-web + ${org.springframework.version} - org.apache.tomcat.embed - tomcat-embed-websocket - provided + org.springframework + spring-webmvc + ${org.springframework.version} javax.servlet javax.servlet-api + ${javax.servlet.version} + provided - - javax.servlet.jsp - javax.servlet.jsp-api - ${javax.servlet.jsp-api.version} - + javax.servlet jstl + ${jstl.version} + runtime - - org.springframework.security - spring-security-taglibs - - - javax.el - el-api - 2.2 - + org.springframework spring-test + ${org.springframework.version} test @@ -77,17 +118,19 @@ org.passay passay - 1.0 + ${passay.version} org.springframework.data spring-data-jpa + ${spring-data-jpa.version} org.hibernate hibernate-entitymanager + ${hibernate.version} @@ -98,25 +141,29 @@ org.hibernate hibernate-validator + ${hibernate-validator.version} mysql mysql-connector-java + ${mysql-connector-java.version} commons-dbcp commons-dbcp + ${commons-dbcp.version} com.fasterxml.jackson.core jackson-databind + ${jackson.version} javax.mail mail - 1.4.7 + ${javax.mail.version} com.google.guava @@ -128,32 +175,51 @@ org.slf4j slf4j-api + ${org.slf4j.version} ch.qos.logback logback-classic + ${logback.version} + org.slf4j jcl-over-slf4j + ${org.slf4j.version} org.slf4j log4j-over-slf4j + ${org.slf4j.version} junit junit + ${junit.version} test - + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + com.jayway.restassured rest-assured - 2.4.0 + ${rest-assured.version} test @@ -163,6 +229,11 @@ + + javax.el + el-api + 2.2 + @@ -181,8 +252,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - ${java-version} - ${java-version} + 1.8 + 1.8 @@ -192,6 +263,20 @@ ${maven-war-plugin.version} + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + + org.codehaus.cargo cargo-maven2-plugin @@ -199,7 +284,7 @@ true - tomcat8x + jetty8x embedded @@ -207,43 +292,39 @@ - 8081 + 8082 - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - true - - **/*IntegrationTest.java - **/*LiveTest.java - - - - - - - + - 1.7 - 4.1.6.RELEASE + 1.8 + + + 4.2.4.RELEASE 4.0.3.RELEASE + + 4.3.11.Final + 5.2.2.Final + 5.1.37 + 1.9.2.RELEASE + + 1.7.13 1.1.3 2.3.2-b01 - + 3.0.1 + 1.2 + 1 @@ -253,6 +334,14 @@ 19.0 + 1.3 + 4.12 + 1.0 + 2.4.0 + 1.4.7 + 2.6.4 + 1.4 + 1.4.17 3.3 diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java index e8d995e781ea..94440f8a89ae 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.servlet.LocaleResolver; -@Component +@Component("authenticationFailureHandler") public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler { @Autowired diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java index 56141d8f339b..1234cde0d02a 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java @@ -35,7 +35,7 @@ public MvcConfig() { @Override public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - registry.addViewController("/login.html"); + registry.addViewController("/login"); registry.addViewController("/registration.html"); registry.addViewController("/logout.html"); registry.addViewController("/homepage.html"); diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 677ad514e56f..9ae8f6e78b12 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -51,7 +51,7 @@ protected void configure(final HttpSecurity http) throws Exception { http .csrf().disable() .authorizeRequests() - .antMatchers("/j_spring_security_check*","/login*", "/logout*", "/signin/**", "/signup/**", + .antMatchers("/login*","/login*", "/logout*", "/signin/**", "/signup/**", "/user/registration*", "/regitrationConfirm*", "/expiredAccount*", "/registration*", "/badUser*", "/user/resendRegistrationToken*" ,"/forgetPassword*", "/user/resetPassword*", "/user/changePassword*", "/emailError*", "/resources/**","/old/user/registration*","/successRegister*").permitAll() @@ -59,14 +59,11 @@ protected void configure(final HttpSecurity http) throws Exception { .anyRequest().authenticated() .and() .formLogin() - .loginPage("/login.html") - .loginProcessingUrl("/j_spring_security_check") + .loginPage("/login") .defaultSuccessUrl("/homepage.html") - .failureUrl("/login.html?error=true") + .failureUrl("/login?error=true") .successHandler(myAuthenticationSuccessHandler) .failureHandler(authenticationFailureHandler) - .usernameParameter("j_username") - .passwordParameter("j_password") .permitAll() .and() .sessionManagement() @@ -75,7 +72,6 @@ protected void configure(final HttpSecurity http) throws Exception { .and() .logout() .invalidateHttpSession(false) - .logoutUrl("/j_spring_security_logout") .logoutSuccessUrl("/logout.html?logSucc=true") .deleteCookies("JSESSIONID") .permitAll(); diff --git a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml index 3141b19142a2..4e67a1200f84 100644 --- a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ @@ -28,10 +28,17 @@ - - - + + + + + + + + diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp index db3d8f20ba64..ad0a8231adc4 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp @@ -15,7 +15,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp index c5ff23287dca..88836e96f507 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp @@ -17,7 +17,7 @@ diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp index 1cf661af8799..e06cdd39f049 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp @@ -13,7 +13,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp index f8db1632f6f5..027f583d6153 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp @@ -14,7 +14,7 @@ diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp index 86cac0152fd5..af931ac66f94 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp @@ -15,7 +15,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp index 949b8164de94..c22c3241cd8a 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp @@ -58,18 +58,17 @@ ${SPRING_SECURITY_LAST_EXCEPTION} - | + |

- + + - +

- +

- ">"> diff --git a/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java b/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java index 05377d5578d5..3939b5685cc5 100644 --- a/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java +++ b/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java @@ -38,7 +38,7 @@ public class ChangePasswordLiveTest { @Autowired private PasswordEncoder passwordEncoder; - private final FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/j_spring_security_check", "j_username", "j_password"); + private final FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/login", "username", "password"); @Before public void init() { From f060700ceca344930cfabdf08e7698a905d6b56d Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 9 Jan 2016 22:22:58 +0200 Subject: [PATCH 055/626] cleanup and upgrade --- .../src/main/webapp/WEB-INF/view/login.jsp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp index c22c3241cd8a..a71fe9dc3a49 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp @@ -15,20 +15,20 @@ <spring:message code="label.pages.home.title"></spring:message> + + + + + +
+

Foo Details

+
+ + {{foo.id}} +
+ +
+ + {{foo.name}} +
+ +
+ New Foo +
+

+ +

User Details

+
+ + {{user.id}} +
+ +
+ + {{user.username}} +
+ +
+ + {{user.age}} +
+ +
+ New User +
+ +
+ + \ No newline at end of file diff --git a/spring-zuul/spring-zuul-ui/src/main/webapp/resources/angular-utf8-base64.min.js b/spring-zuul/spring-zuul-ui/src/main/webapp/resources/angular-utf8-base64.min.js new file mode 100644 index 000000000000..24af57d02099 --- /dev/null +++ b/spring-zuul/spring-zuul-ui/src/main/webapp/resources/angular-utf8-base64.min.js @@ -0,0 +1 @@ +"use strict";angular.module("ab-base64",[]).constant("base64",function(){var a={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lookup:null,ie:/MSIE /.test(navigator.userAgent),ieo:/MSIE [67]/.test(navigator.userAgent),encode:function(b){var c,d,e,f,g=a.toUtf8(b),h=-1,i=g.length,j=[,,,];if(a.ie){for(c=[];++h>2,j[1]=(3&d)<<4|e>>4,isNaN(e)?j[2]=j[3]=64:(f=g[++h],j[2]=(15&e)<<2|f>>6,j[3]=isNaN(f)?64:63&f),c.push(a.alphabet.charAt(j[0]),a.alphabet.charAt(j[1]),a.alphabet.charAt(j[2]),a.alphabet.charAt(j[3]));return c.join("")}for(c="";++h>2,j[1]=(3&d)<<4|e>>4,isNaN(e)?j[2]=j[3]=64:(f=g[++h],j[2]=(15&e)<<2|f>>6,j[3]=isNaN(f)?64:63&f),c+=a.alphabet[j[0]]+a.alphabet[j[1]]+a.alphabet[j[2]]+a.alphabet[j[3]];return c},decode:function(b){if(b=b.replace(/\s/g,""),b.length%4)throw new Error("InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.");if(/[^A-Za-z0-9+\/=\s]/g.test(b))throw new Error("InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.");var c,d=a.fromUtf8(b),e=0,f=d.length;if(a.ieo){for(c=[];f>e;)c.push(d[e]<128?String.fromCharCode(d[e++]):d[e]>191&&d[e]<224?String.fromCharCode((31&d[e++])<<6|63&d[e++]):String.fromCharCode((15&d[e++])<<12|(63&d[e++])<<6|63&d[e++]));return c.join("")}for(c="";f>e;)c+=String.fromCharCode(d[e]<128?d[e++]:d[e]>191&&d[e]<224?(31&d[e++])<<6|63&d[e++]:(15&d[e++])<<12|(63&d[e++])<<6|63&d[e++]);return c},toUtf8:function(a){var b,c=-1,d=a.length,e=[];if(/^[\x00-\x7f]*$/.test(a))for(;++cb?e.push(b):2048>b?e.push(b>>6|192,63&b|128):e.push(b>>12|224,b>>6&63|128,63&b|128);return e},fromUtf8:function(b){var c,d=-1,e=[],f=[,,,];if(!a.lookup){for(c=a.alphabet.length,a.lookup={};++d>4),f[2]=a.lookup[b.charAt(++d)],64!==f[2])&&(e.push((15&f[1])<<4|f[2]>>2),f[3]=a.lookup[b.charAt(++d)],64!==f[3]);)e.push((3&f[2])<<6|f[3]);return e}},b={decode:function(b){b=b.replace(/-/g,"+").replace(/_/g,"/");var c=b.length%4;if(c){if(1===c)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");b+=new Array(5-c).join("=")}return a.decode(b)},encode:function(b){var c=a.encode(b);return c.replace(/\+/g,"-").replace(/\//g,"_").split("=",1)[0]}};return{decode:a.decode,encode:a.encode,urldecode:b.decode,urlencode:b.encode}}()); \ No newline at end of file diff --git a/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java b/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java new file mode 100644 index 000000000000..094d3250c7c1 --- /dev/null +++ b/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java @@ -0,0 +1,30 @@ +package org.baeldung.web; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.jayway.restassured.RestAssured; +import com.jayway.restassured.response.Response; + +public class LiveTest { + + @Test + public void whenSendRequestToFooResource_thenOK() { + final Response response = RestAssured.get("http://localhost:8080/foos/1"); + assertEquals(200, response.getStatusCode()); + } + + @Test + public void whenSendRequestToUserResource_thenHeaderAdded() { + final Response response = RestAssured.get("http://localhost:8080/users/1"); + assertEquals(200, response.getStatusCode()); + } + + @Test + public void whenSendRequest_thenHeaderAdded() { + final Response response = RestAssured.get("http://localhost:8080/foos/1"); + assertEquals(200, response.getStatusCode()); + assertEquals("TestSample", response.getHeader("Test")); + } +} diff --git a/spring-zuul/spring-zuul-ui/src/test/resources/.gitignore b/spring-zuul/spring-zuul-ui/src/test/resources/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/spring-zuul/spring-zuul-ui/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-zuul/spring-zuul-ui/src/test/resources/persistence-mysql.properties b/spring-zuul/spring-zuul-ui/src/test/resources/persistence-mysql.properties new file mode 100644 index 000000000000..8263b0d9accd --- /dev/null +++ b/spring-zuul/spring-zuul-ui/src/test/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-zuul/spring-zuul-users-resource/.classpath b/spring-zuul/spring-zuul-users-resource/.classpath new file mode 100644 index 000000000000..0cad5db2d090 --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-zuul/spring-zuul-users-resource/.project b/spring-zuul/spring-zuul-users-resource/.project new file mode 100644 index 000000000000..2fedf43db40f --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/.project @@ -0,0 +1,48 @@ + + + spring-zuul-users-resource + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-zuul/spring-zuul-users-resource/pom.xml b/spring-zuul/spring-zuul-users-resource/pom.xml new file mode 100644 index 000000000000..653c6b9d15e0 --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + spring-zuul-users-resource + spring-zuul-users-resource + war + + + org.baeldung + spring-zuul + 1.0.0-SNAPSHOT + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + spring-zuul-users-resource + + + src/main/resources + true + + + + + \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java new file mode 100644 index 000000000000..1e35eff5516f --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java @@ -0,0 +1,14 @@ +package org.baeldung.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.web.SpringBootServletInitializer; + +@SpringBootApplication +public class ResourceServerApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(ResourceServerApplication.class, args); + } + +} \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java new file mode 100644 index 000000000000..c040c8ac425a --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java @@ -0,0 +1,13 @@ +package org.baeldung.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +@ComponentScan({ "org.baeldung.web.controller" }) +public class ResourceServerWebConfig extends WebMvcConfigurerAdapter { + +} diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java new file mode 100644 index 000000000000..b1db89179a57 --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.web.dto.User; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class UserController { + + public UserController() { + super(); + } + + // API - read + @RequestMapping(method = RequestMethod.GET, value = "/users/{id}") + @ResponseBody + public User findById(@PathVariable final long id, HttpServletRequest req, HttpServletResponse res) { + return new User(Long.parseLong(randomNumeric(2)), randomAlphabetic(4), Integer.parseInt(randomNumeric(2))); + } + +} diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java new file mode 100644 index 000000000000..f5e4124f93ad --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java @@ -0,0 +1,46 @@ +package org.baeldung.web.dto; + +public class User { + private long id; + private String username; + private int age; + + public User() { + super(); + } + + public User(final long id, final String name, int age) { + super(); + + this.id = id; + this.username = name; + this.age = age; + } + + // + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(final String username) { + this.username = username; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + +} \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties b/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties new file mode 100644 index 000000000000..81284546cedf --- /dev/null +++ b/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.contextPath=/spring-zuul-users-resource +server.port=8081 \ No newline at end of file From 89651d72f7275ae61ca2642ebd0278c591925539 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 29 Jan 2016 17:44:11 +0200 Subject: [PATCH 153/626] minor fix --- spring-zuul/pom.xml | 1 - .../spring-zuul-foos-resource/.project | 6 +-- spring-zuul/spring-zuul-ui/.classpath | 8 ++-- spring-zuul/spring-zuul-ui/.project | 6 +-- .../src/main/resources/application.yml | 4 -- .../src/main/resources/templates/index.html | 32 ------------- .../test/java/org/baeldung/web/LiveTest.java | 6 --- .../spring-zuul-users-resource/.classpath | 32 ------------- .../spring-zuul-users-resource/.project | 48 ------------------- .../spring-zuul-users-resource/pom.xml | 38 --------------- .../config/ResourceServerApplication.java | 14 ------ .../config/ResourceServerWebConfig.java | 13 ----- .../web/controller/UserController.java | 30 ------------ .../main/java/org/baeldung/web/dto/User.java | 46 ------------------ .../src/main/resources/application.properties | 2 - 15 files changed, 10 insertions(+), 276 deletions(-) delete mode 100644 spring-zuul/spring-zuul-users-resource/.classpath delete mode 100644 spring-zuul/spring-zuul-users-resource/.project delete mode 100644 spring-zuul/spring-zuul-users-resource/pom.xml delete mode 100644 spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java delete mode 100644 spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java delete mode 100644 spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java delete mode 100644 spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java delete mode 100644 spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties diff --git a/spring-zuul/pom.xml b/spring-zuul/pom.xml index 57ad3dfd3097..6ad1d0be34a0 100644 --- a/spring-zuul/pom.xml +++ b/spring-zuul/pom.xml @@ -15,7 +15,6 @@ spring-zuul-foos-resource - spring-zuul-users-resource spring-zuul-ui diff --git a/spring-zuul/spring-zuul-foos-resource/.project b/spring-zuul/spring-zuul-foos-resource/.project index de3fc55423ac..8d04c873fb7a 100644 --- a/spring-zuul/spring-zuul-foos-resource/.project +++ b/spring-zuul/spring-zuul-foos-resource/.project @@ -21,17 +21,17 @@ - org.eclipse.m2e.core.maven2Builder + org.springframework.ide.eclipse.core.springbuilder - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/spring-zuul/spring-zuul-ui/.classpath b/spring-zuul/spring-zuul-ui/.classpath index 1e75b7bbbb82..5c3ac53820a4 100644 --- a/spring-zuul/spring-zuul-ui/.classpath +++ b/spring-zuul/spring-zuul-ui/.classpath @@ -17,20 +17,20 @@
- + - + - - + + diff --git a/spring-zuul/spring-zuul-ui/.project b/spring-zuul/spring-zuul-ui/.project index d87aec6becd7..ec0f2cde815b 100644 --- a/spring-zuul/spring-zuul-ui/.project +++ b/spring-zuul/spring-zuul-ui/.project @@ -21,17 +21,17 @@ - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.m2e.core.maven2Builder - org.eclipse.wst.validation.validationbuilder + org.springframework.ide.eclipse.core.springbuilder - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder diff --git a/spring-zuul/spring-zuul-ui/src/main/resources/application.yml b/spring-zuul/spring-zuul-ui/src/main/resources/application.yml index 14660c497ba6..855020a40e96 100644 --- a/spring-zuul/spring-zuul-ui/src/main/resources/application.yml +++ b/spring-zuul/spring-zuul-ui/src/main/resources/application.yml @@ -3,7 +3,3 @@ zuul: foos: path: /foos/** url: http://localhost:8081/spring-zuul-foos-resource/foos - users: - path: /users/** - url: http://localhost:8081/spring-zuul-users-resource/users - \ No newline at end of file diff --git a/spring-zuul/spring-zuul-ui/src/main/resources/templates/index.html b/spring-zuul/spring-zuul-ui/src/main/resources/templates/index.html index 07d2b77f7fe1..d279f9eaf9c6 100755 --- a/spring-zuul/spring-zuul-ui/src/main/resources/templates/index.html +++ b/spring-zuul/spring-zuul-ui/src/main/resources/templates/index.html @@ -33,17 +33,6 @@ $scope.foo = $scope.foos.get({fooId:$scope.foo.id}); } - $scope.user = {id:0 , username:"john", age:11}; - $scope.users = $resource("/users/:userId",{userId:'@id'}); - - $scope.getUser = function(){ - $scope.user = $scope.users.get({userId:$scope.user.id}); - } - - - - - }); /*]]>*/ @@ -63,27 +52,6 @@

Foo Details

-

- -

User Details

-
- - {{user.id}} -
- -
- - {{user.username}} -
- -
- - {{user.age}} -
- -
- New User -
diff --git a/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java b/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java index 094d3250c7c1..7ced52777809 100644 --- a/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java +++ b/spring-zuul/spring-zuul-ui/src/test/java/org/baeldung/web/LiveTest.java @@ -15,12 +15,6 @@ public void whenSendRequestToFooResource_thenOK() { assertEquals(200, response.getStatusCode()); } - @Test - public void whenSendRequestToUserResource_thenHeaderAdded() { - final Response response = RestAssured.get("http://localhost:8080/users/1"); - assertEquals(200, response.getStatusCode()); - } - @Test public void whenSendRequest_thenHeaderAdded() { final Response response = RestAssured.get("http://localhost:8080/foos/1"); diff --git a/spring-zuul/spring-zuul-users-resource/.classpath b/spring-zuul/spring-zuul-users-resource/.classpath deleted file mode 100644 index 0cad5db2d090..000000000000 --- a/spring-zuul/spring-zuul-users-resource/.classpath +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-zuul/spring-zuul-users-resource/.project b/spring-zuul/spring-zuul-users-resource/.project deleted file mode 100644 index 2fedf43db40f..000000000000 --- a/spring-zuul/spring-zuul-users-resource/.project +++ /dev/null @@ -1,48 +0,0 @@ - - - spring-zuul-users-resource - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.springframework.ide.eclipse.core.springnature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/spring-zuul/spring-zuul-users-resource/pom.xml b/spring-zuul/spring-zuul-users-resource/pom.xml deleted file mode 100644 index 653c6b9d15e0..000000000000 --- a/spring-zuul/spring-zuul-users-resource/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - 4.0.0 - spring-zuul-users-resource - spring-zuul-users-resource - war - - - org.baeldung - spring-zuul - 1.0.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - spring-zuul-users-resource - - - src/main/resources - true - - - - - \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java deleted file mode 100644 index 1e35eff5516f..000000000000 --- a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.config; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.web.SpringBootServletInitializer; - -@SpringBootApplication -public class ResourceServerApplication extends SpringBootServletInitializer { - - public static void main(String[] args) { - SpringApplication.run(ResourceServerApplication.class, args); - } - -} \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java deleted file mode 100644 index c040c8ac425a..000000000000 --- a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -@EnableWebMvc -@ComponentScan({ "org.baeldung.web.controller" }) -public class ResourceServerWebConfig extends WebMvcConfigurerAdapter { - -} diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java deleted file mode 100644 index b1db89179a57..000000000000 --- a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/controller/UserController.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.baeldung.web.controller; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.baeldung.web.dto.User; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class UserController { - - public UserController() { - super(); - } - - // API - read - @RequestMapping(method = RequestMethod.GET, value = "/users/{id}") - @ResponseBody - public User findById(@PathVariable final long id, HttpServletRequest req, HttpServletResponse res) { - return new User(Long.parseLong(randomNumeric(2)), randomAlphabetic(4), Integer.parseInt(randomNumeric(2))); - } - -} diff --git a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java b/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java deleted file mode 100644 index f5e4124f93ad..000000000000 --- a/spring-zuul/spring-zuul-users-resource/src/main/java/org/baeldung/web/dto/User.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.baeldung.web.dto; - -public class User { - private long id; - private String username; - private int age; - - public User() { - super(); - } - - public User(final long id, final String name, int age) { - super(); - - this.id = id; - this.username = name; - this.age = age; - } - - // - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public String getUsername() { - return username; - } - - public void setUsername(final String username) { - this.username = username; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - -} \ No newline at end of file diff --git a/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties b/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties deleted file mode 100644 index 81284546cedf..000000000000 --- a/spring-zuul/spring-zuul-users-resource/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -server.contextPath=/spring-zuul-users-resource -server.port=8081 \ No newline at end of file From 796d3668e7ca1e43951a313753922dee6983578b Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 30 Jan 2016 12:00:06 +0200 Subject: [PATCH 154/626] minor maven upgrades --- spring-data-cassandra/pom.xml | 5 ++++- spring-data-mongodb/.project | 4 ++-- spring-data-mongodb/pom.xml | 4 +++- spring-jpa/pom.xml | 2 +- .../pom.xml | 2 +- spring-security-mvc-ldap/pom.xml | 2 +- spring-security-rest-custom/pom.xml | 2 +- spring-security-rest-full/pom.xml | 20 +++++++++---------- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/spring-data-cassandra/pom.xml b/spring-data-cassandra/pom.xml index b2b649a4224a..7e21859b5d00 100644 --- a/spring-data-cassandra/pom.xml +++ b/spring-data-cassandra/pom.xml @@ -11,8 +11,11 @@ UTF-8 + + 4.2.3.RELEASE + 1.3.2.RELEASE - 4.2.2.RELEASE + 4.11 1.7.12 1.1.3 diff --git a/spring-data-mongodb/.project b/spring-data-mongodb/.project index e3d768757313..2e5a0d4bac3e 100644 --- a/spring-data-mongodb/.project +++ b/spring-data-mongodb/.project @@ -11,12 +11,12 @@ - org.eclipse.m2e.core.maven2Builder + org.springframework.ide.eclipse.core.springbuilder - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml index 23ac3533507c..558af930b35e 100644 --- a/spring-data-mongodb/pom.xml +++ b/spring-data-mongodb/pom.xml @@ -117,9 +117,11 @@ UTF-8 + + 4.2.4.RELEASE 1.7.1.RELEASE - 4.2.2.RELEASE + 1.3 4.11 2.4.1 diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 20be07ca5bb0..2e8f81877674 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -186,7 +186,7 @@ 4.3.11.Final 5.1.37 - 1.7.2.RELEASE + 1.8.2.RELEASE 1.7.13 diff --git a/spring-security-login-and-registration/pom.xml b/spring-security-login-and-registration/pom.xml index 9e0f15688fd2..f5b62be553de 100644 --- a/spring-security-login-and-registration/pom.xml +++ b/spring-security-login-and-registration/pom.xml @@ -329,7 +329,7 @@ 1 - 1.8.0.RELEASE + 1.8.2.RELEASE 19.0 diff --git a/spring-security-mvc-ldap/pom.xml b/spring-security-mvc-ldap/pom.xml index 3f9b9ad1ede7..317c8dfb73af 100644 --- a/spring-security-mvc-ldap/pom.xml +++ b/spring-security-mvc-ldap/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.1.RELEASE + 1.3.2.RELEASE diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml index a112fdcd4307..df936353d930 100644 --- a/spring-security-rest-custom/pom.xml +++ b/spring-security-rest-custom/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.1.RELEASE + 1.3.2.RELEASE diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index b48d87473b60..270774ee1313 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.1.RELEASE + 1.3.2.RELEASE @@ -92,13 +92,11 @@ org.springframework spring-webmvc - - - org.springframework.data - spring-data-commons - - - + + + org.springframework.data + spring-data-commons + @@ -238,7 +236,7 @@ spring-test test - + org.springframework.security spring-security-test @@ -435,11 +433,11 @@ 4.3.11.Final 5.1.37 - 1.7.2.RELEASE + 1.8.2.RELEASE 2.0.0 3.6.2 - + 2.5.5 1.4.01 From 95e2d063f4e28486d8765e5063d7e3488e335d35 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 30 Jan 2016 12:01:41 +0200 Subject: [PATCH 155/626] general formatting work --- .../java/CollectionJavaPartitionUnitTest.java | 4 ---- .../baeldung/customannotation/DataAccess.java | 2 +- .../DataAccessAnnotationProcessor.java | 6 ++--- .../DataAccessFieldCallback.java | 22 ++++++------------- .../customannotation/BeanWithGenericDAO.java | 5 +++-- .../DataAccessFieldCallbackTest.java | 4 +--- .../spring_batch_intro/SpringBatchConfig.java | 13 ++++------- .../spring_batch_intro/SpringConfig.java | 3 +-- .../spring_batch_intro/model/Transaction.java | 4 +--- .../service/CustomItemProcessor.java | 3 +-- .../persistence/dao/impl/ChildDao.java | 2 +- .../baeldung/persistence/dao/impl/FooDao.java | 2 +- .../persistence/dao/impl/ParentDao.java | 2 +- .../service/impl/ChildService.java | 2 +- .../persistence/service/impl/FooService.java | 2 +- .../service/impl/ParentService.java | 2 +- .../org/baeldung/persistence/dao/FooDao.java | 2 +- .../dao/common/GenericHibernateDao.java | 2 +- .../service/impl/ChildService.java | 2 +- .../persistence/service/impl/FooService.java | 2 +- .../service/impl/ParentService.java | 2 +- .../persistence/audit/JPABarAuditTest.java | 4 ---- .../org/baeldung/persistence/dao/FooDao.java | 2 +- .../org/baeldung/persistence/model/User.java | 2 +- .../java/org/baeldung/aop/LoggingAspect.java | 9 +++++--- .../org/baeldung/aop/PerformanceAspect.java | 3 ++- .../org/baeldung/aop/PublishingAspect.java | 9 +++++--- .../src/main/java/org/baeldung/model/Foo.java | 5 +---- .../web/controller/UserController.java | 21 +++++++++--------- .../java/org/baeldung/aop/AopLoggingTest.java | 4 ++-- .../org/baeldung/aop/AopPerformanceTest.java | 2 +- .../org/baeldung/aop/AopPublishingTest.java | 5 ++--- .../java/org/baeldung/config/TestConfig.java | 2 +- .../baeldung/validation/PasswordMatches.java | 4 ++-- .../org/baeldung/validation/ValidEmail.java | 4 ++-- .../baeldung/validation/ValidPassword.java | 4 ++-- 36 files changed, 71 insertions(+), 97 deletions(-) diff --git a/guava/src/test/java/org/baeldung/java/CollectionJavaPartitionUnitTest.java b/guava/src/test/java/org/baeldung/java/CollectionJavaPartitionUnitTest.java index 639aea58f6d2..63583987ea94 100644 --- a/guava/src/test/java/org/baeldung/java/CollectionJavaPartitionUnitTest.java +++ b/guava/src/test/java/org/baeldung/java/CollectionJavaPartitionUnitTest.java @@ -67,8 +67,4 @@ public final void givenList_whenSplittingBySeparator_thenCorrect() { assertThat(lastPartition, equalTo(expectedLastPartition)); } - - - - } diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java b/spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java index 11bc30a84a0c..9a8a493a6d8b 100644 --- a/spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java +++ b/spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java @@ -10,5 +10,5 @@ @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Documented public @interface DataAccess { - Classentity(); + Class entity(); } diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java b/spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java index 7902da746e22..c79207374519 100644 --- a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java +++ b/spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java @@ -19,15 +19,13 @@ public DataAccessAnnotationProcessor(ConfigurableListableBeanFactory bf) { } @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) - throws BeansException { + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { scanDataAccessAnnotation(bean, beanName); return bean; } @Override - public Object postProcessAfterInitialization(Object bean, String beanName) - throws BeansException { + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java b/spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java index 16526fa56f82..8cb62affc4f8 100644 --- a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java +++ b/spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java @@ -12,18 +12,14 @@ import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils.FieldCallback; - public final class DataAccessFieldCallback implements FieldCallback { private static Logger logger = LoggerFactory.getLogger(DataAccessFieldCallback.class); private static int AUTOWIRE_MODE = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; - private static String ERROR_ENTITY_VALUE_NOT_SAME = "@DataAccess(entity) " - + "value should have same type with injected generic type."; - private static String WARN_NON_GENERIC_VALUE = "@DataAccess annotation assigned " - + "to raw (non-generic) declaration. This will make your code less type-safe."; - private static String ERROR_CREATE_INSTANCE = "Cannot create instance of " - + "type '{}' or instance creation is failed because: {}"; + private static String ERROR_ENTITY_VALUE_NOT_SAME = "@DataAccess(entity) " + "value should have same type with injected generic type."; + private static String WARN_NON_GENERIC_VALUE = "@DataAccess annotation assigned " + "to raw (non-generic) declaration. This will make your code less type-safe."; + private static String ERROR_CREATE_INSTANCE = "Cannot create instance of " + "type '{}' or instance creation is failed because: {}"; private ConfigurableListableBeanFactory configurableListableBeanFactory; private Object bean; @@ -34,15 +30,14 @@ public DataAccessFieldCallback(final ConfigurableListableBeanFactory bf, final O } @Override - public void doWith(final Field field) - throws IllegalArgumentException, IllegalAccessException { + public void doWith(final Field field) throws IllegalArgumentException, IllegalAccessException { if (!field.isAnnotationPresent(DataAccess.class)) { return; } ReflectionUtils.makeAccessible(field); final Type fieldGenericType = field.getGenericType(); - // In this example, get actual "GenericDAO' type. - final Class generic = field.getType(); + // In this example, get actual "GenericDAO' type. + final Class generic = field.getType(); final Class classValue = field.getDeclaredAnnotation(DataAccess.class).entity(); if (genericTypeIsValid(classValue, fieldGenericType)) { @@ -54,7 +49,6 @@ public void doWith(final Field field) } } - /** * For example, if user write: *
@@ -75,8 +69,6 @@ public boolean genericTypeIsValid(final Class clazz, final Type field) {
         }
     }
 
-
-
     public final Object getBeanInstance(final String beanName, final Class genericClass, final Class paramClass) {
         Object daoInstance = null;
         if (!configurableListableBeanFactory.containsBean(beanName)) {
@@ -90,7 +82,7 @@ public final Object getBeanInstance(final String beanName, final Class generi
                 logger.error(ERROR_CREATE_INSTANCE, genericClass.getTypeName(), e);
                 throw new RuntimeException(e);
             }
-            
+
             daoInstance = configurableListableBeanFactory.initializeBean(toRegister, beanName);
             configurableListableBeanFactory.autowireBeanProperties(daoInstance, AUTOWIRE_MODE, true);
             configurableListableBeanFactory.registerSingleton(beanName, daoInstance);
diff --git a/spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java b/spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java
index 32d4660f41f8..9ba915f296f2 100644
--- a/spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java
+++ b/spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java
@@ -5,10 +5,11 @@
 @Repository
 public class BeanWithGenericDAO {
 
-    @DataAccess(entity=Person.class)
+    @DataAccess(entity = Person.class)
     private GenericDAO personGenericDAO;
 
-    public BeanWithGenericDAO() {}
+    public BeanWithGenericDAO() {
+    }
 
     public GenericDAO getPersonGenericDAO() {
         return personGenericDAO;
diff --git a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java
index f025a3e00ae4..e47d03c961c6 100644
--- a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java
+++ b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java
@@ -15,7 +15,6 @@
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = { CustomAnnotationConfiguration.class })
 public class DataAccessFieldCallbackTest {
@@ -36,8 +35,7 @@ public void whenObjectCreated_thenObjectCreationIsSuccessful() {
     }
 
     @Test
-    public void whenMethodGenericTypeIsValidCalled_thenReturnCorrectValue()
-            throws NoSuchFieldException, SecurityException {
+    public void whenMethodGenericTypeIsValidCalled_thenReturnCorrectValue() throws NoSuchFieldException, SecurityException {
         final DataAccessFieldCallback callback = new DataAccessFieldCallback(configurableListableBeanFactory, beanWithGenericDAO);
         final Type fieldType = BeanWithGenericDAO.class.getDeclaredField("personGenericDAO").getGenericType();
         final boolean result = callback.genericTypeIsValid(Person.class, fieldType);
diff --git a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java
index a024cbc04e9f..9973005c7c21 100644
--- a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java
+++ b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringBatchConfig.java
@@ -40,8 +40,7 @@ public class SpringBatchConfig {
     private Resource outputXml;
 
     @Bean
-    public ItemReader itemReader()
-        throws UnexpectedInputException, ParseException {
+    public ItemReader itemReader() throws UnexpectedInputException, ParseException {
         FlatFileItemReader reader = new FlatFileItemReader();
         DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
         String[] tokens = { "username", "userid", "transactiondate", "amount" };
@@ -61,8 +60,7 @@ public ItemProcessor itemProcessor() {
     }
 
     @Bean
-    public ItemWriter itemWriter(Marshaller marshaller)
-        throws MalformedURLException {
+    public ItemWriter itemWriter(Marshaller marshaller) throws MalformedURLException {
         StaxEventItemWriter itemWriter = new StaxEventItemWriter();
         itemWriter.setMarshaller(marshaller);
         itemWriter.setRootTagName("transactionRecord");
@@ -78,11 +76,8 @@ public Marshaller marshaller() {
     }
 
     @Bean
-    protected Step step1(ItemReader reader,
-        ItemProcessor processor,
-        ItemWriter writer) {
-        return steps.get("step1"). chunk(10)
-            .reader(reader).processor(processor).writer(writer).build();
+    protected Step step1(ItemReader reader, ItemProcessor processor, ItemWriter writer) {
+        return steps.get("step1"). chunk(10).reader(reader).processor(processor).writer(writer).build();
     }
 
     @Bean(name = "firstBatchJob")
diff --git a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java
index 91366d872163..ed7d302047bf 100644
--- a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java
+++ b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/SpringConfig.java
@@ -38,8 +38,7 @@ public DataSource dataSource() {
     }
 
     @Bean
-    public DataSourceInitializer dataSourceInitializer(DataSource dataSource)
-        throws MalformedURLException {
+    public DataSourceInitializer dataSourceInitializer(DataSource dataSource) throws MalformedURLException {
         ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
 
         databasePopulator.addScript(dropReopsitoryTables);
diff --git a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java
index 6e80298ff0d7..3b2b9610f2cb 100644
--- a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java
+++ b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/model/Transaction.java
@@ -48,9 +48,7 @@ public void setAmount(double amount) {
 
     @Override
     public String toString() {
-        return "Transaction [username=" + username + ", userId=" + userId
-            + ", transactionDate=" + transactionDate + ", amount=" + amount
-            + "]";
+        return "Transaction [username=" + username + ", userId=" + userId + ", transactionDate=" + transactionDate + ", amount=" + amount + "]";
     }
 
 }
diff --git a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java
index baabe794097b..ebee1d2802b6 100644
--- a/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java
+++ b/spring-batch/src/main/java/org/baeldung/spring_batch_intro/service/CustomItemProcessor.java
@@ -3,8 +3,7 @@
 import org.baeldung.spring_batch_intro.model.Transaction;
 import org.springframework.batch.item.ItemProcessor;
 
-public class CustomItemProcessor implements
-    ItemProcessor {
+public class CustomItemProcessor implements ItemProcessor {
 
     public Transaction process(Transaction item) {
         System.out.println("Processing..." + item);
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java
index 771da435c60a..e068573c5c2f 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java
@@ -8,7 +8,7 @@
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class ChildDao extends AbstractHibernateDaoimplements IChildDao {
+public class ChildDao extends AbstractHibernateDao implements IChildDao {
 
     @Autowired
     private SessionFactory sessionFactory;
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java
index a5d995cec02d..baf29c9ecdb7 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java
@@ -8,7 +8,7 @@
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class FooDao extends AbstractHibernateDaoimplements IFooDao {
+public class FooDao extends AbstractHibernateDao implements IFooDao {
 
     @Autowired
     private SessionFactory sessionFactory;
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java
index 207e01de58a4..5634137b63dd 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java
@@ -8,7 +8,7 @@
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class ParentDao extends AbstractHibernateDaoimplements IParentDao {
+public class ParentDao extends AbstractHibernateDao implements IParentDao {
 
     @Autowired
     private SessionFactory sessionFactory;
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java
index 987466643b9f..89597313eaf2 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java
@@ -9,7 +9,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class ChildService extends AbstractServiceimplements IChildService {
+public class ChildService extends AbstractService implements IChildService {
 
     @Autowired
     private IChildDao dao;
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java
index 382368bbd426..f0a4d7a6490c 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java
@@ -9,7 +9,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class FooService extends AbstractServiceimplements IFooService {
+public class FooService extends AbstractService implements IFooService {
 
     @Autowired
     private IFooDao dao;
diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java
index e40ccfd2f87e..97c44f4a2f6d 100644
--- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java
+++ b/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java
@@ -9,7 +9,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class ParentService extends AbstractServiceimplements IParentService {
+public class ParentService extends AbstractService implements IParentService {
 
     @Autowired
     private IParentDao dao;
diff --git a/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java
index cb8d7488ead6..23de04169eb4 100644
--- a/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java
+++ b/spring-hibernate3/src/main/java/org/baeldung/persistence/dao/FooDao.java
@@ -4,7 +4,7 @@
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class FooDao extends AbstractHibernateDaoimplements IFooDao {
+public class FooDao extends AbstractHibernateDao implements IFooDao {
 
     public FooDao() {
         super();
diff --git a/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java b/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
index d45fea5a737f..18b16fa03306 100644
--- a/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
+++ b/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java
@@ -8,6 +8,6 @@
 
 @Repository
 @Scope(BeanDefinition.SCOPE_PROTOTYPE)
-public class GenericHibernateDao extends AbstractHibernateDaoimplements IGenericDao {
+public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao {
     //
 }
\ No newline at end of file
diff --git a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
index 6fd8c2780317..417fe2c49ae0 100644
--- a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
+++ b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java
@@ -9,7 +9,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class ChildService extends AbstractHibernateServiceimplements IChildService {
+public class ChildService extends AbstractHibernateService implements IChildService {
 
     @Autowired
     private IChildDao dao;
diff --git a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java
index 008763c00de2..84cf018feef0 100644
--- a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java
+++ b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java
@@ -10,7 +10,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class FooService extends AbstractHibernateServiceimplements IFooService {
+public class FooService extends AbstractHibernateService implements IFooService {
 
     @Autowired
     @Qualifier("fooHibernateDao")
diff --git a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
index cbcd5da3d4f8..078acfc369e8 100644
--- a/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
+++ b/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java
@@ -9,7 +9,7 @@
 import org.springframework.stereotype.Service;
 
 @Service
-public class ParentService extends AbstractHibernateServiceimplements IParentService {
+public class ParentService extends AbstractHibernateService implements IParentService {
 
     @Autowired
     private IParentDao dao;
diff --git a/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditTest.java b/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditTest.java
index 73fa04969e4b..1e4a10f61cb1 100644
--- a/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditTest.java
+++ b/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditTest.java
@@ -41,7 +41,6 @@ public static void tearDownAfterClass() throws Exception {
         logger.info("tearDownAfterClass()");
     }
 
-
     @Autowired
     @Qualifier("barJpaService")
     private IBarService barService;
@@ -51,7 +50,6 @@ public static void tearDownAfterClass() throws Exception {
 
     private EntityManager em;
 
-
     @Before
     public void setUp() throws Exception {
         logger.info("setUp()");
@@ -64,7 +62,6 @@ public void tearDown() throws Exception {
         em.close();
     }
 
-
     @Test
     public final void whenBarsModified_thenBarsAudited() {
 
@@ -84,7 +81,6 @@ public final void whenBarsModified_thenBarsAudited() {
         bar1.setName("BAR1b");
         barService.update(bar1);
 
-
         // get BAR1 and BAR2 from the DB and check the audit values
         // detach instances from persistence context to make sure we fire db
         em.detach(bar1);
diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java
index becd8d5f67df..77978c5cf282 100644
--- a/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java
+++ b/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java
@@ -4,7 +4,7 @@
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class FooDao extends AbstractJpaDAOimplements IFooDao {
+public class FooDao extends AbstractJpaDAO implements IFooDao {
 
     public FooDao() {
         super();
diff --git a/spring-katharsis/src/main/java/org/baeldung/persistence/model/User.java b/spring-katharsis/src/main/java/org/baeldung/persistence/model/User.java
index 58a92002c87c..67e4c6ae1d89 100644
--- a/spring-katharsis/src/main/java/org/baeldung/persistence/model/User.java
+++ b/spring-katharsis/src/main/java/org/baeldung/persistence/model/User.java
@@ -30,7 +30,7 @@ public class User {
     private String email;
 
     @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
+    @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id") )
     @JsonApiToMany
     @JsonApiIncludeByDefault
     private Set roles;
diff --git a/spring-mvc-java/src/main/java/org/baeldung/aop/LoggingAspect.java b/spring-mvc-java/src/main/java/org/baeldung/aop/LoggingAspect.java
index 72ac610abd6f..c59c4f060ad8 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/aop/LoggingAspect.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/aop/LoggingAspect.java
@@ -24,13 +24,16 @@ protected SimpleDateFormat initialValue() {
     };
 
     @Pointcut("@target(org.springframework.stereotype.Repository)")
-    public void repositoryMethods() {}
+    public void repositoryMethods() {
+    }
 
     @Pointcut("@annotation(org.baeldung.aop.annotations.Loggable)")
-    public void loggableMethods() {}
+    public void loggableMethods() {
+    }
 
     @Pointcut("@args(org.baeldung.aop.annotations.Entity)")
-    public void methodsAcceptingEntities() {}
+    public void methodsAcceptingEntities() {
+    }
 
     @Before("repositoryMethods()")
     public void logMethodCall(JoinPoint jp) {
diff --git a/spring-mvc-java/src/main/java/org/baeldung/aop/PerformanceAspect.java b/spring-mvc-java/src/main/java/org/baeldung/aop/PerformanceAspect.java
index 57f5bc5edd06..2d07e5a5f3f4 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/aop/PerformanceAspect.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/aop/PerformanceAspect.java
@@ -16,7 +16,8 @@ public class PerformanceAspect {
     private static Logger logger = Logger.getLogger(PerformanceAspect.class.getName());
 
     @Pointcut("within(@org.springframework.stereotype.Repository *)")
-    public void repositoryClassMethods() {}
+    public void repositoryClassMethods() {
+    }
 
     @Around("repositoryClassMethods()")
     public Object measureMethodExecutionTime(ProceedingJoinPoint pjp) throws Throwable {
diff --git a/spring-mvc-java/src/main/java/org/baeldung/aop/PublishingAspect.java b/spring-mvc-java/src/main/java/org/baeldung/aop/PublishingAspect.java
index 20a10f4f6a2c..324605dab17b 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/aop/PublishingAspect.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/aop/PublishingAspect.java
@@ -21,13 +21,16 @@ public void setEventPublisher(ApplicationEventPublisher eventPublisher) {
     }
 
     @Pointcut("@target(org.springframework.stereotype.Repository)")
-    public void repositoryMethods() {}
+    public void repositoryMethods() {
+    }
 
     @Pointcut("execution(* *..create*(Long,..))")
-    public void firstLongParamMethods() {}
+    public void firstLongParamMethods() {
+    }
 
     @Pointcut("repositoryMethods() && firstLongParamMethods()")
-    public void entityCreationMethods() {}
+    public void entityCreationMethods() {
+    }
 
     @AfterReturning(value = "entityCreationMethods()", returning = "entity")
     public void logMethodCall(JoinPoint jp, Object entity) throws Throwable {
diff --git a/spring-mvc-java/src/main/java/org/baeldung/model/Foo.java b/spring-mvc-java/src/main/java/org/baeldung/model/Foo.java
index 0b1a553afcd5..87bd7132e6b1 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/model/Foo.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/model/Foo.java
@@ -14,9 +14,6 @@ public Foo(Long id, String name) {
 
     @Override
     public String toString() {
-        return "Foo{" +
-                "id=" + id +
-                ", name='" + name + '\'' +
-                '}';
+        return "Foo{" + "id=" + id + ", name='" + name + '\'' + '}';
     }
 }
diff --git a/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java
index 731424c33679..da39a36adfdd 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java
@@ -13,20 +13,19 @@ public class UserController {
 
     @RequestMapping(value = "/", method = RequestMethod.GET)
     public String showForm(final Model model) {
-	final User user = new User();
-	user.setFirstname("John");
-	user.setLastname("Roy");
-	user.setEmailId("John.Roy@gmail.com");
-	model.addAttribute("user", user);
-	return "index";
+        final User user = new User();
+        user.setFirstname("John");
+        user.setLastname("Roy");
+        user.setEmailId("John.Roy@gmail.com");
+        model.addAttribute("user", user);
+        return "index";
     }
 
     @RequestMapping(value = "/processForm", method = RequestMethod.POST)
-    public String processForm(@ModelAttribute(value = "user") final User user,
-	    final Model model) {
-	// Insert User into DB
-	model.addAttribute("name", user.getFirstname() + " " + user.getLastname());
-	return "hello";
+    public String processForm(@ModelAttribute(value = "user") final User user, final Model model) {
+        // Insert User into DB
+        model.addAttribute("name", user.getFirstname() + " " + user.getLastname());
+        return "hello";
     }
 
 }
diff --git a/spring-mvc-java/src/test/java/org/baeldung/aop/AopLoggingTest.java b/spring-mvc-java/src/test/java/org/baeldung/aop/AopLoggingTest.java
index 4c8fcd50a82f..b1c9867e4180 100644
--- a/spring-mvc-java/src/test/java/org/baeldung/aop/AopLoggingTest.java
+++ b/spring-mvc-java/src/test/java/org/baeldung/aop/AopLoggingTest.java
@@ -24,12 +24,12 @@
 import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class)
 public class AopLoggingTest {
 
     @Before
     public void setUp() {
-        messages =  new ArrayList<>();
+        messages = new ArrayList<>();
 
         logEventHandler = new Handler() {
             @Override
diff --git a/spring-mvc-java/src/test/java/org/baeldung/aop/AopPerformanceTest.java b/spring-mvc-java/src/test/java/org/baeldung/aop/AopPerformanceTest.java
index 82af95957a5f..69083c60a23c 100644
--- a/spring-mvc-java/src/test/java/org/baeldung/aop/AopPerformanceTest.java
+++ b/spring-mvc-java/src/test/java/org/baeldung/aop/AopPerformanceTest.java
@@ -23,7 +23,7 @@
 import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class)
 public class AopPerformanceTest {
 
     @Before
diff --git a/spring-mvc-java/src/test/java/org/baeldung/aop/AopPublishingTest.java b/spring-mvc-java/src/test/java/org/baeldung/aop/AopPublishingTest.java
index 561eec06eca3..e691dbd32e06 100644
--- a/spring-mvc-java/src/test/java/org/baeldung/aop/AopPublishingTest.java
+++ b/spring-mvc-java/src/test/java/org/baeldung/aop/AopPublishingTest.java
@@ -22,7 +22,7 @@
 import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class)
+@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class)
 public class AopPublishingTest {
 
     @Before
@@ -60,8 +60,7 @@ public void givenPublishingAspect_whenCallCreate_thenCreationEventIsPublished()
         dao.create(1L, "Bar");
 
         String logMessage = messages.get(0);
-        Pattern pattern = Pattern.compile("Created foo instance: " +
-                Pattern.quote(new Foo(1L, "Bar").toString()));
+        Pattern pattern = Pattern.compile("Created foo instance: " + Pattern.quote(new Foo(1L, "Bar").toString()));
         assertTrue(pattern.matcher(logMessage).matches());
     }
 }
diff --git a/spring-mvc-java/src/test/java/org/baeldung/config/TestConfig.java b/spring-mvc-java/src/test/java/org/baeldung/config/TestConfig.java
index 0d103f10290c..f9573b2add67 100644
--- a/spring-mvc-java/src/test/java/org/baeldung/config/TestConfig.java
+++ b/spring-mvc-java/src/test/java/org/baeldung/config/TestConfig.java
@@ -5,7 +5,7 @@
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 
 @Configuration
-@ComponentScan(basePackages = {"org.baeldung.dao", "org.baeldung.aop", "org.baeldung.events"})
+@ComponentScan(basePackages = { "org.baeldung.dao", "org.baeldung.aop", "org.baeldung.events" })
 @EnableAspectJAutoProxy
 public class TestConfig {
 }
diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/PasswordMatches.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/PasswordMatches.java
index 1e3193b7b50a..fcc7e228a7ee 100644
--- a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/PasswordMatches.java
+++ b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/PasswordMatches.java
@@ -19,8 +19,8 @@
 
     String message() default "Passwords don't match";
 
-    Class[]groups() default {};
+    Class[] groups() default {};
 
-    Class[]payload() default {};
+    Class[] payload() default {};
 
 }
diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidEmail.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidEmail.java
index b5dc4f0f46c2..a520a45b0c66 100644
--- a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidEmail.java
+++ b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidEmail.java
@@ -20,7 +20,7 @@
 
     String message() default "Invalid Email";
 
-    Class[]groups() default {};
+    Class[] groups() default {};
 
-    Class[]payload() default {};
+    Class[] payload() default {};
 }
diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidPassword.java b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidPassword.java
index 5b92f4d1335f..37b217213a23 100644
--- a/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidPassword.java
+++ b/spring-security-login-and-registration/src/main/java/org/baeldung/validation/ValidPassword.java
@@ -20,8 +20,8 @@
 
     String message() default "Invalid Password";
 
-    Class[]groups() default {};
+    Class[] groups() default {};
 
-    Class[]payload() default {};
+    Class[] payload() default {};
 
 }

From c14e7ad1a17b34a60b74a4a4b63e8850567365d6 Mon Sep 17 00:00:00 2001
From: "giuseppe.bueti" 
Date: Sat, 30 Jan 2016 17:48:56 +0100
Subject: [PATCH 156/626] RestEasy Tutorial, CRUD Services example

---
 RestEasy Example/pom.xml                      |  91 +++
 .../src/main/java/com/baeldung/Movie.java     | 535 ++++++++++++++++++
 .../baeldung/client/ServicesInterface.java    |  44 ++
 .../server/service/MovieCrudService.java      |  94 +++
 .../server/service/RestEasyServices.java      |  40 ++
 .../src/main/resources/schema1.xsd            |  29 +
 .../main/webapp/WEB-INF/classes/logback.xml   |   3 +
 .../WEB-INF/jboss-deployment-structure.xml    |  16 +
 .../src/main/webapp/WEB-INF/jboss-web.xml     |   4 +
 .../src/main/webapp/WEB-INF/web.xml           |  51 ++
 .../com/baeldung/server/RestEasyClient.java   |  50 ++
 .../resources/server/movies/transformer.json  |  22 +
 12 files changed, 979 insertions(+)
 create mode 100644 RestEasy Example/pom.xml
 create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java
 create mode 100644 RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
 create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java
 create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java
 create mode 100644 RestEasy Example/src/main/resources/schema1.xsd
 create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml
 create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
 create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml
 create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/web.xml
 create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java
 create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json

diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml
new file mode 100644
index 000000000000..b16c5e82678b
--- /dev/null
+++ b/RestEasy Example/pom.xml	
@@ -0,0 +1,91 @@
+
+
+    4.0.0
+
+    com.baeldung
+    resteasy-tutorial
+    1.0
+    war
+
+    
+        
+            jboss
+            http://repository.jboss.org/nexus/content/groups/public/
+        
+    
+
+    
+        3.0.14.Final
+        runtime
+    
+
+    
+        RestEasyTutorial
+        
+            
+                org.apache.maven.plugins
+                maven-compiler-plugin
+                
+                    1.8
+                    1.8
+                
+            
+        
+    
+
+    
+        
+        
+            org.jboss.resteasy
+            jaxrs-api
+            3.0.12.Final
+            ${resteasy.scope}
+        
+
+        
+            org.jboss.resteasy
+            resteasy-servlet-initializer
+            ${resteasy.version}
+            ${resteasy.scope}
+            
+                
+                    jboss-jaxrs-api_2.0_spec
+                    org.jboss.spec.javax.ws.rs
+                
+            
+        
+
+        
+            org.jboss.resteasy
+            resteasy-client
+            ${resteasy.version}
+            ${resteasy.scope}
+        
+
+
+        
+            javax.ws.rs
+            javax.ws.rs-api
+            2.0.1
+        
+
+        
+            org.jboss.resteasy
+            resteasy-jackson-provider
+            ${resteasy.version}
+            ${resteasy.scope}
+        
+
+        
+            org.jboss.resteasy
+            resteasy-jaxb-provider
+            ${resteasy.version}
+            ${resteasy.scope}
+        
+
+    
+
+
+
\ No newline at end of file
diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java
new file mode 100644
index 000000000000..c0041d2e95d2
--- /dev/null
+++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java	
@@ -0,0 +1,535 @@
+
+package com.baeldung;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "movie", propOrder = {
+    "actors",
+    "awards",
+    "country",
+    "director",
+    "genre",
+    "imdbID",
+    "imdbRating",
+    "imdbVotes",
+    "language",
+    "metascore",
+    "plot",
+    "poster",
+    "rated",
+    "released",
+    "response",
+    "runtime",
+    "title",
+    "type",
+    "writer",
+    "year"
+})
+public class Movie {
+
+    protected String actors;
+    protected String awards;
+    protected String country;
+    protected String director;
+    protected String genre;
+    protected String imdbID;
+    protected String imdbRating;
+    protected String imdbVotes;
+    protected String language;
+    protected String metascore;
+    protected String plot;
+    protected String poster;
+    protected String rated;
+    protected String released;
+    protected String response;
+    protected String runtime;
+    protected String title;
+    protected String type;
+    protected String writer;
+    protected String year;
+
+    /**
+     * Recupera il valore della propriet� actors.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getActors() {
+        return actors;
+    }
+
+    /**
+     * Imposta il valore della propriet� actors.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setActors(String value) {
+        this.actors = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� awards.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getAwards() {
+        return awards;
+    }
+
+    /**
+     * Imposta il valore della propriet� awards.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setAwards(String value) {
+        this.awards = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� country.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getCountry() {
+        return country;
+    }
+
+    /**
+     * Imposta il valore della propriet� country.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setCountry(String value) {
+        this.country = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� director.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getDirector() {
+        return director;
+    }
+
+    /**
+     * Imposta il valore della propriet� director.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setDirector(String value) {
+        this.director = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� genre.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getGenre() {
+        return genre;
+    }
+
+    /**
+     * Imposta il valore della propriet� genre.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setGenre(String value) {
+        this.genre = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� imdbID.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getImdbID() {
+        return imdbID;
+    }
+
+    /**
+     * Imposta il valore della propriet� imdbID.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setImdbID(String value) {
+        this.imdbID = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� imdbRating.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getImdbRating() {
+        return imdbRating;
+    }
+
+    /**
+     * Imposta il valore della propriet� imdbRating.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setImdbRating(String value) {
+        this.imdbRating = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� imdbVotes.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getImdbVotes() {
+        return imdbVotes;
+    }
+
+    /**
+     * Imposta il valore della propriet� imdbVotes.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setImdbVotes(String value) {
+        this.imdbVotes = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� language.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getLanguage() {
+        return language;
+    }
+
+    /**
+     * Imposta il valore della propriet� language.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setLanguage(String value) {
+        this.language = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� metascore.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getMetascore() {
+        return metascore;
+    }
+
+    /**
+     * Imposta il valore della propriet� metascore.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setMetascore(String value) {
+        this.metascore = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� plot.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getPlot() {
+        return plot;
+    }
+
+    /**
+     * Imposta il valore della propriet� plot.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setPlot(String value) {
+        this.plot = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� poster.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getPoster() {
+        return poster;
+    }
+
+    /**
+     * Imposta il valore della propriet� poster.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setPoster(String value) {
+        this.poster = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� rated.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getRated() {
+        return rated;
+    }
+
+    /**
+     * Imposta il valore della propriet� rated.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setRated(String value) {
+        this.rated = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� released.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getReleased() {
+        return released;
+    }
+
+    /**
+     * Imposta il valore della propriet� released.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setReleased(String value) {
+        this.released = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� response.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getResponse() {
+        return response;
+    }
+
+    /**
+     * Imposta il valore della propriet� response.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setResponse(String value) {
+        this.response = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� runtime.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getRuntime() {
+        return runtime;
+    }
+
+    /**
+     * Imposta il valore della propriet� runtime.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setRuntime(String value) {
+        this.runtime = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� title.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * Imposta il valore della propriet� title.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setTitle(String value) {
+        this.title = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� type.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Imposta il valore della propriet� type.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setType(String value) {
+        this.type = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� writer.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getWriter() {
+        return writer;
+    }
+
+    /**
+     * Imposta il valore della propriet� writer.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setWriter(String value) {
+        this.writer = value;
+    }
+
+    /**
+     * Recupera il valore della propriet� year.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getYear() {
+        return year;
+    }
+
+    /**
+     * Imposta il valore della propriet� year.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setYear(String value) {
+        this.year = value;
+    }
+
+}
diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
new file mode 100644
index 000000000000..53e88961be34
--- /dev/null
+++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java	
@@ -0,0 +1,44 @@
+package com.baeldung.client;
+
+import com.baeldung.Movie;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+public interface ServicesInterface {
+
+
+    @GET
+    @Path("/getinfo")
+    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    Movie movieByImdbID(@QueryParam("imdbID") String imdbID);
+
+
+    @POST
+    @Path("/addmovie")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    Response addMovie(Movie movie);
+
+
+    @PUT
+    @Path("/updatemovie")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    Response updateMovie(Movie movie);
+
+
+    @DELETE
+    @Path("/deletemovie")
+    Response deleteMovie(@QueryParam("imdbID") String imdbID);
+
+
+    @GET
+    @Path("/listmovies")
+    @Produces({"application/json"})
+    List listMovies();
+
+}
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java
new file mode 100644
index 000000000000..d1973e703738
--- /dev/null
+++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java	
@@ -0,0 +1,94 @@
+package com.baeldung.server.service;
+
+import com.baeldung.Movie;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+@Path("/movies")
+public class MovieCrudService {
+
+
+    private Map inventory = new HashMap();
+
+    @GET
+    @Path("/getinfo")
+    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){
+
+        System.out.println("*** Calling  getinfo ***");
+
+        Movie movie=new Movie();
+        movie.setImdbID(imdbID);
+        return movie;
+    }
+
+    @POST
+    @Path("/addmovie")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    public Response addMovie(Movie movie){
+
+        System.out.println("*** Calling  addMovie ***");
+
+        if (null!=inventory.get(movie.getImdbID())){
+            return Response.status(Response.Status.NOT_MODIFIED)
+                    .entity("Movie is Already in the database.").build();
+        }
+        inventory.put(movie.getImdbID(),movie);
+
+        return Response.status(Response.Status.CREATED).build();
+    }
+
+
+    @PUT
+    @Path("/updatemovie")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    public Response updateMovie(Movie movie){
+
+        System.out.println("*** Calling  updateMovie ***");
+
+        if (null!=inventory.get(movie.getImdbID())){
+            return Response.status(Response.Status.NOT_MODIFIED)
+                    .entity("Movie is not in the database.\nUnable to Update").build();
+        }
+        inventory.put(movie.getImdbID(),movie);
+        return Response.status(Response.Status.OK).build();
+
+    }
+
+
+    @DELETE
+    @Path("/deletemovie")
+    public Response deleteMovie(@QueryParam("imdbID") String imdbID){
+
+        System.out.println("*** Calling  deleteMovie ***");
+
+        if (null==inventory.get(imdbID)){
+            return Response.status(Response.Status.NOT_FOUND)
+                    .entity("Movie is not in the database.\nUnable to Delete").build();
+        }
+
+        inventory.remove(imdbID);
+        return Response.status(Response.Status.OK).build();
+    }
+
+    @GET
+    @Path("/listmovies")
+    @Produces({"application/json"})
+    public List  listMovies(){
+
+        return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new));
+
+    }
+
+
+
+}
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java
new file mode 100644
index 000000000000..16b6200ad1f2
--- /dev/null
+++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java	
@@ -0,0 +1,40 @@
+package com.baeldung.server.service;
+
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by Admin on 29/01/2016.
+ */
+
+
+
+@ApplicationPath("/rest")
+public class RestEasyServices extends Application {
+
+    private Set singletons = new HashSet();
+
+    public RestEasyServices() {
+        singletons.add(new MovieCrudService());
+    }
+
+    @Override
+    public Set getSingletons() {
+        return singletons;
+    }
+
+    @Override
+    public Set> getClasses() {
+        return super.getClasses();
+    }
+
+    @Override
+    public Map getProperties() {
+        return super.getProperties();
+    }
+}
diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd
new file mode 100644
index 000000000000..0d74b7c366bb
--- /dev/null
+++ b/RestEasy Example/src/main/resources/schema1.xsd	
@@ -0,0 +1,29 @@
+
+
+
+  
+    
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+    
+  
+
+
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml
new file mode 100644
index 000000000000..d94e9f71abbb
--- /dev/null
+++ b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml	
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
new file mode 100644
index 000000000000..84d75934a70c
--- /dev/null
+++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml	
@@ -0,0 +1,16 @@
+
+    
+        
+            
+        
+
+        
+            
+            
+            
+        
+
+        
+    
+
+
\ No newline at end of file
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml
new file mode 100644
index 000000000000..694bb7133232
--- /dev/null
+++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml	
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000000..c66d3b56ae77
--- /dev/null
+++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml	
@@ -0,0 +1,51 @@
+
+
+
+    RestEasy Example
+
+    
+        
+            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+        
+    
+
+    RestEasy Example
+
+    
+        webAppRootKey
+        RestEasyExample
+    
+
+
+    
+    
+        resteasy.servlet.mapping.prefix
+        /rest
+    
+
+
+    
+        resteasy-servlet
+        
+            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+        
+        
+            javax.ws.rs.Application
+            com.baeldung.server.service.RestEasyServices
+        
+    
+
+    
+        resteasy-servlet
+        /rest/*
+    
+
+
+    
+        index.html
+    
+
+
+
\ No newline at end of file
diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java
new file mode 100644
index 000000000000..e7112339793b
--- /dev/null
+++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java	
@@ -0,0 +1,50 @@
+package com.baeldung.server;
+
+import com.baeldung.Movie;
+import com.baeldung.client.ServicesInterface;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
+
+import java.util.List;
+
+public class RestEasyClient {
+
+    public static void main(String[] args) {
+
+        Movie st = new Movie();
+        st.setImdbID("12345");
+
+		/*
+		 *  Alternatively you can use this simple String to send
+		 *  instead of using a Student instance
+		 *
+		 *  String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}";
+		 */
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies");
+
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+            final List movies = simple.listMovies();
+
+            /*
+            if (response.getStatus() != 200) {
+                throw new RuntimeException("Failed : HTTP error code : "
+                        + response.getStatus());
+            }
+
+            System.out.println("Server response : \n");
+            System.out.println(response.readEntity(String.class));
+
+            response.close();
+*/
+        } catch (Exception e) {
+
+            e.printStackTrace();
+
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json
new file mode 100644
index 000000000000..215486826560
--- /dev/null
+++ b/RestEasy Example/src/test/resources/server/movies/transformer.json	
@@ -0,0 +1,22 @@
+{
+  "title": "Transformers",
+  "year": "2007",
+  "rated": "PG-13",
+  "released": "03 Jul 2007",
+  "runtime": "144 min",
+  "genre": "Action, Adventure, Sci-Fi",
+  "director": "Michael Bay",
+  "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)",
+  "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson",
+  "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.",
+  "language": "English, Spanish",
+  "country": "USA",
+  "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.",
+  "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg",
+  "metascore": "61",
+  "imdbRating": "7.1",
+  "imdbVotes": "492,225",
+  "imdbID": "tt0418279",
+  "Type": "movie",
+  "response": "True"
+}
\ No newline at end of file

From a85c9cbda573fc25ac4d0f133eaf6ed779611ad6 Mon Sep 17 00:00:00 2001
From: Giuseppe Bueti 
Date: Sat, 30 Jan 2016 20:39:28 +0100
Subject: [PATCH 157/626] Added testCase for List All Movies and Add a Movie

---
 RestEasy Example/pom.xml                      |  29 +++++
 .../baeldung/client/ServicesInterface.java    |   6 +-
 .../java/com/baeldung/{ => model}/Movie.java  |  45 +++++++-
 .../{service => }/MovieCrudService.java       |   5 +-
 .../{service => }/RestEasyServices.java       |   2 +-
 .../com/baeldung/server/RestEasyClient.java   | 104 ++++++++++++++----
 .../com/baeldung/server/movies/batman.json    |  22 ++++
 .../baeldung}/server/movies/transformer.json  |   2 +-
 8 files changed, 184 insertions(+), 31 deletions(-)
 rename RestEasy Example/src/main/java/com/baeldung/{ => model}/Movie.java (86%)
 rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/MovieCrudService.java (96%)
 rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/RestEasyServices.java (95%)
 create mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json
 rename RestEasy Example/src/test/resources/{ => com/baeldung}/server/movies/transformer.json (99%)

diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml
index b16c5e82678b..8dabfc863bc4 100644
--- a/RestEasy Example/pom.xml	
+++ b/RestEasy Example/pom.xml	
@@ -85,6 +85,35 @@
             ${resteasy.scope}
         
 
+        
+
+        
+            junit
+            junit
+            4.4
+        
+
+        
+            commons-io
+            commons-io
+            2.4
+        
+
+        
+            com.fasterxml.jackson.core
+            jackson-core
+            2.7.0
+        
+
+        
+            com.fasterxml.jackson.core
+            jackson-annotations
+            2.7.0
+        
+
+
+
+
     
 
 
diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
index 53e88961be34..2585c32438ec 100644
--- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java	
@@ -1,15 +1,13 @@
 package com.baeldung.client;
 
-import com.baeldung.Movie;
+import com.baeldung.model.Movie;
 
 import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
-
 
+@Path("/movies")
 public interface ServicesInterface {
 
 
diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java
similarity index 86%
rename from RestEasy Example/src/main/java/com/baeldung/Movie.java
rename to RestEasy Example/src/main/java/com/baeldung/model/Movie.java
index c0041d2e95d2..052ba081c1a0 100644
--- a/RestEasy Example/src/main/java/com/baeldung/Movie.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java	
@@ -1,5 +1,5 @@
 
-package com.baeldung;
+package com.baeldung.model;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -532,4 +532,47 @@ public void setYear(String value) {
         this.year = value;
     }
 
+    @Override
+    public String toString() {
+        return "Movie{" +
+                "actors='" + actors + '\'' +
+                ", awards='" + awards + '\'' +
+                ", country='" + country + '\'' +
+                ", director='" + director + '\'' +
+                ", genre='" + genre + '\'' +
+                ", imdbID='" + imdbID + '\'' +
+                ", imdbRating='" + imdbRating + '\'' +
+                ", imdbVotes='" + imdbVotes + '\'' +
+                ", language='" + language + '\'' +
+                ", metascore='" + metascore + '\'' +
+                ", poster='" + poster + '\'' +
+                ", rated='" + rated + '\'' +
+                ", released='" + released + '\'' +
+                ", response='" + response + '\'' +
+                ", runtime='" + runtime + '\'' +
+                ", title='" + title + '\'' +
+                ", type='" + type + '\'' +
+                ", writer='" + writer + '\'' +
+                ", year='" + year + '\'' +
+                '}';
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        Movie movie = (Movie) o;
+
+        if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false;
+        return title != null ? title.equals(movie.title) : movie.title == null;
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = imdbID != null ? imdbID.hashCode() : 0;
+        result = 31 * result + (title != null ? title.hashCode() : 0);
+        return result;
+    }
 }
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
similarity index 96%
rename from RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java
rename to RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
index d1973e703738..60e0121966df 100644
--- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java	
@@ -1,11 +1,10 @@
-package com.baeldung.server.service;
+package com.baeldung.server;
 
-import com.baeldung.Movie;
+import com.baeldung.model.Movie;
 
 import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.Provider;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java
similarity index 95%
rename from RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java
rename to RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java
index 16b6200ad1f2..8c57d2c9b466 100644
--- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java	
@@ -1,4 +1,4 @@
-package com.baeldung.server.service;
+package com.baeldung.server;
 
 
 import javax.ws.rs.ApplicationPath;
diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java
index e7112339793b..c77f494862f5 100644
--- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java	
+++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java	
@@ -1,49 +1,111 @@
 package com.baeldung.server;
 
-import com.baeldung.Movie;
+import com.baeldung.model.Movie;
 import com.baeldung.client.ServicesInterface;
+import org.apache.commons.io.IOUtils;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.jboss.resteasy.client.jaxrs.ResteasyClient;
 import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
 import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
+import javax.naming.NamingException;
+import javax.ws.rs.core.Link;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 
 public class RestEasyClient {
 
-    public static void main(String[] args) {
 
-        Movie st = new Movie();
-        st.setImdbID("12345");
+    Movie  transformerMovie=null;
+    Movie   batmanMovie=null;
+    ObjectMapper jsonMapper=null;
 
-		/*
-		 *  Alternatively you can use this simple String to send
-		 *  instead of using a Student instance
-		 *
-		 *  String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}";
-		 */
+    @BeforeClass
+    public static void loadMovieInventory(){
+
+
+
+    }
+
+    @Before
+    public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException {
+
+
+        jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
+        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
+        jsonMapper.setDateFormat(sdf);
+
+        try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) {
+            String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
+            transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("Test is going to die ...", e);
+        }
+
+        try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) {
+            String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
+            batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("Test is going to die ...", e);
+        }
+
+    }
+
+    @Test
+    public void testListAllMovies() {
 
         try {
             ResteasyClient client = new ResteasyClientBuilder().build();
-            ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies");
-
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
             ServicesInterface simple = target.proxy(ServicesInterface.class);
+
             final List movies = simple.listMovies();
+            System.out.println(movies);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
 
-            /*
-            if (response.getStatus() != 200) {
+
+    @Test
+    public void testAddMovie() {
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+            final Response moviesResponse = simple.addMovie(batmanMovie);
+
+            if (moviesResponse.getStatus() != 201) {
+                System.out.println(moviesResponse.readEntity(String.class));
                 throw new RuntimeException("Failed : HTTP error code : "
-                        + response.getStatus());
+                        + moviesResponse.getStatus());
             }
 
-            System.out.println("Server response : \n");
-            System.out.println(response.readEntity(String.class));
+            moviesResponse.close();
 
-            response.close();
-*/
         } catch (Exception e) {
-
             e.printStackTrace();
-
         }
     }
 
diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json
new file mode 100644
index 000000000000..28061d5bf94d
--- /dev/null
+++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json	
@@ -0,0 +1,22 @@
+{
+  "title": "Batman",
+  "year": "1989",
+  "rated": "PG-13",
+  "released": "23 Jun 1989",
+  "runtime": "126 min",
+  "genre": "Action, Adventure",
+  "director": "Tim Burton",
+  "writer": "Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)",
+  "actors": "Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl",
+  "plot": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.",
+  "language": "English, French",
+  "country": "USA, UK",
+  "awards": "Won 1 Oscar. Another 9 wins & 22 nominations.",
+  "poster": "http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg",
+  "metascore": "66",
+  "imdbRating": "7.6",
+  "imdbVotes": "256,000",
+  "imdbID": "tt0096895",
+  "type": "movie",
+  "response": "True"
+}
\ No newline at end of file
diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json
similarity index 99%
rename from RestEasy Example/src/test/resources/server/movies/transformer.json
rename to RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json
index 215486826560..a3b033a8ba6f 100644
--- a/RestEasy Example/src/test/resources/server/movies/transformer.json	
+++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json	
@@ -17,6 +17,6 @@
   "imdbRating": "7.1",
   "imdbVotes": "492,225",
   "imdbID": "tt0418279",
-  "Type": "movie",
+  "type": "movie",
   "response": "True"
 }
\ No newline at end of file

From 453d9953858aa8ef9b5c0e54a3c7887e6fd36f9d Mon Sep 17 00:00:00 2001
From: amedviediev 
Date: Sat, 30 Jan 2016 23:05:06 +0200
Subject: [PATCH 158/626] - Updated source code for the article "Returning
 Custom Status Codes from Spring MVC Controllers" to be included in the
 spring-rest project

---
 spring-mvc-custom-status-codes/.gitignore     | 13 ------
 spring-mvc-custom-status-codes/pom.xml        | 44 -------------------
 .../CustomStatusCodesApplication.java         | 11 -----
 .../src/main/resources/application.properties |  0
 .../controller/status}/ExampleController.java |  2 +-
 .../status}/ForbiddenException.java           |  2 +-
 6 files changed, 2 insertions(+), 70 deletions(-)
 delete mode 100644 spring-mvc-custom-status-codes/.gitignore
 delete mode 100644 spring-mvc-custom-status-codes/pom.xml
 delete mode 100644 spring-mvc-custom-status-codes/src/main/java/com/baeldung/CustomStatusCodesApplication.java
 delete mode 100644 spring-mvc-custom-status-codes/src/main/resources/application.properties
 rename {spring-mvc-custom-status-codes/src/main/java/com/baeldung => spring-rest/src/main/java/org/baeldung/web/controller/status}/ExampleController.java (94%)
 rename {spring-mvc-custom-status-codes/src/main/java/com/baeldung => spring-rest/src/main/java/org/baeldung/web/controller/status}/ForbiddenException.java (85%)

diff --git a/spring-mvc-custom-status-codes/.gitignore b/spring-mvc-custom-status-codes/.gitignore
deleted file mode 100644
index 83c05e60c802..000000000000
--- a/spring-mvc-custom-status-codes/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*.class
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-
-# Packaged files #
-*.jar
-*.war
-*.ear
\ No newline at end of file
diff --git a/spring-mvc-custom-status-codes/pom.xml b/spring-mvc-custom-status-codes/pom.xml
deleted file mode 100644
index 3fce332645d4..000000000000
--- a/spring-mvc-custom-status-codes/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-	4.0.0
-
-	com.baeldung
-	custom-status-codes
-	0.0.1-SNAPSHOT
-	jar
-
-	spring-mvc-custom-status-codes
-	Returning Custom Status Codes from Spring MVC Controllers
-
-	
-		org.springframework.boot
-		spring-boot-starter-parent
-		1.3.2.RELEASE
-		 
-	
-
-	
-		UTF-8
-		1.8
-	
-
-	
-        
-            org.springframework.boot
-            spring-boot-starter-web
-            1.3.2.RELEASE
-        
-	
-	
-	
-		
-			
-				org.springframework.boot
-				spring-boot-maven-plugin
-			
-		
-	
-	
-
-
diff --git a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/CustomStatusCodesApplication.java b/spring-mvc-custom-status-codes/src/main/java/com/baeldung/CustomStatusCodesApplication.java
deleted file mode 100644
index 2baf4b122fe5..000000000000
--- a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/CustomStatusCodesApplication.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.baeldung;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class CustomStatusCodesApplication {
-	public static void main(String[] args) {
-		SpringApplication.run(CustomStatusCodesApplication.class, args);
-	}
-}
diff --git a/spring-mvc-custom-status-codes/src/main/resources/application.properties b/spring-mvc-custom-status-codes/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/ExampleController.java b/spring-rest/src/main/java/org/baeldung/web/controller/status/ExampleController.java
similarity index 94%
rename from spring-mvc-custom-status-codes/src/main/java/com/baeldung/ExampleController.java
rename to spring-rest/src/main/java/org/baeldung/web/controller/status/ExampleController.java
index 2d8f69977661..ceda138768eb 100644
--- a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/ExampleController.java
+++ b/spring-rest/src/main/java/org/baeldung/web/controller/status/ExampleController.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package org.baeldung.web.controller.status;
 
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
diff --git a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/ForbiddenException.java b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
similarity index 85%
rename from spring-mvc-custom-status-codes/src/main/java/com/baeldung/ForbiddenException.java
rename to spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
index 858d428681e6..1d4aff2ebf1d 100644
--- a/spring-mvc-custom-status-codes/src/main/java/com/baeldung/ForbiddenException.java
+++ b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package org.baeldung.web.controller.status;
 
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.ResponseStatus;

From cc8d42c58bfa5dc671a9fb670cae5b196f9e2e53 Mon Sep 17 00:00:00 2001
From: David Morley 
Date: Sat, 30 Jan 2016 15:41:48 -0600
Subject: [PATCH 159/626] Clean up Spring Data Redis example

---
 .../main/java/org/baeldung/spring/data/redis/model/Student.java | 2 --
 1 file changed, 2 deletions(-)

diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java
index 825248f18367..acc96899ce46 100644
--- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java
+++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java
@@ -4,8 +4,6 @@
 
 public class Student implements Serializable {
 
-    private static final long serialVersionUID = -1907106213598514113L;
-
     public enum Gender {
         MALE, FEMALE
     }

From a2a026a503167a5e3a0fb2f3e8856686ce1428cc Mon Sep 17 00:00:00 2001
From: Giuseppe Bueti 
Date: Sun, 31 Jan 2016 11:05:11 +0100
Subject: [PATCH 160/626] Added testCase for all Services

---
 RestEasy Example/pom.xml                      |  15 --
 .../baeldung/client/ServicesInterface.java    |  10 +-
 .../com/baeldung/server/MovieCrudService.java |  15 +-
 .../src/main/webapp/WEB-INF/web.xml           |   2 +-
 .../com/baeldung/server/RestEasyClient.java   | 112 -----------
 .../baeldung/server/RestEasyClientTest.java   | 189 ++++++++++++++++++
 6 files changed, 206 insertions(+), 137 deletions(-)
 delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java
 create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java

diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml
index 8dabfc863bc4..6935238d910f 100644
--- a/RestEasy Example/pom.xml	
+++ b/RestEasy Example/pom.xml	
@@ -99,21 +99,6 @@
             2.4
         
 
-        
-            com.fasterxml.jackson.core
-            jackson-core
-            2.7.0
-        
-
-        
-            com.fasterxml.jackson.core
-            jackson-annotations
-            2.7.0
-        
-
-
-
-
     
 
 
diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
index 2585c32438ec..7efed546d896 100644
--- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java	
@@ -17,6 +17,12 @@ public interface ServicesInterface {
     Movie movieByImdbID(@QueryParam("imdbID") String imdbID);
 
 
+    @GET
+    @Path("/listmovies")
+    @Produces({"application/json"})
+    List listMovies();
+
+
     @POST
     @Path("/addmovie")
     @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@@ -34,9 +40,5 @@ public interface ServicesInterface {
     Response deleteMovie(@QueryParam("imdbID") String imdbID);
 
 
-    @GET
-    @Path("/listmovies")
-    @Produces({"application/json"})
-    List listMovies();
 
 }
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
index 60e0121966df..18366e2faafc 100644
--- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java	
+++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java	
@@ -18,18 +18,21 @@ public class MovieCrudService {
 
     private Map inventory = new HashMap();
 
+
     @GET
     @Path("/getinfo")
     @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
     public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){
 
-        System.out.println("*** Calling  getinfo ***");
+        System.out.println("*** Calling  getinfo for a given ImdbID***");
+
+        if(inventory.containsKey(imdbID)){
+            return inventory.get(imdbID);
+        }else return null;
 
-        Movie movie=new Movie();
-        movie.setImdbID(imdbID);
-        return movie;
     }
 
+
     @POST
     @Path("/addmovie")
     @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@@ -41,6 +44,7 @@ public Response addMovie(Movie movie){
             return Response.status(Response.Status.NOT_MODIFIED)
                     .entity("Movie is Already in the database.").build();
         }
+
         inventory.put(movie.getImdbID(),movie);
 
         return Response.status(Response.Status.CREATED).build();
@@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){
 
         System.out.println("*** Calling  updateMovie ***");
 
-        if (null!=inventory.get(movie.getImdbID())){
+        if (null==inventory.get(movie.getImdbID())){
             return Response.status(Response.Status.NOT_MODIFIED)
                     .entity("Movie is not in the database.\nUnable to Update").build();
         }
@@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){
         return Response.status(Response.Status.OK).build();
     }
 
+
     @GET
     @Path("/listmovies")
     @Produces({"application/json"})
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml
index c66d3b56ae77..ab3bc1aa8362 100644
--- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml	
+++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml	
@@ -33,7 +33,7 @@
         
         
             javax.ws.rs.Application
-            com.baeldung.server.service.RestEasyServices
+            com.baeldung.server.RestEasyServices
         
     
 
diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java
deleted file mode 100644
index c77f494862f5..000000000000
--- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java	
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.baeldung.server;
-
-import com.baeldung.model.Movie;
-import com.baeldung.client.ServicesInterface;
-import org.apache.commons.io.IOUtils;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.jboss.resteasy.client.jaxrs.ResteasyClient;
-import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
-import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.naming.NamingException;
-import javax.ws.rs.core.Link;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-
-public class RestEasyClient {
-
-
-    Movie  transformerMovie=null;
-    Movie   batmanMovie=null;
-    ObjectMapper jsonMapper=null;
-
-    @BeforeClass
-    public static void loadMovieInventory(){
-
-
-
-    }
-
-    @Before
-    public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException {
-
-
-        jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
-        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
-        jsonMapper.setDateFormat(sdf);
-
-        try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) {
-            String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
-            transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException("Test is going to die ...", e);
-        }
-
-        try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) {
-            String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
-            batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException("Test is going to die ...", e);
-        }
-
-    }
-
-    @Test
-    public void testListAllMovies() {
-
-        try {
-            ResteasyClient client = new ResteasyClientBuilder().build();
-            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
-            ServicesInterface simple = target.proxy(ServicesInterface.class);
-
-            final List movies = simple.listMovies();
-            System.out.println(movies);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-
-
-    @Test
-    public void testAddMovie() {
-
-        try {
-            ResteasyClient client = new ResteasyClientBuilder().build();
-            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
-
-            ServicesInterface simple = target.proxy(ServicesInterface.class);
-            final Response moviesResponse = simple.addMovie(batmanMovie);
-
-            if (moviesResponse.getStatus() != 201) {
-                System.out.println(moviesResponse.readEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + moviesResponse.getStatus());
-            }
-
-            moviesResponse.close();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java
new file mode 100644
index 000000000000..fb4205bcd79b
--- /dev/null
+++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java	
@@ -0,0 +1,189 @@
+package com.baeldung.server;
+
+import com.baeldung.model.Movie;
+import com.baeldung.client.ServicesInterface;
+import org.apache.commons.io.IOUtils;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.naming.NamingException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Locale;
+
+public class RestEasyClientTest {
+
+
+    Movie  transformerMovie=null;
+    Movie   batmanMovie=null;
+    ObjectMapper jsonMapper=null;
+
+    @BeforeClass
+    public static void loadMovieInventory(){
+
+
+
+    }
+
+    @Before
+    public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException {
+
+
+        jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
+        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
+        jsonMapper.setDateFormat(sdf);
+
+        try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) {
+            String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
+            transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("Test is going to die ...", e);
+        }
+
+        try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) {
+            String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
+            batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("Test is going to die ...", e);
+        }
+
+    }
+
+
+    @Test
+    public void testListAllMovies() {
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+
+            Response moviesResponse = simple.addMovie(transformerMovie);
+            moviesResponse.close();
+            moviesResponse = simple.addMovie(batmanMovie);
+            moviesResponse.close();
+
+            final List movies = simple.listMovies();
+            System.out.println(movies);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Test
+    public void testMovieByImdbID() {
+
+        String transformerImdbId="tt0418279";
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+
+            Response moviesResponse = simple.addMovie(transformerMovie);
+            moviesResponse.close();
+
+            final Movie movies = simple.movieByImdbID(transformerImdbId);
+            System.out.println(movies);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Test
+    public void testAddMovie() {
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+
+            Response moviesResponse = simple.addMovie(batmanMovie);
+            moviesResponse.close();
+            moviesResponse = simple.addMovie(transformerMovie);
+
+            if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
+                //System.out.println(moviesResponse.readEntity(String.class));
+                System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
+            }
+            moviesResponse.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Test
+    public void testDeleteMovie() {
+
+        String transformerImdbId="tt0418279";
+
+        try {
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+
+            Response moviesResponse = simple.addMovie(batmanMovie);
+            moviesResponse.close();
+            moviesResponse = simple.deleteMovie(transformerImdbId);
+            moviesResponse.close();
+
+            if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
+                System.out.println(moviesResponse.readEntity(String.class));
+                throw new RuntimeException("Failed : HTTP error code : "  + moviesResponse.getStatus());
+            }
+
+            moviesResponse.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Test
+    public void testUpdateMovie() {
+
+        try {
+
+            ResteasyClient client = new ResteasyClientBuilder().build();
+            ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
+            ServicesInterface simple = target.proxy(ServicesInterface.class);
+
+            Response moviesResponse = simple.addMovie(batmanMovie);
+            moviesResponse.close();
+            batmanMovie.setImdbVotes("300,000");
+            moviesResponse = simple.updateMovie(batmanMovie);
+
+            if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
+                //System.out.println(moviesResponse.readEntity(String.class));
+                System.out.println("Failed : HTTP error code : "  + moviesResponse.getStatus());
+            }
+
+            moviesResponse.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}
\ No newline at end of file

From e2527695e6f873a44d2b41c147e444fc60bfa7e3 Mon Sep 17 00:00:00 2001
From: DOHA 
Date: Sun, 31 Jan 2016 19:08:02 +0200
Subject: [PATCH 161/626] upgrade to tomcat 8.0.30

---
 spring-hibernate4/pom.xml                     |  2 +-
 .../baeldung/spring/PersistenceConfig.java    | 38 +++++++++----------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/spring-hibernate4/pom.xml b/spring-hibernate4/pom.xml
index 33eee53c7815..652636b7ccd2 100644
--- a/spring-hibernate4/pom.xml
+++ b/spring-hibernate4/pom.xml
@@ -222,7 +222,7 @@
         4.3.11.Final
         ${hibernate.version}
         5.1.37
-        7.0.42
+        8.0.30
         1.1
         2.2.4
 
diff --git a/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java
index 05efc7a4ff8b..35e80b81a5ba 100644
--- a/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java
+++ b/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java
@@ -4,25 +4,7 @@
 
 import javax.sql.DataSource;
 
-import com.baeldung.persistence.dao.impl.BarDao;
-import com.baeldung.persistence.dao.impl.FooDao;
-import com.baeldung.persistence.service.IBarAuditableService;
-import com.baeldung.persistence.service.IFooAuditableService;
-import com.baeldung.persistence.service.IFooService;
-import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
-import com.baeldung.persistence.dao.IBarAuditableDao;
-import com.baeldung.persistence.dao.IBarDao;
-import com.baeldung.persistence.dao.IFooAuditableDao;
-import com.baeldung.persistence.dao.IFooDao;
-import com.baeldung.persistence.dao.impl.BarAuditableDao;
-import com.baeldung.persistence.dao.impl.BarJpaDao;
-import com.baeldung.persistence.dao.impl.FooAuditableDao;
-import com.baeldung.persistence.service.IBarService;
-import com.baeldung.persistence.service.impl.BarAuditableService;
-import com.baeldung.persistence.service.impl.BarJpaService;
-import com.baeldung.persistence.service.impl.BarSpringDataJpaService;
-import com.baeldung.persistence.service.impl.FooAuditableService;
-import com.baeldung.persistence.service.impl.FooService;
+import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
@@ -41,6 +23,24 @@
 import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
+import com.baeldung.persistence.dao.IBarAuditableDao;
+import com.baeldung.persistence.dao.IBarDao;
+import com.baeldung.persistence.dao.IFooAuditableDao;
+import com.baeldung.persistence.dao.IFooDao;
+import com.baeldung.persistence.dao.impl.BarAuditableDao;
+import com.baeldung.persistence.dao.impl.BarDao;
+import com.baeldung.persistence.dao.impl.BarJpaDao;
+import com.baeldung.persistence.dao.impl.FooAuditableDao;
+import com.baeldung.persistence.dao.impl.FooDao;
+import com.baeldung.persistence.service.IBarAuditableService;
+import com.baeldung.persistence.service.IBarService;
+import com.baeldung.persistence.service.IFooAuditableService;
+import com.baeldung.persistence.service.IFooService;
+import com.baeldung.persistence.service.impl.BarAuditableService;
+import com.baeldung.persistence.service.impl.BarJpaService;
+import com.baeldung.persistence.service.impl.BarSpringDataJpaService;
+import com.baeldung.persistence.service.impl.FooAuditableService;
+import com.baeldung.persistence.service.impl.FooService;
 import com.google.common.base.Preconditions;
 
 @Configuration

From e6cc0bb7225757ae91994e0549589bc47077d658 Mon Sep 17 00:00:00 2001
From: DOHA 
Date: Sun, 31 Jan 2016 19:36:30 +0200
Subject: [PATCH 162/626] upgrade to tomcat8

---
 spring-hibernate4/src/main/resources/hibernate4Config.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spring-hibernate4/src/main/resources/hibernate4Config.xml b/spring-hibernate4/src/main/resources/hibernate4Config.xml
index 661cc942d8ef..ca507802cd63 100644
--- a/spring-hibernate4/src/main/resources/hibernate4Config.xml
+++ b/spring-hibernate4/src/main/resources/hibernate4Config.xml
@@ -18,7 +18,7 @@
         
     
 
-    
+    
         
         
         

From ddec979e4d0383161654b79fce48b88f59286735 Mon Sep 17 00:00:00 2001
From: David Morley 
Date: Mon, 1 Feb 2016 05:51:27 -0600
Subject: [PATCH 163/626] Update Spring Data Redis example to use constructor
 injection

---
 .../data/redis/repo/StudentRepository.java    |  3 ++-
 .../redis/repo/StudentRepositoryImpl.java     | 24 ++++++++++++++-----
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java
index 6a909ed13756..9e5502f8e0e7 100644
--- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java
+++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java
@@ -1,12 +1,13 @@
 package org.baeldung.spring.data.redis.repo;
 
 import org.baeldung.spring.data.redis.model.Student;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.util.Map;
 
 public interface StudentRepository {
-    
+
     void saveStudent(Student person);
     
     void updateStudent(Student student);
diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java
index 55e6ad5edc6d..43294cae58c5 100644
--- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java
+++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java
@@ -2,9 +2,11 @@
 
 import org.baeldung.spring.data.redis.model.Student;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.HashOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Repository;
 
+import javax.annotation.PostConstruct;
 import java.util.Map;
 
 @Repository
@@ -12,26 +14,36 @@ public class StudentRepositoryImpl implements StudentRepository {
 
     private static final String KEY = "Student";
 
-    @Autowired
     private RedisTemplate redisTemplate;
+    private HashOperations hashOperations;
+
+    @Autowired
+    public StudentRepositoryImpl(RedisTemplate redisTemplate) {
+        this.redisTemplate = redisTemplate;
+    }
+
+    @PostConstruct
+    private void init() {
+        hashOperations = redisTemplate.opsForHash();
+    }
 
     public void saveStudent(final Student student) {
-        redisTemplate.opsForHash().put(KEY, student.getId(), student);
+        hashOperations.put(KEY, student.getId(), student);
     }
 
     public void updateStudent(final Student student) {
-        redisTemplate.opsForHash().put(KEY, student.getId(), student);
+        hashOperations.put(KEY, student.getId(), student);
     }
 
     public Student findStudent(final String id) {
-        return (Student) redisTemplate.opsForHash().get(KEY, id);
+        return (Student) hashOperations.get(KEY, id);
     }
 
     public Map findAllStudents() {
-        return redisTemplate.opsForHash().entries(KEY);
+        return hashOperations.entries(KEY);
     }
 
     public void deleteStudent(final String id) {
-        this.redisTemplate.opsForHash().delete(KEY, id);
+        hashOperations.delete(KEY, id);
     }
 }

From de3b09bfd1d72942b333b73c4ff735d5fcf17f04 Mon Sep 17 00:00:00 2001
From: amedviediev 
Date: Mon, 1 Feb 2016 20:38:01 +0200
Subject: [PATCH 164/626] - Added test code for the article "Returning Custom
 Status Codes from Spring MVC Controllers"

---
 .../status/ExampleControllerTest.java         | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java

diff --git a/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java b/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java
new file mode 100644
index 000000000000..8d4f583a08f2
--- /dev/null
+++ b/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java
@@ -0,0 +1,43 @@
+package com.baeldung;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.junit.Before;
+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.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = WebConfig.class)
+@WebAppConfiguration
+public class ExampleControllerTest {
+
+    private MockMvc mockMvc;
+
+    @Autowired
+    private WebApplicationContext webApplicationContext;
+
+    @Before
+    public void setUp() {
+        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
+    }
+
+    @Test
+    public void whenGetRequestSentToController_thenReturnsStatusNotAcceptable() throws Exception {
+        mockMvc.perform(get("/controller"))
+            .andExpect(status().isNotAcceptable());
+    }
+
+    @Test
+    public void whenGetRequestSentToException_thenReturnsStatusForbidden() throws Exception {
+        mockMvc.perform(get("/exception"))
+                .andExpect(status().isForbidden());
+    }
+}

From 6a203ae91bcad889998d2ff579b74eefbec90ad9 Mon Sep 17 00:00:00 2001
From: Ivan 
Date: Tue, 2 Feb 2016 17:37:39 +0100
Subject: [PATCH 165/626] Add multiple ViewResolver configuration example

---
 .../baeldung/spring/web/config/WebConfig.java | 49 +++++++++++++++++--
 .../src/main/resources/views.properties       |  3 ++
 spring-mvc-java/src/main/resources/views.xml  | 10 ++++
 3 files changed, 58 insertions(+), 4 deletions(-)
 create mode 100644 spring-mvc-java/src/main/resources/views.properties
 create mode 100644 spring-mvc-java/src/main/resources/views.xml

diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
index d60bcfe12760..58438d2976f8 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
@@ -1,19 +1,60 @@
 package org.baeldung.spring.web.config;
 
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.web.servlet.ViewResolver;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+import org.springframework.web.servlet.view.JstlView;
+import org.springframework.web.servlet.view.ResourceBundleViewResolver;
+import org.springframework.web.servlet.view.XmlViewResolver;
 
 @Configuration
 @EnableWebMvc
 @ComponentScan("org.baeldung.web")
 public class WebConfig extends WebMvcConfigurerAdapter {
 
-    public WebConfig() {
-        super();
-    }
+	public WebConfig() {
+		super();
+	}
 
-    // API
+	@Override
+	public void addViewControllers(final ViewControllerRegistry registry) {
 
+		super.addViewControllers(registry);
+		registry.addViewController("/sample.html");
+	}
+
+	@Bean
+	public ViewResolver internalResourceViewResolver() {
+
+		final InternalResourceViewResolver bean = new InternalResourceViewResolver();
+		bean.setViewClass(JstlView.class);
+		bean.setPrefix("/WEB-INF/view/");
+		bean.setSuffix(".jsp");
+		bean.setOrder(2);
+		return bean;
+	}
+
+	@Bean
+	public ViewResolver xmlViewResolver() {
+
+		final XmlViewResolver bean = new XmlViewResolver();
+		bean.setLocation(new ClassPathResource("views.xml"));
+		bean.setOrder(1);
+		return bean;
+	}
+
+	@Bean
+	public ViewResolver resourceBundleViewResolver() {
+
+		final ResourceBundleViewResolver bean = new ResourceBundleViewResolver();
+		bean.setBasename("views");
+		bean.setOrder(0);
+		return bean;
+	}
 }
\ No newline at end of file
diff --git a/spring-mvc-java/src/main/resources/views.properties b/spring-mvc-java/src/main/resources/views.properties
new file mode 100644
index 000000000000..95687cb62aae
--- /dev/null
+++ b/spring-mvc-java/src/main/resources/views.properties
@@ -0,0 +1,3 @@
+sample.(class)=org.springframework.web.servlet.view.JstlView
+sample.url=/WEB-INF/view/sample.jsp
+
diff --git a/spring-mvc-java/src/main/resources/views.xml b/spring-mvc-java/src/main/resources/views.xml
new file mode 100644
index 000000000000..83bca5293df3
--- /dev/null
+++ b/spring-mvc-java/src/main/resources/views.xml
@@ -0,0 +1,10 @@
+
+ 
+    
+        
+    
+    
+
\ No newline at end of file

From dfc96b2dd101a98d214e9b289f05b6a0cc885d25 Mon Sep 17 00:00:00 2001
From: amedviediev 
Date: Tue, 2 Feb 2016 20:15:51 +0200
Subject: [PATCH 166/626] - Fixed tests

---
 spring-rest/pom.xml                                          | 4 ----
 .../web/controller/status/ExampleControllerTest.java         | 5 +++--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml
index e2cf9d7c3e1a..54ac868b95f7 100644
--- a/spring-rest/pom.xml
+++ b/spring-rest/pom.xml
@@ -33,7 +33,6 @@
         
             org.springframework
             spring-web
-            ${org.springframework.version}
             
                 
                     commons-logging
@@ -44,12 +43,10 @@
         
             org.springframework
             spring-webmvc
-            ${org.springframework.version}
         
         
             org.springframework
             spring-oxm
-            ${org.springframework.version}
         
 
         
@@ -229,7 +226,6 @@
 
     
         
-        4.2.4.RELEASE
         4.0.3.RELEASE
 
         
diff --git a/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java b/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java
index 8d4f583a08f2..1344d2d40e8b 100644
--- a/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java
+++ b/spring-rest/src/test/java/org/baeldung/web/controller/status/ExampleControllerTest.java
@@ -1,13 +1,14 @@
-package com.baeldung;
+package org.baeldung.web.controller.status;
 
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
+import org.baeldung.config.WebConfig;
 import org.junit.Before;
 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.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 import org.springframework.test.web.servlet.MockMvc;

From dffa1d2504053dccf48d5effe7ff60aa806f35ce Mon Sep 17 00:00:00 2001
From: eugenp 
Date: Wed, 3 Feb 2016 19:28:48 +0200
Subject: [PATCH 167/626] minor cleanup work

---
 .../converter/UserWriterConverter.java        |  2 +
 .../baeldung/spring/web/config/WebConfig.java | 77 +++++++++----------
 2 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java b/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java
index 54fa78e2d0f5..2dedda46ec83 100644
--- a/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java
+++ b/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java
@@ -9,6 +9,7 @@
 
 @Component
 public class UserWriterConverter implements Converter {
+
     @Override
     public DBObject convert(final User user) {
         final DBObject dbObject = new BasicDBObject();
@@ -22,4 +23,5 @@ public DBObject convert(final User user) {
         dbObject.removeField("_class");
         return dbObject;
     }
+
 }
diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
index 58438d2976f8..09e9cff9177f 100644
--- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
+++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/WebConfig.java
@@ -18,43 +18,42 @@
 @ComponentScan("org.baeldung.web")
 public class WebConfig extends WebMvcConfigurerAdapter {
 
-	public WebConfig() {
-		super();
-	}
-
-	@Override
-	public void addViewControllers(final ViewControllerRegistry registry) {
-
-		super.addViewControllers(registry);
-		registry.addViewController("/sample.html");
-	}
-
-	@Bean
-	public ViewResolver internalResourceViewResolver() {
-
-		final InternalResourceViewResolver bean = new InternalResourceViewResolver();
-		bean.setViewClass(JstlView.class);
-		bean.setPrefix("/WEB-INF/view/");
-		bean.setSuffix(".jsp");
-		bean.setOrder(2);
-		return bean;
-	}
-
-	@Bean
-	public ViewResolver xmlViewResolver() {
-
-		final XmlViewResolver bean = new XmlViewResolver();
-		bean.setLocation(new ClassPathResource("views.xml"));
-		bean.setOrder(1);
-		return bean;
-	}
-
-	@Bean
-	public ViewResolver resourceBundleViewResolver() {
-
-		final ResourceBundleViewResolver bean = new ResourceBundleViewResolver();
-		bean.setBasename("views");
-		bean.setOrder(0);
-		return bean;
-	}
+    public WebConfig() {
+        super();
+    }
+
+    //
+
+    @Override
+    public void addViewControllers(final ViewControllerRegistry registry) {
+        super.addViewControllers(registry);
+        registry.addViewController("/sample.html");
+    }
+
+    @Bean
+    public ViewResolver internalResourceViewResolver() {
+        final InternalResourceViewResolver bean = new InternalResourceViewResolver();
+        bean.setViewClass(JstlView.class);
+        bean.setPrefix("/WEB-INF/view/");
+        bean.setSuffix(".jsp");
+        bean.setOrder(2);
+        return bean;
+    }
+
+    @Bean
+    public ViewResolver xmlViewResolver() {
+        final XmlViewResolver bean = new XmlViewResolver();
+        bean.setLocation(new ClassPathResource("views.xml"));
+        bean.setOrder(1);
+        return bean;
+    }
+
+    @Bean
+    public ViewResolver resourceBundleViewResolver() {
+        final ResourceBundleViewResolver bean = new ResourceBundleViewResolver();
+        bean.setBasename("views");
+        bean.setOrder(0);
+        return bean;
+    }
+
 }
\ No newline at end of file

From e14be27fcc4e43cc597ddb79bce2ce7aab8e0288 Mon Sep 17 00:00:00 2001
From: ypatil 
Date: Thu, 4 Feb 2016 14:10:46 +0530
Subject: [PATCH 168/626] Spring with Apache Camel for file processing

---
 spring-apache-camel/data/file1.txt            |  1 +
 .../data/input/.camel/file1.txt               |  1 +
 .../data/outputLowerCase/file1.txt            |  1 +
 .../data/outputUppperCase/file1.txt           |  1 +
 spring-apache-camel/pom.xml                   | 43 +++++++++++++++++++
 .../main/java/org/apache/camel/main/App.java  | 12 ++++++
 .../apache/camel/processor/FileProcessor.java | 19 ++++++++
 .../src/main/resources/camel-context.xml      | 41 ++++++++++++++++++
 8 files changed, 119 insertions(+)
 create mode 100644 spring-apache-camel/data/file1.txt
 create mode 100644 spring-apache-camel/data/input/.camel/file1.txt
 create mode 100644 spring-apache-camel/data/outputLowerCase/file1.txt
 create mode 100644 spring-apache-camel/data/outputUppperCase/file1.txt
 create mode 100644 spring-apache-camel/pom.xml
 create mode 100644 spring-apache-camel/src/main/java/org/apache/camel/main/App.java
 create mode 100644 spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java
 create mode 100644 spring-apache-camel/src/main/resources/camel-context.xml

diff --git a/spring-apache-camel/data/file1.txt b/spring-apache-camel/data/file1.txt
new file mode 100644
index 000000000000..c8436b654b15
--- /dev/null
+++ b/spring-apache-camel/data/file1.txt
@@ -0,0 +1 @@
+THIS IS UPPERCASE CONTENT. this is lowecase content.
\ No newline at end of file
diff --git a/spring-apache-camel/data/input/.camel/file1.txt b/spring-apache-camel/data/input/.camel/file1.txt
new file mode 100644
index 000000000000..c8436b654b15
--- /dev/null
+++ b/spring-apache-camel/data/input/.camel/file1.txt
@@ -0,0 +1 @@
+THIS IS UPPERCASE CONTENT. this is lowecase content.
\ No newline at end of file
diff --git a/spring-apache-camel/data/outputLowerCase/file1.txt b/spring-apache-camel/data/outputLowerCase/file1.txt
new file mode 100644
index 000000000000..06a9866342a2
--- /dev/null
+++ b/spring-apache-camel/data/outputLowerCase/file1.txt
@@ -0,0 +1 @@
+this is uppercase content. this is lowecase content.
\ No newline at end of file
diff --git a/spring-apache-camel/data/outputUppperCase/file1.txt b/spring-apache-camel/data/outputUppperCase/file1.txt
new file mode 100644
index 000000000000..ce07e477bc26
--- /dev/null
+++ b/spring-apache-camel/data/outputUppperCase/file1.txt
@@ -0,0 +1 @@
+THIS IS UPPERCASE CONTENT. THIS IS LOWECASE CONTENT.
\ No newline at end of file
diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml
new file mode 100644
index 000000000000..5b143fedb404
--- /dev/null
+++ b/spring-apache-camel/pom.xml
@@ -0,0 +1,43 @@
+
+	4.0.0
+	org.apache.camel
+	spring-apache-camel
+	jar
+	1.0-SNAPSHOT
+	spring-apache-camel
+	http://maven.apache.org
+
+	
+		2.16.1
+		4.2.4.RELEASE
+	
+
+	
+	
+		
+			org.apache.camel
+			camel-core
+			${env.camel.version}
+		
+		
+		
+			org.apache.camel
+			camel-spring
+			${env.camel.version}
+		
+
+		
+			org.apache.camel
+			camel-stream
+			${env.camel.version}
+		
+
+		
+			org.springframework
+			spring-context
+			${env.spring.version}
+		
+
+	
+
diff --git a/spring-apache-camel/src/main/java/org/apache/camel/main/App.java b/spring-apache-camel/src/main/java/org/apache/camel/main/App.java
new file mode 100644
index 000000000000..4d0793903ed9
--- /dev/null
+++ b/spring-apache-camel/src/main/java/org/apache/camel/main/App.java
@@ -0,0 +1,12 @@
+package org.apache.camel.main;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class App {
+    public static void main(final String[] args) throws Exception {
+    	//Load application context
+    	ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml");
+        Thread.sleep(5000);
+        applicationContext.close();
+    }
+}
\ No newline at end of file
diff --git a/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java b/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java
new file mode 100644
index 000000000000..961f8778066c
--- /dev/null
+++ b/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java
@@ -0,0 +1,19 @@
+package org.apache.camel.processor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class FileProcessor implements Processor {
+
+	public void process(Exchange exchange) throws Exception {
+		//Read file content
+		String originalFileContent = (String)exchange.getIn().getBody(String.class);
+		
+		//Convert file content to upper case.
+		String upperCaseFileContent = originalFileContent.toUpperCase();
+		
+		//Update file content.
+		exchange.getIn().setBody(upperCaseFileContent);
+	}
+
+}
diff --git a/spring-apache-camel/src/main/resources/camel-context.xml b/spring-apache-camel/src/main/resources/camel-context.xml
new file mode 100644
index 000000000000..d304ceb85710
--- /dev/null
+++ b/spring-apache-camel/src/main/resources/camel-context.xml
@@ -0,0 +1,41 @@
+
+
+
+	
+		
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+				${body.toLowerCase()}
+			
+			
+			
+			
+			
+			
+			
+				 .......... File content conversion completed ..........
+			
+			
+			
+		
+	
+	
+
+	
+
\ No newline at end of file

From c385d23cd53543d6bb0a0f6f7ec8c97a8679c31d Mon Sep 17 00:00:00 2001
From: ypatil 
Date: Thu, 4 Feb 2016 14:13:39 +0530
Subject: [PATCH 169/626] Readme file added

---
 spring-apache-camel/README.md | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 spring-apache-camel/README.md

diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md
new file mode 100644
index 000000000000..28b95bdf8975
--- /dev/null
+++ b/spring-apache-camel/README.md
@@ -0,0 +1,28 @@
+
+

Configure and Use Apache Camel with Spring

+ +This article will demonstrate how to configure and use Apache Camel with Spring Framework. + +

Relevant Article

+ + + +

Framework Versions:

+ +
    +
  • Spring 4.2.4
  • +
  • Apache Camel 2.16.1
  • +
+ +

Build and Run Application

+ +To build this application execute following maven command in ApacheCamelFileProcessor directory. + +mvn clean install + +To run this application you can either run our main class org.apache.camel.main.App from your IDE or you can execute following maven command: + +mvn exec:java -Dexec.mainClass="org.apache.camel.main.App" \ No newline at end of file From 032be8319e108f95f0d87d9f020a9f021186ef93 Mon Sep 17 00:00:00 2001 From: Dmitry Zinkevich Date: Thu, 14 Jan 2016 08:42:10 +0300 Subject: [PATCH 170/626] Add Elasticsearch Spring Data test cases --- spring-data-elasticsearch/.classpath | 31 +++++ spring-data-elasticsearch/.project | 29 ++++ spring-data-elasticsearch/README.md | 12 ++ spring-data-elasticsearch/pom.xml | 78 +++++++++++ .../main/java/com/baeldung/config/Config.java | 53 +++++++ .../com/baeldung/dao/ArticleRepository.java | 16 +++ .../main/java/com/baeldung/model/Article.java | 60 ++++++++ .../main/java/com/baeldung/model/Author.java | 28 ++++ .../com/baeldung/service/ArticleService.java | 15 ++ .../baeldung/service/ArticleServiceImpl.java | 54 ++++++++ .../src/main/resources/logback.xml | 20 +++ .../java/com/baeldung/ElasticSearchTest.java | 130 ++++++++++++++++++ 12 files changed, 526 insertions(+) create mode 100644 spring-data-elasticsearch/.classpath create mode 100644 spring-data-elasticsearch/.project create mode 100644 spring-data-elasticsearch/README.md create mode 100644 spring-data-elasticsearch/pom.xml create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java create mode 100644 spring-data-elasticsearch/src/main/resources/logback.xml create mode 100644 spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java diff --git a/spring-data-elasticsearch/.classpath b/spring-data-elasticsearch/.classpath new file mode 100644 index 000000000000..698778fef337 --- /dev/null +++ b/spring-data-elasticsearch/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-data-elasticsearch/.project b/spring-data-elasticsearch/.project new file mode 100644 index 000000000000..09b9a781eda5 --- /dev/null +++ b/spring-data-elasticsearch/.project @@ -0,0 +1,29 @@ + + + spring-data-elasticsearch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/spring-data-elasticsearch/README.md b/spring-data-elasticsearch/README.md new file mode 100644 index 000000000000..0dae92e0e750 --- /dev/null +++ b/spring-data-elasticsearch/README.md @@ -0,0 +1,12 @@ +## Spring Data Elasticsearch + +### Build the Project with Tests Running +``` +mvn clean install +``` + +### Run Tests Directly +``` +mvn test +``` + diff --git a/spring-data-elasticsearch/pom.xml b/spring-data-elasticsearch/pom.xml new file mode 100644 index 000000000000..7ac6dd0fcf09 --- /dev/null +++ b/spring-data-elasticsearch/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + org.baeldung + spring-data-elasticsearch + 0.0.1-SNAPSHOT + jar + + spring-data-elasticsearch + + + UTF-8 + 1.3.2.RELEASE + 4.2.2.RELEASE + 4.11 + 1.7.12 + 1.1.3 + 1.3.2.RELEASE + + + + + org.springframework + spring-core + ${org.springframework.version} + + + junit + junit-dep + ${junit.version} + test + + + org.springframework + spring-test + ${org.springframework.version} + test + + + org.springframework.data + spring-data-elasticsearch + ${elasticsearch.version} + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + + + maven-compiler-plugin + 2.3.2 + + 1.8 + 1.8 + + + + + diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java b/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java new file mode 100644 index 000000000000..eb65e38f6506 --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java @@ -0,0 +1,53 @@ +package com.baeldung.config; + +import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.node.NodeBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; +import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +@Configuration +@EnableElasticsearchRepositories(basePackages = "com.baeldung.dao") +@ComponentScan(basePackages = {"com.baeldung.service"}) +public class Config { + + private static Logger logger = LoggerFactory.getLogger(Config.class); + + @Bean + public NodeBuilder nodeBuilder() { + return new NodeBuilder(); + } + + @Bean + public ElasticsearchOperations elasticsearchTemplate() { + + try { + Path tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir")), "elasticsearch_data"); + + ImmutableSettings.Builder elasticsearchSettings = ImmutableSettings.settingsBuilder() + .put("http.enabled", "false") + .put("path.data", tmpDir.toAbsolutePath().toString()); + + logger.debug(tmpDir.toAbsolutePath().toString()); + + return new ElasticsearchTemplate(nodeBuilder() + .local(true) + .settings(elasticsearchSettings.build()) + .node() + .client()); + } catch (IOException ioex) { + logger.error("Cannot create temp dir", ioex); + throw new RuntimeException(); + } + } +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java b/spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java new file mode 100644 index 000000000000..6ed86eff9be0 --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java @@ -0,0 +1,16 @@ +package com.baeldung.dao; + +import com.baeldung.model.Article; +import com.baeldung.model.Article; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.elasticsearch.annotations.Query; +import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; + +public interface ArticleRepository extends ElasticsearchRepository { + + Page
findByAuthorsName(String name, Pageable pageable); + + @Query("{\"bool\": {\"must\": [{\"match\": {\"authors.name\": \"?0\"}}]}}") + Page
findByAuthorsNameUsingCustomQuery(String name, Pageable pageable); +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java new file mode 100644 index 000000000000..17580ca0db66 --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java @@ -0,0 +1,60 @@ +package com.baeldung.model; + +import org.springframework.data.annotation.Id; +import org.springframework.data.elasticsearch.annotations.Document; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldIndex; +import org.springframework.data.elasticsearch.annotations.FieldType; + +import java.util.List; + +@Document(indexName = "article", type = "article") +public class Article { + + @Id + private String id; + @Field(type = FieldType.String, index = FieldIndex.not_analyzed) + private String title; + @Field(type = FieldType.Nested) + private List authors; + + public Article() { + } + + public Article(String title) { + this.title = title; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public List getAuthors() { + return authors; + } + + public void setAuthors(List authors) { + this.authors = authors; + } + + @Override + public String toString() { + return "Article{" + + "id='" + id + '\'' + + ", title='" + title + '\'' + + ", authors=" + authors + + '}'; + } +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java new file mode 100644 index 000000000000..09239efbe598 --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java @@ -0,0 +1,28 @@ +package com.baeldung.model; + +public class Author { + + private String name; + + public Author() { + } + + public Author(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Author{" + + "name='" + name + '\'' + + '}'; + } +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java new file mode 100644 index 000000000000..052e22c67dba --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java @@ -0,0 +1,15 @@ +package com.baeldung.service; + +import com.baeldung.model.Article; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface ArticleService { + Article save(Article article); + Article findOne(String id); + Iterable
findAll(); + Page
findByAuthorName(String name, Pageable pageable); + Page
findByAuthorNameUsingCustomQuery(String name, Pageable pageable); + long count(); + void delete(Article article); +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java new file mode 100644 index 000000000000..4dc100ec2241 --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java @@ -0,0 +1,54 @@ +package com.baeldung.service; + +import com.baeldung.dao.ArticleRepository; +import com.baeldung.model.Article; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +@Service +public class ArticleServiceImpl implements ArticleService { + + private ArticleRepository articleRepository; + + @Autowired + public void setArticleRepository(ArticleRepository articleRepository) { + this.articleRepository = articleRepository; + } + + @Override + public Article save(Article article) { + return articleRepository.save(article); + } + + @Override + public Article findOne(String id) { + return articleRepository.findOne(id); + } + + @Override + public Iterable
findAll() { + return articleRepository.findAll(); + } + + @Override + public Page
findByAuthorName(String name, Pageable pageable) { + return articleRepository.findByAuthorsName(name, pageable); + } + + @Override + public Page
findByAuthorNameUsingCustomQuery(String name, Pageable pageable) { + return articleRepository.findByAuthorsNameUsingCustomQuery(name, pageable); + } + + @Override + public long count() { + return articleRepository.count(); + } + + @Override + public void delete(Article article) { + articleRepository.delete(article); + } +} diff --git a/spring-data-elasticsearch/src/main/resources/logback.xml b/spring-data-elasticsearch/src/main/resources/logback.xml new file mode 100644 index 000000000000..37a9e2edbf48 --- /dev/null +++ b/spring-data-elasticsearch/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + elasticsearch - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java b/spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java new file mode 100644 index 000000000000..07248149c20a --- /dev/null +++ b/spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java @@ -0,0 +1,130 @@ +package com.baeldung; + +import com.baeldung.config.Config; +import com.baeldung.model.Article; +import com.baeldung.model.Author; +import com.baeldung.service.ArticleService; +import org.elasticsearch.index.query.QueryBuilder; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; +import org.springframework.data.elasticsearch.core.query.SearchQuery; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import java.util.List; + +import static java.util.Arrays.asList; +import static org.elasticsearch.index.query.FilterBuilders.regexpFilter; +import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {Config.class}, loader = AnnotationConfigContextLoader.class) +public class ElasticSearchTest { + + @Autowired + private ElasticsearchTemplate elasticsearchTemplate; + @Autowired + private ArticleService articleService; + + private final Author johnSmith = new Author("John Smith"); + private final Author johnDoe = new Author("John Doe"); + + @Before + public void before() { + elasticsearchTemplate.deleteIndex(Article.class); + elasticsearchTemplate.createIndex(Article.class); + + Article article = new Article("Spring Data Elasticsearch"); + article.setAuthors(asList(johnSmith, johnDoe)); + articleService.save(article); + + article = new Article("Search engines"); + article.setAuthors(asList(johnDoe)); + articleService.save(article); + + article = new Article("Second Article About Elasticsearch"); + article.setAuthors(asList(johnSmith)); + articleService.save(article); + } + + @Test + public void givenArticleService_whenSaveArticle_thenIdIsAssigned() { + List authors = asList( + new Author("John Smith"), johnDoe); + + Article article = new Article("Making Search Elastic"); + article.setAuthors(authors); + + article = articleService.save(article); + assertNotNull(article.getId()); + } + + @Test + public void givenPersistedArticles_whenSearchByAuthorsName_thenRightFound() { + + Page
articleByAuthorName = articleService.findByAuthorName(johnSmith.getName(), new PageRequest(0, 10)); + assertEquals(2L, articleByAuthorName.getTotalElements()); + } + + @Test + public void givenCustomQuery_whenSearchByAuthorsName_thenArticleIsFound() { + + Page
articleByAuthorName = articleService.findByAuthorNameUsingCustomQuery("John Smith", new PageRequest(0, 10)); + assertEquals(3L, articleByAuthorName.getTotalElements()); + } + + + @Test + public void givenPersistedArticles_whenUseRegexQuery_thenRightArticlesFound() { + + SearchQuery searchQuery = new NativeSearchQueryBuilder() + .withFilter(regexpFilter("title", ".*data.*")) + .build(); + List
articles = elasticsearchTemplate.queryForList(searchQuery, Article.class); + + assertEquals(1, articles.size()); + } + + @Test + public void givenSavedDoc_whenTitleUpdated_thenCouldFindByUpdatedTitle() { + SearchQuery searchQuery = new NativeSearchQueryBuilder() + .withQuery(fuzzyQuery("title", "serch")) + .build(); + List
articles = elasticsearchTemplate.queryForList(searchQuery, Article.class); + + assertEquals(1, articles.size()); + + Article article = articles.get(0); + final String newTitle = "Getting started with Search Engines"; + article.setTitle(newTitle); + articleService.save(article); + + assertEquals(newTitle, articleService.findOne(article.getId()).getTitle()); + } + + @Test + public void givenSavedDoc_whenDelete_thenRemovedFromIndex() { + + final String articleTitle = "Spring Data Elasticsearch"; + + SearchQuery searchQuery = new NativeSearchQueryBuilder() + .withQuery(matchQuery("title", articleTitle).minimumShouldMatch("75%")) + .build(); + List
articles = elasticsearchTemplate.queryForList(searchQuery, Article.class); + assertEquals(1, articles.size()); + final long count = articleService.count(); + + articleService.delete(articles.get(0)); + + assertEquals(count - 1, articleService.count()); + } +} From 68f33a231298f75ed4d73d86a879491b4a05e4a1 Mon Sep 17 00:00:00 2001 From: Dmitry Zinkevich Date: Thu, 4 Feb 2016 15:10:06 +0300 Subject: [PATCH 171/626] Change index name to 'blog' and rename package to 'repository' --- .../src/main/java/com/baeldung/config/Config.java | 2 +- .../src/main/java/com/baeldung/model/Article.java | 2 +- .../baeldung/repository/ArticleRepository.java | 15 +++++++++++++++ .../com/baeldung/service/ArticleServiceImpl.java | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java b/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java index eb65e38f6506..a67ec6453473 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java @@ -17,7 +17,7 @@ import java.nio.file.Paths; @Configuration -@EnableElasticsearchRepositories(basePackages = "com.baeldung.dao") +@EnableElasticsearchRepositories(basePackages = "com.baeldung.repository") @ComponentScan(basePackages = {"com.baeldung.service"}) public class Config { diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java index 17580ca0db66..dee1d0817eef 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java @@ -8,7 +8,7 @@ import java.util.List; -@Document(indexName = "article", type = "article") +@Document(indexName = "blog", type = "article") public class Article { @Id diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java b/spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java new file mode 100644 index 000000000000..1cb74889c58e --- /dev/null +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java @@ -0,0 +1,15 @@ +package com.baeldung.repository; + +import com.baeldung.model.Article; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.elasticsearch.annotations.Query; +import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; + +public interface ArticleRepository extends ElasticsearchRepository { + + Page
findByAuthorsName(String name, Pageable pageable); + + @Query("{\"bool\": {\"must\": [{\"match\": {\"authors.name\": \"?0\"}}]}}") + Page
findByAuthorsNameUsingCustomQuery(String name, Pageable pageable); +} diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java index 4dc100ec2241..59feb2816c14 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java @@ -1,6 +1,6 @@ package com.baeldung.service; -import com.baeldung.dao.ArticleRepository; +import com.baeldung.repository.ArticleRepository; import com.baeldung.model.Article; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; From 596486aea00f488010c79ff1931c418c1b5ffa12 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Fri, 5 Feb 2016 14:11:39 +0700 Subject: [PATCH 172/626] initial commit for json-path --- json-path/.classpath | 32 +++++++ json-path/.gitignore | 13 +++ json-path/.project | 23 +++++ json-path/pom.xml | 61 +++++++++++++ json-path/src/main/resources/intro_api.json | 57 +++++++++++++ json-path/src/main/resources/intro_user.json | 46 ++++++++++ .../introduction/ChangingPasswordTest.java | 85 +++++++++++++++++++ .../jsonpath/introduction/LoggingInTest.java | 50 +++++++++++ .../jsonpath/introduction/OperationTest.java | 71 ++++++++++++++++ .../introduction/RegisteringAccountTest.java | 46 ++++++++++ 10 files changed, 484 insertions(+) create mode 100644 json-path/.classpath create mode 100644 json-path/.gitignore create mode 100644 json-path/.project create mode 100644 json-path/pom.xml create mode 100644 json-path/src/main/resources/intro_api.json create mode 100644 json-path/src/main/resources/intro_user.json create mode 100644 json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java create mode 100644 json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java create mode 100644 json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java create mode 100644 json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java diff --git a/json-path/.classpath b/json-path/.classpath new file mode 100644 index 000000000000..2244ed1e21c3 --- /dev/null +++ b/json-path/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/json-path/.gitignore b/json-path/.gitignore new file mode 100644 index 000000000000..83c05e60c802 --- /dev/null +++ b/json-path/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/json-path/.project b/json-path/.project new file mode 100644 index 000000000000..caa2c41711ff --- /dev/null +++ b/json-path/.project @@ -0,0 +1,23 @@ + + + json-path + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/json-path/pom.xml b/json-path/pom.xml new file mode 100644 index 000000000000..b51f59c41107 --- /dev/null +++ b/json-path/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + org.baeldung + json-path + 0.0.1-SNAPSHOT + json-path + + + + + com.jayway.jsonpath + json-path + ${json-path.version} + + + + + joda-time + joda-time + ${joda-time.version} + + + + + junit + junit + ${junit.version} + test + + + + + org.slf4j + slf4j-api + ${slf4j.version} + runtime + + + ch.qos.logback + logback-classic + ${logback.version} + runtime + + + + + + 2.1.0 + + + 2.9.2 + + + 4.12 + + + 1.7.14 + 1.1.3 + + \ No newline at end of file diff --git a/json-path/src/main/resources/intro_api.json b/json-path/src/main/resources/intro_api.json new file mode 100644 index 000000000000..8a252f2971f5 --- /dev/null +++ b/json-path/src/main/resources/intro_api.json @@ -0,0 +1,57 @@ +{ + "tool": + { + "jsonpath": + { + "creator": + { + "name": "Jayway Inc.", + "location": + [ + "Malmo", + "Stockholm", + "Copenhagen", + "San Francisco", + "Karlskrona", + "Halmstad", + "Helsingborg" + ] + }, + + "current release": "2.1" + } + }, + + "book": + [ + { + "title": "Beginning JSON", + "author": "Ben Smith", + "price": 49.99 + }, + + { + "title": "JSON at Work", + "author": "Tom Marrs", + "price": 29.99 + }, + + { + "title": "Learn JSON in a DAY", + "author": "Acodemy", + "price": 8.99 + }, + + { + "title": "JSON: Questions and Answers", + "author": "George Duckett", + "price": 6.00 + } + ], + + "price range": + { + "cheap": 10.00, + "medium": 20.00 + } +} \ No newline at end of file diff --git a/json-path/src/main/resources/intro_user.json b/json-path/src/main/resources/intro_user.json new file mode 100644 index 000000000000..c35914c6c4d1 --- /dev/null +++ b/json-path/src/main/resources/intro_user.json @@ -0,0 +1,46 @@ +[ + { + "username": "oracle", + "password": + { + "current": + { + "value": "Java_SE_8", + "created": 1397754000000 + }, + + "old": + [ + { + "value": "Java_SE_7", + "created": 1312650000000 + } + ] + } + }, + + { + "username": "sun", + "password": + { + "current": + { + "value": "Java_SE_6", + "created": 1168448400000 + }, + + "old": + [ + { + "value": "J2SE_5.0", + "created": 1099069200000 + }, + + { + "value": "J2SE_1.4", + "created": 1025542800000 + } + ] + } + } +] \ No newline at end of file diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java b/json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java new file mode 100644 index 000000000000..24f8500d3dea --- /dev/null +++ b/json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java @@ -0,0 +1,85 @@ +package org.baeldung.jsonpath.introduction; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; + +import org.joda.time.DateTime; +import org.joda.time.Years; + +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Option; + +public class ChangingPasswordTest { + + enum Result { + SUCCESS, FAILURE + } + + InputStream jsonValueInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_user.json"); + String jsonDataSourceString = new Scanner(jsonValueInputStream, "UTF-8").useDelimiter("\\Z").next(); + + @Test + public void givenUseCase_whenChangingPasswordOfNonExistentUser_thenFail() { + String failedRequestBody = "{\"username\":\"jayway\", \"new_password\":\"JsonPath\"}"; + Result result = changingPasswordHelper(failedRequestBody); + + assertEquals(Result.FAILURE, result); + } + + @Test + public void givenUseCase_whenChangingToUnusedPassword_thenSucceed() { + String successfulRequestBody = "{\"username\":\"oracle\", \"new_password\":\"Java_SE_9\"}"; + Result result = changingPasswordHelper(successfulRequestBody); + + assertEquals(Result.SUCCESS, result); + } + + @Test + public void givenUseCase_whenChangingToRecentlyUsedPassword_thenFail() { + String failedRequestBody = "{\"username\":\"oracle\", \"new_password\":\"Java_SE_7\"}"; + Result result = changingPasswordHelper(failedRequestBody); + + assertEquals(Result.FAILURE, result); + } + + @Test + public void givenUseCase_whenChangingToLongTimeAgoPassword_thenSucceed() { + String successfulRequestBody = "{\"username\":\"sun\", \"new_password\":\"J2SE_5.0\"}"; + Result result = changingPasswordHelper(successfulRequestBody); + + assertEquals(Result.SUCCESS, result); + } + + private Result changingPasswordHelper(String requestBody) { + DocumentContext requestContext = JsonPath.parse(requestBody); + String extractedUsername = requestContext.read("$['username']"); + String extractedPassword = requestContext.read("$['new_password']"); + + DocumentContext jsonContext = JsonPath.parse(jsonDataSourceString); + List dataSourceUsername = jsonContext.read("$[?(@.username == '" + extractedUsername + "')]"); + if (dataSourceUsername.size() == 0) + return Result.FAILURE; + + Configuration pathConfiguration = Configuration.builder().options(Option.AS_PATH_LIST).build(); + List pathToCurrentUser = JsonPath.using(pathConfiguration).parse(jsonDataSourceString).read("$[?(@.username == '" + extractedUsername + "')]"); + List passwordCreatedTimeList = jsonContext.read(pathToCurrentUser.get(0) + "['password']['old'][?(@.value == '" + extractedPassword + "')]['created']"); + if (passwordCreatedTimeList.size() == 0) + return Result.SUCCESS; + + Long[] passwordCreatedTimeArray = (passwordCreatedTimeList.toArray(new Long[passwordCreatedTimeList.size()])); + Arrays.sort(passwordCreatedTimeArray); + DateTime oldDate = new DateTime(passwordCreatedTimeArray[passwordCreatedTimeArray.length - 1]); + if (Years.yearsBetween(oldDate, new DateTime()).getYears() <= 10) + return Result.FAILURE; + + return Result.SUCCESS; + } +} diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java b/json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java new file mode 100644 index 000000000000..1ab7dad88ec8 --- /dev/null +++ b/json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java @@ -0,0 +1,50 @@ +package org.baeldung.jsonpath.introduction; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import java.io.InputStream; +import java.util.List; +import java.util.Scanner; + +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; + +public class LoggingInTest { + + enum Result { + SUCCESS, FAILURE + } + + InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_user.json"); + String jsonDataSourceString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); + + @Test + public void givenUseCase_whenLoggingInWithCorrectUserData_thenSucceed() { + String correctRequestBody = "{\"username\":\"sun\", \"password\":\"Java_SE_6\"}"; + Result result = loggingInHelper(correctRequestBody); + + assertEquals(Result.SUCCESS, result); + } + + @Test + public void givenUseCase_whenLoggingInWithIncorrectUserData_thenFail() { + String incorrectRequestBody = "{\"username\":\"oracle\", \"password\":\"Java_SE_9\"}"; + Result result = loggingInHelper(incorrectRequestBody); + + assertEquals(Result.FAILURE, result); + } + + private Result loggingInHelper(String requestBody) { + DocumentContext requestContext = JsonPath.parse(requestBody); + String extractedUsername = requestContext.read("$['username']"); + String extractedPassword = requestContext.read("$['password']"); + List list = JsonPath.parse(jsonDataSourceString).read("$[?(@.username == '" + extractedUsername + "' && @.password.current.value == '" + extractedPassword + "')]"); + + if (list.size() == 0) + return Result.FAILURE; + return Result.SUCCESS; + } + +} diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java b/json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java new file mode 100644 index 000000000000..9347a7f75499 --- /dev/null +++ b/json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java @@ -0,0 +1,71 @@ +package org.baeldung.jsonpath.introduction; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; + +import org.junit.Test; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import java.util.Scanner; + +import com.jayway.jsonpath.Criteria; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.Filter; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Predicate; + +public class OperationTest { + InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_api.json"); + String jsonDataSourceString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); + + @Test + public void givenJsonPathWithoutPredicates_whenReading_thenCorrect() { + String jsonpathCreatorNamePath = "$['tool']['jsonpath']['creator']['name']"; + String jsonpathCreatorLocationPath = "$['tool']['jsonpath']['creator']['location'][*]"; + + DocumentContext jsonContext = JsonPath.parse(jsonDataSourceString); + String jsonpathCreatorName = jsonContext.read(jsonpathCreatorNamePath); + List jsonpathCreatorLocation = jsonContext.read(jsonpathCreatorLocationPath); + + assertEquals("Jayway Inc.", jsonpathCreatorName); + assertThat(jsonpathCreatorLocation.toString(), containsString("Malmo")); + assertThat(jsonpathCreatorLocation.toString(), containsString("San Francisco")); + assertThat(jsonpathCreatorLocation.toString(), containsString("Helsingborg")); + } + + @Test + public void givenJsonPathWithFilterPredicate_whenReading_thenCorrect() { + Filter expensiveFilter = Filter.filter(Criteria.where("price").gt(20.00)); + List> expensive = JsonPath.parse(jsonDataSourceString).read("$['book'][?]", expensiveFilter); + predicateUsageAssertionHelper(expensive); + } + + @Test + public void givenJsonPathWithCustomizedPredicate_whenReading_thenCorrect() { + Predicate expensivePredicate = new Predicate() { + public boolean apply(PredicateContext context) { + String value = context.item(Map.class).get("price").toString(); + return Float.valueOf(value) > 20.00; + } + }; + List> expensive = JsonPath.parse(jsonDataSourceString).read("$['book'][?]", expensivePredicate); + predicateUsageAssertionHelper(expensive); + } + + @Test + public void givenJsonPathWithInlinePredicate_whenReading_thenCorrect() { + List> expensive = JsonPath.parse(jsonDataSourceString).read("$['book'][?(@['price'] > $['price range']['medium'])]"); + predicateUsageAssertionHelper(expensive); + } + + private void predicateUsageAssertionHelper(List predicate) { + assertThat(predicate.toString(), containsString("Beginning JSON")); + assertThat(predicate.toString(), containsString("JSON at Work")); + assertThat(predicate.toString(), not(containsString("Learn JSON in a DAY"))); + assertThat(predicate.toString(), not(containsString("JSON: Questions and Answers"))); + } +} diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java b/json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java new file mode 100644 index 000000000000..6e5cba63b0d3 --- /dev/null +++ b/json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java @@ -0,0 +1,46 @@ +package org.baeldung.jsonpath.introduction; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import java.io.InputStream; +import java.util.List; +import java.util.Scanner; + +import com.jayway.jsonpath.JsonPath; + +public class RegisteringAccountTest { + + enum Result { + SUCCESS, FAILURE + } + + InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_user.json"); + String jsonDataSourceString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); + + @Test + public void givenUseCase_whenRegisteringUnusedAccount_thenSucceed() { + String unusedRequestBody = "{\"username\":\"jayway\", \"password\":\"JsonPath\"}"; + Result result = registeringNewAccountHelper(unusedRequestBody); + + assertEquals(Result.SUCCESS, result); + } + + @Test + public void givenUseCase_whenRegisteringUsedAccount_thenFail() { + String usedRequestBody = "{\"username\":\"oracle\", \"password\":\"Java_SE_9\"}"; + Result result = registeringNewAccountHelper(usedRequestBody); + + assertEquals(Result.FAILURE, result); + } + + private Result registeringNewAccountHelper(String requestBody) { + List userDataSource = JsonPath.parse(jsonDataSourceString).read("$[*]['username']"); + String extractedUsername = JsonPath.parse(requestBody).read("$['username']"); + + if (userDataSource.toString().contains(extractedUsername)) + return Result.FAILURE; + return Result.SUCCESS; + } +} From 65635956703a6473aef19009070118e536c71076 Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 5 Feb 2016 10:25:17 +0200 Subject: [PATCH 173/626] Create README.md --- spring-batch/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 spring-batch/README.md diff --git a/spring-batch/README.md b/spring-batch/README.md new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/spring-batch/README.md @@ -0,0 +1 @@ + From 6ab868cef39ac442eba1421b38826aaf9f4b541e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 6 Feb 2016 12:50:32 +0200 Subject: [PATCH 174/626] cleanup work --- ...pse.wst.jsdt.core.javascriptValidator.launch | 7 +++++++ spring-security-login-and-registration/.project | 17 ++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 spring-security-login-and-registration/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch diff --git a/spring-security-login-and-registration/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/spring-security-login-and-registration/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch new file mode 100644 index 000000000000..627021fb9640 --- /dev/null +++ b/spring-security-login-and-registration/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spring-security-login-and-registration/.project b/spring-security-login-and-registration/.project index 2c3e86ed0694..4a27f224a450 100644 --- a/spring-security-login-and-registration/.project +++ b/spring-security-login-and-registration/.project @@ -6,8 +6,13 @@ - org.eclipse.wst.jsdt.core.javascriptValidator + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch + @@ -25,16 +30,6 @@ - - org.jboss.tools.jst.web.kb.kbbuilder - - - - - org.hibernate.eclipse.console.hibernateBuilder - - - org.eclipse.wst.validation.validationbuilder From 0d45b71098d3dc53b0abe2ae9af500fc1a58c410 Mon Sep 17 00:00:00 2001 From: Kevin Gilmore Date: Sat, 6 Feb 2016 11:32:12 -0600 Subject: [PATCH 175/626] API for RAML modularization article --- .../api-before-modularization.raml | 119 ++++++++++++++++++ raml/modularization/api-with-libraries.raml | 50 ++++++++ .../api-with-typed-fragments.raml | 74 +++++++++++ raml/modularization/api.raml | 47 +++++++ raml/modularization/examples/Bar.json | 6 + raml/modularization/examples/Bars.json | 19 +++ raml/modularization/examples/Error.json | 4 + raml/modularization/examples/Foo.json | 4 + raml/modularization/examples/Foos.json | 16 +++ .../extensions/en_US/additionalResources.raml | 16 +++ raml/modularization/libraries/dataTypes.raml | 19 +++ .../libraries/resourceTypes.raml | 32 +++++ .../libraries/securitySchemes.raml | 20 +++ raml/modularization/libraries/traits.raml | 33 +++++ .../overlays/es_ES/additionalResources.raml | 13 ++ .../overlays/es_ES/documentationItems.raml | 23 ++++ .../resourceTypes/collection.raml | 12 ++ raml/modularization/resourceTypes/item.raml | 14 +++ raml/modularization/traits/hasNotFound.raml | 8 ++ .../modularization/traits/hasRequestItem.raml | 5 + .../traits/hasResponseCollection.raml | 8 ++ .../traits/hasResponseItem.raml | 8 ++ raml/modularization/types/Bar.raml | 7 ++ raml/modularization/types/Error.raml | 5 + raml/modularization/types/Foo.raml | 6 + 25 files changed, 568 insertions(+) create mode 100644 raml/modularization/api-before-modularization.raml create mode 100644 raml/modularization/api-with-libraries.raml create mode 100644 raml/modularization/api-with-typed-fragments.raml create mode 100644 raml/modularization/api.raml create mode 100644 raml/modularization/examples/Bar.json create mode 100644 raml/modularization/examples/Bars.json create mode 100644 raml/modularization/examples/Error.json create mode 100644 raml/modularization/examples/Foo.json create mode 100644 raml/modularization/examples/Foos.json create mode 100644 raml/modularization/extensions/en_US/additionalResources.raml create mode 100644 raml/modularization/libraries/dataTypes.raml create mode 100644 raml/modularization/libraries/resourceTypes.raml create mode 100644 raml/modularization/libraries/securitySchemes.raml create mode 100644 raml/modularization/libraries/traits.raml create mode 100644 raml/modularization/overlays/es_ES/additionalResources.raml create mode 100644 raml/modularization/overlays/es_ES/documentationItems.raml create mode 100644 raml/modularization/resourceTypes/collection.raml create mode 100644 raml/modularization/resourceTypes/item.raml create mode 100644 raml/modularization/traits/hasNotFound.raml create mode 100644 raml/modularization/traits/hasRequestItem.raml create mode 100644 raml/modularization/traits/hasResponseCollection.raml create mode 100644 raml/modularization/traits/hasResponseItem.raml create mode 100644 raml/modularization/types/Bar.raml create mode 100644 raml/modularization/types/Error.raml create mode 100644 raml/modularization/types/Foo.raml diff --git a/raml/modularization/api-before-modularization.raml b/raml/modularization/api-before-modularization.raml new file mode 100644 index 000000000000..b580c3398325 --- /dev/null +++ b/raml/modularization/api-before-modularization.raml @@ -0,0 +1,119 @@ +#%RAML 1.0 +title: API for REST Services used in the RAML tutorials on Baeldung.com +documentation: + - title: Overview + - content: | + This document defines the interface for the REST services + used in the popular RAML Tutorial series at Baeldung.com. + - title: Disclaimer: + - content: | + All names used in this definition are purely fictional. + Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental. + - title: Copyright + - content: Copyright 2016 by Baeldung.com. All rights reserved. +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: basicAuth +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: | + Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to + access the content provided by the requested URL. +types: + Foo: !include types/Foo.raml + Bar: !include types/Bar.raml + Error: !include types/Error.raml +resourceTypes: + - collection: + usage: Use this resourceType to represent a collection of items + description: A collection of <> + get: + description: | + Get all <>, + optionally filtered + is: [ hasResponseCollection ] + post: + description: | + Create a new <> + is: [ hasRequestItem ] + - item: + usage: Use this resourceType to represent any single item + description: A single <> + get: + description: Get a <> by <> + is: [ hasResponseItem, hasNotFound ] + put: + description: Update a <> by <> + is: [ hasRequestItem, hasResponseItem, hasNotFound ] + delete: + description: Delete a <> by <> + is: [ hasNotFound ] + responses: + 204: +traits: + - hasRequestItem: + body: + application/json: + type: <> + - hasResponseItem: + responses: + 200: + body: + application/json: + type: <> + example: !include examples/<>.json + - hasResponseCollection: + responses: + 200: + body: + application/json: + type: <>[] + example: !include examples/<>.json + - hasNotFound: + responses: + 404: + body: + application/json: + type: Error + example: !include examples/Error.json +/foos: + type: collection + typeName: Foo + get: + queryParameters: + name?: string + ownerName?: string + /{fooId}: + type: item + typeName: Foo + /name/{name}: + get: + description: List all foos with a certain name + typeName: Foo + is: [ hasResponseCollection ] +/bars: + type: collection + typeName: Bar + /{barId}: + type: item + typeName: Bar + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + typeName: Bar + is: [ hasResponseCollection ] \ No newline at end of file diff --git a/raml/modularization/api-with-libraries.raml b/raml/modularization/api-with-libraries.raml new file mode 100644 index 000000000000..b3081e843a87 --- /dev/null +++ b/raml/modularization/api-with-libraries.raml @@ -0,0 +1,50 @@ +#%RAML 1.0 +title: API for REST Services used in the RAML tutorials on Baeldung.com +documentation: + - title: Overview + - content: | + This document defines the interface for the REST services + used in the popular RAML Tutorial series at Baeldung.com. + - title: Disclaimer: + - content: | + All names used in this definition are purely fictional. + Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental. + - title: Copyright + - content: Copyright 2016 by Baeldung.com. All rights reserved. +uses: + mySecuritySchemes: !include libraries/security.raml + myDataTypes: !include libraries/dataTypes.raml + myResourceTypes: !include libraries/resourceTypes.raml + myTraits: !include libraries/traits.raml +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: [ mySecuritySchemes.basicAuth ] +/foos: + type: myResourceTypes.collection + typeName: myDataTypes.Foo + get: + queryParameters: + name?: string + ownerName?: string + /{fooId}: + type: myResourceTypes.item + typeName: myDataTypes.Foo + /name/{name}: + get: + description: List all foos with a certain name + typeName: myDataTypes.Foo + is: [ myTraits.hasResponseCollection ] +/bars: + type: myResourceTypes.collection + typeName: myDataTypes.Bar + /{barId}: + type: myResourceTypes.item + typeName: myDataTypes.Bar + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + type: myResourceTypes.item + typeName: myDataTypes.Bar + is: [ myTraits.hasResponseCollection ] \ No newline at end of file diff --git a/raml/modularization/api-with-typed-fragments.raml b/raml/modularization/api-with-typed-fragments.raml new file mode 100644 index 000000000000..2bb4e317c1f1 --- /dev/null +++ b/raml/modularization/api-with-typed-fragments.raml @@ -0,0 +1,74 @@ +#%RAML 1.0 +title: API for REST Services used in the RAML tutorials on Baeldung.com +documentation: + - title: Overview + - content: | + This document defines the interface for the REST services + used in the popular RAML Tutorial series at Baeldung.com. + - title: Disclaimer: + - content: | + All names used in this definition are purely fictional. + Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental. + - title: Copyright + - content: Copyright 2016 by Baeldung.com. All rights reserved. +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: [ basicAuth ] +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: | + Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to + access the content provided by the requested URL. +types: + Foo: !include types/Foo.raml + Bar: !include types/Bar.raml + Error: !include types/Error.raml +resourceTypes: + - collection: !include resourceTypes/collection.raml + - item: !include resourceTypes/item.raml +traits: + - hasRequestItem: !include traits/hasRequestItem.raml + - hasResponseItem: !include traits/hasResponseItem.raml + - hasResponseCollection: !include traits/hasResponseCollection.raml + - hasNotFound: !include traits/hasNotFound.raml +/foos: + type: collection + typeName: Foo + get: + queryParameters: + name?: string + ownerName?: string + /{fooId}: + type: item + typeName: Foo + /name/{name}: + get: + description: List all foos with a certain name + typeName: Foo + is: [ hasResponseCollection ] +/bars: + type: collection + typeName: Bar + /{barId}: + type: item + typeName: Bar + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + typeName: Bar + is: [ hasResponseCollection ] \ No newline at end of file diff --git a/raml/modularization/api.raml b/raml/modularization/api.raml new file mode 100644 index 000000000000..184027cd2658 --- /dev/null +++ b/raml/modularization/api.raml @@ -0,0 +1,47 @@ +#%RAML 1.0 +title: Baeldung Foo REST Services API +uses: + security: !include libraries/security.raml +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: [ security.basicAuth ] +types: + Foo: !include types/Foo.raml + Bar: !include types/Bar.raml + Error: !include types/Error.raml +resourceTypes: + - collection: !include resourceTypes/collection.raml + - item: !include resourceTypes/item.raml +traits: + - hasRequestItem: !include traits/hasRequestItem.raml + - hasResponseItem: !include traits/hasResponseItem.raml + - hasResponseCollection: !include traits/hasResponseCollection.raml + - hasNotFound: !include traits/hasNotFound.raml +/foos: + type: collection + typeName: Foo + get: + queryParameters: + name?: string + ownerName?: string + /{fooId}: + type: item + typeName: Foo + /name/{name}: + get: + description: List all foos with a certain name + typeName: Foo + is: [ hasResponseCollection ] +/bars: + type: collection + typeName: Bar + /{barId}: + type: item + typeName: Bar + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + typeName: Bar + is: [ hasResponseCollection ] \ No newline at end of file diff --git a/raml/modularization/examples/Bar.json b/raml/modularization/examples/Bar.json new file mode 100644 index 000000000000..0ee1b34edbfe --- /dev/null +++ b/raml/modularization/examples/Bar.json @@ -0,0 +1,6 @@ +{ + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 +} \ No newline at end of file diff --git a/raml/modularization/examples/Bars.json b/raml/modularization/examples/Bars.json new file mode 100644 index 000000000000..89ea87543244 --- /dev/null +++ b/raml/modularization/examples/Bars.json @@ -0,0 +1,19 @@ +[ + { + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 + }, + { + "id" : 2, + "name" : "Second Bar", + "city" : "Dallas", + "fooId" : 1 + }, + { + "id" : 3, + "name" : "Third Bar", + "fooId" : 2 + } +] \ No newline at end of file diff --git a/raml/modularization/examples/Error.json b/raml/modularization/examples/Error.json new file mode 100644 index 000000000000..dca56da7c2b7 --- /dev/null +++ b/raml/modularization/examples/Error.json @@ -0,0 +1,4 @@ +{ + "message" : "Not found", + "code" : 1001 +} \ No newline at end of file diff --git a/raml/modularization/examples/Foo.json b/raml/modularization/examples/Foo.json new file mode 100644 index 000000000000..1b1b8c891e05 --- /dev/null +++ b/raml/modularization/examples/Foo.json @@ -0,0 +1,4 @@ +{ + "id" : 1, + "name" : "First Foo" +} \ No newline at end of file diff --git a/raml/modularization/examples/Foos.json b/raml/modularization/examples/Foos.json new file mode 100644 index 000000000000..74f64689f016 --- /dev/null +++ b/raml/modularization/examples/Foos.json @@ -0,0 +1,16 @@ +[ + { + "id" : 1, + "name" : "First Foo", + "ownerName" : "Jack Robinson" + }, + { + "id" : 2, + "name" : "Second Foo" + }, + { + "id" : 3, + "name" : "Third Foo", + "ownerName" : "Chuck Norris" + } +] \ No newline at end of file diff --git a/raml/modularization/extensions/en_US/additionalResources.raml b/raml/modularization/extensions/en_US/additionalResources.raml new file mode 100644 index 000000000000..20c6851f230d --- /dev/null +++ b/raml/modularization/extensions/en_US/additionalResources.raml @@ -0,0 +1,16 @@ +#%RAML 1.0 Extension +# File located at: +# /extensions/en_US/additionalResources.raml +masterRef: /api.raml +usage: This extension defines additional resources for version 2 of the API. +version: v2 +/foos: + /bar/{barId}: + get: + description: | + Get the foo that is related to the bar having barId = {barId} + typeName: Foo + queryParameters: + barId?: integer + typeName: Foo + is: [ hasResponseItem ] diff --git a/raml/modularization/libraries/dataTypes.raml b/raml/modularization/libraries/dataTypes.raml new file mode 100644 index 000000000000..8a240e62dccb --- /dev/null +++ b/raml/modularization/libraries/dataTypes.raml @@ -0,0 +1,19 @@ +#%RAML 1.0 Library +# This is the file /libraries/dataTypes.raml +usage: This library defines the data types for the API +types: + Foo: + properties: + id: integer + name: string + ownerName?: string + Bar: + properties: + id: integer + name: string + city?: string + fooId: integer + Error: + properties: + code: integer + message: string diff --git a/raml/modularization/libraries/resourceTypes.raml b/raml/modularization/libraries/resourceTypes.raml new file mode 100644 index 000000000000..681ff710d6a4 --- /dev/null +++ b/raml/modularization/libraries/resourceTypes.raml @@ -0,0 +1,32 @@ +#%RAML 1.0 Library +# This is the file /libraries/resourceTypes.raml +usage: This library defines the resource types for the API +uses: + myTraits: !include traits.raml +resourceTypes: + collection: + usage: Use this resourceType to represent a collection of items + description: A collection of <> + get: + description: | + Get all <>, + optionally filtered + is: [ myTraits.hasResponseCollection ] + post: + description: | + Create a new <> + is: [ myTraits.hasRequestItem ] + item: + usage: Use this resourceType to represent any single item + description: A single <> + get: + description: Get a <> by <> + is: [ myTraits.hasResponseItem, myTraits.hasNotFound ] + put: + description: Update a <> by <> + is: [ myTraits.hasRequestItem, myTraits.hasResponseItem, myTraits.hasNotFound ] + delete: + description: Delete a <> by <> + is: [ myTraits.hasNotFound ] + responses: + 204: diff --git a/raml/modularization/libraries/securitySchemes.raml b/raml/modularization/libraries/securitySchemes.raml new file mode 100644 index 000000000000..621c6ac97512 --- /dev/null +++ b/raml/modularization/libraries/securitySchemes.raml @@ -0,0 +1,20 @@ +#%RAML 1.0 Library +# This is the file /libraries/securitySchemes.raml +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: | + Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to + access the content provided by the requested URL. diff --git a/raml/modularization/libraries/traits.raml b/raml/modularization/libraries/traits.raml new file mode 100644 index 000000000000..c101d94c02d5 --- /dev/null +++ b/raml/modularization/libraries/traits.raml @@ -0,0 +1,33 @@ +#%RAML 1.0 Library +# This is the file /libraries/traits.raml +usage: This library defines some basic traits +traits: + hasRequestItem: + usage: Use this trait for resources whose request body is a single item + body: + application/json: + type: <> + hasResponseItem: + usage: Use this trait for resources whose response body is a single item + responses: + 200: + body: + application/json: + type: <> + example: !include /examples/<>.json + hasResponseCollection: + usage: Use this trait for resources whose response body is a collection of items + responses: + 200: + body: + application/json: + type: <>[] + example: !include /examples/<>.json + hasNotFound: + usage: Use this trait for resources that could respond with a 404 status + responses: + 404: + body: + application/json: + type: Error + example: !include /examples/Error.json diff --git a/raml/modularization/overlays/es_ES/additionalResources.raml b/raml/modularization/overlays/es_ES/additionalResources.raml new file mode 100644 index 000000000000..e8748fd72607 --- /dev/null +++ b/raml/modularization/overlays/es_ES/additionalResources.raml @@ -0,0 +1,13 @@ +#%RAML 1.0 Overlay +# Archivo situado en: +# /overlays/es_ES/additionalResources.raml +masterRef: /api.raml +usage: | + Se trata de un español demasiado que describe los recursos adicionales + para la versión 2 del API. +version: v2 +/foos: + /bar/{barId}: + get: + description: | + Obtener el foo que se relaciona con el bar tomando barId = {barId} diff --git a/raml/modularization/overlays/es_ES/documentationItems.raml b/raml/modularization/overlays/es_ES/documentationItems.raml new file mode 100644 index 000000000000..dc6ca3eaef9b --- /dev/null +++ b/raml/modularization/overlays/es_ES/documentationItems.raml @@ -0,0 +1,23 @@ +#%RAML 1.0 Overlay +# File located at (archivo situado en): +# /overlays/es_ES/documentationItems.raml +masterRef: /api.raml +usage: | + To provide user documentation and other descriptive text in Spanish + (Para proporcionar la documentación del usuario y otro texto descriptivo en español) +title: API para servicios REST utilizados en los tutoriales RAML en Baeldung.com +documentation: + - title: Descripción general + - content: | + Este documento define la interfaz para los servicios REST + utilizados en la popular serie de RAML Tutorial en Baeldung.com + - title: Renuncia + - content: | + Todos los nombres usados ​​en esta definición son pura ficción. + Cualquier similitud entre los nombres utilizados en este tutorial + y los de las personas reales, ya sea vivo o muerto, + no son más que coincidenta. + + - title: Derechos de autor + - content: | + Derechos de autor 2016 por Baeldung.com. Todos los derechos reservados. diff --git a/raml/modularization/resourceTypes/collection.raml b/raml/modularization/resourceTypes/collection.raml new file mode 100644 index 000000000000..0cab417f146c --- /dev/null +++ b/raml/modularization/resourceTypes/collection.raml @@ -0,0 +1,12 @@ +#%RAML 1.0 ResourceType +usage: Use this resourceType to represent a collection of items +description: A collection of <> +get: + description: | + Get all <>, + optionally filtered + is: [ hasResponseCollection ] +post: + description: | + Create a new <> + is: [ hasRequestItem ] diff --git a/raml/modularization/resourceTypes/item.raml b/raml/modularization/resourceTypes/item.raml new file mode 100644 index 000000000000..59f057ca985d --- /dev/null +++ b/raml/modularization/resourceTypes/item.raml @@ -0,0 +1,14 @@ +#%RAML 1.0 ResourceType +usage: Use this resourceType to represent any single item +description: A single <> +get: + description: Get a <> by <> + is: [ hasResponseItem, hasNotFound ] +put: + description: Update a <> by <> + is: [ hasRequestItem, hasResponseItem, hasNotFound ] +delete: + description: Delete a <> by <> + is: [ hasNotFound ] + responses: + 204: diff --git a/raml/modularization/traits/hasNotFound.raml b/raml/modularization/traits/hasNotFound.raml new file mode 100644 index 000000000000..8d2d940c0389 --- /dev/null +++ b/raml/modularization/traits/hasNotFound.raml @@ -0,0 +1,8 @@ +#%RAML 1.0 Trait +usage: Use this trait for resources that could respond with a 404 status +responses: + 404: + body: + application/json: + type: Error + example: !include /examples/Error.json diff --git a/raml/modularization/traits/hasRequestItem.raml b/raml/modularization/traits/hasRequestItem.raml new file mode 100644 index 000000000000..06281781c0e5 --- /dev/null +++ b/raml/modularization/traits/hasRequestItem.raml @@ -0,0 +1,5 @@ +#%RAML 1.0 Trait +usage: Use this trait for resources whose request body is a single item +body: + application/json: + type: <> diff --git a/raml/modularization/traits/hasResponseCollection.raml b/raml/modularization/traits/hasResponseCollection.raml new file mode 100644 index 000000000000..47dc1c2d5f3e --- /dev/null +++ b/raml/modularization/traits/hasResponseCollection.raml @@ -0,0 +1,8 @@ +#%RAML 1.0 Trait +usage: Use this trait for resources whose response body is a collection of items +responses: + 200: + body: + application/json: + type: <>[] + example: !include /examples/<>.json diff --git a/raml/modularization/traits/hasResponseItem.raml b/raml/modularization/traits/hasResponseItem.raml new file mode 100644 index 000000000000..94d3ba075691 --- /dev/null +++ b/raml/modularization/traits/hasResponseItem.raml @@ -0,0 +1,8 @@ +#%RAML 1.0 Trait +usage: Use this trait for resources whose response body is a single item +responses: + 200: + body: + application/json: + type: <> + example: !include /examples/<>.json diff --git a/raml/modularization/types/Bar.raml b/raml/modularization/types/Bar.raml new file mode 100644 index 000000000000..92255a75fe44 --- /dev/null +++ b/raml/modularization/types/Bar.raml @@ -0,0 +1,7 @@ +#%RAML 1.0 DataType + +properties: + id: integer + name: string + city?: string + fooId: integer diff --git a/raml/modularization/types/Error.raml b/raml/modularization/types/Error.raml new file mode 100644 index 000000000000..8d54b5f181df --- /dev/null +++ b/raml/modularization/types/Error.raml @@ -0,0 +1,5 @@ +#%RAML 1.0 DataType + + properties: + code: integer + message: string diff --git a/raml/modularization/types/Foo.raml b/raml/modularization/types/Foo.raml new file mode 100644 index 000000000000..1702865e050d --- /dev/null +++ b/raml/modularization/types/Foo.raml @@ -0,0 +1,6 @@ +#%RAML 1.0 DataType + +properties: + id: integer + name: string + ownerName?: string From 8506171908e954c3453a3050fce22963d09e127a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 6 Feb 2016 21:09:04 +0200 Subject: [PATCH 176/626] removing unused file --- .../src/main/resources/webSecurityConfig.xml | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 spring-jpa/src/main/resources/webSecurityConfig.xml diff --git a/spring-jpa/src/main/resources/webSecurityConfig.xml b/spring-jpa/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index 88af78dabc9c..000000000000 --- a/spring-jpa/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 2be93cd3216df16ced5143fb69e3056e628b80e0 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 6 Feb 2016 21:25:59 +0200 Subject: [PATCH 177/626] minimal cleanup in Eclipse --- .../org.hibernate.eclipse.console.hibernateBuilder.launch | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 spring-security-rest-full/.externalToolBuilders/org.hibernate.eclipse.console.hibernateBuilder.launch diff --git a/spring-security-rest-full/.externalToolBuilders/org.hibernate.eclipse.console.hibernateBuilder.launch b/spring-security-rest-full/.externalToolBuilders/org.hibernate.eclipse.console.hibernateBuilder.launch deleted file mode 100644 index 9bc0284d26ba..000000000000 --- a/spring-security-rest-full/.externalToolBuilders/org.hibernate.eclipse.console.hibernateBuilder.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - From 8b7e761c00f4a1db8710e8f38a4fdf061fa489bb Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Sat, 6 Feb 2016 23:48:50 +0200 Subject: [PATCH 178/626] Update README.md --- spring-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index 11df42ac5205..387e3c00eb6a 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -7,3 +7,4 @@ - [Spring 3 and JPA with Hibernate](http://www.baeldung.com/2011/12/13/the-persistence-layer-with-spring-3-1-and-jpa/) - [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) - [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa) +- [JPA Pagination](http://www.baeldung.com/jpa-pagination) From f09bce94f9e670e48ad8b00030bb967ea2e5326b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Sat, 6 Feb 2016 23:51:06 +0200 Subject: [PATCH 179/626] Update README.md --- spring-hibernate4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index 0d1ac1600ef8..96f8074165c6 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -5,6 +5,7 @@ ### Relevant Articles: - [Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring) - [The DAO with Spring 3 and Hibernate](http://www.baeldung.com/2011/12/02/the-persistence-layer-with-spring-3-1-and-hibernate/) +- [Hibernate Pagination](http://www.baeldung.com/hibernate-pagination) ### Quick Start From ab4b2d8a1a51f0c24e455f17f671c503fd4c1928 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Sat, 6 Feb 2016 23:52:34 +0200 Subject: [PATCH 180/626] Update README.md --- spring-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index 387e3c00eb6a..da55ca7b7549 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -8,3 +8,4 @@ - [Transactions with Spring 3 and JPA](http://www.baeldung.com/2011/12/26/transaction-configuration-with-jpa-and-spring-3-1/) - [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa) - [JPA Pagination](http://www.baeldung.com/jpa-pagination) +- [Sorting with JPA](http://www.baeldung.com/jpa-sort) From 1ba1bf2bc5056effb8d718f41885ff30075fd4e0 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 7 Feb 2016 12:49:30 +0200 Subject: [PATCH 181/626] jackson skip conditionally --- .../jackson/dynamicIgnore/Address.java | 41 +++++++ .../jackson/dynamicIgnore/Hidable.java | 9 ++ .../dynamicIgnore/HidableSerializer.java | 29 +++++ .../jackson/dynamicIgnore/Person.java | 41 +++++++ .../test/JacksonDynamicIgnoreTest.java | 100 ++++++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Address.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Hidable.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/HidableSerializer.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Person.java create mode 100644 jackson/src/test/java/org/baeldung/jackson/test/JacksonDynamicIgnoreTest.java diff --git a/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Address.java b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Address.java new file mode 100644 index 000000000000..41ea8e7be376 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Address.java @@ -0,0 +1,41 @@ +package org.baeldung.jackson.dynamicIgnore; + + +public class Address implements Hidable { + private String city; + private String country; + private boolean hidden; + + public Address(final String city, final String country, final boolean hidden) { + super(); + this.city = city; + this.country = country; + this.hidden = hidden; + } + + public String getCity() { + return city; + } + + public void setCity(final String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(final String country) { + this.country = country; + } + + @Override + public boolean isHidden() { + return hidden; + } + + public void setHidden(final boolean hidden) { + this.hidden = hidden; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Hidable.java b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Hidable.java new file mode 100644 index 000000000000..9eaa0c96191f --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Hidable.java @@ -0,0 +1,9 @@ +package org.baeldung.jackson.dynamicIgnore; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + + +@JsonIgnoreProperties("hidden") +public interface Hidable { + boolean isHidden(); +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/HidableSerializer.java b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/HidableSerializer.java new file mode 100644 index 000000000000..35bd8fd7f6a9 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/HidableSerializer.java @@ -0,0 +1,29 @@ +package org.baeldung.jackson.dynamicIgnore; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class HidableSerializer extends JsonSerializer { + + private JsonSerializer defaultSerializer; + + public HidableSerializer(final JsonSerializer serializer) { + defaultSerializer = serializer; + } + + @Override + public void serialize(final Hidable value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + if (value.isHidden()) + return; + defaultSerializer.serialize(value, jgen, provider); + } + + @Override + public boolean isEmpty(final SerializerProvider provider, final Hidable value) { + return (value == null || value.isHidden()); + } +} diff --git a/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Person.java b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Person.java new file mode 100644 index 000000000000..5fe294a5e1a9 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/dynamicIgnore/Person.java @@ -0,0 +1,41 @@ +package org.baeldung.jackson.dynamicIgnore; + + +public class Person implements Hidable { + private String name; + private Address address; + private boolean hidden; + + public Person(final String name, final Address address, final boolean hidden) { + super(); + this.name = name; + this.address = address; + this.hidden = hidden; + } + + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public Address getAddress() { + return address; + } + + public void setAddress(final Address address) { + this.address = address; + } + @Override + public boolean isHidden() { + return hidden; + } + + public void setHidden(final boolean hidden) { + this.hidden = hidden; + } + +} diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonDynamicIgnoreTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDynamicIgnoreTest.java new file mode 100644 index 000000000000..d98f948deca5 --- /dev/null +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonDynamicIgnoreTest.java @@ -0,0 +1,100 @@ +package org.baeldung.jackson.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; + +import org.baeldung.jackson.dynamicIgnore.Address; +import org.baeldung.jackson.dynamicIgnore.Hidable; +import org.baeldung.jackson.dynamicIgnore.HidableSerializer; +import org.baeldung.jackson.dynamicIgnore.Person; +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.BeanDescription; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; + +public class JacksonDynamicIgnoreTest { + + private ObjectMapper mapper = new ObjectMapper(); + + @Before + public void setUp() { + mapper.setSerializationInclusion(Include.NON_EMPTY); + mapper.registerModule(new SimpleModule() { + @Override + public void setupModule(final SetupContext context) { + super.setupModule(context); + context.addBeanSerializerModifier(new BeanSerializerModifier() { + @Override + public JsonSerializer modifySerializer(final SerializationConfig config, final BeanDescription beanDesc, final JsonSerializer serializer) { + if (Hidable.class.isAssignableFrom(beanDesc.getBeanClass())) { + return new HidableSerializer((JsonSerializer) serializer); + } + return serializer; + } + }); + } + }); + } + + @Test + public void whenNotHidden_thenCorrect() throws JsonProcessingException { + final Address ad = new Address("ny", "usa", false); + final Person person = new Person("john", ad, false); + final String result = mapper.writeValueAsString(person); + + assertTrue(result.contains("name")); + assertTrue(result.contains("john")); + assertTrue(result.contains("address")); + assertTrue(result.contains("usa")); + + System.out.println("Not Hidden = " + result); + } + + @Test + public void whenAddressHidden_thenCorrect() throws JsonProcessingException { + final Address ad = new Address("ny", "usa", true); + final Person person = new Person("john", ad, false); + final String result = mapper.writeValueAsString(person); + + assertTrue(result.contains("name")); + assertTrue(result.contains("john")); + assertFalse(result.contains("address")); + assertFalse(result.contains("usa")); + + System.out.println("Address Hidden = " + result); + } + + @Test + public void whenAllHidden_thenCorrect() throws JsonProcessingException { + final Address ad = new Address("ny", "usa", false); + final Person person = new Person("john", ad, true); + final String result = mapper.writeValueAsString(person); + + assertTrue(result.length() == 0); + + System.out.println("All Hidden = " + result); + } + + @Test + public void whenSerializeList_thenCorrect() throws JsonProcessingException { + final Address ad1 = new Address("tokyo", "jp", true); + final Address ad2 = new Address("london", "uk", false); + final Address ad3 = new Address("ny", "usa", false); + final Person p1 = new Person("john", ad1, false); + final Person p2 = new Person("tom", ad2, true); + final Person p3 = new Person("adam", ad3, false); + + final String result = mapper.writeValueAsString(Arrays.asList(p1, p2, p3)); + + System.out.println(result); + } +} From 333e8793bd20d4faabce6733e635844d050f5a2a Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 7 Feb 2016 18:15:42 +0200 Subject: [PATCH 182/626] minor upgrade --- jackson/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackson/pom.xml b/jackson/pom.xml index 999633036138..ed7a5944a53f 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -140,7 +140,7 @@ 5.1.35 - 2.5.5 + 2.7.1-1 1.7.13 From 80b3e457f2eb16c2082381cf198c0be7c3b096a3 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 183/626] Minor Bugfix --- .../baeldung/client/ServicesInterface.java | 4 +- .../main/java/com/baeldung/model/Movie.java | 22 +-- .../com/baeldung/server/MovieCrudService.java | 12 +- .../src/main/webapp/WEB-INF/web.xml | 37 +---- .../java/baeldung/client/RestEasyClient.java | 7 + .../baeldung/server/RestEasyClientTest.java | 149 +++++++----------- 6 files changed, 81 insertions(+), 150 deletions(-) create mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 7efed546d896..749cabc757cf 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -14,7 +14,7 @@ public interface ServicesInterface { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + Movie movieByImdbId(@QueryParam("imdbId") String imdbId); @GET @@ -37,7 +37,7 @@ public interface ServicesInterface { @DELETE @Path("/deletemovie") - Response deleteMovie(@QueryParam("imdbID") String imdbID); + Response deleteMovie(@QueryParam("imdbId") String imdbID); diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index ab3bc1aa8362..f70fdf79751a 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,47 +5,12 @@ RestEasy Example - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - RestEasy Example - - - webAppRootKey - RestEasyExample - - - - + resteasy.servlet.mapping.prefix /rest - - resteasy-servlet - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - javax.ws.rs.Application - com.baeldung.server.RestEasyServices - - - - - resteasy-servlet - /rest/* - - - - - index.html - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java new file mode 100644 index 000000000000..b474b3d4f834 --- /dev/null +++ b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java @@ -0,0 +1,7 @@ +package baeldung.client; + +/** + * Created by Admin on 29/01/2016. + */ +public class RestEasyClient { +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index fb4205bcd79b..b6a2e2a0c108 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -1,7 +1,7 @@ package com.baeldung.server; -import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import com.baeldung.model.Movie; import org.apache.commons.io.IOUtils; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; @@ -9,7 +9,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import javax.naming.NamingException; @@ -23,22 +22,13 @@ public class RestEasyClientTest { - Movie transformerMovie=null; Movie batmanMovie=null; ObjectMapper jsonMapper=null; - @BeforeClass - public static void loadMovieInventory(){ - - - - } - @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); @@ -57,133 +47,102 @@ public void setup() throws ClassNotFoundException, IllegalAccessException, Insta batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); } catch (Exception e) { - e.printStackTrace(); throw new RuntimeException("Test is going to die ...", e); } - } - @Test public void testListAllMovies() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - final List movies = simple.listMovies(); - System.out.println(movies); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); - } catch (Exception e) { - e.printStackTrace(); - } + List movies = simple.listMovies(); + System.out.println(movies); } - @Test - public void testMovieByImdbID() { + public void testMovieByImdbId() { String transformerImdbId="tt0418279"; - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); - final Movie movies = simple.movieByImdbID(transformerImdbId); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } + Movie movies = simple.movieByImdbId(transformerImdbId); + System.out.println(movies); } @Test public void testAddMovie() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test - public void testDeleteMovie() { - - String transformerImdbId="tt0418279"; - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.deleteMovie(transformerImdbId); - moviesResponse.close(); + public void testDeleteMovi1e() { - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test public void testUpdateMovie() { - try { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - batmanMovie.setImdbVotes("300,000"); - moviesResponse = simple.updateMovie(batmanMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } } \ No newline at end of file From a0c22cc22514d0190d14d51e6bcc06ad5eed8836 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sat, 30 Jan 2016 17:48:56 +0100 Subject: [PATCH 184/626] RestEasy Tutorial, CRUD Services example --- RestEasy Example/pom.xml | 91 +++ .../src/main/java/com/baeldung/Movie.java | 535 ++++++++++++++++++ .../baeldung/client/ServicesInterface.java | 44 ++ .../server/service/MovieCrudService.java | 94 +++ .../server/service/RestEasyServices.java | 40 ++ .../src/main/resources/schema1.xsd | 29 + .../main/webapp/WEB-INF/classes/logback.xml | 3 + .../WEB-INF/jboss-deployment-structure.xml | 16 + .../src/main/webapp/WEB-INF/jboss-web.xml | 4 + .../src/main/webapp/WEB-INF/web.xml | 51 ++ .../com/baeldung/server/RestEasyClient.java | 50 ++ .../resources/server/movies/transformer.json | 22 + 12 files changed, 979 insertions(+) create mode 100644 RestEasy Example/pom.xml create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java create mode 100644 RestEasy Example/src/main/resources/schema1.xsd create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/web.xml create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml new file mode 100644 index 000000000000..b16c5e82678b --- /dev/null +++ b/RestEasy Example/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + + jboss + http://repository.jboss.org/nexus/content/groups/public/ + + + + + 3.0.14.Final + runtime + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + org.jboss.resteasy + jaxrs-api + 3.0.12.Final + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + ${resteasy.scope} + + + jboss-jaxrs-api_2.0_spec + org.jboss.spec.javax.ws.rs + + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + ${resteasy.scope} + + + + + javax.ws.rs + javax.ws.rs-api + 2.0.1 + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + ${resteasy.scope} + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java new file mode 100644 index 000000000000..c0041d2e95d2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java @@ -0,0 +1,535 @@ + +package com.baeldung; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "movie", propOrder = { + "actors", + "awards", + "country", + "director", + "genre", + "imdbID", + "imdbRating", + "imdbVotes", + "language", + "metascore", + "plot", + "poster", + "rated", + "released", + "response", + "runtime", + "title", + "type", + "writer", + "year" +}) +public class Movie { + + protected String actors; + protected String awards; + protected String country; + protected String director; + protected String genre; + protected String imdbID; + protected String imdbRating; + protected String imdbVotes; + protected String language; + protected String metascore; + protected String plot; + protected String poster; + protected String rated; + protected String released; + protected String response; + protected String runtime; + protected String title; + protected String type; + protected String writer; + protected String year; + + /** + * Recupera il valore della propriet� actors. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActors() { + return actors; + } + + /** + * Imposta il valore della propriet� actors. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActors(String value) { + this.actors = value; + } + + /** + * Recupera il valore della propriet� awards. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAwards() { + return awards; + } + + /** + * Imposta il valore della propriet� awards. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAwards(String value) { + this.awards = value; + } + + /** + * Recupera il valore della propriet� country. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Imposta il valore della propriet� country. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Recupera il valore della propriet� director. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDirector() { + return director; + } + + /** + * Imposta il valore della propriet� director. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDirector(String value) { + this.director = value; + } + + /** + * Recupera il valore della propriet� genre. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGenre() { + return genre; + } + + /** + * Imposta il valore della propriet� genre. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenre(String value) { + this.genre = value; + } + + /** + * Recupera il valore della propriet� imdbID. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbID() { + return imdbID; + } + + /** + * Imposta il valore della propriet� imdbID. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbID(String value) { + this.imdbID = value; + } + + /** + * Recupera il valore della propriet� imdbRating. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbRating() { + return imdbRating; + } + + /** + * Imposta il valore della propriet� imdbRating. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbRating(String value) { + this.imdbRating = value; + } + + /** + * Recupera il valore della propriet� imdbVotes. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbVotes() { + return imdbVotes; + } + + /** + * Imposta il valore della propriet� imdbVotes. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbVotes(String value) { + this.imdbVotes = value; + } + + /** + * Recupera il valore della propriet� language. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Imposta il valore della propriet� language. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Recupera il valore della propriet� metascore. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMetascore() { + return metascore; + } + + /** + * Imposta il valore della propriet� metascore. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMetascore(String value) { + this.metascore = value; + } + + /** + * Recupera il valore della propriet� plot. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlot() { + return plot; + } + + /** + * Imposta il valore della propriet� plot. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlot(String value) { + this.plot = value; + } + + /** + * Recupera il valore della propriet� poster. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPoster() { + return poster; + } + + /** + * Imposta il valore della propriet� poster. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPoster(String value) { + this.poster = value; + } + + /** + * Recupera il valore della propriet� rated. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRated() { + return rated; + } + + /** + * Imposta il valore della propriet� rated. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRated(String value) { + this.rated = value; + } + + /** + * Recupera il valore della propriet� released. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReleased() { + return released; + } + + /** + * Imposta il valore della propriet� released. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReleased(String value) { + this.released = value; + } + + /** + * Recupera il valore della propriet� response. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponse() { + return response; + } + + /** + * Imposta il valore della propriet� response. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponse(String value) { + this.response = value; + } + + /** + * Recupera il valore della propriet� runtime. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRuntime() { + return runtime; + } + + /** + * Imposta il valore della propriet� runtime. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRuntime(String value) { + this.runtime = value; + } + + /** + * Recupera il valore della propriet� title. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Imposta il valore della propriet� title. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Recupera il valore della propriet� type. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Imposta il valore della propriet� type. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Recupera il valore della propriet� writer. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWriter() { + return writer; + } + + /** + * Imposta il valore della propriet� writer. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWriter(String value) { + this.writer = value; + } + + /** + * Recupera il valore della propriet� year. + * + * @return + * possible object is + * {@link String } + * + */ + public String getYear() { + return year; + } + + /** + * Imposta il valore della propriet� year. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setYear(String value) { + this.year = value; + } + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java new file mode 100644 index 000000000000..53e88961be34 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -0,0 +1,44 @@ +package com.baeldung.client; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +public interface ServicesInterface { + + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response addMovie(Movie movie); + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response updateMovie(Movie movie); + + + @DELETE + @Path("/deletemovie") + Response deleteMovie(@QueryParam("imdbID") String imdbID); + + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java new file mode 100644 index 000000000000..d1973e703738 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java @@ -0,0 +1,94 @@ +package com.baeldung.server.service; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.Provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Path("/movies") +public class MovieCrudService { + + + private Map inventory = new HashMap(); + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling getinfo ***"); + + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; + } + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response addMovie(Movie movie){ + + System.out.println("*** Calling addMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is Already in the database.").build(); + } + inventory.put(movie.getImdbID(),movie); + + return Response.status(Response.Status.CREATED).build(); + } + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response updateMovie(Movie movie){ + + System.out.println("*** Calling updateMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is not in the database.\nUnable to Update").build(); + } + inventory.put(movie.getImdbID(),movie); + return Response.status(Response.Status.OK).build(); + + } + + + @DELETE + @Path("/deletemovie") + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling deleteMovie ***"); + + if (null==inventory.get(imdbID)){ + return Response.status(Response.Status.NOT_FOUND) + .entity("Movie is not in the database.\nUnable to Delete").build(); + } + + inventory.remove(imdbID); + return Response.status(Response.Status.OK).build(); + } + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + public List listMovies(){ + + return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); + + } + + + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java new file mode 100644 index 000000000000..16b6200ad1f2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java @@ -0,0 +1,40 @@ +package com.baeldung.server.service; + + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by Admin on 29/01/2016. + */ + + + +@ApplicationPath("/rest") +public class RestEasyServices extends Application { + + private Set singletons = new HashSet(); + + public RestEasyServices() { + singletons.add(new MovieCrudService()); + } + + @Override + public Set getSingletons() { + return singletons; + } + + @Override + public Set> getClasses() { + return super.getClasses(); + } + + @Override + public Map getProperties() { + return super.getProperties(); + } +} diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd new file mode 100644 index 000000000000..0d74b7c366bb --- /dev/null +++ b/RestEasy Example/src/main/resources/schema1.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml new file mode 100644 index 000000000000..d94e9f71abbb --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 000000000000..84d75934a70c --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 000000000000..694bb7133232 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..c66d3b56ae77 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + RestEasy Example + + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + + + RestEasy Example + + + webAppRootKey + RestEasyExample + + + + + + resteasy.servlet.mapping.prefix + /rest + + + + + resteasy-servlet + + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher + + + javax.ws.rs.Application + com.baeldung.server.service.RestEasyServices + + + + + resteasy-servlet + /rest/* + + + + + index.html + + + + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java new file mode 100644 index 000000000000..e7112339793b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -0,0 +1,50 @@ +package com.baeldung.server; + +import com.baeldung.Movie; +import com.baeldung.client.ServicesInterface; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import java.util.List; + +public class RestEasyClient { + + public static void main(String[] args) { + + Movie st = new Movie(); + st.setImdbID("12345"); + + /* + * Alternatively you can use this simple String to send + * instead of using a Student instance + * + * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; + */ + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + + /* + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Server response : \n"); + System.out.println(response.readEntity(String.class)); + + response.close(); +*/ + } catch (Exception e) { + + e.printStackTrace(); + + } + } + +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json new file mode 100644 index 000000000000..215486826560 --- /dev/null +++ b/RestEasy Example/src/test/resources/server/movies/transformer.json @@ -0,0 +1,22 @@ +{ + "title": "Transformers", + "year": "2007", + "rated": "PG-13", + "released": "03 Jul 2007", + "runtime": "144 min", + "genre": "Action, Adventure, Sci-Fi", + "director": "Michael Bay", + "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", + "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", + "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", + "language": "English, Spanish", + "country": "USA", + "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", + "metascore": "61", + "imdbRating": "7.1", + "imdbVotes": "492,225", + "imdbID": "tt0418279", + "Type": "movie", + "response": "True" +} \ No newline at end of file From 72a74b8096cd535da6ff3c96d7cc05d305c5e1a9 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 30 Jan 2016 20:39:28 +0100 Subject: [PATCH 185/626] Added testCase for List All Movies and Add a Movie --- RestEasy Example/pom.xml | 29 +++++ .../baeldung/client/ServicesInterface.java | 6 +- .../java/com/baeldung/{ => model}/Movie.java | 45 +++++++- .../{service => }/MovieCrudService.java | 5 +- .../{service => }/RestEasyServices.java | 2 +- .../com/baeldung/server/RestEasyClient.java | 104 ++++++++++++++---- .../com/baeldung/server/movies/batman.json | 22 ++++ .../baeldung}/server/movies/transformer.json | 2 +- 8 files changed, 184 insertions(+), 31 deletions(-) rename RestEasy Example/src/main/java/com/baeldung/{ => model}/Movie.java (86%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/MovieCrudService.java (96%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/RestEasyServices.java (95%) create mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json rename RestEasy Example/src/test/resources/{ => com/baeldung}/server/movies/transformer.json (99%) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index b16c5e82678b..8dabfc863bc4 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -85,6 +85,35 @@ ${resteasy.scope} + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + com.fasterxml.jackson.core + jackson-core + 2.7.0 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.0 + + + + + diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 53e88961be34..2585c32438ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,15 +1,13 @@ package com.baeldung.client; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - +@Path("/movies") public interface ServicesInterface { diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java similarity index 86% rename from RestEasy Example/src/main/java/com/baeldung/Movie.java rename to RestEasy Example/src/main/java/com/baeldung/model/Movie.java index c0041d2e95d2..052ba081c1a0 100644 --- a/RestEasy Example/src/main/java/com/baeldung/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,5 +1,5 @@ -package com.baeldung; +package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -532,4 +532,47 @@ public void setYear(String value) { this.year = value; } + @Override + public String toString() { + return "Movie{" + + "actors='" + actors + '\'' + + ", awards='" + awards + '\'' + + ", country='" + country + '\'' + + ", director='" + director + '\'' + + ", genre='" + genre + '\'' + + ", imdbID='" + imdbID + '\'' + + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + + ", language='" + language + '\'' + + ", metascore='" + metascore + '\'' + + ", poster='" + poster + '\'' + + ", rated='" + rated + '\'' + + ", released='" + released + '\'' + + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + + ", title='" + title + '\'' + + ", type='" + type + '\'' + + ", writer='" + writer + '\'' + + ", year='" + year + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Movie movie = (Movie) o; + + if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + return title != null ? title.equals(movie.title) : movie.title == null; + + } + + @Override + public int hashCode() { + int result = imdbID != null ? imdbID.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + return result; + } } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java similarity index 96% rename from RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java rename to RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index d1973e703738..60e0121966df 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,11 +1,10 @@ -package com.baeldung.server.service; +package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java similarity index 95% rename from RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java rename to RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 16b6200ad1f2..8c57d2c9b466 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,4 +1,4 @@ -package com.baeldung.server.service; +package com.baeldung.server; import javax.ws.rs.ApplicationPath; diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java index e7112339793b..c77f494862f5 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -1,49 +1,111 @@ package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.List; +import java.util.Locale; public class RestEasyClient { - public static void main(String[] args) { - Movie st = new Movie(); - st.setImdbID("12345"); + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; - /* - * Alternatively you can use this simple String to send - * instead of using a Student instance - * - * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; - */ + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + @Test + public void testListAllMovies() { try { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); - + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + - /* - if (response.getStatus() != 200) { + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final Response moviesResponse = simple.addMovie(batmanMovie); + + if (moviesResponse.getStatus() != 201) { + System.out.println(moviesResponse.readEntity(String.class)); throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); + + moviesResponse.getStatus()); } - System.out.println("Server response : \n"); - System.out.println(response.readEntity(String.class)); + moviesResponse.close(); - response.close(); -*/ } catch (Exception e) { - e.printStackTrace(); - } } diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json new file mode 100644 index 000000000000..28061d5bf94d --- /dev/null +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -0,0 +1,22 @@ +{ + "title": "Batman", + "year": "1989", + "rated": "PG-13", + "released": "23 Jun 1989", + "runtime": "126 min", + "genre": "Action, Adventure", + "director": "Tim Burton", + "writer": "Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)", + "actors": "Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl", + "plot": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.", + "language": "English, French", + "country": "USA, UK", + "awards": "Won 1 Oscar. Another 9 wins & 22 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg", + "metascore": "66", + "imdbRating": "7.6", + "imdbVotes": "256,000", + "imdbID": "tt0096895", + "type": "movie", + "response": "True" +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json similarity index 99% rename from RestEasy Example/src/test/resources/server/movies/transformer.json rename to RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index 215486826560..a3b033a8ba6f 100644 --- a/RestEasy Example/src/test/resources/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -17,6 +17,6 @@ "imdbRating": "7.1", "imdbVotes": "492,225", "imdbID": "tt0418279", - "Type": "movie", + "type": "movie", "response": "True" } \ No newline at end of file From 4174ff7dd2a1deb7e023067326e8fa2495385003 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 31 Jan 2016 11:05:11 +0100 Subject: [PATCH 186/626] Added testCase for all Services --- RestEasy Example/pom.xml | 15 -- .../baeldung/client/ServicesInterface.java | 10 +- .../com/baeldung/server/MovieCrudService.java | 15 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- .../com/baeldung/server/RestEasyClient.java | 112 ----------- .../baeldung/server/RestEasyClientTest.java | 189 ++++++++++++++++++ 6 files changed, 206 insertions(+), 137 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 8dabfc863bc4..6935238d910f 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -99,21 +99,6 @@ 2.4 - - com.fasterxml.jackson.core - jackson-core - 2.7.0 - - - - com.fasterxml.jackson.core - jackson-annotations - 2.7.0 - - - - - diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 2585c32438ec..7efed546d896 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -17,6 +17,12 @@ public interface ServicesInterface { Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -34,9 +40,5 @@ public interface ServicesInterface { Response deleteMovie(@QueryParam("imdbID") String imdbID); - @GET - @Path("/listmovies") - @Produces({"application/json"}) - List listMovies(); } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 60e0121966df..18366e2faafc 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,18 +18,21 @@ public class MovieCrudService { private Map inventory = new HashMap(); + @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - System.out.println("*** Calling getinfo ***"); + System.out.println("*** Calling getinfo for a given ImdbID***"); + + if(inventory.containsKey(imdbID)){ + return inventory.get(imdbID); + }else return null; - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; } + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -41,6 +44,7 @@ public Response addMovie(Movie movie){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); @@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } @@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){ return Response.status(Response.Status.OK).build(); } + @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index c66d3b56ae77..ab3bc1aa8362 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -33,7 +33,7 @@ javax.ws.rs.Application - com.baeldung.server.service.RestEasyServices + com.baeldung.server.RestEasyServices diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java deleted file mode 100644 index c77f494862f5..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.model.Movie; -import com.baeldung.client.ServicesInterface; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.naming.NamingException; -import javax.ws.rs.core.Link; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class RestEasyClient { - - - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; - - @BeforeClass - public static void loadMovieInventory(){ - - - - } - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - } - - @Test - public void testListAllMovies() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - final List movies = simple.listMovies(); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testAddMovie() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - - ServicesInterface simple = target.proxy(ServicesInterface.class); - final Response moviesResponse = simple.addMovie(batmanMovie); - - if (moviesResponse.getStatus() != 201) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " - + moviesResponse.getStatus()); - } - - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java new file mode 100644 index 000000000000..fb4205bcd79b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -0,0 +1,189 @@ +package com.baeldung.server; + +import com.baeldung.model.Movie; +import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.naming.NamingException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + +public class RestEasyClientTest { + + + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; + + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + + @Test + public void testListAllMovies() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testMovieByImdbID() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + + final Movie movies = simple.movieByImdbID(transformerImdbId); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); + + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testDeleteMovie() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(transformerImdbId); + moviesResponse.close(); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testUpdateMovie() { + + try { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file From 85d299e739fa00317d687fdd2af2ffa43a9dfc1c Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 187/626] Minor Bugfix --- .../baeldung/client/ServicesInterface.java | 4 +- .../main/java/com/baeldung/model/Movie.java | 22 +-- .../com/baeldung/server/MovieCrudService.java | 12 +- .../src/main/webapp/WEB-INF/web.xml | 37 +---- .../java/baeldung/client/RestEasyClient.java | 7 + .../baeldung/server/RestEasyClientTest.java | 149 +++++++----------- 6 files changed, 81 insertions(+), 150 deletions(-) create mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 7efed546d896..749cabc757cf 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -14,7 +14,7 @@ public interface ServicesInterface { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + Movie movieByImdbId(@QueryParam("imdbId") String imdbId); @GET @@ -37,7 +37,7 @@ public interface ServicesInterface { @DELETE @Path("/deletemovie") - Response deleteMovie(@QueryParam("imdbID") String imdbID); + Response deleteMovie(@QueryParam("imdbId") String imdbID); diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index ab3bc1aa8362..f70fdf79751a 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,47 +5,12 @@ RestEasy Example - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - RestEasy Example - - - webAppRootKey - RestEasyExample - - - - + resteasy.servlet.mapping.prefix /rest - - resteasy-servlet - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - javax.ws.rs.Application - com.baeldung.server.RestEasyServices - - - - - resteasy-servlet - /rest/* - - - - - index.html - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java new file mode 100644 index 000000000000..b474b3d4f834 --- /dev/null +++ b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java @@ -0,0 +1,7 @@ +package baeldung.client; + +/** + * Created by Admin on 29/01/2016. + */ +public class RestEasyClient { +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index fb4205bcd79b..b6a2e2a0c108 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -1,7 +1,7 @@ package com.baeldung.server; -import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import com.baeldung.model.Movie; import org.apache.commons.io.IOUtils; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; @@ -9,7 +9,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import javax.naming.NamingException; @@ -23,22 +22,13 @@ public class RestEasyClientTest { - Movie transformerMovie=null; Movie batmanMovie=null; ObjectMapper jsonMapper=null; - @BeforeClass - public static void loadMovieInventory(){ - - - - } - @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); @@ -57,133 +47,102 @@ public void setup() throws ClassNotFoundException, IllegalAccessException, Insta batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); } catch (Exception e) { - e.printStackTrace(); throw new RuntimeException("Test is going to die ...", e); } - } - @Test public void testListAllMovies() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - final List movies = simple.listMovies(); - System.out.println(movies); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); - } catch (Exception e) { - e.printStackTrace(); - } + List movies = simple.listMovies(); + System.out.println(movies); } - @Test - public void testMovieByImdbID() { + public void testMovieByImdbId() { String transformerImdbId="tt0418279"; - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); - final Movie movies = simple.movieByImdbID(transformerImdbId); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } + Movie movies = simple.movieByImdbId(transformerImdbId); + System.out.println(movies); } @Test public void testAddMovie() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test - public void testDeleteMovie() { - - String transformerImdbId="tt0418279"; - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.deleteMovie(transformerImdbId); - moviesResponse.close(); + public void testDeleteMovi1e() { - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test public void testUpdateMovie() { - try { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - batmanMovie.setImdbVotes("300,000"); - moviesResponse = simple.updateMovie(batmanMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } } \ No newline at end of file From d4a4d20fa03d9356ee122834846551cd71427c44 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:39:35 +0100 Subject: [PATCH 188/626] Minor Bugfix --- .../main/java/com/baeldung/model/Movie.java | 321 +----------------- 1 file changed, 1 insertion(+), 320 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index a2b2bd5250d4..805ba95209ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -52,482 +52,163 @@ public class Movie { protected String writer; protected String year; - /** - * Recupera il valore della propriet� actors. - * - * @return - * possible object is - * {@link String } - * - */ + public String getActors() { return actors; } - /** - * Imposta il valore della propriet� actors. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setActors(String value) { this.actors = value; } - /** - * Recupera il valore della propriet� awards. - * - * @return - * possible object is - * {@link String } - * - */ public String getAwards() { return awards; } - /** - * Imposta il valore della propriet� awards. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setAwards(String value) { this.awards = value; } - /** - * Recupera il valore della propriet� country. - * - * @return - * possible object is - * {@link String } - * - */ public String getCountry() { return country; } - /** - * Imposta il valore della propriet� country. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setCountry(String value) { this.country = value; } - /** - * Recupera il valore della propriet� director. - * - * @return - * possible object is - * {@link String } - * - */ public String getDirector() { return director; } - /** - * Imposta il valore della propriet� director. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setDirector(String value) { this.director = value; } - /** - * Recupera il valore della propriet� genre. - * - * @return - * possible object is - * {@link String } - * - */ public String getGenre() { return genre; } - /** - * Imposta il valore della propriet� genre. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setGenre(String value) { this.genre = value; } - /** - * Recupera il valore della propriet� imdbId. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbId() { return imdbId; } - /** - * Imposta il valore della propriet� imdbId. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbId(String value) { this.imdbId = value; } - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbRating() { return imdbRating; } - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbRating(String value) { this.imdbRating = value; } - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbVotes() { return imdbVotes; } - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbVotes(String value) { this.imdbVotes = value; } - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ public String getLanguage() { return language; } - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setLanguage(String value) { this.language = value; } - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ public String getMetascore() { return metascore; } - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setMetascore(String value) { this.metascore = value; } - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ public String getPlot() { return plot; } - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPlot(String value) { this.plot = value; } - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ public String getPoster() { return poster; } - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPoster(String value) { this.poster = value; } - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ public String getRated() { return rated; } - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRated(String value) { this.rated = value; } - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ public String getReleased() { return released; } - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setReleased(String value) { this.released = value; } - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ public String getResponse() { return response; } - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setResponse(String value) { this.response = value; } - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ public String getRuntime() { return runtime; } - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRuntime(String value) { this.runtime = value; } - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ public String getTitle() { return title; } - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setTitle(String value) { this.title = value; } - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ public String getType() { return type; } - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setType(String value) { this.type = value; } - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ public String getWriter() { return writer; } - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setWriter(String value) { this.writer = value; } - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ public String getYear() { return year; } - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setYear(String value) { this.year = value; } From 183ae3d3b9bae2ce9151c4ab0702b74ecb54d1dd Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:47:42 +0100 Subject: [PATCH 189/626] Minor Bugfix --- .../main/java/com/baeldung/model/Movie.java | 260 ------------------ 1 file changed, 260 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 8eb8283d2862..76e84a63782e 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -84,390 +84,130 @@ public void setDirector(String value) { this.director = value; } - public String getGenre() { return genre; } - public void setGenre(String value) { this.genre = value; } - /** - * Recupera il valore della propriet� imdbId. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbId() { return imdbId; } - /** - * Imposta il valore della propriet� imdbId. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbId(String value) { this.imdbId = value; } - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbRating() { return imdbRating; } - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbRating(String value) { this.imdbRating = value; } - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbVotes() { return imdbVotes; } public void setImdbVotes(String value) { - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ this.imdbVotes = value; } public String getLanguage() { - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ return language; } - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setLanguage(String value) { this.language = value; } - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ public String getMetascore() { return metascore; } - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setMetascore(String value) { this.metascore = value; } - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ public String getPlot() { return plot; } - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPlot(String value) { this.plot = value; } - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ public String getPoster() { return poster; } - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPoster(String value) { this.poster = value; } - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ public String getRated() { return rated; } - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRated(String value) { this.rated = value; } - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ public String getReleased() { return released; } - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setReleased(String value) { this.released = value; } - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ public String getResponse() { return response; } - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setResponse(String value) { this.response = value; } - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ public String getRuntime() { return runtime; } - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRuntime(String value) { this.runtime = value; } - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ public String getTitle() { return title; } - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setTitle(String value) { this.title = value; } -<<<<<<< HEAD -======= - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ ->>>>>>> origin/master public String getType() { return type; } -<<<<<<< HEAD -======= - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ ->>>>>>> origin/master public void setType(String value) { this.type = value; } -<<<<<<< HEAD -======= - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ ->>>>>>> origin/master public String getWriter() { return writer; } -<<<<<<< HEAD -======= - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ ->>>>>>> origin/master public void setWriter(String value) { this.writer = value; } -<<<<<<< HEAD -======= - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ ->>>>>>> origin/master public String getYear() { return year; } -<<<<<<< HEAD -======= - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ ->>>>>>> origin/master public void setYear(String value) { this.year = value; } From 03b6cbf3e545dcb817abf364f1edea3e2b074a03 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:55:46 +0100 Subject: [PATCH 190/626] CleanUp Code --- RestEasy Example/pom.xml | 3 +- .../baeldung/client/ServicesInterface.java | 1 - .../main/java/com/baeldung/model/Movie.java | 2 -- .../com/baeldung/server/MovieCrudService.java | 17 ++++------- .../com/baeldung/server/RestEasyServices.java | 8 ----- .../src/main/resources/schema1.xsd | 29 ------------------- .../src/main/webapp/WEB-INF/web.xml | 3 -- .../java/baeldung/client/RestEasyClient.java | 7 ----- .../baeldung/server/RestEasyClientTest.java | 1 - 9 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 RestEasy Example/src/main/resources/schema1.xsd delete mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 6935238d910f..9c890da2b75e 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -36,7 +36,7 @@ - + org.jboss.resteasy jaxrs-api @@ -101,5 +101,4 @@ - \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 749cabc757cf..3c8d6abc00e2 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,7 +1,6 @@ package com.baeldung.client; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 76e84a63782e..7590f104876e 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,11 +1,9 @@ - package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; - @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "movie", propOrder = { "actors", diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 29226aa0e094..bbb3b1e9531e 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,7 +1,6 @@ package com.baeldung.server; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -11,23 +10,21 @@ import java.util.Map; import java.util.stream.Collectors; - @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbID)){ - return inventory.get(imdbID); + if(inventory.containsKey(imdbId)){ + return inventory.get(imdbId); }else return null; } @@ -70,16 +67,16 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbID)){ + if (null==inventory.get(imdbId)){ return Response.status(Response.Status.NOT_FOUND) .entity("Movie is not in the database.\nUnable to Delete").build(); } - inventory.remove(imdbID); + inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } @@ -93,6 +90,4 @@ public List listMovies(){ } - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 8c57d2c9b466..7726e49f3830 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,19 +1,11 @@ package com.baeldung.server; - import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Set; -/** - * Created by Admin on 29/01/2016. - */ - - - @ApplicationPath("/rest") public class RestEasyServices extends Application { diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd deleted file mode 100644 index 0d74b7c366bb..000000000000 --- a/RestEasy Example/src/main/resources/schema1.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index f70fdf79751a..1e7f64004dd0 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,12 +5,9 @@ RestEasy Example - resteasy.servlet.mapping.prefix /rest - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java deleted file mode 100644 index b474b3d4f834..000000000000 --- a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java +++ /dev/null @@ -1,7 +0,0 @@ -package baeldung.client; - -/** - * Created by Admin on 29/01/2016. - */ -public class RestEasyClient { -} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index b6a2e2a0c108..faa39e019992 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -10,7 +10,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; import org.junit.Test; - import javax.naming.NamingException; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; From 9c60f320892dcdfe2d15b5b68332c58e103fa64a Mon Sep 17 00:00:00 2001 From: David Morley Date: Sun, 7 Feb 2016 14:54:04 -0600 Subject: [PATCH 191/626] Clean up examples for Spring Data Elasticsearch --- .../baeldung/{ => spring/data/es}/config/Config.java | 4 ++-- .../data/es/dao}/ArticleRepository.java | 4 ++-- .../baeldung/{ => spring/data/es}/model/Article.java | 2 +- .../baeldung/{ => spring/data/es}/model/Author.java | 2 +- .../data/es/repository}/ArticleRepository.java | 5 ++--- .../{ => spring/data/es}/service/ArticleService.java | 4 ++-- .../data/es}/service/ArticleServiceImpl.java | 6 +++--- .../{ => spring/data/es}/ElasticSearchTest.java | 11 +++++------ 8 files changed, 18 insertions(+), 20 deletions(-) rename spring-data-elasticsearch/src/main/java/com/baeldung/{ => spring/data/es}/config/Config.java (94%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{repository => spring/data/es/dao}/ArticleRepository.java (86%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{ => spring/data/es}/model/Article.java (96%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{ => spring/data/es}/model/Author.java (90%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{dao => spring/data/es/repository}/ArticleRepository.java (85%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{ => spring/data/es}/service/ArticleService.java (82%) rename spring-data-elasticsearch/src/main/java/com/baeldung/{ => spring/data/es}/service/ArticleServiceImpl.java (89%) rename spring-data-elasticsearch/src/test/java/com/baeldung/{ => spring/data/es}/ElasticSearchTest.java (94%) diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/config/Config.java similarity index 94% rename from spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/config/Config.java index a67ec6453473..78e4083a28d7 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/config/Config.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/config/Config.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.spring.data.es.config; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.node.NodeBuilder; @@ -18,7 +18,7 @@ @Configuration @EnableElasticsearchRepositories(basePackages = "com.baeldung.repository") -@ComponentScan(basePackages = {"com.baeldung.service"}) +@ComponentScan(basePackages = {"com.baeldung.spring.data.es.service"}) public class Config { private static Logger logger = LoggerFactory.getLogger(Config.class); diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/dao/ArticleRepository.java similarity index 86% rename from spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/dao/ArticleRepository.java index 1cb74889c58e..313eba5b369a 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/repository/ArticleRepository.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/dao/ArticleRepository.java @@ -1,6 +1,6 @@ -package com.baeldung.repository; +package com.baeldung.spring.data.es.dao; -import com.baeldung.model.Article; +import com.baeldung.spring.data.es.model.Article; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.annotations.Query; diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Article.java similarity index 96% rename from spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Article.java index dee1d0817eef..dd472982cef4 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Article.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Article.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.spring.data.es.model; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Author.java similarity index 90% rename from spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Author.java index 09239efbe598..c335c4534ae9 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/model/Author.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/model/Author.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.spring.data.es.model; public class Author { diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/repository/ArticleRepository.java similarity index 85% rename from spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/repository/ArticleRepository.java index 6ed86eff9be0..27628950d784 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/dao/ArticleRepository.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/repository/ArticleRepository.java @@ -1,7 +1,6 @@ -package com.baeldung.dao; +package com.baeldung.spring.data.es.repository; -import com.baeldung.model.Article; -import com.baeldung.model.Article; +import com.baeldung.spring.data.es.model.Article; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.annotations.Query; diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleService.java similarity index 82% rename from spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleService.java index 052e22c67dba..760bad4b01ce 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleService.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleService.java @@ -1,6 +1,6 @@ -package com.baeldung.service; +package com.baeldung.spring.data.es.service; -import com.baeldung.model.Article; +import com.baeldung.spring.data.es.model.Article; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleServiceImpl.java similarity index 89% rename from spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleServiceImpl.java index 59feb2816c14..3bb6e6a0e0ff 100644 --- a/spring-data-elasticsearch/src/main/java/com/baeldung/service/ArticleServiceImpl.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/spring/data/es/service/ArticleServiceImpl.java @@ -1,7 +1,7 @@ -package com.baeldung.service; +package com.baeldung.spring.data.es.service; -import com.baeldung.repository.ArticleRepository; -import com.baeldung.model.Article; +import com.baeldung.spring.data.es.repository.ArticleRepository; +import com.baeldung.spring.data.es.model.Article; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java b/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchTest.java similarity index 94% rename from spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java rename to spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchTest.java index 07248149c20a..34ccfd788e99 100644 --- a/spring-data-elasticsearch/src/test/java/com/baeldung/ElasticSearchTest.java +++ b/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchTest.java @@ -1,10 +1,9 @@ -package com.baeldung; +package com.baeldung.spring.data.es; -import com.baeldung.config.Config; -import com.baeldung.model.Article; -import com.baeldung.model.Author; -import com.baeldung.service.ArticleService; -import org.elasticsearch.index.query.QueryBuilder; +import com.baeldung.spring.data.es.config.Config; +import com.baeldung.spring.data.es.model.Article; +import com.baeldung.spring.data.es.model.Author; +import com.baeldung.spring.data.es.service.ArticleService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; From 58e82f3c1f630af700aa2890a1f01835969b9667 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 11:46:02 +0200 Subject: [PATCH 192/626] Update README.md --- spring-hibernate4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index 96f8074165c6..acf20632fef0 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -6,6 +6,7 @@ - [Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring) - [The DAO with Spring 3 and Hibernate](http://www.baeldung.com/2011/12/02/the-persistence-layer-with-spring-3-1-and-hibernate/) - [Hibernate Pagination](http://www.baeldung.com/hibernate-pagination) +- [Sorting with Hibernate](http://www.baeldung.com/hibernate-sort) ### Quick Start From d68375cd6da76a53a8074daf862d659da21f22bb Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 11:57:26 +0200 Subject: [PATCH 193/626] Update README.md --- httpclient/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/httpclient/README.md b/httpclient/README.md index 529ac754f8e9..b9dd431500fe 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -5,12 +5,13 @@ ### Relevant Articles: -- [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) -- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) -- [HttpClient 4 – Cancel / Abort Request](http://www.baeldung.com/httpclient-cancel-request) +- [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) +- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) +- [HttpClient 4 – Cancel / Abort Request](http://www.baeldung.com/httpclient-cancel-request) - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) - [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) - [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) -- [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) -- [HttpClient – Set Custom Header](http://www.baeldung.com/httpclient-custom-http-header) +- [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) +- [HttpClient – Set Custom Header](http://www.baeldung.com/httpclient-custom-http-header) - [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) +- [Multipart Upload with HttpClient 4](http://www.baeldung.com/httpclient-multipart-upload) From e4e5a9e479859468c26a061711beeb3712d421f8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 11:58:55 +0200 Subject: [PATCH 194/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 63ca8c79268a..b53435a22279 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -11,6 +11,7 @@ - [ETags for REST with Spring](http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/) - [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) - [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/2011/10/16/how-to-set-up-integration-testing-with-the-maven-cargo-plugin/) +- [Introduction to Spring Data JPA](http://www.baeldung.com/2011/12/22/the-persistence-layer-with-spring-data-jpa/) ### Build the Project From 72bd9c54b9f53a8c01581cb0a6f3fd6f0a8aebe8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:01:25 +0200 Subject: [PATCH 195/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 772681ad57ce..665a06a3c8ef 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -6,4 +6,5 @@ - [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) - [Java - Reading a Large File Efficiently](http://www.baeldung.com/java-read-lines-large-file) - [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) +- [Converting between an Array and a List in Java](http://www.baeldung.com/convert-array-to-list-and-list-to-array) From ec551bfe3fc43a6aeb2c3c20adcb0c8bef125149 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:02:58 +0200 Subject: [PATCH 196/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 665a06a3c8ef..6aa04df33f0f 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -7,4 +7,5 @@ - [Java - Reading a Large File Efficiently](http://www.baeldung.com/java-read-lines-large-file) - [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) - [Converting between an Array and a List in Java](http://www.baeldung.com/convert-array-to-list-and-list-to-array) +- [Converting between an Array and a Set in Java](http://www.baeldung.com/convert-array-to-set-and-set-to-array) From 693081d509ac9d9cb1e991ea5e18348f4cfd1c40 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:04:32 +0200 Subject: [PATCH 197/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 6aa04df33f0f..a98e5524ac53 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -8,4 +8,5 @@ - [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) - [Converting between an Array and a List in Java](http://www.baeldung.com/convert-array-to-list-and-list-to-array) - [Converting between an Array and a Set in Java](http://www.baeldung.com/convert-array-to-set-and-set-to-array) +- [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list) From c5cad39354069a1888cc547c2cf5cc165b298bf3 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:07:07 +0200 Subject: [PATCH 198/626] Update README.md --- core-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/README.md b/core-java/README.md index a98e5524ac53..b8f63717edf1 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -9,4 +9,4 @@ - [Converting between an Array and a List in Java](http://www.baeldung.com/convert-array-to-list-and-list-to-array) - [Converting between an Array and a Set in Java](http://www.baeldung.com/convert-array-to-set-and-set-to-array) - [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list) - +- [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set) From 9f9aee658f21ac127c2b1158832d7311bd1193ee Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:08:35 +0200 Subject: [PATCH 199/626] Update README.md --- spring-security-mvc-persisted-remember-me/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-persisted-remember-me/README.md b/spring-security-mvc-persisted-remember-me/README.md index 11f541702845..df83fd3d7740 100644 --- a/spring-security-mvc-persisted-remember-me/README.md +++ b/spring-security-mvc-persisted-remember-me/README.md @@ -4,7 +4,7 @@ ### Relevant Articles: -- [Spring Security Persisted Remember Me] +- [Spring Security Persisted Remember Me](http://www.baeldung.com/spring-security-persistent-remember-me) - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) - [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) From 7bc00c24b721a406a3434964b803f835335a4e43 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:13:41 +0200 Subject: [PATCH 200/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index b53435a22279..cffbcf40f086 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -12,6 +12,7 @@ - [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) - [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/2011/10/16/how-to-set-up-integration-testing-with-the-maven-cargo-plugin/) - [Introduction to Spring Data JPA](http://www.baeldung.com/2011/12/22/the-persistence-layer-with-spring-data-jpa/) +- [Project Configuration with Spring](http://www.baeldung.com/2012/03/12/project-configuration-with-spring/) ### Build the Project From dfc7b2113d40bf7c5a350027473f88ea6a51245a Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:14:54 +0200 Subject: [PATCH 201/626] Update README.md --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 908e21d4bf72..2409ec8174a4 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -7,3 +7,4 @@ ### Relevant Articles: - [Spring MVC Tutorial](http://www.baeldung.com/spring-mvc-tutorial) - [Servlet Session Timeout](http://www.baeldung.com/servlet-session-timeout) +- [Basic Forms with Spring MVC](http://www.baeldung.com/spring-mvc-form-tutorial) From 550068f5a8fb8f0f02a5edeb66edd831f875ad47 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:19:34 +0200 Subject: [PATCH 202/626] Update README.md --- gson/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gson/README.md b/gson/README.md index 559e536d8120..47d8ecfb391d 100644 --- a/gson/README.md +++ b/gson/README.md @@ -2,5 +2,6 @@ ## GSON Cookbooks and Examples -### Relevant Articles: +### Relevant Articles: +-[Gson Deserialization Cookbook](http://www.baeldung.com/gson-deserialization-guide) From adc258155690a4d45e0ffd9c238cbf89081c8f29 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:20:01 +0200 Subject: [PATCH 203/626] Update README.md --- gson/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gson/README.md b/gson/README.md index 47d8ecfb391d..67651b732e59 100644 --- a/gson/README.md +++ b/gson/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: --[Gson Deserialization Cookbook](http://www.baeldung.com/gson-deserialization-guide) +- [Gson Deserialization Cookbook](http://www.baeldung.com/gson-deserialization-guide) From d33f16a68d762b189c4ea17fc2199ddacb748b81 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:21:29 +0200 Subject: [PATCH 204/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 1c5b16d6f6ad..1638e8275659 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -5,6 +5,7 @@ ### Relevant Articles: - [Spring Security Registration Tutorial](http://www.baeldung.com/spring-security-registration) +- [The Registration Process With Spring Security](http://www.baeldung.com/registration-with-spring-mvc-and-spring-security) From 28bddf2d8ebde5847c9f7f0cda79b7f9a24db63d Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:22:55 +0200 Subject: [PATCH 205/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index b8f63717edf1..6db2b370f656 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -10,3 +10,4 @@ - [Converting between an Array and a Set in Java](http://www.baeldung.com/convert-array-to-set-and-set-to-array) - [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list) - [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set) +- [Java – Write to File](http://www.baeldung.com/java-write-to-file) From 1d24669cbb35963cc06791a3156613cb7ada28c4 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:26:06 +0200 Subject: [PATCH 206/626] Update README.md --- guava/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/guava/README.md b/guava/README.md index 8960b4676efb..948087ff1eec 100644 --- a/guava/README.md +++ b/guava/README.md @@ -7,7 +7,6 @@ - [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) - [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) - [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) - - [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) - - [Partition a List in Java](http://www.baeldung.com/java-list-split) +- [Filtering and Transforming Collections in Guava](http://www.baeldung.com/guava-filter-and-transform-a-collection) From 20d79082dd70ddf6118e0e0bf2155ef6821371d4 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:28:15 +0200 Subject: [PATCH 207/626] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 948087ff1eec..86771a740c39 100644 --- a/guava/README.md +++ b/guava/README.md @@ -10,3 +10,4 @@ - [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) - [Partition a List in Java](http://www.baeldung.com/java-list-split) - [Filtering and Transforming Collections in Guava](http://www.baeldung.com/guava-filter-and-transform-a-collection) +- [Guava – Join and Split Collections](http://www.baeldung.com/guava-joiner-and-splitter-tutorial) From d8bb9affec51c483f021dd8564eb6597e4952b33 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:29:23 +0200 Subject: [PATCH 208/626] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 86771a740c39..43acf04bd149 100644 --- a/guava/README.md +++ b/guava/README.md @@ -11,3 +11,4 @@ - [Partition a List in Java](http://www.baeldung.com/java-list-split) - [Filtering and Transforming Collections in Guava](http://www.baeldung.com/guava-filter-and-transform-a-collection) - [Guava – Join and Split Collections](http://www.baeldung.com/guava-joiner-and-splitter-tutorial) +- [Guava – Write to File, Read from File](http://www.baeldung.com/guava-write-to-file-read-from-file) From c2a226141b750871e580b8e77f25561e7456b6eb Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:33:13 +0200 Subject: [PATCH 209/626] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 43acf04bd149..dfffe8bc073f 100644 --- a/guava/README.md +++ b/guava/README.md @@ -12,3 +12,4 @@ - [Filtering and Transforming Collections in Guava](http://www.baeldung.com/guava-filter-and-transform-a-collection) - [Guava – Join and Split Collections](http://www.baeldung.com/guava-joiner-and-splitter-tutorial) - [Guava – Write to File, Read from File](http://www.baeldung.com/guava-write-to-file-read-from-file) +- [Guava – Lists](http://www.baeldung.com/guava-lists) From 30b74f9d04a3614061c4c13748a91fa4fae3c564 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:34:20 +0200 Subject: [PATCH 210/626] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index dfffe8bc073f..7fdf28033d6e 100644 --- a/guava/README.md +++ b/guava/README.md @@ -13,3 +13,4 @@ - [Guava – Join and Split Collections](http://www.baeldung.com/guava-joiner-and-splitter-tutorial) - [Guava – Write to File, Read from File](http://www.baeldung.com/guava-write-to-file-read-from-file) - [Guava – Lists](http://www.baeldung.com/guava-lists) +- [Guava – Sets](http://www.baeldung.com/guava-sets) From 371ebf5db18d1495ba41b0cda5f7cc96b098d496 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:35:14 +0200 Subject: [PATCH 211/626] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 7fdf28033d6e..28bcfeb91205 100644 --- a/guava/README.md +++ b/guava/README.md @@ -14,3 +14,4 @@ - [Guava – Write to File, Read from File](http://www.baeldung.com/guava-write-to-file-read-from-file) - [Guava – Lists](http://www.baeldung.com/guava-lists) - [Guava – Sets](http://www.baeldung.com/guava-sets) +- [Guava – Maps](http://www.baeldung.com/guava-maps) From 86ca22330b3ee915b44032a0829de436b05ced9c Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:38:54 +0200 Subject: [PATCH 212/626] Update README.md --- mockito/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mockito/README.md b/mockito/README.md index 5ecc5722b08b..eb80042c4be0 100644 --- a/mockito/README.md +++ b/mockito/README.md @@ -6,4 +6,4 @@ ### Relevant Articles: - [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) - [Mockito When/Then Cookbook](http://www.baeldung.com/mockito-behavior) - +- [Mockito – Using Spies](http://www.baeldung.com/mockito-spy) From b3dff4d5de740eab323a390895a66d5c8fb2eb32 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:40:40 +0200 Subject: [PATCH 213/626] Update README.md --- spring-all/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-all/README.md b/spring-all/README.md index 4a3bd2507704..baab7ec08395 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -6,4 +6,5 @@ This project is used to replicate Spring Exceptions only. ### Relevant articles: -- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage \ No newline at end of file +- [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage +- [Spring Profiles](http://www.baeldung.com/spring-profiles) From 731c0803c4e5833c619ea40aa1f78e8f1f86f87a Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:42:32 +0200 Subject: [PATCH 214/626] Update README.md --- mockito/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/mockito/README.md b/mockito/README.md index eb80042c4be0..5e7cd19f78c1 100644 --- a/mockito/README.md +++ b/mockito/README.md @@ -7,3 +7,4 @@ - [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) - [Mockito When/Then Cookbook](http://www.baeldung.com/mockito-behavior) - [Mockito – Using Spies](http://www.baeldung.com/mockito-spy) +- [Mockito – @Mock, @Spy, @Captor and @InjectMocks](http://www.baeldung.com/mockito-annotations) From cfc4d69a88218b4a44db4a52fb2d1c23963c6641 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:44:18 +0200 Subject: [PATCH 215/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 6db2b370f656..9a7c0d3776db 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -11,3 +11,4 @@ - [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list) - [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set) - [Java – Write to File](http://www.baeldung.com/java-write-to-file) +- [Java Scanner](http://www.baeldung.com/java-scanner) From 32f6d8ab6c4776853fd3bc29c5a334fd5bd481ca Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:45:35 +0200 Subject: [PATCH 216/626] Update README.md --- httpclient/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient/README.md b/httpclient/README.md index b9dd431500fe..1cf788287cf5 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -15,3 +15,4 @@ - [HttpClient – Set Custom Header](http://www.baeldung.com/httpclient-custom-http-header) - [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) - [Multipart Upload with HttpClient 4](http://www.baeldung.com/httpclient-multipart-upload) +- [HttpAsyncClient Tutorial](http://www.baeldung.com/httpasyncclient-tutorial) From e2de29e24ba0c8b422d0a4ad9c50658898b10b6e Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:47:00 +0200 Subject: [PATCH 217/626] Update README.md --- core-java-8/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index 9bb6bb811c97..f957b90799aa 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -3,4 +3,5 @@ ## Core Java 8 Cookbooks and Examples ### Relevant Articles: -// - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) +// - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) +// - [Java – Directory Size](http://www.baeldung.com/java-folder-size) From 68aa809456ac772c98b0da813400d346926b9fd8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:47:21 +0200 Subject: [PATCH 218/626] Update README.md --- core-java-8/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index f957b90799aa..e3fa3f98483c 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: // - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) -// - [Java – Directory Size](http://www.baeldung.com/java-folder-size) +- [Java – Directory Size](http://www.baeldung.com/java-folder-size) From a8165f78fece34a7c572208f65497dda37c4473b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:48:14 +0200 Subject: [PATCH 219/626] Update README.md --- core-java-8/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index e3fa3f98483c..f957b90799aa 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: // - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) -- [Java – Directory Size](http://www.baeldung.com/java-folder-size) +// - [Java – Directory Size](http://www.baeldung.com/java-folder-size) From 06f00f1cb166492332794ce4aabd1fd1a7521b33 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:48:29 +0200 Subject: [PATCH 220/626] Update README.md --- core-java-8/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index f957b90799aa..e3fa3f98483c 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: // - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) -// - [Java – Directory Size](http://www.baeldung.com/java-folder-size) +- [Java – Directory Size](http://www.baeldung.com/java-folder-size) From d9f9436f758683edd57b5d54b9b1605c964fc9b8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:50:49 +0200 Subject: [PATCH 221/626] Update README.md --- spring-security-login-and-registration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 1638e8275659..a5a9701ff89c 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -6,7 +6,7 @@ ### Relevant Articles: - [Spring Security Registration Tutorial](http://www.baeldung.com/spring-security-registration) - [The Registration Process With Spring Security](http://www.baeldung.com/registration-with-spring-mvc-and-spring-security) - +- [Registration – Activate a New Account by Email](http://www.baeldung.com/registration-verify-user-by-email) ### Build the Project From d12e115d0bf5cf9736f8aef516c42adbe51a0f28 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:53:05 +0200 Subject: [PATCH 222/626] Update README.md --- jackson/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jackson/README.md b/jackson/README.md index 539cb347615f..bb19fc7f772e 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -4,9 +4,8 @@ ### Relevant Articles: - [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) -- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) +- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) - [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) -- [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) -- [Jackson – Custom Deserializer](http://www.baeldung.com/jackson-deserialization) - - +- [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) +- [Jackson – Custom Deserializer](http://www.baeldung.com/jackson-deserialization) +- [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) From 9877e0008b0f1b7ea2fea271e9c5f661985e86dd Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Mon, 8 Feb 2016 12:54:36 +0200 Subject: [PATCH 223/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index bb19fc7f772e..046c6b6cfb38 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -9,3 +9,4 @@ - [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) - [Jackson – Custom Deserializer](http://www.baeldung.com/jackson-deserialization) - [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) +- [Jackson Date](http://www.baeldung.com/jackson-serialize-dates) From c3ef41a10ddf15cc2e919272334fe666579863da Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 14:00:11 +0100 Subject: [PATCH 224/626] CleanUp and reformatting Code; dependency fix in pom.xml --- RestEasy Example/pom.xml | 175 ++++++++---------- .../baeldung/client/ServicesInterface.java | 15 +- .../main/java/com/baeldung/model/Movie.java | 56 +----- .../com/baeldung/server/MovieCrudService.java | 49 +++-- .../WEB-INF/jboss-deployment-structure.xml | 22 +-- .../src/main/webapp/WEB-INF/web.xml | 14 +- .../baeldung/server/RestEasyClientTest.java | 23 +-- .../com/baeldung/server/movies/batman.json | 2 +- .../baeldung/server/movies/transformer.json | 2 +- 9 files changed, 139 insertions(+), 219 deletions(-) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 9c890da2b75e..ec9e87b0d1e2 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -1,104 +1,77 @@ - - 4.0.0 - - com.baeldung - resteasy-tutorial - 1.0 - war - - - - jboss - http://repository.jboss.org/nexus/content/groups/public/ - - - - - 3.0.14.Final - runtime - - - - RestEasyTutorial - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - - - - org.jboss.resteasy - jaxrs-api - 3.0.12.Final - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-servlet-initializer - ${resteasy.version} - ${resteasy.scope} - - - jboss-jaxrs-api_2.0_spec - org.jboss.spec.javax.ws.rs - - - - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - ${resteasy.scope} - - - - - javax.ws.rs - javax.ws.rs-api - 2.0.1 - - - - org.jboss.resteasy - resteasy-jackson-provider - ${resteasy.version} - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - ${resteasy.scope} - - - - - - junit - junit - 4.4 - - - - commons-io - commons-io - 2.4 - - - + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + 3.0.14.Final + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + + + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + + + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 3c8d6abc00e2..3d03c16fafd4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -9,35 +9,28 @@ @Path("/movies") public interface ServicesInterface { - @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Movie movieByImdbId(@QueryParam("imdbId") String imdbId); - @GET @Path("/listmovies") - @Produces({"application/json"}) + @Produces({ "application/json" }) List listMovies(); - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response addMovie(Movie movie); - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response updateMovie(Movie movie); - @DELETE @Path("/deletemovie") Response deleteMovie(@QueryParam("imdbId") String imdbID); - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 7590f104876e..5aade4591a5f 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -5,28 +5,7 @@ import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { - "actors", - "awards", - "country", - "director", - "genre", - "imdbId", - "imdbRating", - "imdbVotes", - "language", - "metascore", - "plot", - "poster", - "rated", - "released", - "response", - "runtime", - "title", - "type", - "writer", - "year" -}) +@XmlType(name = "movie", propOrder = { "actors", "awards", "country", "director", "genre", "imdbId", "imdbRating", "imdbVotes", "language", "metascore", "plot", "poster", "rated", "released", "response", "runtime", "title", "type", "writer", "year" }) public class Movie { protected String actors; @@ -212,37 +191,22 @@ public void setYear(String value) { @Override public String toString() { - return "Movie{" + - "actors='" + actors + '\'' + - ", awards='" + awards + '\'' + - ", country='" + country + '\'' + - ", director='" + director + '\'' + - ", genre='" + genre + '\'' + - ", imdbId='" + imdbId + '\'' + - ", imdbRating='" + imdbRating + '\'' + - ", imdbVotes='" + imdbVotes + '\'' + - ", language='" + language + '\'' + - ", metascore='" + metascore + '\'' + - ", poster='" + poster + '\'' + - ", rated='" + rated + '\'' + - ", released='" + released + '\'' + - ", response='" + response + '\'' + - ", runtime='" + runtime + '\'' + - ", title='" + title + '\'' + - ", type='" + type + '\'' + - ", writer='" + writer + '\'' + - ", year='" + year + '\'' + - '}'; + return "Movie{" + "actors='" + actors + '\'' + ", awards='" + awards + '\'' + ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + ", metascore='" + metascore + '\'' + ", poster='" + poster + '\'' + ", rated='" + rated + '\'' + ", released='" + released + '\'' + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + ", title='" + title + '\'' + ", type='" + type + '\'' + ", writer='" + writer + '\'' + ", year='" + year + '\'' + '}'; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; Movie movie = (Movie) o; - if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) + return false; return title != null ? title.equals(movie.title) : movie.title == null; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index bbb3b1e9531e..6a0699874a19 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -13,78 +13,71 @@ @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); - + private Map inventory = new HashMap(); @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbId)){ + if (inventory.containsKey(imdbId)) { return inventory.get(imdbId); - }else return null; + } else + return null; } - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response addMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response addMovie(Movie movie) { System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is Already in the database.").build(); + if (null != inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.CREATED).build(); } - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response updateMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response updateMovie(Movie movie) { System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is not in the database.\nUnable to Update").build(); + if (null == inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); } - @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbId){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbId)){ - return Response.status(Response.Status.NOT_FOUND) - .entity("Movie is not in the database.\nUnable to Delete").build(); + if (null == inventory.get(imdbId)) { + return Response.status(Response.Status.NOT_FOUND).entity("Movie is not in the database.\nUnable to Delete").build(); } inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } - @GET @Path("/listmovies") - @Produces({"application/json"}) - public List listMovies(){ + @Produces({ "application/json" }) + public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 84d75934a70c..7879603d19ac 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,16 +1,16 @@ - - - - + + + + - - - - - + + + + + - - + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index 1e7f64004dd0..d5f00293f4e7 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -1,13 +1,13 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - RestEasy Example + RestEasy Example - - resteasy.servlet.mapping.prefix - /rest - + + resteasy.servlet.mapping.prefix + /rest + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index faa39e019992..3760ae241598 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -21,14 +21,14 @@ public class RestEasyClientTest { - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; + Movie transformerMovie = null; + Movie batmanMovie = null; + ObjectMapper jsonMapper = null; @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper = new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); jsonMapper.setDateFormat(sdf); @@ -69,7 +69,7 @@ public void testListAllMovies() { @Test public void testMovieByImdbId() { - String transformerImdbId="tt0418279"; + String transformerImdbId = "tt0418279"; ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); @@ -82,7 +82,6 @@ public void testMovieByImdbId() { System.out.println(movies); } - @Test public void testAddMovie() { @@ -99,10 +98,9 @@ public void testAddMovie() { } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testDeleteMovi1e() { @@ -116,14 +114,13 @@ public void testDeleteMovi1e() { if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testUpdateMovie() { @@ -137,11 +134,11 @@ public void testUpdateMovie() { moviesResponse = simple.updateMovie(batmanMovie); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json index 28061d5bf94d..173901c9483f 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -16,7 +16,7 @@ "metascore": "66", "imdbRating": "7.6", "imdbVotes": "256,000", - "imdbID": "tt0096895", + "imdbId": "tt0096895", "type": "movie", "response": "True" } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index a3b033a8ba6f..a4fd061a82db 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -16,7 +16,7 @@ "metascore": "61", "imdbRating": "7.1", "imdbVotes": "492,225", - "imdbID": "tt0418279", + "imdbId": "tt0418279", "type": "movie", "response": "True" } \ No newline at end of file From d362112a31f1c283556f94f2a470eed1053dbdd6 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 16:08:15 +0100 Subject: [PATCH 225/626] CleanUp and reformatting Code. --- .../src/main/java/com/baeldung/server/MovieCrudService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 6a0699874a19..b7f3215f3ff2 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -26,7 +26,6 @@ public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { return inventory.get(imdbId); } else return null; - } @POST @@ -41,7 +40,6 @@ public Response addMovie(Movie movie) { } inventory.put(movie.getImdbId(), movie); - return Response.status(Response.Status.CREATED).build(); } @@ -55,9 +53,9 @@ public Response updateMovie(Movie movie) { if (null == inventory.get(movie.getImdbId())) { return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); - } @DELETE @@ -80,7 +78,6 @@ public Response deleteMovie(@QueryParam("imdbId") String imdbId) { public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); - } } From ae772727ce8e66289c6e883c22335d17fbdbdc43 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sat, 30 Jan 2016 17:48:56 +0100 Subject: [PATCH 226/626] RestEasy Tutorial, CRUD Services example --- RestEasy Example/pom.xml | 91 +++ .../src/main/java/com/baeldung/Movie.java | 535 ++++++++++++++++++ .../baeldung/client/ServicesInterface.java | 44 ++ .../server/service/MovieCrudService.java | 94 +++ .../server/service/RestEasyServices.java | 40 ++ .../src/main/resources/schema1.xsd | 29 + .../main/webapp/WEB-INF/classes/logback.xml | 3 + .../WEB-INF/jboss-deployment-structure.xml | 16 + .../src/main/webapp/WEB-INF/jboss-web.xml | 4 + .../src/main/webapp/WEB-INF/web.xml | 51 ++ .../com/baeldung/server/RestEasyClient.java | 50 ++ .../resources/server/movies/transformer.json | 22 + 12 files changed, 979 insertions(+) create mode 100644 RestEasy Example/pom.xml create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java create mode 100644 RestEasy Example/src/main/resources/schema1.xsd create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/web.xml create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml new file mode 100644 index 000000000000..b16c5e82678b --- /dev/null +++ b/RestEasy Example/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + + jboss + http://repository.jboss.org/nexus/content/groups/public/ + + + + + 3.0.14.Final + runtime + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + org.jboss.resteasy + jaxrs-api + 3.0.12.Final + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + ${resteasy.scope} + + + jboss-jaxrs-api_2.0_spec + org.jboss.spec.javax.ws.rs + + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + ${resteasy.scope} + + + + + javax.ws.rs + javax.ws.rs-api + 2.0.1 + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + ${resteasy.scope} + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java new file mode 100644 index 000000000000..c0041d2e95d2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java @@ -0,0 +1,535 @@ + +package com.baeldung; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "movie", propOrder = { + "actors", + "awards", + "country", + "director", + "genre", + "imdbID", + "imdbRating", + "imdbVotes", + "language", + "metascore", + "plot", + "poster", + "rated", + "released", + "response", + "runtime", + "title", + "type", + "writer", + "year" +}) +public class Movie { + + protected String actors; + protected String awards; + protected String country; + protected String director; + protected String genre; + protected String imdbID; + protected String imdbRating; + protected String imdbVotes; + protected String language; + protected String metascore; + protected String plot; + protected String poster; + protected String rated; + protected String released; + protected String response; + protected String runtime; + protected String title; + protected String type; + protected String writer; + protected String year; + + /** + * Recupera il valore della propriet� actors. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActors() { + return actors; + } + + /** + * Imposta il valore della propriet� actors. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActors(String value) { + this.actors = value; + } + + /** + * Recupera il valore della propriet� awards. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAwards() { + return awards; + } + + /** + * Imposta il valore della propriet� awards. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAwards(String value) { + this.awards = value; + } + + /** + * Recupera il valore della propriet� country. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Imposta il valore della propriet� country. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Recupera il valore della propriet� director. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDirector() { + return director; + } + + /** + * Imposta il valore della propriet� director. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDirector(String value) { + this.director = value; + } + + /** + * Recupera il valore della propriet� genre. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGenre() { + return genre; + } + + /** + * Imposta il valore della propriet� genre. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenre(String value) { + this.genre = value; + } + + /** + * Recupera il valore della propriet� imdbID. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbID() { + return imdbID; + } + + /** + * Imposta il valore della propriet� imdbID. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbID(String value) { + this.imdbID = value; + } + + /** + * Recupera il valore della propriet� imdbRating. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbRating() { + return imdbRating; + } + + /** + * Imposta il valore della propriet� imdbRating. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbRating(String value) { + this.imdbRating = value; + } + + /** + * Recupera il valore della propriet� imdbVotes. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbVotes() { + return imdbVotes; + } + + /** + * Imposta il valore della propriet� imdbVotes. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbVotes(String value) { + this.imdbVotes = value; + } + + /** + * Recupera il valore della propriet� language. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Imposta il valore della propriet� language. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Recupera il valore della propriet� metascore. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMetascore() { + return metascore; + } + + /** + * Imposta il valore della propriet� metascore. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMetascore(String value) { + this.metascore = value; + } + + /** + * Recupera il valore della propriet� plot. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlot() { + return plot; + } + + /** + * Imposta il valore della propriet� plot. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlot(String value) { + this.plot = value; + } + + /** + * Recupera il valore della propriet� poster. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPoster() { + return poster; + } + + /** + * Imposta il valore della propriet� poster. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPoster(String value) { + this.poster = value; + } + + /** + * Recupera il valore della propriet� rated. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRated() { + return rated; + } + + /** + * Imposta il valore della propriet� rated. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRated(String value) { + this.rated = value; + } + + /** + * Recupera il valore della propriet� released. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReleased() { + return released; + } + + /** + * Imposta il valore della propriet� released. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReleased(String value) { + this.released = value; + } + + /** + * Recupera il valore della propriet� response. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponse() { + return response; + } + + /** + * Imposta il valore della propriet� response. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponse(String value) { + this.response = value; + } + + /** + * Recupera il valore della propriet� runtime. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRuntime() { + return runtime; + } + + /** + * Imposta il valore della propriet� runtime. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRuntime(String value) { + this.runtime = value; + } + + /** + * Recupera il valore della propriet� title. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Imposta il valore della propriet� title. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Recupera il valore della propriet� type. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Imposta il valore della propriet� type. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Recupera il valore della propriet� writer. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWriter() { + return writer; + } + + /** + * Imposta il valore della propriet� writer. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWriter(String value) { + this.writer = value; + } + + /** + * Recupera il valore della propriet� year. + * + * @return + * possible object is + * {@link String } + * + */ + public String getYear() { + return year; + } + + /** + * Imposta il valore della propriet� year. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setYear(String value) { + this.year = value; + } + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java new file mode 100644 index 000000000000..53e88961be34 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -0,0 +1,44 @@ +package com.baeldung.client; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +public interface ServicesInterface { + + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response addMovie(Movie movie); + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response updateMovie(Movie movie); + + + @DELETE + @Path("/deletemovie") + Response deleteMovie(@QueryParam("imdbID") String imdbID); + + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java new file mode 100644 index 000000000000..d1973e703738 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java @@ -0,0 +1,94 @@ +package com.baeldung.server.service; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.Provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Path("/movies") +public class MovieCrudService { + + + private Map inventory = new HashMap(); + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling getinfo ***"); + + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; + } + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response addMovie(Movie movie){ + + System.out.println("*** Calling addMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is Already in the database.").build(); + } + inventory.put(movie.getImdbID(),movie); + + return Response.status(Response.Status.CREATED).build(); + } + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response updateMovie(Movie movie){ + + System.out.println("*** Calling updateMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is not in the database.\nUnable to Update").build(); + } + inventory.put(movie.getImdbID(),movie); + return Response.status(Response.Status.OK).build(); + + } + + + @DELETE + @Path("/deletemovie") + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling deleteMovie ***"); + + if (null==inventory.get(imdbID)){ + return Response.status(Response.Status.NOT_FOUND) + .entity("Movie is not in the database.\nUnable to Delete").build(); + } + + inventory.remove(imdbID); + return Response.status(Response.Status.OK).build(); + } + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + public List listMovies(){ + + return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); + + } + + + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java new file mode 100644 index 000000000000..16b6200ad1f2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java @@ -0,0 +1,40 @@ +package com.baeldung.server.service; + + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by Admin on 29/01/2016. + */ + + + +@ApplicationPath("/rest") +public class RestEasyServices extends Application { + + private Set singletons = new HashSet(); + + public RestEasyServices() { + singletons.add(new MovieCrudService()); + } + + @Override + public Set getSingletons() { + return singletons; + } + + @Override + public Set> getClasses() { + return super.getClasses(); + } + + @Override + public Map getProperties() { + return super.getProperties(); + } +} diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd new file mode 100644 index 000000000000..0d74b7c366bb --- /dev/null +++ b/RestEasy Example/src/main/resources/schema1.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml new file mode 100644 index 000000000000..d94e9f71abbb --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 000000000000..84d75934a70c --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 000000000000..694bb7133232 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..c66d3b56ae77 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + RestEasy Example + + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + + + RestEasy Example + + + webAppRootKey + RestEasyExample + + + + + + resteasy.servlet.mapping.prefix + /rest + + + + + resteasy-servlet + + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher + + + javax.ws.rs.Application + com.baeldung.server.service.RestEasyServices + + + + + resteasy-servlet + /rest/* + + + + + index.html + + + + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java new file mode 100644 index 000000000000..e7112339793b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -0,0 +1,50 @@ +package com.baeldung.server; + +import com.baeldung.Movie; +import com.baeldung.client.ServicesInterface; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import java.util.List; + +public class RestEasyClient { + + public static void main(String[] args) { + + Movie st = new Movie(); + st.setImdbID("12345"); + + /* + * Alternatively you can use this simple String to send + * instead of using a Student instance + * + * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; + */ + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + + /* + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Server response : \n"); + System.out.println(response.readEntity(String.class)); + + response.close(); +*/ + } catch (Exception e) { + + e.printStackTrace(); + + } + } + +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json new file mode 100644 index 000000000000..215486826560 --- /dev/null +++ b/RestEasy Example/src/test/resources/server/movies/transformer.json @@ -0,0 +1,22 @@ +{ + "title": "Transformers", + "year": "2007", + "rated": "PG-13", + "released": "03 Jul 2007", + "runtime": "144 min", + "genre": "Action, Adventure, Sci-Fi", + "director": "Michael Bay", + "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", + "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", + "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", + "language": "English, Spanish", + "country": "USA", + "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", + "metascore": "61", + "imdbRating": "7.1", + "imdbVotes": "492,225", + "imdbID": "tt0418279", + "Type": "movie", + "response": "True" +} \ No newline at end of file From 09c853477edb3a0cb0f4154b6a8c9077f877ae02 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 30 Jan 2016 20:39:28 +0100 Subject: [PATCH 227/626] Added testCase for List All Movies and Add a Movie --- RestEasy Example/pom.xml | 29 +++++ .../baeldung/client/ServicesInterface.java | 6 +- .../java/com/baeldung/{ => model}/Movie.java | 45 +++++++- .../{service => }/MovieCrudService.java | 5 +- .../{service => }/RestEasyServices.java | 2 +- .../com/baeldung/server/RestEasyClient.java | 104 ++++++++++++++---- .../com/baeldung/server/movies/batman.json | 22 ++++ .../baeldung}/server/movies/transformer.json | 2 +- 8 files changed, 184 insertions(+), 31 deletions(-) rename RestEasy Example/src/main/java/com/baeldung/{ => model}/Movie.java (86%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/MovieCrudService.java (96%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/RestEasyServices.java (95%) create mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json rename RestEasy Example/src/test/resources/{ => com/baeldung}/server/movies/transformer.json (99%) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index b16c5e82678b..8dabfc863bc4 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -85,6 +85,35 @@ ${resteasy.scope} + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + com.fasterxml.jackson.core + jackson-core + 2.7.0 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.0 + + + + + diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 53e88961be34..2585c32438ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,15 +1,13 @@ package com.baeldung.client; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - +@Path("/movies") public interface ServicesInterface { diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java similarity index 86% rename from RestEasy Example/src/main/java/com/baeldung/Movie.java rename to RestEasy Example/src/main/java/com/baeldung/model/Movie.java index c0041d2e95d2..052ba081c1a0 100644 --- a/RestEasy Example/src/main/java/com/baeldung/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,5 +1,5 @@ -package com.baeldung; +package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -532,4 +532,47 @@ public void setYear(String value) { this.year = value; } + @Override + public String toString() { + return "Movie{" + + "actors='" + actors + '\'' + + ", awards='" + awards + '\'' + + ", country='" + country + '\'' + + ", director='" + director + '\'' + + ", genre='" + genre + '\'' + + ", imdbID='" + imdbID + '\'' + + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + + ", language='" + language + '\'' + + ", metascore='" + metascore + '\'' + + ", poster='" + poster + '\'' + + ", rated='" + rated + '\'' + + ", released='" + released + '\'' + + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + + ", title='" + title + '\'' + + ", type='" + type + '\'' + + ", writer='" + writer + '\'' + + ", year='" + year + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Movie movie = (Movie) o; + + if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + return title != null ? title.equals(movie.title) : movie.title == null; + + } + + @Override + public int hashCode() { + int result = imdbID != null ? imdbID.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + return result; + } } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java similarity index 96% rename from RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java rename to RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index d1973e703738..60e0121966df 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,11 +1,10 @@ -package com.baeldung.server.service; +package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java similarity index 95% rename from RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java rename to RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 16b6200ad1f2..8c57d2c9b466 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,4 +1,4 @@ -package com.baeldung.server.service; +package com.baeldung.server; import javax.ws.rs.ApplicationPath; diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java index e7112339793b..c77f494862f5 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -1,49 +1,111 @@ package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.List; +import java.util.Locale; public class RestEasyClient { - public static void main(String[] args) { - Movie st = new Movie(); - st.setImdbID("12345"); + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; - /* - * Alternatively you can use this simple String to send - * instead of using a Student instance - * - * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; - */ + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + @Test + public void testListAllMovies() { try { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); - + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + - /* - if (response.getStatus() != 200) { + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final Response moviesResponse = simple.addMovie(batmanMovie); + + if (moviesResponse.getStatus() != 201) { + System.out.println(moviesResponse.readEntity(String.class)); throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); + + moviesResponse.getStatus()); } - System.out.println("Server response : \n"); - System.out.println(response.readEntity(String.class)); + moviesResponse.close(); - response.close(); -*/ } catch (Exception e) { - e.printStackTrace(); - } } diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json new file mode 100644 index 000000000000..28061d5bf94d --- /dev/null +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -0,0 +1,22 @@ +{ + "title": "Batman", + "year": "1989", + "rated": "PG-13", + "released": "23 Jun 1989", + "runtime": "126 min", + "genre": "Action, Adventure", + "director": "Tim Burton", + "writer": "Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)", + "actors": "Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl", + "plot": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.", + "language": "English, French", + "country": "USA, UK", + "awards": "Won 1 Oscar. Another 9 wins & 22 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg", + "metascore": "66", + "imdbRating": "7.6", + "imdbVotes": "256,000", + "imdbID": "tt0096895", + "type": "movie", + "response": "True" +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json similarity index 99% rename from RestEasy Example/src/test/resources/server/movies/transformer.json rename to RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index 215486826560..a3b033a8ba6f 100644 --- a/RestEasy Example/src/test/resources/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -17,6 +17,6 @@ "imdbRating": "7.1", "imdbVotes": "492,225", "imdbID": "tt0418279", - "Type": "movie", + "type": "movie", "response": "True" } \ No newline at end of file From 6263054087798e2bf302a2f72f231616b1c5488e Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 31 Jan 2016 11:05:11 +0100 Subject: [PATCH 228/626] Added testCase for all Services --- RestEasy Example/pom.xml | 15 -- .../baeldung/client/ServicesInterface.java | 10 +- .../com/baeldung/server/MovieCrudService.java | 15 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- .../com/baeldung/server/RestEasyClient.java | 112 ----------- .../baeldung/server/RestEasyClientTest.java | 189 ++++++++++++++++++ 6 files changed, 206 insertions(+), 137 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 8dabfc863bc4..6935238d910f 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -99,21 +99,6 @@ 2.4 - - com.fasterxml.jackson.core - jackson-core - 2.7.0 - - - - com.fasterxml.jackson.core - jackson-annotations - 2.7.0 - - - - - diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 2585c32438ec..7efed546d896 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -17,6 +17,12 @@ public interface ServicesInterface { Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -34,9 +40,5 @@ public interface ServicesInterface { Response deleteMovie(@QueryParam("imdbID") String imdbID); - @GET - @Path("/listmovies") - @Produces({"application/json"}) - List listMovies(); } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 60e0121966df..18366e2faafc 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,18 +18,21 @@ public class MovieCrudService { private Map inventory = new HashMap(); + @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - System.out.println("*** Calling getinfo ***"); + System.out.println("*** Calling getinfo for a given ImdbID***"); + + if(inventory.containsKey(imdbID)){ + return inventory.get(imdbID); + }else return null; - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; } + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -41,6 +44,7 @@ public Response addMovie(Movie movie){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); @@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } @@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){ return Response.status(Response.Status.OK).build(); } + @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index c66d3b56ae77..ab3bc1aa8362 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -33,7 +33,7 @@ javax.ws.rs.Application - com.baeldung.server.service.RestEasyServices + com.baeldung.server.RestEasyServices diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java deleted file mode 100644 index c77f494862f5..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.model.Movie; -import com.baeldung.client.ServicesInterface; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.naming.NamingException; -import javax.ws.rs.core.Link; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class RestEasyClient { - - - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; - - @BeforeClass - public static void loadMovieInventory(){ - - - - } - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - } - - @Test - public void testListAllMovies() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - final List movies = simple.listMovies(); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testAddMovie() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - - ServicesInterface simple = target.proxy(ServicesInterface.class); - final Response moviesResponse = simple.addMovie(batmanMovie); - - if (moviesResponse.getStatus() != 201) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " - + moviesResponse.getStatus()); - } - - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java new file mode 100644 index 000000000000..fb4205bcd79b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -0,0 +1,189 @@ +package com.baeldung.server; + +import com.baeldung.model.Movie; +import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.naming.NamingException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + +public class RestEasyClientTest { + + + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; + + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + + @Test + public void testListAllMovies() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testMovieByImdbID() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + + final Movie movies = simple.movieByImdbID(transformerImdbId); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); + + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testDeleteMovie() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(transformerImdbId); + moviesResponse.close(); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testUpdateMovie() { + + try { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file From c57578dba5d51ed62541518498550b6431b71cf6 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 229/626] Minor Bugfix --- .../baeldung/client/ServicesInterface.java | 4 +- .../main/java/com/baeldung/model/Movie.java | 22 +-- .../com/baeldung/server/MovieCrudService.java | 12 +- .../src/main/webapp/WEB-INF/web.xml | 37 +---- .../java/baeldung/client/RestEasyClient.java | 7 + .../baeldung/server/RestEasyClientTest.java | 149 +++++++----------- 6 files changed, 81 insertions(+), 150 deletions(-) create mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 7efed546d896..749cabc757cf 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -14,7 +14,7 @@ public interface ServicesInterface { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + Movie movieByImdbId(@QueryParam("imdbId") String imdbId); @GET @@ -37,7 +37,7 @@ public interface ServicesInterface { @DELETE @Path("/deletemovie") - Response deleteMovie(@QueryParam("imdbID") String imdbID); + Response deleteMovie(@QueryParam("imdbId") String imdbID); diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index ab3bc1aa8362..f70fdf79751a 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,47 +5,12 @@ RestEasy Example - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - RestEasy Example - - - webAppRootKey - RestEasyExample - - - - + resteasy.servlet.mapping.prefix /rest - - resteasy-servlet - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - javax.ws.rs.Application - com.baeldung.server.RestEasyServices - - - - - resteasy-servlet - /rest/* - - - - - index.html - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java new file mode 100644 index 000000000000..b474b3d4f834 --- /dev/null +++ b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java @@ -0,0 +1,7 @@ +package baeldung.client; + +/** + * Created by Admin on 29/01/2016. + */ +public class RestEasyClient { +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index fb4205bcd79b..b6a2e2a0c108 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -1,7 +1,7 @@ package com.baeldung.server; -import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import com.baeldung.model.Movie; import org.apache.commons.io.IOUtils; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; @@ -9,7 +9,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import javax.naming.NamingException; @@ -23,22 +22,13 @@ public class RestEasyClientTest { - Movie transformerMovie=null; Movie batmanMovie=null; ObjectMapper jsonMapper=null; - @BeforeClass - public static void loadMovieInventory(){ - - - - } - @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); @@ -57,133 +47,102 @@ public void setup() throws ClassNotFoundException, IllegalAccessException, Insta batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); } catch (Exception e) { - e.printStackTrace(); throw new RuntimeException("Test is going to die ...", e); } - } - @Test public void testListAllMovies() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - final List movies = simple.listMovies(); - System.out.println(movies); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); - } catch (Exception e) { - e.printStackTrace(); - } + List movies = simple.listMovies(); + System.out.println(movies); } - @Test - public void testMovieByImdbID() { + public void testMovieByImdbId() { String transformerImdbId="tt0418279"; - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); - final Movie movies = simple.movieByImdbID(transformerImdbId); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } + Movie movies = simple.movieByImdbId(transformerImdbId); + System.out.println(movies); } @Test public void testAddMovie() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test - public void testDeleteMovie() { - - String transformerImdbId="tt0418279"; - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.deleteMovie(transformerImdbId); - moviesResponse.close(); + public void testDeleteMovi1e() { - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test public void testUpdateMovie() { - try { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - batmanMovie.setImdbVotes("300,000"); - moviesResponse = simple.updateMovie(batmanMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } } \ No newline at end of file From 9d3f34d6367e623aac467de603eba275f878e580 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sat, 30 Jan 2016 17:48:56 +0100 Subject: [PATCH 230/626] RestEasy Tutorial, CRUD Services example --- .../src/main/java/com/baeldung/Movie.java | 535 ++++++++++++++++++ .../server/service/MovieCrudService.java | 94 +++ .../server/service/RestEasyServices.java | 40 ++ .../com/baeldung/server/RestEasyClient.java | 50 ++ .../resources/server/movies/transformer.json | 22 + 5 files changed, 741 insertions(+) create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java new file mode 100644 index 000000000000..c0041d2e95d2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java @@ -0,0 +1,535 @@ + +package com.baeldung; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "movie", propOrder = { + "actors", + "awards", + "country", + "director", + "genre", + "imdbID", + "imdbRating", + "imdbVotes", + "language", + "metascore", + "plot", + "poster", + "rated", + "released", + "response", + "runtime", + "title", + "type", + "writer", + "year" +}) +public class Movie { + + protected String actors; + protected String awards; + protected String country; + protected String director; + protected String genre; + protected String imdbID; + protected String imdbRating; + protected String imdbVotes; + protected String language; + protected String metascore; + protected String plot; + protected String poster; + protected String rated; + protected String released; + protected String response; + protected String runtime; + protected String title; + protected String type; + protected String writer; + protected String year; + + /** + * Recupera il valore della propriet� actors. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActors() { + return actors; + } + + /** + * Imposta il valore della propriet� actors. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActors(String value) { + this.actors = value; + } + + /** + * Recupera il valore della propriet� awards. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAwards() { + return awards; + } + + /** + * Imposta il valore della propriet� awards. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAwards(String value) { + this.awards = value; + } + + /** + * Recupera il valore della propriet� country. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Imposta il valore della propriet� country. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Recupera il valore della propriet� director. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDirector() { + return director; + } + + /** + * Imposta il valore della propriet� director. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDirector(String value) { + this.director = value; + } + + /** + * Recupera il valore della propriet� genre. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGenre() { + return genre; + } + + /** + * Imposta il valore della propriet� genre. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenre(String value) { + this.genre = value; + } + + /** + * Recupera il valore della propriet� imdbID. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbID() { + return imdbID; + } + + /** + * Imposta il valore della propriet� imdbID. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbID(String value) { + this.imdbID = value; + } + + /** + * Recupera il valore della propriet� imdbRating. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbRating() { + return imdbRating; + } + + /** + * Imposta il valore della propriet� imdbRating. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbRating(String value) { + this.imdbRating = value; + } + + /** + * Recupera il valore della propriet� imdbVotes. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbVotes() { + return imdbVotes; + } + + /** + * Imposta il valore della propriet� imdbVotes. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbVotes(String value) { + this.imdbVotes = value; + } + + /** + * Recupera il valore della propriet� language. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Imposta il valore della propriet� language. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Recupera il valore della propriet� metascore. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMetascore() { + return metascore; + } + + /** + * Imposta il valore della propriet� metascore. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMetascore(String value) { + this.metascore = value; + } + + /** + * Recupera il valore della propriet� plot. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlot() { + return plot; + } + + /** + * Imposta il valore della propriet� plot. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlot(String value) { + this.plot = value; + } + + /** + * Recupera il valore della propriet� poster. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPoster() { + return poster; + } + + /** + * Imposta il valore della propriet� poster. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPoster(String value) { + this.poster = value; + } + + /** + * Recupera il valore della propriet� rated. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRated() { + return rated; + } + + /** + * Imposta il valore della propriet� rated. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRated(String value) { + this.rated = value; + } + + /** + * Recupera il valore della propriet� released. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReleased() { + return released; + } + + /** + * Imposta il valore della propriet� released. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReleased(String value) { + this.released = value; + } + + /** + * Recupera il valore della propriet� response. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponse() { + return response; + } + + /** + * Imposta il valore della propriet� response. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponse(String value) { + this.response = value; + } + + /** + * Recupera il valore della propriet� runtime. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRuntime() { + return runtime; + } + + /** + * Imposta il valore della propriet� runtime. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRuntime(String value) { + this.runtime = value; + } + + /** + * Recupera il valore della propriet� title. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Imposta il valore della propriet� title. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Recupera il valore della propriet� type. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Imposta il valore della propriet� type. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Recupera il valore della propriet� writer. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWriter() { + return writer; + } + + /** + * Imposta il valore della propriet� writer. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWriter(String value) { + this.writer = value; + } + + /** + * Recupera il valore della propriet� year. + * + * @return + * possible object is + * {@link String } + * + */ + public String getYear() { + return year; + } + + /** + * Imposta il valore della propriet� year. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setYear(String value) { + this.year = value; + } + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java new file mode 100644 index 000000000000..d1973e703738 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java @@ -0,0 +1,94 @@ +package com.baeldung.server.service; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.Provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Path("/movies") +public class MovieCrudService { + + + private Map inventory = new HashMap(); + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling getinfo ***"); + + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; + } + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response addMovie(Movie movie){ + + System.out.println("*** Calling addMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is Already in the database.").build(); + } + inventory.put(movie.getImdbID(),movie); + + return Response.status(Response.Status.CREATED).build(); + } + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response updateMovie(Movie movie){ + + System.out.println("*** Calling updateMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is not in the database.\nUnable to Update").build(); + } + inventory.put(movie.getImdbID(),movie); + return Response.status(Response.Status.OK).build(); + + } + + + @DELETE + @Path("/deletemovie") + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling deleteMovie ***"); + + if (null==inventory.get(imdbID)){ + return Response.status(Response.Status.NOT_FOUND) + .entity("Movie is not in the database.\nUnable to Delete").build(); + } + + inventory.remove(imdbID); + return Response.status(Response.Status.OK).build(); + } + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + public List listMovies(){ + + return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); + + } + + + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java new file mode 100644 index 000000000000..16b6200ad1f2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java @@ -0,0 +1,40 @@ +package com.baeldung.server.service; + + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by Admin on 29/01/2016. + */ + + + +@ApplicationPath("/rest") +public class RestEasyServices extends Application { + + private Set singletons = new HashSet(); + + public RestEasyServices() { + singletons.add(new MovieCrudService()); + } + + @Override + public Set getSingletons() { + return singletons; + } + + @Override + public Set> getClasses() { + return super.getClasses(); + } + + @Override + public Map getProperties() { + return super.getProperties(); + } +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java new file mode 100644 index 000000000000..e7112339793b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -0,0 +1,50 @@ +package com.baeldung.server; + +import com.baeldung.Movie; +import com.baeldung.client.ServicesInterface; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import java.util.List; + +public class RestEasyClient { + + public static void main(String[] args) { + + Movie st = new Movie(); + st.setImdbID("12345"); + + /* + * Alternatively you can use this simple String to send + * instead of using a Student instance + * + * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; + */ + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + + /* + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Server response : \n"); + System.out.println(response.readEntity(String.class)); + + response.close(); +*/ + } catch (Exception e) { + + e.printStackTrace(); + + } + } + +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json new file mode 100644 index 000000000000..215486826560 --- /dev/null +++ b/RestEasy Example/src/test/resources/server/movies/transformer.json @@ -0,0 +1,22 @@ +{ + "title": "Transformers", + "year": "2007", + "rated": "PG-13", + "released": "03 Jul 2007", + "runtime": "144 min", + "genre": "Action, Adventure, Sci-Fi", + "director": "Michael Bay", + "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", + "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", + "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", + "language": "English, Spanish", + "country": "USA", + "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", + "metascore": "61", + "imdbRating": "7.1", + "imdbVotes": "492,225", + "imdbID": "tt0418279", + "Type": "movie", + "response": "True" +} \ No newline at end of file From fa973988fb4b4d6357eac6bcadf1f3ac4143605a Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 30 Jan 2016 20:39:28 +0100 Subject: [PATCH 231/626] Added testCase for List All Movies and Add a Movie --- .../src/main/java/com/baeldung/Movie.java | 535 ------------------ .../main/java/com/baeldung/model/Movie.java | 22 +- .../com/baeldung/server/MovieCrudService.java | 25 +- .../server/service/MovieCrudService.java | 94 --- .../server/service/RestEasyServices.java | 40 -- .../com/baeldung/server/RestEasyClient.java | 104 +++- .../resources/server/movies/transformer.json | 22 - 7 files changed, 104 insertions(+), 738 deletions(-) delete mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java delete mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java delete mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java delete mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java deleted file mode 100644 index c0041d2e95d2..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/Movie.java +++ /dev/null @@ -1,535 +0,0 @@ - -package com.baeldung; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { - "actors", - "awards", - "country", - "director", - "genre", - "imdbID", - "imdbRating", - "imdbVotes", - "language", - "metascore", - "plot", - "poster", - "rated", - "released", - "response", - "runtime", - "title", - "type", - "writer", - "year" -}) -public class Movie { - - protected String actors; - protected String awards; - protected String country; - protected String director; - protected String genre; - protected String imdbID; - protected String imdbRating; - protected String imdbVotes; - protected String language; - protected String metascore; - protected String plot; - protected String poster; - protected String rated; - protected String released; - protected String response; - protected String runtime; - protected String title; - protected String type; - protected String writer; - protected String year; - - /** - * Recupera il valore della propriet� actors. - * - * @return - * possible object is - * {@link String } - * - */ - public String getActors() { - return actors; - } - - /** - * Imposta il valore della propriet� actors. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setActors(String value) { - this.actors = value; - } - - /** - * Recupera il valore della propriet� awards. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAwards() { - return awards; - } - - /** - * Imposta il valore della propriet� awards. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAwards(String value) { - this.awards = value; - } - - /** - * Recupera il valore della propriet� country. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountry() { - return country; - } - - /** - * Imposta il valore della propriet� country. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountry(String value) { - this.country = value; - } - - /** - * Recupera il valore della propriet� director. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDirector() { - return director; - } - - /** - * Imposta il valore della propriet� director. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDirector(String value) { - this.director = value; - } - - /** - * Recupera il valore della propriet� genre. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGenre() { - return genre; - } - - /** - * Imposta il valore della propriet� genre. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGenre(String value) { - this.genre = value; - } - - /** - * Recupera il valore della propriet� imdbID. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbID() { - return imdbID; - } - - /** - * Imposta il valore della propriet� imdbID. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbID(String value) { - this.imdbID = value; - } - - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbRating() { - return imdbRating; - } - - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbRating(String value) { - this.imdbRating = value; - } - - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbVotes() { - return imdbVotes; - } - - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbVotes(String value) { - this.imdbVotes = value; - } - - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ - public String getLanguage() { - return language; - } - - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setLanguage(String value) { - this.language = value; - } - - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMetascore() { - return metascore; - } - - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMetascore(String value) { - this.metascore = value; - } - - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPlot() { - return plot; - } - - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPlot(String value) { - this.plot = value; - } - - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPoster() { - return poster; - } - - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPoster(String value) { - this.poster = value; - } - - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRated() { - return rated; - } - - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRated(String value) { - this.rated = value; - } - - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReleased() { - return released; - } - - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReleased(String value) { - this.released = value; - } - - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ - public String getResponse() { - return response; - } - - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setResponse(String value) { - this.response = value; - } - - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRuntime() { - return runtime; - } - - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRuntime(String value) { - this.runtime = value; - } - - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTitle() { - return title; - } - - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTitle(String value) { - this.title = value; - } - - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ - public String getWriter() { - return writer; - } - - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWriter(String value) { - this.writer = value; - } - - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ - public String getYear() { - return year; - } - - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setYear(String value) { - this.year = value; - } - -} diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index a2b2bd5250d4..052ba081c1a0 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbId", + "imdbID", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbId; + protected String imdbID; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbId. + * Recupera il valore della propriet� imdbID. * * @return * possible object is * {@link String } * */ - public String getImdbId() { - return imdbId; + public String getImdbID() { + return imdbID; } /** - * Imposta il valore della propriet� imdbId. + * Imposta il valore della propriet� imdbID. * * @param value * allowed object is * {@link String } * */ - public void setImdbId(String value) { - this.imdbId = value; + public void setImdbID(String value) { + this.imdbID = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbId='" + imdbId + '\'' + + ", imdbID='" + imdbID + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; + if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbId != null ? imdbId.hashCode() : 0; + int result = imdbID != null ? imdbID.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 29226aa0e094..60e0121966df 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,21 +18,18 @@ public class MovieCrudService { private Map inventory = new HashMap(); - @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ - - System.out.println("*** Calling getinfo for a given ImdbID***"); + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - if(inventory.containsKey(imdbID)){ - return inventory.get(imdbID); - }else return null; + System.out.println("*** Calling getinfo ***"); + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; } - @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -40,12 +37,11 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbId())){ + if (null!=inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +54,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbId())){ + if (null!=inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +66,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbID){ + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ System.out.println("*** Calling deleteMovie ***"); @@ -83,7 +79,6 @@ public Response deleteMovie(@QueryParam("imdbId") String imdbID){ return Response.status(Response.Status.OK).build(); } - @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java deleted file mode 100644 index d1973e703738..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.baeldung.server.service; - -import com.baeldung.Movie; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - - -@Path("/movies") -public class MovieCrudService { - - - private Map inventory = new HashMap(); - - @GET - @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - - System.out.println("*** Calling getinfo ***"); - - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; - } - - @POST - @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response addMovie(Movie movie){ - - System.out.println("*** Calling addMovie ***"); - - if (null!=inventory.get(movie.getImdbID())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is Already in the database.").build(); - } - inventory.put(movie.getImdbID(),movie); - - return Response.status(Response.Status.CREATED).build(); - } - - - @PUT - @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response updateMovie(Movie movie){ - - System.out.println("*** Calling updateMovie ***"); - - if (null!=inventory.get(movie.getImdbID())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is not in the database.\nUnable to Update").build(); - } - inventory.put(movie.getImdbID(),movie); - return Response.status(Response.Status.OK).build(); - - } - - - @DELETE - @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ - - System.out.println("*** Calling deleteMovie ***"); - - if (null==inventory.get(imdbID)){ - return Response.status(Response.Status.NOT_FOUND) - .entity("Movie is not in the database.\nUnable to Delete").build(); - } - - inventory.remove(imdbID); - return Response.status(Response.Status.OK).build(); - } - - @GET - @Path("/listmovies") - @Produces({"application/json"}) - public List listMovies(){ - - return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); - - } - - - -} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java deleted file mode 100644 index 16b6200ad1f2..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.server.service; - - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Created by Admin on 29/01/2016. - */ - - - -@ApplicationPath("/rest") -public class RestEasyServices extends Application { - - private Set singletons = new HashSet(); - - public RestEasyServices() { - singletons.add(new MovieCrudService()); - } - - @Override - public Set getSingletons() { - return singletons; - } - - @Override - public Set> getClasses() { - return super.getClasses(); - } - - @Override - public Map getProperties() { - return super.getProperties(); - } -} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java index e7112339793b..c77f494862f5 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -1,49 +1,111 @@ package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.List; +import java.util.Locale; public class RestEasyClient { - public static void main(String[] args) { - Movie st = new Movie(); - st.setImdbID("12345"); + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; - /* - * Alternatively you can use this simple String to send - * instead of using a Student instance - * - * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; - */ + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + @Test + public void testListAllMovies() { try { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); - + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + - /* - if (response.getStatus() != 200) { + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final Response moviesResponse = simple.addMovie(batmanMovie); + + if (moviesResponse.getStatus() != 201) { + System.out.println(moviesResponse.readEntity(String.class)); throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); + + moviesResponse.getStatus()); } - System.out.println("Server response : \n"); - System.out.println(response.readEntity(String.class)); + moviesResponse.close(); - response.close(); -*/ } catch (Exception e) { - e.printStackTrace(); - } } diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json deleted file mode 100644 index 215486826560..000000000000 --- a/RestEasy Example/src/test/resources/server/movies/transformer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "Transformers", - "year": "2007", - "rated": "PG-13", - "released": "03 Jul 2007", - "runtime": "144 min", - "genre": "Action, Adventure, Sci-Fi", - "director": "Michael Bay", - "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", - "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", - "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", - "language": "English, Spanish", - "country": "USA", - "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", - "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", - "metascore": "61", - "imdbRating": "7.1", - "imdbVotes": "492,225", - "imdbID": "tt0418279", - "Type": "movie", - "response": "True" -} \ No newline at end of file From 913f2908e0468550647ac32d61db4da23d7093a3 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 31 Jan 2016 11:05:11 +0100 Subject: [PATCH 232/626] Added testCase for all Services --- .../baeldung/client/ServicesInterface.java | 6 + .../com/baeldung/server/MovieCrudService.java | 15 ++- .../com/baeldung/server/RestEasyClient.java | 112 ------------------ 3 files changed, 16 insertions(+), 117 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 749cabc757cf..8898b834838b 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -23,6 +23,12 @@ public interface ServicesInterface { List listMovies(); + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 60e0121966df..18366e2faafc 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,18 +18,21 @@ public class MovieCrudService { private Map inventory = new HashMap(); + @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - System.out.println("*** Calling getinfo ***"); + System.out.println("*** Calling getinfo for a given ImdbID***"); + + if(inventory.containsKey(imdbID)){ + return inventory.get(imdbID); + }else return null; - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; } + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -41,6 +44,7 @@ public Response addMovie(Movie movie){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); @@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } @@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){ return Response.status(Response.Status.OK).build(); } + @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java deleted file mode 100644 index c77f494862f5..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.model.Movie; -import com.baeldung.client.ServicesInterface; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.naming.NamingException; -import javax.ws.rs.core.Link; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class RestEasyClient { - - - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; - - @BeforeClass - public static void loadMovieInventory(){ - - - - } - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - } - - @Test - public void testListAllMovies() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - final List movies = simple.listMovies(); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testAddMovie() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - - ServicesInterface simple = target.proxy(ServicesInterface.class); - final Response moviesResponse = simple.addMovie(batmanMovie); - - if (moviesResponse.getStatus() != 201) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " - + moviesResponse.getStatus()); - } - - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file From 929a7d7483b6361f28ec19e8513ed7468f2686e8 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 233/626] Minor Bugfix --- .../baeldung/client/ServicesInterface.java | 6 ----- .../main/java/com/baeldung/model/Movie.java | 22 +++++++++---------- .../com/baeldung/server/MovieCrudService.java | 12 +++++----- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 8898b834838b..749cabc757cf 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -23,12 +23,6 @@ public interface ServicesInterface { List listMovies(); - @GET - @Path("/listmovies") - @Produces({"application/json"}) - List listMovies(); - - @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); From bcad6811a346b82cb38c1a6cbe5d8fc7408450b8 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:39:35 +0100 Subject: [PATCH 234/626] Minor Bugfix --- .../main/java/com/baeldung/model/Movie.java | 321 +----------------- 1 file changed, 1 insertion(+), 320 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index a2b2bd5250d4..805ba95209ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -52,482 +52,163 @@ public class Movie { protected String writer; protected String year; - /** - * Recupera il valore della propriet� actors. - * - * @return - * possible object is - * {@link String } - * - */ + public String getActors() { return actors; } - /** - * Imposta il valore della propriet� actors. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setActors(String value) { this.actors = value; } - /** - * Recupera il valore della propriet� awards. - * - * @return - * possible object is - * {@link String } - * - */ public String getAwards() { return awards; } - /** - * Imposta il valore della propriet� awards. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setAwards(String value) { this.awards = value; } - /** - * Recupera il valore della propriet� country. - * - * @return - * possible object is - * {@link String } - * - */ public String getCountry() { return country; } - /** - * Imposta il valore della propriet� country. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setCountry(String value) { this.country = value; } - /** - * Recupera il valore della propriet� director. - * - * @return - * possible object is - * {@link String } - * - */ public String getDirector() { return director; } - /** - * Imposta il valore della propriet� director. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setDirector(String value) { this.director = value; } - /** - * Recupera il valore della propriet� genre. - * - * @return - * possible object is - * {@link String } - * - */ public String getGenre() { return genre; } - /** - * Imposta il valore della propriet� genre. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setGenre(String value) { this.genre = value; } - /** - * Recupera il valore della propriet� imdbId. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbId() { return imdbId; } - /** - * Imposta il valore della propriet� imdbId. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbId(String value) { this.imdbId = value; } - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbRating() { return imdbRating; } - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbRating(String value) { this.imdbRating = value; } - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbVotes() { return imdbVotes; } - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbVotes(String value) { this.imdbVotes = value; } - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ public String getLanguage() { return language; } - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setLanguage(String value) { this.language = value; } - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ public String getMetascore() { return metascore; } - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setMetascore(String value) { this.metascore = value; } - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ public String getPlot() { return plot; } - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPlot(String value) { this.plot = value; } - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ public String getPoster() { return poster; } - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPoster(String value) { this.poster = value; } - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ public String getRated() { return rated; } - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRated(String value) { this.rated = value; } - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ public String getReleased() { return released; } - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setReleased(String value) { this.released = value; } - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ public String getResponse() { return response; } - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setResponse(String value) { this.response = value; } - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ public String getRuntime() { return runtime; } - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRuntime(String value) { this.runtime = value; } - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ public String getTitle() { return title; } - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setTitle(String value) { this.title = value; } - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ public String getType() { return type; } - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setType(String value) { this.type = value; } - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ public String getWriter() { return writer; } - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setWriter(String value) { this.writer = value; } - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ public String getYear() { return year; } - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setYear(String value) { this.year = value; } From 31fbff34eb181c3898691c778920db10e8ffa18b Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:55:46 +0100 Subject: [PATCH 235/626] CleanUp Code --- RestEasy Example/pom.xml | 3 +- .../baeldung/client/ServicesInterface.java | 1 - .../main/java/com/baeldung/model/Movie.java | 2 -- .../com/baeldung/server/MovieCrudService.java | 17 ++++------- .../com/baeldung/server/RestEasyServices.java | 8 ----- .../src/main/resources/schema1.xsd | 29 ------------------- .../src/main/webapp/WEB-INF/web.xml | 3 -- .../java/baeldung/client/RestEasyClient.java | 7 ----- .../baeldung/server/RestEasyClientTest.java | 1 - 9 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 RestEasy Example/src/main/resources/schema1.xsd delete mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 6935238d910f..9c890da2b75e 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -36,7 +36,7 @@ - + org.jboss.resteasy jaxrs-api @@ -101,5 +101,4 @@ - \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 749cabc757cf..3c8d6abc00e2 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,7 +1,6 @@ package com.baeldung.client; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 805ba95209ec..56ba766ff401 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,11 +1,9 @@ - package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; - @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "movie", propOrder = { "actors", diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 29226aa0e094..bbb3b1e9531e 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,7 +1,6 @@ package com.baeldung.server; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -11,23 +10,21 @@ import java.util.Map; import java.util.stream.Collectors; - @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbID)){ - return inventory.get(imdbID); + if(inventory.containsKey(imdbId)){ + return inventory.get(imdbId); }else return null; } @@ -70,16 +67,16 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbID)){ + if (null==inventory.get(imdbId)){ return Response.status(Response.Status.NOT_FOUND) .entity("Movie is not in the database.\nUnable to Delete").build(); } - inventory.remove(imdbID); + inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } @@ -93,6 +90,4 @@ public List listMovies(){ } - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 8c57d2c9b466..7726e49f3830 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,19 +1,11 @@ package com.baeldung.server; - import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Set; -/** - * Created by Admin on 29/01/2016. - */ - - - @ApplicationPath("/rest") public class RestEasyServices extends Application { diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd deleted file mode 100644 index 0d74b7c366bb..000000000000 --- a/RestEasy Example/src/main/resources/schema1.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index f70fdf79751a..1e7f64004dd0 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,12 +5,9 @@ RestEasy Example - resteasy.servlet.mapping.prefix /rest - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java deleted file mode 100644 index b474b3d4f834..000000000000 --- a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java +++ /dev/null @@ -1,7 +0,0 @@ -package baeldung.client; - -/** - * Created by Admin on 29/01/2016. - */ -public class RestEasyClient { -} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index b6a2e2a0c108..faa39e019992 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -10,7 +10,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; import org.junit.Test; - import javax.naming.NamingException; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; From 37acdef2a7bbe867416c1e1208cd93a068cd5bbc Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 14:00:11 +0100 Subject: [PATCH 236/626] CleanUp and reformatting Code; dependency fix in pom.xml --- RestEasy Example/pom.xml | 175 ++++++++---------- .../baeldung/client/ServicesInterface.java | 15 +- .../main/java/com/baeldung/model/Movie.java | 56 +----- .../com/baeldung/server/MovieCrudService.java | 49 +++-- .../WEB-INF/jboss-deployment-structure.xml | 22 +-- .../src/main/webapp/WEB-INF/web.xml | 14 +- .../baeldung/server/RestEasyClientTest.java | 23 +-- .../com/baeldung/server/movies/batman.json | 2 +- .../baeldung/server/movies/transformer.json | 2 +- 9 files changed, 139 insertions(+), 219 deletions(-) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 9c890da2b75e..ec9e87b0d1e2 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -1,104 +1,77 @@ - - 4.0.0 - - com.baeldung - resteasy-tutorial - 1.0 - war - - - - jboss - http://repository.jboss.org/nexus/content/groups/public/ - - - - - 3.0.14.Final - runtime - - - - RestEasyTutorial - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - - - - org.jboss.resteasy - jaxrs-api - 3.0.12.Final - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-servlet-initializer - ${resteasy.version} - ${resteasy.scope} - - - jboss-jaxrs-api_2.0_spec - org.jboss.spec.javax.ws.rs - - - - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - ${resteasy.scope} - - - - - javax.ws.rs - javax.ws.rs-api - 2.0.1 - - - - org.jboss.resteasy - resteasy-jackson-provider - ${resteasy.version} - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - ${resteasy.scope} - - - - - - junit - junit - 4.4 - - - - commons-io - commons-io - 2.4 - - - + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + 3.0.14.Final + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + + + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + + + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 3c8d6abc00e2..3d03c16fafd4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -9,35 +9,28 @@ @Path("/movies") public interface ServicesInterface { - @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Movie movieByImdbId(@QueryParam("imdbId") String imdbId); - @GET @Path("/listmovies") - @Produces({"application/json"}) + @Produces({ "application/json" }) List listMovies(); - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response addMovie(Movie movie); - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response updateMovie(Movie movie); - @DELETE @Path("/deletemovie") Response deleteMovie(@QueryParam("imdbId") String imdbID); - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 56ba766ff401..a959682a75e5 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -5,28 +5,7 @@ import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { - "actors", - "awards", - "country", - "director", - "genre", - "imdbId", - "imdbRating", - "imdbVotes", - "language", - "metascore", - "plot", - "poster", - "rated", - "released", - "response", - "runtime", - "title", - "type", - "writer", - "year" -}) +@XmlType(name = "movie", propOrder = { "actors", "awards", "country", "director", "genre", "imdbId", "imdbRating", "imdbVotes", "language", "metascore", "plot", "poster", "rated", "released", "response", "runtime", "title", "type", "writer", "year" }) public class Movie { protected String actors; @@ -213,37 +192,22 @@ public void setYear(String value) { @Override public String toString() { - return "Movie{" + - "actors='" + actors + '\'' + - ", awards='" + awards + '\'' + - ", country='" + country + '\'' + - ", director='" + director + '\'' + - ", genre='" + genre + '\'' + - ", imdbId='" + imdbId + '\'' + - ", imdbRating='" + imdbRating + '\'' + - ", imdbVotes='" + imdbVotes + '\'' + - ", language='" + language + '\'' + - ", metascore='" + metascore + '\'' + - ", poster='" + poster + '\'' + - ", rated='" + rated + '\'' + - ", released='" + released + '\'' + - ", response='" + response + '\'' + - ", runtime='" + runtime + '\'' + - ", title='" + title + '\'' + - ", type='" + type + '\'' + - ", writer='" + writer + '\'' + - ", year='" + year + '\'' + - '}'; + return "Movie{" + "actors='" + actors + '\'' + ", awards='" + awards + '\'' + ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + ", metascore='" + metascore + '\'' + ", poster='" + poster + '\'' + ", rated='" + rated + '\'' + ", released='" + released + '\'' + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + ", title='" + title + '\'' + ", type='" + type + '\'' + ", writer='" + writer + '\'' + ", year='" + year + '\'' + '}'; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; Movie movie = (Movie) o; - if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) + return false; return title != null ? title.equals(movie.title) : movie.title == null; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index bbb3b1e9531e..6a0699874a19 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -13,78 +13,71 @@ @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); - + private Map inventory = new HashMap(); @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbId)){ + if (inventory.containsKey(imdbId)) { return inventory.get(imdbId); - }else return null; + } else + return null; } - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response addMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response addMovie(Movie movie) { System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is Already in the database.").build(); + if (null != inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.CREATED).build(); } - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response updateMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response updateMovie(Movie movie) { System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is not in the database.\nUnable to Update").build(); + if (null == inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); } - @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbId){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbId)){ - return Response.status(Response.Status.NOT_FOUND) - .entity("Movie is not in the database.\nUnable to Delete").build(); + if (null == inventory.get(imdbId)) { + return Response.status(Response.Status.NOT_FOUND).entity("Movie is not in the database.\nUnable to Delete").build(); } inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } - @GET @Path("/listmovies") - @Produces({"application/json"}) - public List listMovies(){ + @Produces({ "application/json" }) + public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 84d75934a70c..7879603d19ac 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,16 +1,16 @@ - - - - + + + + - - - - - + + + + + - - + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index 1e7f64004dd0..d5f00293f4e7 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -1,13 +1,13 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - RestEasy Example + RestEasy Example - - resteasy.servlet.mapping.prefix - /rest - + + resteasy.servlet.mapping.prefix + /rest + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index faa39e019992..3760ae241598 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -21,14 +21,14 @@ public class RestEasyClientTest { - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; + Movie transformerMovie = null; + Movie batmanMovie = null; + ObjectMapper jsonMapper = null; @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper = new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); jsonMapper.setDateFormat(sdf); @@ -69,7 +69,7 @@ public void testListAllMovies() { @Test public void testMovieByImdbId() { - String transformerImdbId="tt0418279"; + String transformerImdbId = "tt0418279"; ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); @@ -82,7 +82,6 @@ public void testMovieByImdbId() { System.out.println(movies); } - @Test public void testAddMovie() { @@ -99,10 +98,9 @@ public void testAddMovie() { } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testDeleteMovi1e() { @@ -116,14 +114,13 @@ public void testDeleteMovi1e() { if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testUpdateMovie() { @@ -137,11 +134,11 @@ public void testUpdateMovie() { moviesResponse = simple.updateMovie(batmanMovie); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json index 28061d5bf94d..173901c9483f 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -16,7 +16,7 @@ "metascore": "66", "imdbRating": "7.6", "imdbVotes": "256,000", - "imdbID": "tt0096895", + "imdbId": "tt0096895", "type": "movie", "response": "True" } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index a3b033a8ba6f..a4fd061a82db 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -16,7 +16,7 @@ "metascore": "61", "imdbRating": "7.1", "imdbVotes": "492,225", - "imdbID": "tt0418279", + "imdbId": "tt0418279", "type": "movie", "response": "True" } \ No newline at end of file From 06bbf19265938d444d07841989397369cf01d3fd Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 16:08:15 +0100 Subject: [PATCH 237/626] CleanUp and reformatting Code. --- .../src/main/java/com/baeldung/server/MovieCrudService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 6a0699874a19..b7f3215f3ff2 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -26,7 +26,6 @@ public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { return inventory.get(imdbId); } else return null; - } @POST @@ -41,7 +40,6 @@ public Response addMovie(Movie movie) { } inventory.put(movie.getImdbId(), movie); - return Response.status(Response.Status.CREATED).build(); } @@ -55,9 +53,9 @@ public Response updateMovie(Movie movie) { if (null == inventory.get(movie.getImdbId())) { return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); - } @DELETE @@ -80,7 +78,6 @@ public Response deleteMovie(@QueryParam("imdbId") String imdbId) { public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); - } } From 420cbb202b3d101b10ea1b4eb9f8784ede50f112 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:27:46 +0200 Subject: [PATCH 238/626] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 9a7c0d3776db..23fe12465ff4 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -12,3 +12,4 @@ - [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set) - [Java – Write to File](http://www.baeldung.com/java-write-to-file) - [Java Scanner](http://www.baeldung.com/java-scanner) +- [Java Timer](http://www.baeldung.com/java-timer-and-timertask) From 0757706c4718548c8031ef97be8c702196689977 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:30:27 +0200 Subject: [PATCH 239/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index 046c6b6cfb38..d49ad9088a03 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -10,3 +10,4 @@ - [Jackson – Custom Deserializer](http://www.baeldung.com/jackson-deserialization) - [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) - [Jackson Date](http://www.baeldung.com/jackson-serialize-dates) +- [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) From 86157e6beeb25cd85221038fbeb7291b48127aef Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:31:59 +0200 Subject: [PATCH 240/626] Update README.md --- spring-security-login-and-registration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index a5a9701ff89c..57e7fd28f030 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -7,7 +7,7 @@ - [Spring Security Registration Tutorial](http://www.baeldung.com/spring-security-registration) - [The Registration Process With Spring Security](http://www.baeldung.com/registration-with-spring-mvc-and-spring-security) - [Registration – Activate a New Account by Email](http://www.baeldung.com/registration-verify-user-by-email) - +- [Registration with Spring Security – Password Encoding](http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt) ### Build the Project ``` From 58d169cd241c998618969c2ead01eac5b2262ee9 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:33:43 +0200 Subject: [PATCH 241/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 57e7fd28f030..299d096c374a 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -8,6 +8,7 @@ - [The Registration Process With Spring Security](http://www.baeldung.com/registration-with-spring-mvc-and-spring-security) - [Registration – Activate a New Account by Email](http://www.baeldung.com/registration-verify-user-by-email) - [Registration with Spring Security – Password Encoding](http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt) +- [Spring Security – Roles and Privileges](http://www.baeldung.com/role-and-privilege-for-spring-security-registration) ### Build the Project ``` From d806fa3925b681e4e81a74de4a27dc093d267806 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:35:18 +0200 Subject: [PATCH 242/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index cffbcf40f086..64478589a312 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -13,6 +13,7 @@ - [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/2011/10/16/how-to-set-up-integration-testing-with-the-maven-cargo-plugin/) - [Introduction to Spring Data JPA](http://www.baeldung.com/2011/12/22/the-persistence-layer-with-spring-data-jpa/) - [Project Configuration with Spring](http://www.baeldung.com/2012/03/12/project-configuration-with-spring/) +- [REST Query Language with Spring and JPA Criteria](http://www.baeldung.com/rest-search-language-spring-jpa-criteria) ### Build the Project From ad0dd95004b88106744065cf68c28770433466bf Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:38:17 +0200 Subject: [PATCH 243/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 64478589a312..c5f52f44adca 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -14,6 +14,7 @@ - [Introduction to Spring Data JPA](http://www.baeldung.com/2011/12/22/the-persistence-layer-with-spring-data-jpa/) - [Project Configuration with Spring](http://www.baeldung.com/2012/03/12/project-configuration-with-spring/) - [REST Query Language with Spring and JPA Criteria](http://www.baeldung.com/rest-search-language-spring-jpa-criteria) +- [REST Query Language with Spring Data JPA Specifications](http://www.baeldung.com/rest-api-search-language-spring-data-specifications) ### Build the Project From 00ecb8c947a542eba055e214e3cda4d17a43c903 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:43:43 +0200 Subject: [PATCH 244/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index c5f52f44adca..e2db0e030730 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -15,6 +15,7 @@ - [Project Configuration with Spring](http://www.baeldung.com/2012/03/12/project-configuration-with-spring/) - [REST Query Language with Spring and JPA Criteria](http://www.baeldung.com/rest-search-language-spring-jpa-criteria) - [REST Query Language with Spring Data JPA Specifications](http://www.baeldung.com/rest-api-search-language-spring-data-specifications) +- [REST Query Language with Spring Data JPA and QueryDSL](http://www.baeldung.com/rest-api-search-language-spring-data-querydsl) ### Build the Project From 2bad287a2eee1acd22deaf9b6ef5c00d08a6d149 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 9 Feb 2016 14:44:49 +0200 Subject: [PATCH 245/626] Update README.md --- spring-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-jpa/README.md b/spring-jpa/README.md index da55ca7b7549..f974c6e22cc2 100644 --- a/spring-jpa/README.md +++ b/spring-jpa/README.md @@ -9,3 +9,4 @@ - [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa) - [JPA Pagination](http://www.baeldung.com/jpa-pagination) - [Sorting with JPA](http://www.baeldung.com/jpa-sort) +- [Spring JPA – Multiple Databases](http://www.baeldung.com/spring-data-jpa-multiple-databases) From 5d896c28d386e6f86783dac649f0ba10fd1d54ff Mon Sep 17 00:00:00 2001 From: David Morley Date: Wed, 10 Feb 2016 05:14:57 -0600 Subject: [PATCH 246/626] Clean up Guava 19 examples --- .../test/java/com/baeldung/guava/GuavaMiscUtilsTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/guava19/src/test/java/com/baeldung/guava/GuavaMiscUtilsTest.java b/guava19/src/test/java/com/baeldung/guava/GuavaMiscUtilsTest.java index 903381bd29fa..c7b8441b7819 100644 --- a/guava19/src/test/java/com/baeldung/guava/GuavaMiscUtilsTest.java +++ b/guava19/src/test/java/com/baeldung/guava/GuavaMiscUtilsTest.java @@ -1,16 +1,9 @@ package com.baeldung.guava; -import com.baeldung.guava.entity.User; -import com.google.common.base.CharMatcher; import com.google.common.base.Throwables; import com.google.common.collect.*; -import com.google.common.hash.HashCode; -import com.google.common.hash.HashFunction; -import com.google.common.hash.Hashing; -import com.google.common.reflect.TypeToken; import org.junit.Test; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; From ed0c9aca109f02ea1e68db24df642578c67dc501 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:33:35 +0200 Subject: [PATCH 247/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 299d096c374a..7235ef3bf6e6 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -9,6 +9,7 @@ - [Registration – Activate a New Account by Email](http://www.baeldung.com/registration-verify-user-by-email) - [Registration with Spring Security – Password Encoding](http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt) - [Spring Security – Roles and Privileges](http://www.baeldung.com/role-and-privilege-for-spring-security-registration) +- [Prevent Brute Force Authentication Attempts with Spring Security](http://www.baeldung.com/spring-security-block-brute-force-authentication-attempts) ### Build the Project ``` From 855c8b153ca209f171750f069bf007ecb520b803 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:34:34 +0200 Subject: [PATCH 248/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 7235ef3bf6e6..8f47992c1d62 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -10,6 +10,7 @@ - [Registration with Spring Security – Password Encoding](http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt) - [Spring Security – Roles and Privileges](http://www.baeldung.com/role-and-privilege-for-spring-security-registration) - [Prevent Brute Force Authentication Attempts with Spring Security](http://www.baeldung.com/spring-security-block-brute-force-authentication-attempts) +- [Spring Security – Reset Your Password](http://www.baeldung.com/spring-security-registration-i-forgot-my-password) ### Build the Project ``` From 32373392a952a6c5bdb72fbc5754202889e4962c Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:35:55 +0200 Subject: [PATCH 249/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index e2db0e030730..3df3947d5edf 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -16,6 +16,7 @@ - [REST Query Language with Spring and JPA Criteria](http://www.baeldung.com/rest-search-language-spring-jpa-criteria) - [REST Query Language with Spring Data JPA Specifications](http://www.baeldung.com/rest-api-search-language-spring-data-specifications) - [REST Query Language with Spring Data JPA and QueryDSL](http://www.baeldung.com/rest-api-search-language-spring-data-querydsl) +- [REST Query Language – Advanced Search Operations](http://www.baeldung.com/rest-api-query-search-language-more-operations) ### Build the Project From bf6519b860da52ed8491c7bddeb7cc2d7d684dab Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:37:24 +0200 Subject: [PATCH 250/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 8f47992c1d62..5b1980dcbf91 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -11,6 +11,7 @@ - [Spring Security – Roles and Privileges](http://www.baeldung.com/role-and-privilege-for-spring-security-registration) - [Prevent Brute Force Authentication Attempts with Spring Security](http://www.baeldung.com/spring-security-block-brute-force-authentication-attempts) - [Spring Security – Reset Your Password](http://www.baeldung.com/spring-security-registration-i-forgot-my-password) +- [Spring Security Registration – Resend Verification Email](http://www.baeldung.com/spring-security-registration-verification-email) ### Build the Project ``` From e051f36401d19a16a0b36af987807a9f48140a22 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:41:29 +0200 Subject: [PATCH 251/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index 5b1980dcbf91..ee565dca651c 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -12,6 +12,7 @@ - [Prevent Brute Force Authentication Attempts with Spring Security](http://www.baeldung.com/spring-security-block-brute-force-authentication-attempts) - [Spring Security – Reset Your Password](http://www.baeldung.com/spring-security-registration-i-forgot-my-password) - [Spring Security Registration – Resend Verification Email](http://www.baeldung.com/spring-security-registration-verification-email) +- [The Registration API becomes RESTful](http://www.baeldung.com/registration-restful-api) ### Build the Project ``` From 24a8e3803ce097e584b2b1c46f7ff4b497ce4912 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:42:54 +0200 Subject: [PATCH 252/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 3df3947d5edf..6b56f4b918b7 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -17,6 +17,7 @@ - [REST Query Language with Spring Data JPA Specifications](http://www.baeldung.com/rest-api-search-language-spring-data-specifications) - [REST Query Language with Spring Data JPA and QueryDSL](http://www.baeldung.com/rest-api-search-language-spring-data-querydsl) - [REST Query Language – Advanced Search Operations](http://www.baeldung.com/rest-api-query-search-language-more-operations) +- [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) ### Build the Project From 6b0d2165ce7c67a1d367c825dde605e2e121b78a Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:44:08 +0200 Subject: [PATCH 253/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index ee565dca651c..e1b3e61accab 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -13,6 +13,7 @@ - [Spring Security – Reset Your Password](http://www.baeldung.com/spring-security-registration-i-forgot-my-password) - [Spring Security Registration – Resend Verification Email](http://www.baeldung.com/spring-security-registration-verification-email) - [The Registration API becomes RESTful](http://www.baeldung.com/registration-restful-api) +- [Registration – Password Strength and Rules](http://www.baeldung.com/registration-password-strength-and-rules) ### Build the Project ``` From 11065cd00481cc472e9144a4274e7400a3ad53ab Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:45:30 +0200 Subject: [PATCH 254/626] Update README.md --- spring-security-login-and-registration/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-login-and-registration/README.md b/spring-security-login-and-registration/README.md index e1b3e61accab..07fb21bfff66 100644 --- a/spring-security-login-and-registration/README.md +++ b/spring-security-login-and-registration/README.md @@ -14,6 +14,7 @@ - [Spring Security Registration – Resend Verification Email](http://www.baeldung.com/spring-security-registration-verification-email) - [The Registration API becomes RESTful](http://www.baeldung.com/registration-restful-api) - [Registration – Password Strength and Rules](http://www.baeldung.com/registration-password-strength-and-rules) +- [Updating your Password](http://www.baeldung.com/updating-your-password/) ### Build the Project ``` From 95f51e577bc80b8cafe200d2d9ff5b9732eb9566 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:46:41 +0200 Subject: [PATCH 255/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 6b56f4b918b7..b592f7558cad 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -18,6 +18,7 @@ - [REST Query Language with Spring Data JPA and QueryDSL](http://www.baeldung.com/rest-api-search-language-spring-data-querydsl) - [REST Query Language – Advanced Search Operations](http://www.baeldung.com/rest-api-query-search-language-more-operations) - [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) +- [REST Query Language with RSQL](http://www.baeldung.com/rest-api-search-language-rsql-fiql) ### Build the Project From 9f3be320b49901d8900cab69d010f50346e579c4 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:47:44 +0200 Subject: [PATCH 256/626] Update README.md --- httpclient/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient/README.md b/httpclient/README.md index 1cf788287cf5..e06c57da7115 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -16,3 +16,4 @@ - [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) - [Multipart Upload with HttpClient 4](http://www.baeldung.com/httpclient-multipart-upload) - [HttpAsyncClient Tutorial](http://www.baeldung.com/httpasyncclient-tutorial) +- [HttpClient 4 Tutorial](http://www.baeldung.com/httpclient-guide) From ac96fae1a7bd262e77ae1e51b650ad2115bf35a3 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:50:01 +0200 Subject: [PATCH 257/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index d49ad9088a03..c17d89912f11 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -11,3 +11,4 @@ - [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) - [Jackson Date](http://www.baeldung.com/jackson-serialize-dates) - [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) +- [Jackson JSON Tutorial](http://www.baeldung.com/jackson) From dbaf47927008cf4fb467d93a66b55982df354083 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:50:52 +0200 Subject: [PATCH 258/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index c17d89912f11..cd089263866e 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -12,3 +12,4 @@ - [Jackson Date](http://www.baeldung.com/jackson-serialize-dates) - [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) +- [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) From c273b4eda0ce1a5011dca9c04550d0763309a069 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:52:25 +0200 Subject: [PATCH 259/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index cd089263866e..1a445b701bcf 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -13,3 +13,4 @@ - [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) +- [Jackson – Decide What Fields Get Serialized/Deserializaed](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) From 9bba394195c6d274d4a120cc0be6c0ba869a774d Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 13:53:22 +0200 Subject: [PATCH 260/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index 1a445b701bcf..e226721d612b 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -14,3 +14,4 @@ - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) - [Jackson – Decide What Fields Get Serialized/Deserializaed](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) +- [A Guide to Jackson Annotations](http://www.baeldung.com/jackson-annotations) From 6a56dcaa15798e1f6724f3c74683f4e8512778f7 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:03:31 +0200 Subject: [PATCH 261/626] Create README.md --- spring-data-mongodb/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spring-data-mongodb/README.md diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md new file mode 100644 index 000000000000..7d194b72c88a --- /dev/null +++ b/spring-data-mongodb/README.md @@ -0,0 +1,7 @@ +========= + +## Spring Data MongoDB + + +### Relevant Articles: +-[A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) From 034c57571330f02a7616ca4406478728c10c42d6 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:03:50 +0200 Subject: [PATCH 262/626] Update README.md --- spring-data-mongodb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md index 7d194b72c88a..d92edc89405b 100644 --- a/spring-data-mongodb/README.md +++ b/spring-data-mongodb/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: --[A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) +- [A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) From 344c29cc11c84e3de0d042fa448076d5bd63aa24 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:11:27 +0200 Subject: [PATCH 263/626] Update README.md --- spring-data-mongodb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md index d92edc89405b..4a140c1be65f 100644 --- a/spring-data-mongodb/README.md +++ b/spring-data-mongodb/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) +- [Spring Data MongoDB – Indexes, Annotations and Converters](http://www.baeldung.com/spring-data-mongodb-index-annotations-converter) From 04947776da282b21b1b640bef6d76e9167fe7aa5 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:12:20 +0200 Subject: [PATCH 264/626] Update README.md --- spring-data-mongodb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md index 4a140c1be65f..e784176879cd 100644 --- a/spring-data-mongodb/README.md +++ b/spring-data-mongodb/README.md @@ -6,3 +6,4 @@ ### Relevant Articles: - [A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) - [Spring Data MongoDB – Indexes, Annotations and Converters](http://www.baeldung.com/spring-data-mongodb-index-annotations-converter) +- [Custom Cascading in Spring Data MongoDB](http://www.baeldung.com/cascading-with-dbref-and-lifecycle-events-in-spring-data-mongodb) From 11b30eea02668bf6c54f5e78a48821e843b07672 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:13:27 +0200 Subject: [PATCH 265/626] Update README.md --- spring-security-rest-full/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index b592f7558cad..c6d6ed58488a 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -19,6 +19,7 @@ - [REST Query Language – Advanced Search Operations](http://www.baeldung.com/rest-api-query-search-language-more-operations) - [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) - [REST Query Language with RSQL](http://www.baeldung.com/rest-api-search-language-rsql-fiql) +- [Spring RestTemplate Tutorial](http://www.baeldung.com/rest-template) ### Build the Project From 09e896a3577ff8a42c8516f972bdaf8c5abdeeda Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:20:12 +0200 Subject: [PATCH 266/626] Create README.md --- spring-katharsis/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spring-katharsis/README.md diff --git a/spring-katharsis/README.md b/spring-katharsis/README.md new file mode 100644 index 000000000000..ec0141f41a0a --- /dev/null +++ b/spring-katharsis/README.md @@ -0,0 +1,6 @@ +========= + +## Java Web Application + +### Relevant Articles: +- [JSON API in a Java Web Application](http://www.baeldung.com/json-api-java-spring-web-app) From 15b5ac439e675d47bd1151caad401654e129ab92 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:24:04 +0200 Subject: [PATCH 267/626] Update README.md --- spring-all/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-all/README.md b/spring-all/README.md index baab7ec08395..977b8b735795 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -8,3 +8,4 @@ This project is used to replicate Spring Exceptions only. ### Relevant articles: - [Properties with Spring](http://www.baeldung.com/2012/02/06/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage - [Spring Profiles](http://www.baeldung.com/spring-profiles) +- [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor) From 0b55104f32e22152e9dd2657a3359c0f2fe57e85 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:25:03 +0200 Subject: [PATCH 268/626] Update README.md --- spring-data-mongodb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md index e784176879cd..c5d2d2df416d 100644 --- a/spring-data-mongodb/README.md +++ b/spring-data-mongodb/README.md @@ -7,3 +7,4 @@ - [A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) - [Spring Data MongoDB – Indexes, Annotations and Converters](http://www.baeldung.com/spring-data-mongodb-index-annotations-converter) - [Custom Cascading in Spring Data MongoDB](http://www.baeldung.com/cascading-with-dbref-and-lifecycle-events-in-spring-data-mongodb) +- [GridFS in Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-gridfs) From f602cea186c7fe224b2c537116d4e7db9fe73e97 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:25:49 +0200 Subject: [PATCH 269/626] Update README.md --- spring-mvc-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index bf76c7e1d4a3..113f69092058 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -4,3 +4,4 @@ ### Relevant Articles: +- [http://www.baeldung.com/spring-bean-annotations](http://www.baeldung.com/spring-bean-annotations) From d91f7672ff4f8f4b7938be4fd686f3685cce4ac8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:26:17 +0200 Subject: [PATCH 270/626] Update README.md --- spring-mvc-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 113f69092058..ccbd1288f014 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: -- [http://www.baeldung.com/spring-bean-annotations](http://www.baeldung.com/spring-bean-annotations) +- [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) From eb3b30e9b1fa190c26629ef7152607e1c7e02bea Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:27:10 +0200 Subject: [PATCH 271/626] Update README.md --- spring-security-rest/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index a3fce32a9cbb..d17cb24f7e85 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) +- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) From 238f5d340f286e64f91da86a0eb49864e29ea4b6 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:28:15 +0200 Subject: [PATCH 272/626] Update README.md --- spring-mvc-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index ccbd1288f014..f6bb37b6009d 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) +- [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial) From fda7b00e6be4707912c038b7d28e74b52964839b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:29:26 +0200 Subject: [PATCH 273/626] Update README.md --- spring-mvc-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index f6bb37b6009d..2de2373149ac 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -6,3 +6,4 @@ ### Relevant Articles: - [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) - [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial) +- [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial) From 03ddc9056e271240838413ddd857d520d2995db2 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:30:23 +0200 Subject: [PATCH 274/626] Update README.md --- spring-data-cassandra/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-cassandra/README.md b/spring-data-cassandra/README.md index a245ff62a11b..85ea3b864918 100644 --- a/spring-data-cassandra/README.md +++ b/spring-data-cassandra/README.md @@ -2,7 +2,7 @@ ### Relevant Articles: - [Introduction to Spring Data Cassandra](http://www.baeldung.com/spring-data-cassandra-tutorial) - +- [http://www.baeldung.com/spring-data-cassandratemplate-cqltemplate](http://www.baeldung.com/spring-data-cassandratemplate-cqltemplate) ### Build the Project with Tests Running ``` mvn clean install From cde526808ad9c504871c6aa8b7aecb28f2b9542b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:31:11 +0200 Subject: [PATCH 275/626] Update README.md --- spring-data-cassandra/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-data-cassandra/README.md b/spring-data-cassandra/README.md index 85ea3b864918..456eefcf18a6 100644 --- a/spring-data-cassandra/README.md +++ b/spring-data-cassandra/README.md @@ -2,7 +2,8 @@ ### Relevant Articles: - [Introduction to Spring Data Cassandra](http://www.baeldung.com/spring-data-cassandra-tutorial) -- [http://www.baeldung.com/spring-data-cassandratemplate-cqltemplate](http://www.baeldung.com/spring-data-cassandratemplate-cqltemplate) +- [Using the CassandraTemplate from Spring Data](http://www.baeldung.com/spring-data-cassandratemplate-cqltemplate) + ### Build the Project with Tests Running ``` mvn clean install From cd8c2517dbf51fdd0a590afb8ab3b9f000ab62b3 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:32:10 +0200 Subject: [PATCH 276/626] Update README.md --- guava18/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/guava18/README.md b/guava18/README.md index 8960b4676efb..9924d7c16f2e 100644 --- a/guava18/README.md +++ b/guava18/README.md @@ -7,7 +7,6 @@ - [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) - [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) - [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) - - [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) - - [Partition a List in Java](http://www.baeldung.com/java-list-split) +- [Guava 18: What’s New?](http://www.baeldung.com/whats-new-in-guava-18) From f7bd8093d037108b03591e7c32b584b5c495fdba Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:33:03 +0200 Subject: [PATCH 277/626] Update README.md --- core-java-8/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index e3fa3f98483c..62040ba5cf5f 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: // - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) - [Java – Directory Size](http://www.baeldung.com/java-folder-size) +- [Java – Try with Resources](http://www.baeldung.com/java-try-with-resources) From 2b4b9fa79c3fdb70590e7ee8f356da6e2cdac740 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:33:55 +0200 Subject: [PATCH 278/626] Update README.md --- spring-security-mvc-ldap/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-ldap/README.md b/spring-security-mvc-ldap/README.md index 260b4b38d870..686f611f99a3 100644 --- a/spring-security-mvc-ldap/README.md +++ b/spring-security-mvc-ldap/README.md @@ -5,7 +5,7 @@ ### Relevant Article: - [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) - [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) - +- [Intro to Spring Security LDAP](http://www.baeldung.com/spring-security-ldap) ### Notes - the project uses Spring Boot - simply run 'SampleLDAPApplication.java' to start up Spring Boot with a Tomcat container and embedded LDAP server. From 573f4bed69eafd21bbbb3908f538bb746de175dc Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Wed, 10 Feb 2016 14:35:56 +0200 Subject: [PATCH 279/626] Update README.md --- spring-batch/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-batch/README.md b/spring-batch/README.md index 8b137891791f..953e652ceab1 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -1 +1,7 @@ +========= +## Spring Batch + + +### Relevant Articles: +- [Introduction to Spring Batch](http://www.baeldung.com/introduction-to-spring-batch) From ebce69d28d14f77da8c390b92db58d15cd66ce04 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:25:41 +0200 Subject: [PATCH 280/626] Update README.md --- spring-data-mongodb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-mongodb/README.md b/spring-data-mongodb/README.md index c5d2d2df416d..d656bc897c4c 100644 --- a/spring-data-mongodb/README.md +++ b/spring-data-mongodb/README.md @@ -8,3 +8,4 @@ - [Spring Data MongoDB – Indexes, Annotations and Converters](http://www.baeldung.com/spring-data-mongodb-index-annotations-converter) - [Custom Cascading in Spring Data MongoDB](http://www.baeldung.com/cascading-with-dbref-and-lifecycle-events-in-spring-data-mongodb) - [GridFS in Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-gridfs) +- [Introduction to Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-tutorial) From c3e5eb7ccfd942761e01d9b15ed21cf57f8511fe Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:40:35 +0200 Subject: [PATCH 281/626] Update README.md --- core-java-8/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index 62040ba5cf5f..ab89bbdaf23e 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -6,3 +6,4 @@ // - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) - [Java – Directory Size](http://www.baeldung.com/java-folder-size) - [Java – Try with Resources](http://www.baeldung.com/java-try-with-resources) +- [Lambda Expressions and Functional Interfaces: Tips and Best Practices](http://www.baeldung.com/java-8-lambda-expressions-tips) From a7cd46c02230f5f589fa58bb60e3873f092de5ec Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:45:49 +0200 Subject: [PATCH 282/626] Create README.md --- mockito-mocks-spring-beans/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 mockito-mocks-spring-beans/README.md diff --git a/mockito-mocks-spring-beans/README.md b/mockito-mocks-spring-beans/README.md new file mode 100644 index 000000000000..3ced7161fa17 --- /dev/null +++ b/mockito-mocks-spring-beans/README.md @@ -0,0 +1,7 @@ +========= + +## Mockito Mocks into Spring Beans + + +### Relevant Articles: +- [Injecting Mockito Mocks into Spring Beans](http://www.baeldung.com/injecting-mocks-in-spring) From fffeb216f5c22fa3399e61d4a0211c0595be9bfc Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:47:43 +0200 Subject: [PATCH 283/626] Update README.md --- spring-security-rest/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index d17cb24f7e85..6261fbe83d3c 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -6,3 +6,4 @@ ### Relevant Articles: - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) - [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) +- [Custom Error Message Handling for REST API](http://www.baeldung.com/global-error-handler-in-a-spring-rest-api) From ae8d5ca8db2087d120e236c8d1a01d693fb3068b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:48:47 +0200 Subject: [PATCH 284/626] Update README.md --- spring-hibernate4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-hibernate4/README.md b/spring-hibernate4/README.md index acf20632fef0..4c0c6706d638 100644 --- a/spring-hibernate4/README.md +++ b/spring-hibernate4/README.md @@ -7,6 +7,7 @@ - [The DAO with Spring 3 and Hibernate](http://www.baeldung.com/2011/12/02/the-persistence-layer-with-spring-3-1-and-hibernate/) - [Hibernate Pagination](http://www.baeldung.com/hibernate-pagination) - [Sorting with Hibernate](http://www.baeldung.com/hibernate-sort) +- [Auditing with JPA, Hibernate, and Spring Data JPA](http://www.baeldung.com/database-auditing-jpa) ### Quick Start From 80da6e8668dbe02bcd3777529ec801dafb10e8d9 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:51:08 +0200 Subject: [PATCH 285/626] Create README.md --- spring-freemarker/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spring-freemarker/README.md diff --git a/spring-freemarker/README.md b/spring-freemarker/README.md new file mode 100644 index 000000000000..bd939d11e986 --- /dev/null +++ b/spring-freemarker/README.md @@ -0,0 +1,7 @@ +========= + +## Using FreeMarker in Spring MVC + + +### Relevant Articles: +- [Introduction to Using FreeMarker in Spring MVC](http://www.baeldung.com/freemarker-in-spring-mvc-tutorial) From 02ebbd4044ef107f69bc89823827f37064afe50b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:52:17 +0200 Subject: [PATCH 286/626] Update README.md --- spring-security-rest-full/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index c6d6ed58488a..f648c49244b2 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -20,7 +20,7 @@ - [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) - [REST Query Language with RSQL](http://www.baeldung.com/rest-api-search-language-rsql-fiql) - [Spring RestTemplate Tutorial](http://www.baeldung.com/rest-template) - +- [A Guide to CSRF Protection in Spring Security](http://www.baeldung.com/spring-security-csrf) ### Build the Project ``` From 7011fa40fec956a2bfce298d896129ccccc96354 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:53:18 +0200 Subject: [PATCH 287/626] Update README.md --- jackson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson/README.md b/jackson/README.md index e226721d612b..53b9c7c31db7 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -15,3 +15,4 @@ - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) - [Jackson – Decide What Fields Get Serialized/Deserializaed](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) - [A Guide to Jackson Annotations](http://www.baeldung.com/jackson-annotations) +- [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) From edcb2e2e69edcc25c8f9233a899fab5020a2f7f4 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:54:21 +0200 Subject: [PATCH 288/626] Update README.md --- core-java-8/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index ab89bbdaf23e..8bef3a1be0d4 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -7,3 +7,4 @@ - [Java – Directory Size](http://www.baeldung.com/java-folder-size) - [Java – Try with Resources](http://www.baeldung.com/java-try-with-resources) - [Lambda Expressions and Functional Interfaces: Tips and Best Practices](http://www.baeldung.com/java-8-lambda-expressions-tips) +- [The Double Colon Operator in Java 8](http://www.baeldung.com/java-8-double-colon-operator) From 71ef292b3a18992345b58007cb0b9c26d63ff56c Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 02:56:17 +0200 Subject: [PATCH 289/626] Create README.md --- spring-zuul/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spring-zuul/README.md diff --git a/spring-zuul/README.md b/spring-zuul/README.md new file mode 100644 index 000000000000..41a77f70c8ee --- /dev/null +++ b/spring-zuul/README.md @@ -0,0 +1,7 @@ +========= + +## Spring REST with a Zuul + + +### Relevant Articles: +- [Spring REST with a Zuul Proxy](http://www.baeldung.com/spring-rest-with-zuul-proxy) From e77e6ebfcf045138cf9e8b2cf9650516d09718e0 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 03:03:08 +0200 Subject: [PATCH 290/626] Update README.md --- spring-rest/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-rest/README.md b/spring-rest/README.md index 3b93b06d6633..9d373962c42f 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -7,3 +7,4 @@ - [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) - [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) - [Redirect in Spring](http://www.baeldung.com/spring-redirect-and-forward) +- [Returning Custom Status Codes from Spring Controllers](http://www.baeldung.com/spring-mvc-controller-custom-http-status-code) From b0d8d832804b8366d025e02f01e5d6ea2821af81 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Thu, 11 Feb 2016 03:04:45 +0200 Subject: [PATCH 291/626] Update README.md --- spring-mvc-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 2de2373149ac..e5264b037016 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -7,3 +7,4 @@ - [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) - [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial) - [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial) +- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial) From 0fdbd513bcfdc936228c4485caf0b7e5ff15d294 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 12 Feb 2016 00:09:58 +0100 Subject: [PATCH 292/626] Add form tag example --- .../spring/controller/PersonController.java | 86 +++++++++++++ .../java/org/baeldung/spring/form/Person.java | 120 ++++++++++++++++++ .../main/webapp/WEB-INF/view/personForm.jsp | 88 +++++++++++++ .../main/webapp/WEB-INF/view/personResume.jsp | 61 +++++++++ 4 files changed, 355 insertions(+) create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java new file mode 100644 index 000000000000..688e52e51bac --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java @@ -0,0 +1,86 @@ +package org.baeldung.spring.controller; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.validation.Valid; + +import org.baeldung.spring.form.Person; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class PersonController { + + @RequestMapping(value = "/person", method = RequestMethod.GET) + public ModelAndView initForm(final Model model) { + + final List favouriteLanguage = new ArrayList(); + favouriteLanguage.add("Java"); + favouriteLanguage.add("C++"); + favouriteLanguage.add("Perl"); + model.addAttribute("favouriteLanguage", favouriteLanguage); + + final List job = new ArrayList(); + job.add("Full time"); + job.add("Part time"); + model.addAttribute("job", job); + + final Map country = new LinkedHashMap(); + country.put("US", "United Stated"); + country.put("IT", "Italy"); + country.put("UK", "United Kingdom"); + country.put("FR", "Grance"); + model.addAttribute("country", country); + + final List fruit = new ArrayList(); + fruit.add("Banana"); + fruit.add("Mango"); + fruit.add("Apple"); + model.addAttribute("fruit", fruit); + + final List books = new ArrayList(); + books.add("The Great Gatsby"); + books.add("Nineteen Eighty-Four"); + books.add("The Lord of the Rings"); + model.addAttribute("books", books); + + return new ModelAndView("personForm", "person", new Person()); + } + + @RequestMapping(value = "/addPerson", method = RequestMethod.POST) + public String submit(@Valid @ModelAttribute("person") final Person person, final BindingResult result, + final ModelMap model) { + + if (result.hasErrors()) { + return "error"; + } + + model.addAttribute("person", person); + + return "personResume"; + } + // + // protected Map> referenceData(final + // HttpServletRequest request) throws Exception { + // + // final Map> referenceData = new HashMap<>(); + // + // final List favouriteLanguageList = new ArrayList(); + // favouriteLanguageList.add("Java"); + // favouriteLanguageList.add("C++"); + // favouriteLanguageList.add("Perl"); + // referenceData.put("favouriteLanguageList", favouriteLanguageList); + // + // return referenceData; + // + // } +} diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java new file mode 100644 index 000000000000..1b77ab577169 --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java @@ -0,0 +1,120 @@ +package org.baeldung.spring.form; + +import java.util.List; + +public class Person { + + private long id; + private String name; + private String password; + private String sex; + private String country; + private String book; + private String job; + boolean receiveNewsletter; + private String[] hobbies; + private List favouriteLanguage; + private List fruit; + private String notes; + + public Person() { + super(); + } + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(final String password) { + this.password = password; + } + + public String getSex() { + return sex; + } + + public void setSex(final String sex) { + this.sex = sex; + } + + public String getCountry() { + return country; + } + + public void setCountry(final String country) { + this.country = country; + } + + public String getJob() { + return job; + } + + public void setJob(final String job) { + this.job = job; + } + + public boolean isReceiveNewsletter() { + return receiveNewsletter; + } + + public void setReceiveNewsletter(final boolean receiveNewsletter) { + this.receiveNewsletter = receiveNewsletter; + } + + public String[] getHobbies() { + return hobbies; + } + + public void setHobbies(final String[] hobbies) { + this.hobbies = hobbies; + } + + public List getFavouriteLanguage() { + return favouriteLanguage; + } + + public void setFavouriteLanguage(final List favouriteLanguage) { + this.favouriteLanguage = favouriteLanguage; + } + + public String getNotes() { + return notes; + } + + public void setNotes(final String notes) { + this.notes = notes; + } + + public List getFruit() { + return fruit; + } + + public void setFruit(final List fruit) { + this.fruit = fruit; + } + + public String getBook() { + return book; + } + + public void setBook(final String book) { + this.book = book; + } + +} diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp new file mode 100644 index 000000000000..f6cf0bf46087 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp @@ -0,0 +1,88 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + +Form Example - Register a Person + + +

Welcome, Enter The Person Details

+ + +
/>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name
Password
Sex + Male:
+ Female: +
Job + +
Country + +
Book + + + + +
Fruit + +
Receive newsletter
Hobbies + Bird watching: + Astronomy: + Snowboarding: +
Favourite languages + +
Notes
+ + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp new file mode 100644 index 000000000000..81f7fd341143 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp @@ -0,0 +1,61 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + +Spring MVC Form Handling + + + +

Submitted Person Information

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id :${person.id}
Name :${person.name}
Password :${person.password}
Sex :${person.sex}
Job :${person.job}
Country :${person.country}
Fruit :[]
Book :${person.book}
Receive Newsletter :${person.receiveNewsletter}
Hobbies :[]
Favourite Languages :[]
Notes :${person.notes}
+ + \ No newline at end of file From c1f4c574a86d33f216564990870fb6b14ebdcc82 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 12 Feb 2016 14:38:01 +0100 Subject: [PATCH 293/626] Add form tag example --- .../spring/controller/PersonController.java | 53 +++-- .../java/org/baeldung/spring/form/Person.java | 16 ++ .../src/main/resources/messages.properties | 2 + .../src/main/resources/webMvcConfig.xml | 13 ++ .../main/webapp/WEB-INF/view/personForm.jsp | 187 ++++++++++-------- .../main/webapp/WEB-INF/view/personResume.jsp | 4 + .../src/main/webapp/WEB-INF/web.xml | 3 + 7 files changed, 164 insertions(+), 114 deletions(-) create mode 100644 spring-mvc-xml/src/main/resources/messages.properties diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java index 688e52e51bac..d5b68c7516c2 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java @@ -21,7 +21,28 @@ public class PersonController { @RequestMapping(value = "/person", method = RequestMethod.GET) - public ModelAndView initForm(final Model model) { + public ModelAndView showForm(final Model model) { + + initData(model); + return new ModelAndView("personForm", "person", new Person()); + } + + @RequestMapping(value = "/addPerson", method = RequestMethod.POST) + public String submit(@Valid @ModelAttribute("person") final Person person, final BindingResult result, + final ModelMap modelMap, final Model model) { + + if (result.hasErrors()) { + + initData(model); + return "personForm"; + } + + modelMap.addAttribute("person", person); + + return "personResume"; + } + + private void initData(final Model model) { final List favouriteLanguage = new ArrayList(); favouriteLanguage.add("Java"); @@ -52,35 +73,5 @@ public ModelAndView initForm(final Model model) { books.add("Nineteen Eighty-Four"); books.add("The Lord of the Rings"); model.addAttribute("books", books); - - return new ModelAndView("personForm", "person", new Person()); - } - - @RequestMapping(value = "/addPerson", method = RequestMethod.POST) - public String submit(@Valid @ModelAttribute("person") final Person person, final BindingResult result, - final ModelMap model) { - - if (result.hasErrors()) { - return "error"; - } - - model.addAttribute("person", person); - - return "personResume"; } - // - // protected Map> referenceData(final - // HttpServletRequest request) throws Exception { - // - // final Map> referenceData = new HashMap<>(); - // - // final List favouriteLanguageList = new ArrayList(); - // favouriteLanguageList.add("Java"); - // favouriteLanguageList.add("C++"); - // favouriteLanguageList.add("Perl"); - // referenceData.put("favouriteLanguageList", favouriteLanguageList); - // - // return referenceData; - // - // } } diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java index 1b77ab577169..3db8cc4377cf 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java @@ -2,10 +2,17 @@ import java.util.List; +import org.hibernate.validator.constraints.NotEmpty; +import org.springframework.web.multipart.MultipartFile; + public class Person { private long id; + + @NotEmpty private String name; + + @NotEmpty private String password; private String sex; private String country; @@ -16,6 +23,7 @@ public class Person { private List favouriteLanguage; private List fruit; private String notes; + private MultipartFile file; public Person() { super(); @@ -117,4 +125,12 @@ public void setBook(final String book) { this.book = book; } + public MultipartFile getFile() { + return file; + } + + public void setFile(final MultipartFile file) { + this.file = file; + } + } diff --git a/spring-mvc-xml/src/main/resources/messages.properties b/spring-mvc-xml/src/main/resources/messages.properties new file mode 100644 index 000000000000..2a187731aee2 --- /dev/null +++ b/spring-mvc-xml/src/main/resources/messages.properties @@ -0,0 +1,2 @@ +NotEmpty.person.name = Name is required! +NotEmpty.person.password = Password is required! \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-mvc-xml/src/main/resources/webMvcConfig.xml index a7aa252c08a1..f3297fdbf6f6 100644 --- a/spring-mvc-xml/src/main/resources/webMvcConfig.xml +++ b/spring-mvc-xml/src/main/resources/webMvcConfig.xml @@ -11,7 +11,9 @@ > + + @@ -19,4 +21,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp index f6cf0bf46087..9ef02efbae59 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp @@ -1,88 +1,109 @@ <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> - - -Form Example - Register a Person - - -

Welcome, Enter The Person Details

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name
Password
Sex - Male:
- Female: -
Job - -
Country - -
Book - - - - -
Fruit - -
Receive newsletter
Hobbies - Bird watching: - Astronomy: - Snowboarding: -
Favourite languages - -
Notes
-
- - + + + Form Example - Register a Person + + + + + + +

Welcome, Enter The Person Details

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name
Password
Sex + Male:
+ Female: +
Job + +
Country + +
Book + + + + +
Fruit + +
Receive newsletter
Hobbies + Bird watching: + Astronomy: + Snowboarding: +
Favourite languages + +
Notes
Select a file to upload
+ +
+ + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp index 81f7fd341143..857738c54584 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp @@ -56,6 +56,10 @@ Notes : ${person.notes} + + File : + ${person.file.originalFilename} + \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index 5275efdf241a..4e38b2fae62a 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -28,6 +28,9 @@ mvc org.springframework.web.servlet.DispatcherServlet 1 + + C:/Users/ivan/Desktop/tmp + mvc From 45358317b6b4f33ead9c4d923c3d7d3bf3e7c281 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 13 Feb 2016 22:25:31 +0200 Subject: [PATCH 294/626] OpenID Connect example --- spring-openid/.classpath | 32 ++++++++ spring-openid/.project | 48 +++++++++++ spring-openid/pom.xml | 68 ++++++++++++++++ .../config/GoogleOpenIdConnectConfig.java | 51 ++++++++++++ .../org/baeldung/config/HomeController.java | 22 +++++ .../org/baeldung/config/SecurityConfig.java | 49 +++++++++++ .../config/SpringOpenidApplication.java | 13 +++ .../security/OpenIdConnectFilter.java | 71 ++++++++++++++++ .../security/OpenIdConnectUserDetails.java | 81 +++++++++++++++++++ .../src/main/resources/application.properties | 6 ++ 10 files changed, 441 insertions(+) create mode 100644 spring-openid/.classpath create mode 100644 spring-openid/.project create mode 100644 spring-openid/pom.xml create mode 100644 spring-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java create mode 100644 spring-openid/src/main/java/org/baeldung/config/HomeController.java create mode 100644 spring-openid/src/main/java/org/baeldung/config/SecurityConfig.java create mode 100644 spring-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java create mode 100644 spring-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java create mode 100644 spring-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java create mode 100644 spring-openid/src/main/resources/application.properties diff --git a/spring-openid/.classpath b/spring-openid/.classpath new file mode 100644 index 000000000000..0cad5db2d090 --- /dev/null +++ b/spring-openid/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-openid/.project b/spring-openid/.project new file mode 100644 index 000000000000..81874eb896d5 --- /dev/null +++ b/spring-openid/.project @@ -0,0 +1,48 @@ + + + spring-openid + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-openid/pom.xml b/spring-openid/pom.xml new file mode 100644 index 000000000000..641fe93a0932 --- /dev/null +++ b/spring-openid/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + org.baeldung + spring-openid + 0.0.1-SNAPSHOT + war + + spring-openid + Spring OpenID sample project + + + org.springframework.boot + spring-boot-starter-parent + 1.3.2.RELEASE + + + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.security.oauth + spring-security-oauth2 + + + + org.springframework.security + spring-security-jwt + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + UTF-8 + 1.8 + + diff --git a/spring-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java b/spring-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java new file mode 100644 index 000000000000..8e9c6e974ee2 --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java @@ -0,0 +1,51 @@ +package org.baeldung.config; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.client.OAuth2ClientContext; +import org.springframework.security.oauth2.client.OAuth2RestTemplate; +import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; +import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client; + +@Configuration +@EnableOAuth2Client +public class GoogleOpenIdConnectConfig { + @Value("${google.clientId}") + private String clientId; + + @Value("${google.clientSecret}") + private String clientSecret; + + @Value("${google.accessTokenUri}") + private String accessTokenUri; + + @Value("${google.userAuthorizationUri}") + private String userAuthorizationUri; + + @Value("${google.redirectUri}") + private String redirectUri; + + @Bean + public OAuth2ProtectedResourceDetails googleOpenId() { + final AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); + details.setClientId(clientId); + details.setClientSecret(clientSecret); + details.setAccessTokenUri(accessTokenUri); + details.setUserAuthorizationUri(userAuthorizationUri); + details.setScope(Arrays.asList("openid", "email")); + details.setPreEstablishedRedirectUri(redirectUri); + details.setUseCurrentUri(false); + return details; + } + + @Bean + public OAuth2RestTemplate googleOpenIdTemplate(final OAuth2ClientContext clientContext) { + final OAuth2RestTemplate template = new OAuth2RestTemplate(googleOpenId(), clientContext); + return template; + } + +} diff --git a/spring-openid/src/main/java/org/baeldung/config/HomeController.java b/spring-openid/src/main/java/org/baeldung/config/HomeController.java new file mode 100644 index 000000000000..f0a5378019c5 --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/config/HomeController.java @@ -0,0 +1,22 @@ +package org.baeldung.config; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class HomeController { + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @RequestMapping("/") + @ResponseBody + public final String home() { + final String username = SecurityContextHolder.getContext().getAuthentication().getName(); + logger.info(username); + return "Welcome, " + username; + } + +} diff --git a/spring-openid/src/main/java/org/baeldung/config/SecurityConfig.java b/spring-openid/src/main/java/org/baeldung/config/SecurityConfig.java new file mode 100644 index 000000000000..d929bfd631ed --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/config/SecurityConfig.java @@ -0,0 +1,49 @@ +package org.baeldung.config; + +import org.baeldung.security.OpenIdConnectFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.oauth2.client.OAuth2RestTemplate; +import org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter; +import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; +import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; + +@Configuration +@EnableWebSecurity +public class SecurityConfig extends WebSecurityConfigurerAdapter { + @Autowired + private OAuth2RestTemplate restTemplate; + + @Override + public void configure(WebSecurity web) throws Exception { + web.ignoring().antMatchers("/resources/**"); + } + + @Bean + public OpenIdConnectFilter myFilter() { + final OpenIdConnectFilter filter = new OpenIdConnectFilter("/google-login"); + filter.setRestTemplate(restTemplate); + return filter; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + http + .addFilterAfter(new OAuth2ClientContextFilter(), AbstractPreAuthenticatedProcessingFilter.class) + .addFilterAfter(myFilter(), OAuth2ClientContextFilter.class) + .httpBasic().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/google-login")) + .and() + .authorizeRequests() + // .antMatchers("/","/index*").permitAll() + .anyRequest().authenticated() + ; + + // @formatter:on + } +} \ No newline at end of file diff --git a/spring-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java b/spring-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java new file mode 100644 index 000000000000..608e8a681972 --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java @@ -0,0 +1,13 @@ +package org.baeldung.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringOpenidApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringOpenidApplication.class, args); + } + +} diff --git a/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java b/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java new file mode 100644 index 000000000000..c0970ab3cfef --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java @@ -0,0 +1,71 @@ +package org.baeldung.security; + +import java.io.IOException; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.jwt.Jwt; +import org.springframework.security.jwt.JwtHelper; +import org.springframework.security.oauth2.client.OAuth2RestOperations; +import org.springframework.security.oauth2.client.OAuth2RestTemplate; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.common.exceptions.InvalidTokenException; +import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class OpenIdConnectFilter extends AbstractAuthenticationProcessingFilter { + public OAuth2RestOperations restTemplate; + + public OpenIdConnectFilter(String defaultFilterProcessesUrl) { + super(defaultFilterProcessesUrl); + setAuthenticationManager(new NoopAuthenticationManager()); + } + + @Override + public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { + + OAuth2AccessToken accessToken; + try { + accessToken = restTemplate.getAccessToken(); + } catch (final OAuth2Exception e) { + throw new BadCredentialsException("Could not obtain access token", e); + } + try { + final String idToken = accessToken.getAdditionalInformation().get("id_token").toString(); + final Jwt tokenDecoded = JwtHelper.decode(idToken); + System.out.println("===== : " + tokenDecoded.getClaims()); + + final Map authInfo = new ObjectMapper().readValue(tokenDecoded.getClaims(), Map.class); + + final OpenIdConnectUserDetails user = new OpenIdConnectUserDetails(authInfo, accessToken); + return new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities()); + } catch (final InvalidTokenException e) { + throw new BadCredentialsException("Could not obtain user details from token", e); + } + + } + + public void setRestTemplate(OAuth2RestTemplate restTemplate2) { + restTemplate = restTemplate2; + + } + + private static class NoopAuthenticationManager implements AuthenticationManager { + + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + throw new UnsupportedOperationException("No authentication should be done with this AuthenticationManager"); + } + + } +} diff --git a/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java b/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java new file mode 100644 index 000000000000..f0d91fdc279f --- /dev/null +++ b/spring-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java @@ -0,0 +1,81 @@ +package org.baeldung.security; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.oauth2.common.OAuth2AccessToken; + +public class OpenIdConnectUserDetails implements UserDetails { + + private static final long serialVersionUID = 1L; + + private String userId; + private String username; + private OAuth2AccessToken token; + + public OpenIdConnectUserDetails(Map userInfo, OAuth2AccessToken token) { + this.userId = userInfo.get("sub"); + this.username = userInfo.get("email"); + this.token = token; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public Collection getAuthorities() { + return Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public OAuth2AccessToken getToken() { + return token; + } + + public void setToken(OAuth2AccessToken token) { + this.token = token; + } + + public void setUsername(String username) { + this.username = username; + } + + @Override + public String getPassword() { + return null; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + +} diff --git a/spring-openid/src/main/resources/application.properties b/spring-openid/src/main/resources/application.properties new file mode 100644 index 000000000000..fa567a164c43 --- /dev/null +++ b/spring-openid/src/main/resources/application.properties @@ -0,0 +1,6 @@ +server.port=8081 +google.clientId=497324626536-d6fphsh1qpl2o6j2j66nukajrfqc0rtq.apps.googleusercontent.com +google.clientSecret=vtueZycMsrRjjCjnY6JzbEZT +google.accessTokenUri=https://www.googleapis.com/oauth2/v3/token +google.userAuthorizationUri=https://accounts.google.com/o/oauth2/auth +google.redirectUri=http://localhost:8081/google-login \ No newline at end of file From 4b5ad0629a854078437e8248bbbf341165f7e4f8 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sat, 30 Jan 2016 17:48:56 +0100 Subject: [PATCH 295/626] RestEasy Tutorial, CRUD Services example --- RestEasy Example/pom.xml | 91 +++ .../src/main/java/com/baeldung/Movie.java | 535 ++++++++++++++++++ .../baeldung/client/ServicesInterface.java | 44 ++ .../server/service/MovieCrudService.java | 94 +++ .../server/service/RestEasyServices.java | 40 ++ .../src/main/resources/schema1.xsd | 29 + .../main/webapp/WEB-INF/classes/logback.xml | 3 + .../WEB-INF/jboss-deployment-structure.xml | 16 + .../src/main/webapp/WEB-INF/jboss-web.xml | 4 + .../src/main/webapp/WEB-INF/web.xml | 51 ++ .../com/baeldung/server/RestEasyClient.java | 50 ++ .../resources/server/movies/transformer.json | 22 + 12 files changed, 979 insertions(+) create mode 100644 RestEasy Example/pom.xml create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java create mode 100644 RestEasy Example/src/main/resources/schema1.xsd create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml create mode 100644 RestEasy Example/src/main/webapp/WEB-INF/web.xml create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml new file mode 100644 index 000000000000..b16c5e82678b --- /dev/null +++ b/RestEasy Example/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + + jboss + http://repository.jboss.org/nexus/content/groups/public/ + + + + + 3.0.14.Final + runtime + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + org.jboss.resteasy + jaxrs-api + 3.0.12.Final + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + ${resteasy.scope} + + + jboss-jaxrs-api_2.0_spec + org.jboss.spec.javax.ws.rs + + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + ${resteasy.scope} + + + + + javax.ws.rs + javax.ws.rs-api + 2.0.1 + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + ${resteasy.scope} + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + ${resteasy.scope} + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java new file mode 100644 index 000000000000..c0041d2e95d2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java @@ -0,0 +1,535 @@ + +package com.baeldung; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "movie", propOrder = { + "actors", + "awards", + "country", + "director", + "genre", + "imdbID", + "imdbRating", + "imdbVotes", + "language", + "metascore", + "plot", + "poster", + "rated", + "released", + "response", + "runtime", + "title", + "type", + "writer", + "year" +}) +public class Movie { + + protected String actors; + protected String awards; + protected String country; + protected String director; + protected String genre; + protected String imdbID; + protected String imdbRating; + protected String imdbVotes; + protected String language; + protected String metascore; + protected String plot; + protected String poster; + protected String rated; + protected String released; + protected String response; + protected String runtime; + protected String title; + protected String type; + protected String writer; + protected String year; + + /** + * Recupera il valore della propriet� actors. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActors() { + return actors; + } + + /** + * Imposta il valore della propriet� actors. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActors(String value) { + this.actors = value; + } + + /** + * Recupera il valore della propriet� awards. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAwards() { + return awards; + } + + /** + * Imposta il valore della propriet� awards. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAwards(String value) { + this.awards = value; + } + + /** + * Recupera il valore della propriet� country. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Imposta il valore della propriet� country. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Recupera il valore della propriet� director. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDirector() { + return director; + } + + /** + * Imposta il valore della propriet� director. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDirector(String value) { + this.director = value; + } + + /** + * Recupera il valore della propriet� genre. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGenre() { + return genre; + } + + /** + * Imposta il valore della propriet� genre. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenre(String value) { + this.genre = value; + } + + /** + * Recupera il valore della propriet� imdbID. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbID() { + return imdbID; + } + + /** + * Imposta il valore della propriet� imdbID. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbID(String value) { + this.imdbID = value; + } + + /** + * Recupera il valore della propriet� imdbRating. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbRating() { + return imdbRating; + } + + /** + * Imposta il valore della propriet� imdbRating. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbRating(String value) { + this.imdbRating = value; + } + + /** + * Recupera il valore della propriet� imdbVotes. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbVotes() { + return imdbVotes; + } + + /** + * Imposta il valore della propriet� imdbVotes. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbVotes(String value) { + this.imdbVotes = value; + } + + /** + * Recupera il valore della propriet� language. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Imposta il valore della propriet� language. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Recupera il valore della propriet� metascore. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMetascore() { + return metascore; + } + + /** + * Imposta il valore della propriet� metascore. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMetascore(String value) { + this.metascore = value; + } + + /** + * Recupera il valore della propriet� plot. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlot() { + return plot; + } + + /** + * Imposta il valore della propriet� plot. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlot(String value) { + this.plot = value; + } + + /** + * Recupera il valore della propriet� poster. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPoster() { + return poster; + } + + /** + * Imposta il valore della propriet� poster. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPoster(String value) { + this.poster = value; + } + + /** + * Recupera il valore della propriet� rated. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRated() { + return rated; + } + + /** + * Imposta il valore della propriet� rated. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRated(String value) { + this.rated = value; + } + + /** + * Recupera il valore della propriet� released. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReleased() { + return released; + } + + /** + * Imposta il valore della propriet� released. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReleased(String value) { + this.released = value; + } + + /** + * Recupera il valore della propriet� response. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponse() { + return response; + } + + /** + * Imposta il valore della propriet� response. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponse(String value) { + this.response = value; + } + + /** + * Recupera il valore della propriet� runtime. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRuntime() { + return runtime; + } + + /** + * Imposta il valore della propriet� runtime. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRuntime(String value) { + this.runtime = value; + } + + /** + * Recupera il valore della propriet� title. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Imposta il valore della propriet� title. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Recupera il valore della propriet� type. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Imposta il valore della propriet� type. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Recupera il valore della propriet� writer. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWriter() { + return writer; + } + + /** + * Imposta il valore della propriet� writer. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWriter(String value) { + this.writer = value; + } + + /** + * Recupera il valore della propriet� year. + * + * @return + * possible object is + * {@link String } + * + */ + public String getYear() { + return year; + } + + /** + * Imposta il valore della propriet� year. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setYear(String value) { + this.year = value; + } + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java new file mode 100644 index 000000000000..53e88961be34 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -0,0 +1,44 @@ +package com.baeldung.client; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +public interface ServicesInterface { + + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response addMovie(Movie movie); + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + Response updateMovie(Movie movie); + + + @DELETE + @Path("/deletemovie") + Response deleteMovie(@QueryParam("imdbID") String imdbID); + + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java new file mode 100644 index 000000000000..d1973e703738 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java @@ -0,0 +1,94 @@ +package com.baeldung.server.service; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.Provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Path("/movies") +public class MovieCrudService { + + + private Map inventory = new HashMap(); + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling getinfo ***"); + + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; + } + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response addMovie(Movie movie){ + + System.out.println("*** Calling addMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is Already in the database.").build(); + } + inventory.put(movie.getImdbID(),movie); + + return Response.status(Response.Status.CREATED).build(); + } + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response updateMovie(Movie movie){ + + System.out.println("*** Calling updateMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is not in the database.\nUnable to Update").build(); + } + inventory.put(movie.getImdbID(),movie); + return Response.status(Response.Status.OK).build(); + + } + + + @DELETE + @Path("/deletemovie") + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling deleteMovie ***"); + + if (null==inventory.get(imdbID)){ + return Response.status(Response.Status.NOT_FOUND) + .entity("Movie is not in the database.\nUnable to Delete").build(); + } + + inventory.remove(imdbID); + return Response.status(Response.Status.OK).build(); + } + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + public List listMovies(){ + + return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); + + } + + + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java new file mode 100644 index 000000000000..16b6200ad1f2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java @@ -0,0 +1,40 @@ +package com.baeldung.server.service; + + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by Admin on 29/01/2016. + */ + + + +@ApplicationPath("/rest") +public class RestEasyServices extends Application { + + private Set singletons = new HashSet(); + + public RestEasyServices() { + singletons.add(new MovieCrudService()); + } + + @Override + public Set getSingletons() { + return singletons; + } + + @Override + public Set> getClasses() { + return super.getClasses(); + } + + @Override + public Map getProperties() { + return super.getProperties(); + } +} diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd new file mode 100644 index 000000000000..0d74b7c366bb --- /dev/null +++ b/RestEasy Example/src/main/resources/schema1.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml new file mode 100644 index 000000000000..d94e9f71abbb --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 000000000000..84d75934a70c --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 000000000000..694bb7133232 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..c66d3b56ae77 --- /dev/null +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + RestEasy Example + + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + + + RestEasy Example + + + webAppRootKey + RestEasyExample + + + + + + resteasy.servlet.mapping.prefix + /rest + + + + + resteasy-servlet + + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher + + + javax.ws.rs.Application + com.baeldung.server.service.RestEasyServices + + + + + resteasy-servlet + /rest/* + + + + + index.html + + + + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java new file mode 100644 index 000000000000..e7112339793b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -0,0 +1,50 @@ +package com.baeldung.server; + +import com.baeldung.Movie; +import com.baeldung.client.ServicesInterface; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import java.util.List; + +public class RestEasyClient { + + public static void main(String[] args) { + + Movie st = new Movie(); + st.setImdbID("12345"); + + /* + * Alternatively you can use this simple String to send + * instead of using a Student instance + * + * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; + */ + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + + /* + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Server response : \n"); + System.out.println(response.readEntity(String.class)); + + response.close(); +*/ + } catch (Exception e) { + + e.printStackTrace(); + + } + } + +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json new file mode 100644 index 000000000000..215486826560 --- /dev/null +++ b/RestEasy Example/src/test/resources/server/movies/transformer.json @@ -0,0 +1,22 @@ +{ + "title": "Transformers", + "year": "2007", + "rated": "PG-13", + "released": "03 Jul 2007", + "runtime": "144 min", + "genre": "Action, Adventure, Sci-Fi", + "director": "Michael Bay", + "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", + "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", + "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", + "language": "English, Spanish", + "country": "USA", + "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", + "metascore": "61", + "imdbRating": "7.1", + "imdbVotes": "492,225", + "imdbID": "tt0418279", + "Type": "movie", + "response": "True" +} \ No newline at end of file From 663def8e2c00957b8913afcb118bde494c85f987 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 30 Jan 2016 20:39:28 +0100 Subject: [PATCH 296/626] Added testCase for List All Movies and Add a Movie --- RestEasy Example/pom.xml | 29 +++++ .../baeldung/client/ServicesInterface.java | 6 +- .../java/com/baeldung/{ => model}/Movie.java | 45 +++++++- .../{service => }/MovieCrudService.java | 5 +- .../{service => }/RestEasyServices.java | 2 +- .../com/baeldung/server/RestEasyClient.java | 104 ++++++++++++++---- .../com/baeldung/server/movies/batman.json | 22 ++++ .../baeldung}/server/movies/transformer.json | 2 +- 8 files changed, 184 insertions(+), 31 deletions(-) rename RestEasy Example/src/main/java/com/baeldung/{ => model}/Movie.java (86%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/MovieCrudService.java (96%) rename RestEasy Example/src/main/java/com/baeldung/server/{service => }/RestEasyServices.java (95%) create mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json rename RestEasy Example/src/test/resources/{ => com/baeldung}/server/movies/transformer.json (99%) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index b16c5e82678b..8dabfc863bc4 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -85,6 +85,35 @@ ${resteasy.scope} + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + com.fasterxml.jackson.core + jackson-core + 2.7.0 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.0 + + + + + diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 53e88961be34..2585c32438ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,15 +1,13 @@ package com.baeldung.client; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - +@Path("/movies") public interface ServicesInterface { diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java similarity index 86% rename from RestEasy Example/src/main/java/com/baeldung/Movie.java rename to RestEasy Example/src/main/java/com/baeldung/model/Movie.java index c0041d2e95d2..052ba081c1a0 100644 --- a/RestEasy Example/src/main/java/com/baeldung/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,5 +1,5 @@ -package com.baeldung; +package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -532,4 +532,47 @@ public void setYear(String value) { this.year = value; } + @Override + public String toString() { + return "Movie{" + + "actors='" + actors + '\'' + + ", awards='" + awards + '\'' + + ", country='" + country + '\'' + + ", director='" + director + '\'' + + ", genre='" + genre + '\'' + + ", imdbID='" + imdbID + '\'' + + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + + ", language='" + language + '\'' + + ", metascore='" + metascore + '\'' + + ", poster='" + poster + '\'' + + ", rated='" + rated + '\'' + + ", released='" + released + '\'' + + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + + ", title='" + title + '\'' + + ", type='" + type + '\'' + + ", writer='" + writer + '\'' + + ", year='" + year + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Movie movie = (Movie) o; + + if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + return title != null ? title.equals(movie.title) : movie.title == null; + + } + + @Override + public int hashCode() { + int result = imdbID != null ? imdbID.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + return result; + } } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java similarity index 96% rename from RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java rename to RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index d1973e703738..60e0121966df 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,11 +1,10 @@ -package com.baeldung.server.service; +package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java similarity index 95% rename from RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java rename to RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 16b6200ad1f2..8c57d2c9b466 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,4 +1,4 @@ -package com.baeldung.server.service; +package com.baeldung.server; import javax.ws.rs.ApplicationPath; diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java index e7112339793b..c77f494862f5 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -1,49 +1,111 @@ package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.List; +import java.util.Locale; public class RestEasyClient { - public static void main(String[] args) { - Movie st = new Movie(); - st.setImdbID("12345"); + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; - /* - * Alternatively you can use this simple String to send - * instead of using a Student instance - * - * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; - */ + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + @Test + public void testListAllMovies() { try { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); - + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + - /* - if (response.getStatus() != 200) { + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final Response moviesResponse = simple.addMovie(batmanMovie); + + if (moviesResponse.getStatus() != 201) { + System.out.println(moviesResponse.readEntity(String.class)); throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); + + moviesResponse.getStatus()); } - System.out.println("Server response : \n"); - System.out.println(response.readEntity(String.class)); + moviesResponse.close(); - response.close(); -*/ } catch (Exception e) { - e.printStackTrace(); - } } diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json new file mode 100644 index 000000000000..28061d5bf94d --- /dev/null +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -0,0 +1,22 @@ +{ + "title": "Batman", + "year": "1989", + "rated": "PG-13", + "released": "23 Jun 1989", + "runtime": "126 min", + "genre": "Action, Adventure", + "director": "Tim Burton", + "writer": "Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)", + "actors": "Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl", + "plot": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.", + "language": "English, French", + "country": "USA, UK", + "awards": "Won 1 Oscar. Another 9 wins & 22 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg", + "metascore": "66", + "imdbRating": "7.6", + "imdbVotes": "256,000", + "imdbID": "tt0096895", + "type": "movie", + "response": "True" +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json similarity index 99% rename from RestEasy Example/src/test/resources/server/movies/transformer.json rename to RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index 215486826560..a3b033a8ba6f 100644 --- a/RestEasy Example/src/test/resources/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -17,6 +17,6 @@ "imdbRating": "7.1", "imdbVotes": "492,225", "imdbID": "tt0418279", - "Type": "movie", + "type": "movie", "response": "True" } \ No newline at end of file From b39ec7d76ee55ffe0165aa82ff23f2da3bd8475c Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 31 Jan 2016 11:05:11 +0100 Subject: [PATCH 297/626] Added testCase for all Services --- RestEasy Example/pom.xml | 15 -- .../baeldung/client/ServicesInterface.java | 10 +- .../com/baeldung/server/MovieCrudService.java | 15 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- .../com/baeldung/server/RestEasyClient.java | 112 ----------- .../baeldung/server/RestEasyClientTest.java | 189 ++++++++++++++++++ 6 files changed, 206 insertions(+), 137 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 8dabfc863bc4..6935238d910f 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -99,21 +99,6 @@ 2.4 - - com.fasterxml.jackson.core - jackson-core - 2.7.0 - - - - com.fasterxml.jackson.core - jackson-annotations - 2.7.0 - - - - - diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 2585c32438ec..7efed546d896 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -17,6 +17,12 @@ public interface ServicesInterface { Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -34,9 +40,5 @@ public interface ServicesInterface { Response deleteMovie(@QueryParam("imdbID") String imdbID); - @GET - @Path("/listmovies") - @Produces({"application/json"}) - List listMovies(); } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 60e0121966df..18366e2faafc 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,18 +18,21 @@ public class MovieCrudService { private Map inventory = new HashMap(); + @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - System.out.println("*** Calling getinfo ***"); + System.out.println("*** Calling getinfo for a given ImdbID***"); + + if(inventory.containsKey(imdbID)){ + return inventory.get(imdbID); + }else return null; - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; } + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -41,6 +44,7 @@ public Response addMovie(Movie movie){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); @@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } @@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){ return Response.status(Response.Status.OK).build(); } + @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index c66d3b56ae77..ab3bc1aa8362 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -33,7 +33,7 @@ javax.ws.rs.Application - com.baeldung.server.service.RestEasyServices + com.baeldung.server.RestEasyServices diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java deleted file mode 100644 index c77f494862f5..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.model.Movie; -import com.baeldung.client.ServicesInterface; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.naming.NamingException; -import javax.ws.rs.core.Link; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class RestEasyClient { - - - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; - - @BeforeClass - public static void loadMovieInventory(){ - - - - } - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - } - - @Test - public void testListAllMovies() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - final List movies = simple.listMovies(); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testAddMovie() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - - ServicesInterface simple = target.proxy(ServicesInterface.class); - final Response moviesResponse = simple.addMovie(batmanMovie); - - if (moviesResponse.getStatus() != 201) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " - + moviesResponse.getStatus()); - } - - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java new file mode 100644 index 000000000000..fb4205bcd79b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -0,0 +1,189 @@ +package com.baeldung.server; + +import com.baeldung.model.Movie; +import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.naming.NamingException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + +public class RestEasyClientTest { + + + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; + + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + + @Test + public void testListAllMovies() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testMovieByImdbID() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + + final Movie movies = simple.movieByImdbID(transformerImdbId); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); + + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testDeleteMovie() { + + String transformerImdbId="tt0418279"; + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(transformerImdbId); + moviesResponse.close(); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @Test + public void testUpdateMovie() { + + try { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + //System.out.println(moviesResponse.readEntity(String.class)); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file From 5cdf7185a4eed764473b76b365f14c2737f7c0bb Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 298/626] Minor Bugfix --- .../baeldung/client/ServicesInterface.java | 4 +- .../main/java/com/baeldung/model/Movie.java | 22 +-- .../com/baeldung/server/MovieCrudService.java | 12 +- .../src/main/webapp/WEB-INF/web.xml | 37 +---- .../java/baeldung/client/RestEasyClient.java | 7 + .../baeldung/server/RestEasyClientTest.java | 149 +++++++----------- 6 files changed, 81 insertions(+), 150 deletions(-) create mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 7efed546d896..749cabc757cf 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -14,7 +14,7 @@ public interface ServicesInterface { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - Movie movieByImdbID(@QueryParam("imdbID") String imdbID); + Movie movieByImdbId(@QueryParam("imdbId") String imdbId); @GET @@ -37,7 +37,7 @@ public interface ServicesInterface { @DELETE @Path("/deletemovie") - Response deleteMovie(@QueryParam("imdbID") String imdbID); + Response deleteMovie(@QueryParam("imdbId") String imdbID); diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index ab3bc1aa8362..f70fdf79751a 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,47 +5,12 @@ RestEasy Example - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - RestEasy Example - - - webAppRootKey - RestEasyExample - - - - + resteasy.servlet.mapping.prefix /rest - - resteasy-servlet - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - javax.ws.rs.Application - com.baeldung.server.RestEasyServices - - - - - resteasy-servlet - /rest/* - - - - - index.html - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java new file mode 100644 index 000000000000..b474b3d4f834 --- /dev/null +++ b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java @@ -0,0 +1,7 @@ +package baeldung.client; + +/** + * Created by Admin on 29/01/2016. + */ +public class RestEasyClient { +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index fb4205bcd79b..b6a2e2a0c108 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -1,7 +1,7 @@ package com.baeldung.server; -import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import com.baeldung.model.Movie; import org.apache.commons.io.IOUtils; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; @@ -9,7 +9,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import javax.naming.NamingException; @@ -23,22 +22,13 @@ public class RestEasyClientTest { - Movie transformerMovie=null; Movie batmanMovie=null; ObjectMapper jsonMapper=null; - @BeforeClass - public static void loadMovieInventory(){ - - - - } - @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); @@ -57,133 +47,102 @@ public void setup() throws ClassNotFoundException, IllegalAccessException, Insta batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); } catch (Exception e) { - e.printStackTrace(); throw new RuntimeException("Test is going to die ...", e); } - } - @Test public void testListAllMovies() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - final List movies = simple.listMovies(); - System.out.println(movies); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); - } catch (Exception e) { - e.printStackTrace(); - } + List movies = simple.listMovies(); + System.out.println(movies); } - @Test - public void testMovieByImdbID() { + public void testMovieByImdbId() { String transformerImdbId="tt0418279"; - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); - final Movie movies = simple.movieByImdbID(transformerImdbId); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } + Movie movies = simple.movieByImdbId(transformerImdbId); + System.out.println(movies); } @Test public void testAddMovie() { - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test - public void testDeleteMovie() { - - String transformerImdbId="tt0418279"; - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.deleteMovie(transformerImdbId); - moviesResponse.close(); + public void testDeleteMovi1e() { - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - moviesResponse.close(); + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } @Test public void testUpdateMovie() { - try { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - batmanMovie.setImdbVotes("300,000"); - moviesResponse = simple.updateMovie(batmanMovie); + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - //System.out.println(moviesResponse.readEntity(String.class)); - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setImdbVotes("300,000"); + moviesResponse = simple.updateMovie(batmanMovie); - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } + + moviesResponse.close(); + System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); } } \ No newline at end of file From 9b5818262decbcfcfc302ab15c5f3347dbaeecfd Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sat, 30 Jan 2016 17:48:56 +0100 Subject: [PATCH 299/626] RestEasy Tutorial, CRUD Services example --- .../src/main/java/com/baeldung/Movie.java | 535 ++++++++++++++++++ .../server/service/MovieCrudService.java | 94 +++ .../server/service/RestEasyServices.java | 40 ++ .../com/baeldung/server/RestEasyClient.java | 50 ++ .../resources/server/movies/transformer.json | 22 + 5 files changed, 741 insertions(+) create mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java create mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java create mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java create mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java new file mode 100644 index 000000000000..c0041d2e95d2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/Movie.java @@ -0,0 +1,535 @@ + +package com.baeldung; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "movie", propOrder = { + "actors", + "awards", + "country", + "director", + "genre", + "imdbID", + "imdbRating", + "imdbVotes", + "language", + "metascore", + "plot", + "poster", + "rated", + "released", + "response", + "runtime", + "title", + "type", + "writer", + "year" +}) +public class Movie { + + protected String actors; + protected String awards; + protected String country; + protected String director; + protected String genre; + protected String imdbID; + protected String imdbRating; + protected String imdbVotes; + protected String language; + protected String metascore; + protected String plot; + protected String poster; + protected String rated; + protected String released; + protected String response; + protected String runtime; + protected String title; + protected String type; + protected String writer; + protected String year; + + /** + * Recupera il valore della propriet� actors. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActors() { + return actors; + } + + /** + * Imposta il valore della propriet� actors. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActors(String value) { + this.actors = value; + } + + /** + * Recupera il valore della propriet� awards. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAwards() { + return awards; + } + + /** + * Imposta il valore della propriet� awards. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAwards(String value) { + this.awards = value; + } + + /** + * Recupera il valore della propriet� country. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Imposta il valore della propriet� country. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Recupera il valore della propriet� director. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDirector() { + return director; + } + + /** + * Imposta il valore della propriet� director. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDirector(String value) { + this.director = value; + } + + /** + * Recupera il valore della propriet� genre. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGenre() { + return genre; + } + + /** + * Imposta il valore della propriet� genre. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGenre(String value) { + this.genre = value; + } + + /** + * Recupera il valore della propriet� imdbID. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbID() { + return imdbID; + } + + /** + * Imposta il valore della propriet� imdbID. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbID(String value) { + this.imdbID = value; + } + + /** + * Recupera il valore della propriet� imdbRating. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbRating() { + return imdbRating; + } + + /** + * Imposta il valore della propriet� imdbRating. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbRating(String value) { + this.imdbRating = value; + } + + /** + * Recupera il valore della propriet� imdbVotes. + * + * @return + * possible object is + * {@link String } + * + */ + public String getImdbVotes() { + return imdbVotes; + } + + /** + * Imposta il valore della propriet� imdbVotes. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setImdbVotes(String value) { + this.imdbVotes = value; + } + + /** + * Recupera il valore della propriet� language. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLanguage() { + return language; + } + + /** + * Imposta il valore della propriet� language. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLanguage(String value) { + this.language = value; + } + + /** + * Recupera il valore della propriet� metascore. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMetascore() { + return metascore; + } + + /** + * Imposta il valore della propriet� metascore. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMetascore(String value) { + this.metascore = value; + } + + /** + * Recupera il valore della propriet� plot. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlot() { + return plot; + } + + /** + * Imposta il valore della propriet� plot. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlot(String value) { + this.plot = value; + } + + /** + * Recupera il valore della propriet� poster. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPoster() { + return poster; + } + + /** + * Imposta il valore della propriet� poster. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPoster(String value) { + this.poster = value; + } + + /** + * Recupera il valore della propriet� rated. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRated() { + return rated; + } + + /** + * Imposta il valore della propriet� rated. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRated(String value) { + this.rated = value; + } + + /** + * Recupera il valore della propriet� released. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReleased() { + return released; + } + + /** + * Imposta il valore della propriet� released. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReleased(String value) { + this.released = value; + } + + /** + * Recupera il valore della propriet� response. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponse() { + return response; + } + + /** + * Imposta il valore della propriet� response. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponse(String value) { + this.response = value; + } + + /** + * Recupera il valore della propriet� runtime. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRuntime() { + return runtime; + } + + /** + * Imposta il valore della propriet� runtime. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRuntime(String value) { + this.runtime = value; + } + + /** + * Recupera il valore della propriet� title. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Imposta il valore della propriet� title. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Recupera il valore della propriet� type. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Imposta il valore della propriet� type. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Recupera il valore della propriet� writer. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWriter() { + return writer; + } + + /** + * Imposta il valore della propriet� writer. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWriter(String value) { + this.writer = value; + } + + /** + * Recupera il valore della propriet� year. + * + * @return + * possible object is + * {@link String } + * + */ + public String getYear() { + return year; + } + + /** + * Imposta il valore della propriet� year. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setYear(String value) { + this.year = value; + } + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java new file mode 100644 index 000000000000..d1973e703738 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java @@ -0,0 +1,94 @@ +package com.baeldung.server.service; + +import com.baeldung.Movie; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.Provider; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Path("/movies") +public class MovieCrudService { + + + private Map inventory = new HashMap(); + + @GET + @Path("/getinfo") + @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling getinfo ***"); + + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; + } + + @POST + @Path("/addmovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response addMovie(Movie movie){ + + System.out.println("*** Calling addMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is Already in the database.").build(); + } + inventory.put(movie.getImdbID(),movie); + + return Response.status(Response.Status.CREATED).build(); + } + + + @PUT + @Path("/updatemovie") + @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + public Response updateMovie(Movie movie){ + + System.out.println("*** Calling updateMovie ***"); + + if (null!=inventory.get(movie.getImdbID())){ + return Response.status(Response.Status.NOT_MODIFIED) + .entity("Movie is not in the database.\nUnable to Update").build(); + } + inventory.put(movie.getImdbID(),movie); + return Response.status(Response.Status.OK).build(); + + } + + + @DELETE + @Path("/deletemovie") + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + + System.out.println("*** Calling deleteMovie ***"); + + if (null==inventory.get(imdbID)){ + return Response.status(Response.Status.NOT_FOUND) + .entity("Movie is not in the database.\nUnable to Delete").build(); + } + + inventory.remove(imdbID); + return Response.status(Response.Status.OK).build(); + } + + @GET + @Path("/listmovies") + @Produces({"application/json"}) + public List listMovies(){ + + return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); + + } + + + +} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java new file mode 100644 index 000000000000..16b6200ad1f2 --- /dev/null +++ b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java @@ -0,0 +1,40 @@ +package com.baeldung.server.service; + + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by Admin on 29/01/2016. + */ + + + +@ApplicationPath("/rest") +public class RestEasyServices extends Application { + + private Set singletons = new HashSet(); + + public RestEasyServices() { + singletons.add(new MovieCrudService()); + } + + @Override + public Set getSingletons() { + return singletons; + } + + @Override + public Set> getClasses() { + return super.getClasses(); + } + + @Override + public Map getProperties() { + return super.getProperties(); + } +} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java new file mode 100644 index 000000000000..e7112339793b --- /dev/null +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -0,0 +1,50 @@ +package com.baeldung.server; + +import com.baeldung.Movie; +import com.baeldung.client.ServicesInterface; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import java.util.List; + +public class RestEasyClient { + + public static void main(String[] args) { + + Movie st = new Movie(); + st.setImdbID("12345"); + + /* + * Alternatively you can use this simple String to send + * instead of using a Student instance + * + * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; + */ + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + + /* + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Server response : \n"); + System.out.println(response.readEntity(String.class)); + + response.close(); +*/ + } catch (Exception e) { + + e.printStackTrace(); + + } + } + +} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json new file mode 100644 index 000000000000..215486826560 --- /dev/null +++ b/RestEasy Example/src/test/resources/server/movies/transformer.json @@ -0,0 +1,22 @@ +{ + "title": "Transformers", + "year": "2007", + "rated": "PG-13", + "released": "03 Jul 2007", + "runtime": "144 min", + "genre": "Action, Adventure, Sci-Fi", + "director": "Michael Bay", + "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", + "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", + "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", + "language": "English, Spanish", + "country": "USA", + "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", + "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", + "metascore": "61", + "imdbRating": "7.1", + "imdbVotes": "492,225", + "imdbID": "tt0418279", + "Type": "movie", + "response": "True" +} \ No newline at end of file From df982db26b1a356a77b0b9eaf1ba6e2bb32c9b51 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 30 Jan 2016 20:39:28 +0100 Subject: [PATCH 300/626] Added testCase for List All Movies and Add a Movie --- .../src/main/java/com/baeldung/Movie.java | 535 ------------------ .../main/java/com/baeldung/model/Movie.java | 22 +- .../com/baeldung/server/MovieCrudService.java | 25 +- .../server/service/MovieCrudService.java | 94 --- .../server/service/RestEasyServices.java | 40 -- .../com/baeldung/server/RestEasyClient.java | 104 +++- .../resources/server/movies/transformer.json | 22 - 7 files changed, 104 insertions(+), 738 deletions(-) delete mode 100644 RestEasy Example/src/main/java/com/baeldung/Movie.java delete mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java delete mode 100644 RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java delete mode 100644 RestEasy Example/src/test/resources/server/movies/transformer.json diff --git a/RestEasy Example/src/main/java/com/baeldung/Movie.java b/RestEasy Example/src/main/java/com/baeldung/Movie.java deleted file mode 100644 index c0041d2e95d2..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/Movie.java +++ /dev/null @@ -1,535 +0,0 @@ - -package com.baeldung; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { - "actors", - "awards", - "country", - "director", - "genre", - "imdbID", - "imdbRating", - "imdbVotes", - "language", - "metascore", - "plot", - "poster", - "rated", - "released", - "response", - "runtime", - "title", - "type", - "writer", - "year" -}) -public class Movie { - - protected String actors; - protected String awards; - protected String country; - protected String director; - protected String genre; - protected String imdbID; - protected String imdbRating; - protected String imdbVotes; - protected String language; - protected String metascore; - protected String plot; - protected String poster; - protected String rated; - protected String released; - protected String response; - protected String runtime; - protected String title; - protected String type; - protected String writer; - protected String year; - - /** - * Recupera il valore della propriet� actors. - * - * @return - * possible object is - * {@link String } - * - */ - public String getActors() { - return actors; - } - - /** - * Imposta il valore della propriet� actors. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setActors(String value) { - this.actors = value; - } - - /** - * Recupera il valore della propriet� awards. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAwards() { - return awards; - } - - /** - * Imposta il valore della propriet� awards. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAwards(String value) { - this.awards = value; - } - - /** - * Recupera il valore della propriet� country. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountry() { - return country; - } - - /** - * Imposta il valore della propriet� country. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountry(String value) { - this.country = value; - } - - /** - * Recupera il valore della propriet� director. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDirector() { - return director; - } - - /** - * Imposta il valore della propriet� director. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDirector(String value) { - this.director = value; - } - - /** - * Recupera il valore della propriet� genre. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGenre() { - return genre; - } - - /** - * Imposta il valore della propriet� genre. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGenre(String value) { - this.genre = value; - } - - /** - * Recupera il valore della propriet� imdbID. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbID() { - return imdbID; - } - - /** - * Imposta il valore della propriet� imdbID. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbID(String value) { - this.imdbID = value; - } - - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbRating() { - return imdbRating; - } - - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbRating(String value) { - this.imdbRating = value; - } - - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ - public String getImdbVotes() { - return imdbVotes; - } - - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setImdbVotes(String value) { - this.imdbVotes = value; - } - - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ - public String getLanguage() { - return language; - } - - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setLanguage(String value) { - this.language = value; - } - - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMetascore() { - return metascore; - } - - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMetascore(String value) { - this.metascore = value; - } - - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPlot() { - return plot; - } - - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPlot(String value) { - this.plot = value; - } - - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPoster() { - return poster; - } - - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPoster(String value) { - this.poster = value; - } - - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRated() { - return rated; - } - - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRated(String value) { - this.rated = value; - } - - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReleased() { - return released; - } - - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReleased(String value) { - this.released = value; - } - - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ - public String getResponse() { - return response; - } - - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setResponse(String value) { - this.response = value; - } - - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRuntime() { - return runtime; - } - - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRuntime(String value) { - this.runtime = value; - } - - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTitle() { - return title; - } - - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTitle(String value) { - this.title = value; - } - - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ - public String getWriter() { - return writer; - } - - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWriter(String value) { - this.writer = value; - } - - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ - public String getYear() { - return year; - } - - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setYear(String value) { - this.year = value; - } - -} diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index a2b2bd5250d4..052ba081c1a0 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbId", + "imdbID", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbId; + protected String imdbID; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbId. + * Recupera il valore della propriet� imdbID. * * @return * possible object is * {@link String } * */ - public String getImdbId() { - return imdbId; + public String getImdbID() { + return imdbID; } /** - * Imposta il valore della propriet� imdbId. + * Imposta il valore della propriet� imdbID. * * @param value * allowed object is * {@link String } * */ - public void setImdbId(String value) { - this.imdbId = value; + public void setImdbID(String value) { + this.imdbID = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbId='" + imdbId + '\'' + + ", imdbID='" + imdbID + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; + if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbId != null ? imdbId.hashCode() : 0; + int result = imdbID != null ? imdbID.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 29226aa0e094..60e0121966df 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,21 +18,18 @@ public class MovieCrudService { private Map inventory = new HashMap(); - @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ - - System.out.println("*** Calling getinfo for a given ImdbID***"); + public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - if(inventory.containsKey(imdbID)){ - return inventory.get(imdbID); - }else return null; + System.out.println("*** Calling getinfo ***"); + Movie movie=new Movie(); + movie.setImdbID(imdbID); + return movie; } - @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -40,12 +37,11 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbId())){ + if (null!=inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +54,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbId())){ + if (null!=inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +66,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbID){ + public Response deleteMovie(@QueryParam("imdbID") String imdbID){ System.out.println("*** Calling deleteMovie ***"); @@ -83,7 +79,6 @@ public Response deleteMovie(@QueryParam("imdbId") String imdbID){ return Response.status(Response.Status.OK).build(); } - @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java deleted file mode 100644 index d1973e703738..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/MovieCrudService.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.baeldung.server.service; - -import com.baeldung.Movie; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - - -@Path("/movies") -public class MovieCrudService { - - - private Map inventory = new HashMap(); - - @GET - @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - - System.out.println("*** Calling getinfo ***"); - - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; - } - - @POST - @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response addMovie(Movie movie){ - - System.out.println("*** Calling addMovie ***"); - - if (null!=inventory.get(movie.getImdbID())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is Already in the database.").build(); - } - inventory.put(movie.getImdbID(),movie); - - return Response.status(Response.Status.CREATED).build(); - } - - - @PUT - @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response updateMovie(Movie movie){ - - System.out.println("*** Calling updateMovie ***"); - - if (null!=inventory.get(movie.getImdbID())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is not in the database.\nUnable to Update").build(); - } - inventory.put(movie.getImdbID(),movie); - return Response.status(Response.Status.OK).build(); - - } - - - @DELETE - @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ - - System.out.println("*** Calling deleteMovie ***"); - - if (null==inventory.get(imdbID)){ - return Response.status(Response.Status.NOT_FOUND) - .entity("Movie is not in the database.\nUnable to Delete").build(); - } - - inventory.remove(imdbID); - return Response.status(Response.Status.OK).build(); - } - - @GET - @Path("/listmovies") - @Produces({"application/json"}) - public List listMovies(){ - - return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); - - } - - - -} diff --git a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java deleted file mode 100644 index 16b6200ad1f2..000000000000 --- a/RestEasy Example/src/main/java/com/baeldung/server/service/RestEasyServices.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.server.service; - - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Created by Admin on 29/01/2016. - */ - - - -@ApplicationPath("/rest") -public class RestEasyServices extends Application { - - private Set singletons = new HashSet(); - - public RestEasyServices() { - singletons.add(new MovieCrudService()); - } - - @Override - public Set getSingletons() { - return singletons; - } - - @Override - public Set> getClasses() { - return super.getClasses(); - } - - @Override - public Map getProperties() { - return super.getProperties(); - } -} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java index e7112339793b..c77f494862f5 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java @@ -1,49 +1,111 @@ package com.baeldung.server; -import com.baeldung.Movie; +import com.baeldung.model.Movie; import com.baeldung.client.ServicesInterface; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.List; +import java.util.Locale; public class RestEasyClient { - public static void main(String[] args) { - Movie st = new Movie(); - st.setImdbID("12345"); + Movie transformerMovie=null; + Movie batmanMovie=null; + ObjectMapper jsonMapper=null; - /* - * Alternatively you can use this simple String to send - * instead of using a Student instance - * - * String jsonString = "{\"id\":12,\"firstName\":\"Catain\",\"lastName\":\"Hook\",\"age\":10}"; - */ + @BeforeClass + public static void loadMovieInventory(){ + + + + } + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + + jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + } + + @Test + public void testListAllMovies() { try { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:8080/RestEasyTutorial/rest/movies/listmovies"); - + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); ServicesInterface simple = target.proxy(ServicesInterface.class); + final List movies = simple.listMovies(); + System.out.println(movies); + + } catch (Exception e) { + e.printStackTrace(); + } + } + - /* - if (response.getStatus() != 200) { + + @Test + public void testAddMovie() { + + try { + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); + + ServicesInterface simple = target.proxy(ServicesInterface.class); + final Response moviesResponse = simple.addMovie(batmanMovie); + + if (moviesResponse.getStatus() != 201) { + System.out.println(moviesResponse.readEntity(String.class)); throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); + + moviesResponse.getStatus()); } - System.out.println("Server response : \n"); - System.out.println(response.readEntity(String.class)); + moviesResponse.close(); - response.close(); -*/ } catch (Exception e) { - e.printStackTrace(); - } } diff --git a/RestEasy Example/src/test/resources/server/movies/transformer.json b/RestEasy Example/src/test/resources/server/movies/transformer.json deleted file mode 100644 index 215486826560..000000000000 --- a/RestEasy Example/src/test/resources/server/movies/transformer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "title": "Transformers", - "year": "2007", - "rated": "PG-13", - "released": "03 Jul 2007", - "runtime": "144 min", - "genre": "Action, Adventure, Sci-Fi", - "director": "Michael Bay", - "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", - "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", - "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", - "language": "English, Spanish", - "country": "USA", - "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", - "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", - "metascore": "61", - "imdbRating": "7.1", - "imdbVotes": "492,225", - "imdbID": "tt0418279", - "Type": "movie", - "response": "True" -} \ No newline at end of file From 6db36f902b1e7cf6f1c7857e5a14295e8881c732 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 31 Jan 2016 11:05:11 +0100 Subject: [PATCH 301/626] Added testCase for all Services --- .../baeldung/client/ServicesInterface.java | 6 + .../com/baeldung/server/MovieCrudService.java | 15 ++- .../com/baeldung/server/RestEasyClient.java | 112 ------------------ 3 files changed, 16 insertions(+), 117 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 749cabc757cf..8898b834838b 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -23,6 +23,12 @@ public interface ServicesInterface { List listMovies(); + @GET + @Path("/listmovies") + @Produces({"application/json"}) + List listMovies(); + + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 60e0121966df..18366e2faafc 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -18,18 +18,21 @@ public class MovieCrudService { private Map inventory = new HashMap(); + @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ - System.out.println("*** Calling getinfo ***"); + System.out.println("*** Calling getinfo for a given ImdbID***"); + + if(inventory.containsKey(imdbID)){ + return inventory.get(imdbID); + }else return null; - Movie movie=new Movie(); - movie.setImdbID(imdbID); - return movie; } + @POST @Path("/addmovie") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @@ -41,6 +44,7 @@ public Response addMovie(Movie movie){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } + inventory.put(movie.getImdbID(),movie); return Response.status(Response.Status.CREATED).build(); @@ -54,7 +58,7 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbID())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } @@ -79,6 +83,7 @@ public Response deleteMovie(@QueryParam("imdbID") String imdbID){ return Response.status(Response.Status.OK).build(); } + @GET @Path("/listmovies") @Produces({"application/json"}) diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java deleted file mode 100644 index c77f494862f5..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.model.Movie; -import com.baeldung.client.ServicesInterface; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import javax.naming.NamingException; -import javax.ws.rs.core.Link; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class RestEasyClient { - - - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; - - @BeforeClass - public static void loadMovieInventory(){ - - - - } - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClient().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - } - - @Test - public void testListAllMovies() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - final List movies = simple.listMovies(); - System.out.println(movies); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testAddMovie() { - - try { - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest")); - - ServicesInterface simple = target.proxy(ServicesInterface.class); - final Response moviesResponse = simple.addMovie(batmanMovie); - - if (moviesResponse.getStatus() != 201) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " - + moviesResponse.getStatus()); - } - - moviesResponse.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file From 33223becff3f88fd3bb8e5734f621c780c1ba454 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:29:30 +0100 Subject: [PATCH 302/626] Minor Bugfix --- .../main/java/com/baeldung/model/Movie.java | 22 +++++++++---------- .../com/baeldung/server/MovieCrudService.java | 12 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 052ba081c1a0..a2b2bd5250d4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -13,7 +13,7 @@ "country", "director", "genre", - "imdbID", + "imdbId", "imdbRating", "imdbVotes", "language", @@ -36,7 +36,7 @@ public class Movie { protected String country; protected String director; protected String genre; - protected String imdbID; + protected String imdbId; protected String imdbRating; protected String imdbVotes; protected String language; @@ -173,27 +173,27 @@ public void setGenre(String value) { } /** - * Recupera il valore della propriet� imdbID. + * Recupera il valore della propriet� imdbId. * * @return * possible object is * {@link String } * */ - public String getImdbID() { - return imdbID; + public String getImdbId() { + return imdbId; } /** - * Imposta il valore della propriet� imdbID. + * Imposta il valore della propriet� imdbId. * * @param value * allowed object is * {@link String } * */ - public void setImdbID(String value) { - this.imdbID = value; + public void setImdbId(String value) { + this.imdbId = value; } /** @@ -540,7 +540,7 @@ public String toString() { ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + - ", imdbID='" + imdbID + '\'' + + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + @@ -564,14 +564,14 @@ public boolean equals(Object o) { Movie movie = (Movie) o; - if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; return title != null ? title.equals(movie.title) : movie.title == null; } @Override public int hashCode() { - int result = imdbID != null ? imdbID.hashCode() : 0; + int result = imdbId != null ? imdbId.hashCode() : 0; result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 18366e2faafc..29226aa0e094 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -22,7 +22,7 @@ public class MovieCrudService { @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){ + public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling getinfo for a given ImdbID***"); @@ -40,12 +40,12 @@ public Response addMovie(Movie movie){ System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbID())){ + if (null!=inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.CREATED).build(); } @@ -58,11 +58,11 @@ public Response updateMovie(Movie movie){ System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbID())){ + if (null==inventory.get(movie.getImdbId())){ return Response.status(Response.Status.NOT_MODIFIED) .entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbID(),movie); + inventory.put(movie.getImdbId(),movie); return Response.status(Response.Status.OK).build(); } @@ -70,7 +70,7 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbID") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbID){ System.out.println("*** Calling deleteMovie ***"); From 783dc6bdc2cb172dd3bacf01faba9531675c45ab Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:39:35 +0100 Subject: [PATCH 303/626] Minor Bugfix --- .../main/java/com/baeldung/model/Movie.java | 321 +----------------- 1 file changed, 1 insertion(+), 320 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index a2b2bd5250d4..805ba95209ec 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -52,482 +52,163 @@ public class Movie { protected String writer; protected String year; - /** - * Recupera il valore della propriet� actors. - * - * @return - * possible object is - * {@link String } - * - */ + public String getActors() { return actors; } - /** - * Imposta il valore della propriet� actors. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setActors(String value) { this.actors = value; } - /** - * Recupera il valore della propriet� awards. - * - * @return - * possible object is - * {@link String } - * - */ public String getAwards() { return awards; } - /** - * Imposta il valore della propriet� awards. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setAwards(String value) { this.awards = value; } - /** - * Recupera il valore della propriet� country. - * - * @return - * possible object is - * {@link String } - * - */ public String getCountry() { return country; } - /** - * Imposta il valore della propriet� country. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setCountry(String value) { this.country = value; } - /** - * Recupera il valore della propriet� director. - * - * @return - * possible object is - * {@link String } - * - */ public String getDirector() { return director; } - /** - * Imposta il valore della propriet� director. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setDirector(String value) { this.director = value; } - /** - * Recupera il valore della propriet� genre. - * - * @return - * possible object is - * {@link String } - * - */ public String getGenre() { return genre; } - /** - * Imposta il valore della propriet� genre. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setGenre(String value) { this.genre = value; } - /** - * Recupera il valore della propriet� imdbId. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbId() { return imdbId; } - /** - * Imposta il valore della propriet� imdbId. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbId(String value) { this.imdbId = value; } - /** - * Recupera il valore della propriet� imdbRating. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbRating() { return imdbRating; } - /** - * Imposta il valore della propriet� imdbRating. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbRating(String value) { this.imdbRating = value; } - /** - * Recupera il valore della propriet� imdbVotes. - * - * @return - * possible object is - * {@link String } - * - */ public String getImdbVotes() { return imdbVotes; } - /** - * Imposta il valore della propriet� imdbVotes. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setImdbVotes(String value) { this.imdbVotes = value; } - /** - * Recupera il valore della propriet� language. - * - * @return - * possible object is - * {@link String } - * - */ public String getLanguage() { return language; } - /** - * Imposta il valore della propriet� language. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setLanguage(String value) { this.language = value; } - /** - * Recupera il valore della propriet� metascore. - * - * @return - * possible object is - * {@link String } - * - */ public String getMetascore() { return metascore; } - /** - * Imposta il valore della propriet� metascore. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setMetascore(String value) { this.metascore = value; } - /** - * Recupera il valore della propriet� plot. - * - * @return - * possible object is - * {@link String } - * - */ public String getPlot() { return plot; } - /** - * Imposta il valore della propriet� plot. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPlot(String value) { this.plot = value; } - /** - * Recupera il valore della propriet� poster. - * - * @return - * possible object is - * {@link String } - * - */ public String getPoster() { return poster; } - /** - * Imposta il valore della propriet� poster. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setPoster(String value) { this.poster = value; } - /** - * Recupera il valore della propriet� rated. - * - * @return - * possible object is - * {@link String } - * - */ public String getRated() { return rated; } - /** - * Imposta il valore della propriet� rated. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRated(String value) { this.rated = value; } - /** - * Recupera il valore della propriet� released. - * - * @return - * possible object is - * {@link String } - * - */ public String getReleased() { return released; } - /** - * Imposta il valore della propriet� released. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setReleased(String value) { this.released = value; } - /** - * Recupera il valore della propriet� response. - * - * @return - * possible object is - * {@link String } - * - */ public String getResponse() { return response; } - /** - * Imposta il valore della propriet� response. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setResponse(String value) { this.response = value; } - /** - * Recupera il valore della propriet� runtime. - * - * @return - * possible object is - * {@link String } - * - */ public String getRuntime() { return runtime; } - /** - * Imposta il valore della propriet� runtime. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setRuntime(String value) { this.runtime = value; } - /** - * Recupera il valore della propriet� title. - * - * @return - * possible object is - * {@link String } - * - */ public String getTitle() { return title; } - /** - * Imposta il valore della propriet� title. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setTitle(String value) { this.title = value; } - /** - * Recupera il valore della propriet� type. - * - * @return - * possible object is - * {@link String } - * - */ public String getType() { return type; } - /** - * Imposta il valore della propriet� type. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setType(String value) { this.type = value; } - /** - * Recupera il valore della propriet� writer. - * - * @return - * possible object is - * {@link String } - * - */ public String getWriter() { return writer; } - /** - * Imposta il valore della propriet� writer. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setWriter(String value) { this.writer = value; } - /** - * Recupera il valore della propriet� year. - * - * @return - * possible object is - * {@link String } - * - */ public String getYear() { return year; } - /** - * Imposta il valore della propriet� year. - * - * @param value - * allowed object is - * {@link String } - * - */ public void setYear(String value) { this.year = value; } From 71793635d32d50427bc4165b29b39aaabec3d743 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 7 Feb 2016 20:55:46 +0100 Subject: [PATCH 304/626] CleanUp Code --- RestEasy Example/pom.xml | 3 +- .../baeldung/client/ServicesInterface.java | 1 - .../main/java/com/baeldung/model/Movie.java | 2 -- .../com/baeldung/server/MovieCrudService.java | 17 ++++------- .../com/baeldung/server/RestEasyServices.java | 8 ----- .../src/main/resources/schema1.xsd | 29 ------------------- .../src/main/webapp/WEB-INF/web.xml | 3 -- .../java/baeldung/client/RestEasyClient.java | 7 ----- .../baeldung/server/RestEasyClientTest.java | 1 - 9 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 RestEasy Example/src/main/resources/schema1.xsd delete mode 100644 RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 6935238d910f..9c890da2b75e 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -36,7 +36,7 @@ - + org.jboss.resteasy jaxrs-api @@ -101,5 +101,4 @@ - \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 8898b834838b..22669717a8b6 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -1,7 +1,6 @@ package com.baeldung.client; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 805ba95209ec..56ba766ff401 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -1,11 +1,9 @@ - package com.baeldung.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; - @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "movie", propOrder = { "actors", diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 29226aa0e094..bbb3b1e9531e 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -1,7 +1,6 @@ package com.baeldung.server; import com.baeldung.model.Movie; - import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -11,23 +10,21 @@ import java.util.Map; import java.util.stream.Collectors; - @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); @GET @Path("/getinfo") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){ + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbID)){ - return inventory.get(imdbID); + if(inventory.containsKey(imdbId)){ + return inventory.get(imdbId); }else return null; } @@ -70,16 +67,16 @@ public Response updateMovie(Movie movie){ @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbID){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId){ System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbID)){ + if (null==inventory.get(imdbId)){ return Response.status(Response.Status.NOT_FOUND) .entity("Movie is not in the database.\nUnable to Delete").build(); } - inventory.remove(imdbID); + inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } @@ -93,6 +90,4 @@ public List listMovies(){ } - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java index 8c57d2c9b466..7726e49f3830 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java @@ -1,19 +1,11 @@ package com.baeldung.server; - import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Set; -/** - * Created by Admin on 29/01/2016. - */ - - - @ApplicationPath("/rest") public class RestEasyServices extends Application { diff --git a/RestEasy Example/src/main/resources/schema1.xsd b/RestEasy Example/src/main/resources/schema1.xsd deleted file mode 100644 index 0d74b7c366bb..000000000000 --- a/RestEasy Example/src/main/resources/schema1.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index f70fdf79751a..1e7f64004dd0 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -5,12 +5,9 @@ RestEasy Example - resteasy.servlet.mapping.prefix /rest - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java deleted file mode 100644 index b474b3d4f834..000000000000 --- a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java +++ /dev/null @@ -1,7 +0,0 @@ -package baeldung.client; - -/** - * Created by Admin on 29/01/2016. - */ -public class RestEasyClient { -} diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index b6a2e2a0c108..faa39e019992 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -10,7 +10,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.Before; import org.junit.Test; - import javax.naming.NamingException; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; From 04d9bbb7682999c0d90054150aac69cbfa442781 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 14:00:11 +0100 Subject: [PATCH 305/626] CleanUp and reformatting Code; dependency fix in pom.xml --- RestEasy Example/pom.xml | 175 ++++++++---------- .../baeldung/client/ServicesInterface.java | 21 +-- .../main/java/com/baeldung/model/Movie.java | 56 +----- .../com/baeldung/server/MovieCrudService.java | 49 +++-- .../WEB-INF/jboss-deployment-structure.xml | 22 +-- .../src/main/webapp/WEB-INF/web.xml | 14 +- .../baeldung/server/RestEasyClientTest.java | 23 +-- .../com/baeldung/server/movies/batman.json | 2 +- .../baeldung/server/movies/transformer.json | 2 +- 9 files changed, 139 insertions(+), 225 deletions(-) diff --git a/RestEasy Example/pom.xml b/RestEasy Example/pom.xml index 9c890da2b75e..ec9e87b0d1e2 100644 --- a/RestEasy Example/pom.xml +++ b/RestEasy Example/pom.xml @@ -1,104 +1,77 @@ - - 4.0.0 - - com.baeldung - resteasy-tutorial - 1.0 - war - - - - jboss - http://repository.jboss.org/nexus/content/groups/public/ - - - - - 3.0.14.Final - runtime - - - - RestEasyTutorial - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - - - - org.jboss.resteasy - jaxrs-api - 3.0.12.Final - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-servlet-initializer - ${resteasy.version} - ${resteasy.scope} - - - jboss-jaxrs-api_2.0_spec - org.jboss.spec.javax.ws.rs - - - - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - ${resteasy.scope} - - - - - javax.ws.rs - javax.ws.rs-api - 2.0.1 - - - - org.jboss.resteasy - resteasy-jackson-provider - ${resteasy.version} - ${resteasy.scope} - - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - ${resteasy.scope} - - - - - - junit - junit - 4.4 - - - - commons-io - commons-io - 2.4 - - - + + 4.0.0 + + com.baeldung + resteasy-tutorial + 1.0 + war + + + 3.0.14.Final + + + + RestEasyTutorial + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.version} + + + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + + + + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + + + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + \ No newline at end of file diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java index 22669717a8b6..3d03c16fafd4 100644 --- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java @@ -9,41 +9,28 @@ @Path("/movies") public interface ServicesInterface { - @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Movie movieByImdbId(@QueryParam("imdbId") String imdbId); - - @GET - @Path("/listmovies") - @Produces({"application/json"}) - List listMovies(); - - @GET @Path("/listmovies") - @Produces({"application/json"}) + @Produces({ "application/json" }) List listMovies(); - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response addMovie(Movie movie); - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response updateMovie(Movie movie); - @DELETE @Path("/deletemovie") Response deleteMovie(@QueryParam("imdbId") String imdbID); - - } diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 56ba766ff401..a959682a75e5 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -5,28 +5,7 @@ import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { - "actors", - "awards", - "country", - "director", - "genre", - "imdbId", - "imdbRating", - "imdbVotes", - "language", - "metascore", - "plot", - "poster", - "rated", - "released", - "response", - "runtime", - "title", - "type", - "writer", - "year" -}) +@XmlType(name = "movie", propOrder = { "actors", "awards", "country", "director", "genre", "imdbId", "imdbRating", "imdbVotes", "language", "metascore", "plot", "poster", "rated", "released", "response", "runtime", "title", "type", "writer", "year" }) public class Movie { protected String actors; @@ -213,37 +192,22 @@ public void setYear(String value) { @Override public String toString() { - return "Movie{" + - "actors='" + actors + '\'' + - ", awards='" + awards + '\'' + - ", country='" + country + '\'' + - ", director='" + director + '\'' + - ", genre='" + genre + '\'' + - ", imdbId='" + imdbId + '\'' + - ", imdbRating='" + imdbRating + '\'' + - ", imdbVotes='" + imdbVotes + '\'' + - ", language='" + language + '\'' + - ", metascore='" + metascore + '\'' + - ", poster='" + poster + '\'' + - ", rated='" + rated + '\'' + - ", released='" + released + '\'' + - ", response='" + response + '\'' + - ", runtime='" + runtime + '\'' + - ", title='" + title + '\'' + - ", type='" + type + '\'' + - ", writer='" + writer + '\'' + - ", year='" + year + '\'' + - '}'; + return "Movie{" + "actors='" + actors + '\'' + ", awards='" + awards + '\'' + ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' + + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + ", metascore='" + metascore + '\'' + ", poster='" + poster + '\'' + ", rated='" + rated + '\'' + ", released='" + released + '\'' + ", response='" + response + '\'' + + ", runtime='" + runtime + '\'' + ", title='" + title + '\'' + ", type='" + type + '\'' + ", writer='" + writer + '\'' + ", year='" + year + '\'' + '}'; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; Movie movie = (Movie) o; - if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false; + if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) + return false; return title != null ? title.equals(movie.title) : movie.title == null; } diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index bbb3b1e9531e..6a0699874a19 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -13,78 +13,71 @@ @Path("/movies") public class MovieCrudService { - private Map inventory = new HashMap(); - + private Map inventory = new HashMap(); @GET @Path("/getinfo") - @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Movie movieByImdbId(@QueryParam("imdbId") String imdbId){ + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling getinfo for a given ImdbID***"); - if(inventory.containsKey(imdbId)){ + if (inventory.containsKey(imdbId)) { return inventory.get(imdbId); - }else return null; + } else + return null; } - @POST @Path("/addmovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response addMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response addMovie(Movie movie) { System.out.println("*** Calling addMovie ***"); - if (null!=inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is Already in the database.").build(); + if (null != inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is Already in the database.").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.CREATED).build(); } - @PUT @Path("/updatemovie") - @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) - public Response updateMovie(Movie movie){ + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response updateMovie(Movie movie) { System.out.println("*** Calling updateMovie ***"); - if (null==inventory.get(movie.getImdbId())){ - return Response.status(Response.Status.NOT_MODIFIED) - .entity("Movie is not in the database.\nUnable to Update").build(); + if (null == inventory.get(movie.getImdbId())) { + return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } - inventory.put(movie.getImdbId(),movie); + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); } - @DELETE @Path("/deletemovie") - public Response deleteMovie(@QueryParam("imdbId") String imdbId){ + public Response deleteMovie(@QueryParam("imdbId") String imdbId) { System.out.println("*** Calling deleteMovie ***"); - if (null==inventory.get(imdbId)){ - return Response.status(Response.Status.NOT_FOUND) - .entity("Movie is not in the database.\nUnable to Delete").build(); + if (null == inventory.get(imdbId)) { + return Response.status(Response.Status.NOT_FOUND).entity("Movie is not in the database.\nUnable to Delete").build(); } inventory.remove(imdbId); return Response.status(Response.Status.OK).build(); } - @GET @Path("/listmovies") - @Produces({"application/json"}) - public List listMovies(){ + @Produces({ "application/json" }) + public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 84d75934a70c..7879603d19ac 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,16 +1,16 @@ - - - - + + + + - - - - - + + + + + - - + + \ No newline at end of file diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml index 1e7f64004dd0..d5f00293f4e7 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml @@ -1,13 +1,13 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - RestEasy Example + RestEasy Example - - resteasy.servlet.mapping.prefix - /rest - + + resteasy.servlet.mapping.prefix + /rest + \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index faa39e019992..3760ae241598 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -21,14 +21,14 @@ public class RestEasyClientTest { - Movie transformerMovie=null; - Movie batmanMovie=null; - ObjectMapper jsonMapper=null; + Movie transformerMovie = null; + Movie batmanMovie = null; + ObjectMapper jsonMapper = null; @Before public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper = new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); jsonMapper.setDateFormat(sdf); @@ -69,7 +69,7 @@ public void testListAllMovies() { @Test public void testMovieByImdbId() { - String transformerImdbId="tt0418279"; + String transformerImdbId = "tt0418279"; ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); @@ -82,7 +82,6 @@ public void testMovieByImdbId() { System.out.println(movies); } - @Test public void testAddMovie() { @@ -99,10 +98,9 @@ public void testAddMovie() { } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testDeleteMovi1e() { @@ -116,14 +114,13 @@ public void testDeleteMovi1e() { if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } - @Test public void testUpdateMovie() { @@ -137,11 +134,11 @@ public void testUpdateMovie() { moviesResponse = simple.updateMovie(batmanMovie); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); } moviesResponse.close(); - System.out.println("Response Code: "+Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); } } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json index 28061d5bf94d..173901c9483f 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -16,7 +16,7 @@ "metascore": "66", "imdbRating": "7.6", "imdbVotes": "256,000", - "imdbID": "tt0096895", + "imdbId": "tt0096895", "type": "movie", "response": "True" } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index a3b033a8ba6f..a4fd061a82db 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -16,7 +16,7 @@ "metascore": "61", "imdbRating": "7.1", "imdbVotes": "492,225", - "imdbID": "tt0418279", + "imdbId": "tt0418279", "type": "movie", "response": "True" } \ No newline at end of file From 81f498407142bcc91071110ef20d0ee9a5b5da98 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Mon, 8 Feb 2016 16:08:15 +0100 Subject: [PATCH 306/626] CleanUp and reformatting Code. --- .../src/main/java/com/baeldung/server/MovieCrudService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java index 6a0699874a19..b7f3215f3ff2 100644 --- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java +++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java @@ -26,7 +26,6 @@ public Movie movieByImdbId(@QueryParam("imdbId") String imdbId) { return inventory.get(imdbId); } else return null; - } @POST @@ -41,7 +40,6 @@ public Response addMovie(Movie movie) { } inventory.put(movie.getImdbId(), movie); - return Response.status(Response.Status.CREATED).build(); } @@ -55,9 +53,9 @@ public Response updateMovie(Movie movie) { if (null == inventory.get(movie.getImdbId())) { return Response.status(Response.Status.NOT_MODIFIED).entity("Movie is not in the database.\nUnable to Update").build(); } + inventory.put(movie.getImdbId(), movie); return Response.status(Response.Status.OK).build(); - } @DELETE @@ -80,7 +78,6 @@ public Response deleteMovie(@QueryParam("imdbId") String imdbId) { public List listMovies() { return inventory.values().stream().collect(Collectors.toCollection(ArrayList::new)); - } } From 1c8e8a2e0c5683bcc0b992e631807b016d1d45a6 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 13 Feb 2016 23:48:11 +0100 Subject: [PATCH 307/626] Formatting and many fields removed from Movie class --- .../main/java/com/baeldung/model/Movie.java | 188 ++---------------- .../WEB-INF/jboss-deployment-structure.xml | 3 - .../baeldung/server/RestEasyClientTest.java | 2 +- .../com/baeldung/server/movies/batman.json | 20 +- .../baeldung/server/movies/transformer.json | 20 +- 5 files changed, 20 insertions(+), 213 deletions(-) diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java index 5aade4591a5f..408f2144fbde 100644 --- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java +++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java @@ -5,195 +5,33 @@ import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "movie", propOrder = { "actors", "awards", "country", "director", "genre", "imdbId", "imdbRating", "imdbVotes", "language", "metascore", "plot", "poster", "rated", "released", "response", "runtime", "title", "type", "writer", "year" }) +@XmlType(name = "movie", propOrder = { "imdbId", "title" }) public class Movie { - protected String actors; - protected String awards; - protected String country; - protected String director; - protected String genre; protected String imdbId; - protected String imdbRating; - protected String imdbVotes; - protected String language; - protected String metascore; - protected String plot; - protected String poster; - protected String rated; - protected String released; - protected String response; - protected String runtime; protected String title; - protected String type; - protected String writer; - protected String year; - public String getActors() { - return actors; + public Movie(String imdbId, String title) { + this.imdbId = imdbId; + this.title = title; } - public void setActors(String value) { - this.actors = value; - } - - public String getAwards() { - return awards; - } - - public void setAwards(String value) { - this.awards = value; - } - - public String getCountry() { - return country; - } - - public void setCountry(String value) { - this.country = value; - } - - public String getDirector() { - return director; - } - - public void setDirector(String value) { - this.director = value; - } - - public String getGenre() { - return genre; - } - - public void setGenre(String value) { - this.genre = value; - } + public Movie() {} public String getImdbId() { return imdbId; } - public void setImdbId(String value) { - this.imdbId = value; - } - - public String getImdbRating() { - return imdbRating; - } - - public void setImdbRating(String value) { - this.imdbRating = value; - } - - public String getImdbVotes() { - return imdbVotes; - } - - public void setImdbVotes(String value) { - this.imdbVotes = value; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String value) { - this.language = value; - } - - public String getMetascore() { - return metascore; - } - - public void setMetascore(String value) { - this.metascore = value; - } - - public String getPlot() { - return plot; - } - - public void setPlot(String value) { - this.plot = value; - } - - public String getPoster() { - return poster; - } - - public void setPoster(String value) { - this.poster = value; - } - - public String getRated() { - return rated; - } - - public void setRated(String value) { - this.rated = value; - } - - public String getReleased() { - return released; - } - - public void setReleased(String value) { - this.released = value; - } - - public String getResponse() { - return response; - } - - public void setResponse(String value) { - this.response = value; - } - - public String getRuntime() { - return runtime; - } - - public void setRuntime(String value) { - this.runtime = value; + public void setImdbId(String imdbId) { + this.imdbId = imdbId; } public String getTitle() { return title; } - public void setTitle(String value) { - this.title = value; - } - - public String getType() { - return type; - } - - public void setType(String value) { - this.type = value; - } - - public String getWriter() { - return writer; - } - - public void setWriter(String value) { - this.writer = value; - } - - public String getYear() { - return year; - } - - public void setYear(String value) { - this.year = value; - } - - @Override - public String toString() { - return "Movie{" + "actors='" + actors + '\'' + ", awards='" + awards + '\'' + ", country='" + country + '\'' + ", director='" + director + '\'' + ", genre='" + genre + '\'' + ", imdbId='" + imdbId + '\'' + ", imdbRating='" + imdbRating + '\'' - + ", imdbVotes='" + imdbVotes + '\'' + ", language='" + language + '\'' + ", metascore='" + metascore + '\'' + ", poster='" + poster + '\'' + ", rated='" + rated + '\'' + ", released='" + released + '\'' + ", response='" + response + '\'' - + ", runtime='" + runtime + '\'' + ", title='" + title + '\'' + ", type='" + type + '\'' + ", writer='" + writer + '\'' + ", year='" + year + '\'' + '}'; + public void setTitle(String title) { + this.title = title; } @Override @@ -217,4 +55,12 @@ public int hashCode() { result = 31 * result + (title != null ? title.hashCode() : 0); return result; } + + @Override + public String toString() { + return "Movie{" + + "imdbId='" + imdbId + '\'' + + ", title='" + title + '\'' + + '}'; + } } diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 7879603d19ac..e5b893e56aee 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -3,14 +3,11 @@ - - - \ No newline at end of file diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java index 3760ae241598..2a13465ebcd7 100644 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -130,7 +130,7 @@ public void testUpdateMovie() { Response moviesResponse = simple.addMovie(batmanMovie); moviesResponse.close(); - batmanMovie.setImdbVotes("300,000"); + batmanMovie.setTitle("Batman Begins"); moviesResponse = simple.updateMovie(batmanMovie); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json index 173901c9483f..82aaaa8f40ba 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json @@ -1,22 +1,4 @@ { "title": "Batman", - "year": "1989", - "rated": "PG-13", - "released": "23 Jun 1989", - "runtime": "126 min", - "genre": "Action, Adventure", - "director": "Tim Burton", - "writer": "Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)", - "actors": "Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl", - "plot": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.", - "language": "English, French", - "country": "USA, UK", - "awards": "Won 1 Oscar. Another 9 wins & 22 nominations.", - "poster": "http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg", - "metascore": "66", - "imdbRating": "7.6", - "imdbVotes": "256,000", - "imdbId": "tt0096895", - "type": "movie", - "response": "True" + "imdbId": "tt0096895" } \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json index a4fd061a82db..634cefc73c99 100644 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json +++ b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json @@ -1,22 +1,4 @@ { "title": "Transformers", - "year": "2007", - "rated": "PG-13", - "released": "03 Jul 2007", - "runtime": "144 min", - "genre": "Action, Adventure, Sci-Fi", - "director": "Michael Bay", - "writer": "Roberto Orci (screenplay), Alex Kurtzman (screenplay), John Rogers (story), Roberto Orci (story), Alex Kurtzman (story)", - "actors": "Shia LaBeouf, Megan Fox, Josh Duhamel, Tyrese Gibson", - "plot": "A long time ago, far away on the planet of Cybertron, a war is being waged between the noble Autobots (led by the wise Optimus Prime) and the devious Decepticons (commanded by the dreaded Megatron) for control over the Allspark, a mystical talisman that would grant unlimited power to whoever possesses it. The Autobots managed to smuggle the Allspark off the planet, but Megatron blasts off in search of it. He eventually tracks it to the planet of Earth (circa 1850), but his reckless desire for power sends him right into the Arctic Ocean, and the sheer cold forces him into a paralyzed state. His body is later found by Captain Archibald Witwicky, but before going into a comatose state Megatron uses the last of his energy to engrave into the Captain's glasses a map showing the location of the Allspark, and to send a transmission to Cybertron. Megatron is then carried away aboard the Captain's ship. A century later, Captain Witwicky's grandson Sam Witwicky (nicknamed Spike by his friends) buys his first car. To his shock, he discovers it to be Bumblebee, an Autobot in disguise who is to protect Spike, who possesses the Captain's glasses and the map engraved on them. But Bumblebee is not the only Transformer to have arrived on Earth - in the desert of Qatar, the Decepticons Blackout and Scorponok attack a U.S. military base, causing the Pentagon to send their special Sector Seven agents to capture all \"specimens of this alien race.\" Spike and his girlfriend Mikaela find themselves in the midst of a grand battle between the Autobots and the Decepticons, stretching from Hoover Dam all the way to Los Angeles. Meanwhile, deep inside Hoover Dam, the cryogenically stored body of Megatron awakens.", - "language": "English, Spanish", - "country": "USA", - "awards": "Nominated for 3 Oscars. Another 18 wins & 40 nominations.", - "poster": "http://ia.media-imdb.com/images/M/MV5BMTQwNjU5MzUzNl5BMl5BanBnXkFtZTYwMzc1MTI3._V1_SX300.jpg", - "metascore": "61", - "imdbRating": "7.1", - "imdbVotes": "492,225", - "imdbId": "tt0418279", - "type": "movie", - "response": "True" + "imdbId": "tt0418279" } \ No newline at end of file From 957b0958e3190caf2790d8cac15715be20a1e57a Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 14 Feb 2016 00:35:19 +0100 Subject: [PATCH 308/626] Reformatting Code. --- .../main/webapp/WEB-INF/jboss-deployment-structure.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index e5b893e56aee..45dfd9f07513 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,13 +1,17 @@ + - + + - - + + + + \ No newline at end of file From fa39351b6e31f8ed1483e75df5448e3a333cd7b1 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Sun, 14 Feb 2016 00:40:02 +0100 Subject: [PATCH 309/626] Reformatting Code. --- .../WEB-INF/jboss-deployment-structure.xml | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 45dfd9f07513..cb258374a104 100644 --- a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,17 +1,13 @@ + - - - - - - + + + + - - - - - - - + + + + - \ No newline at end of file + From 72214652846664333aaa334b1f05d88e13a0c070 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 Feb 2016 11:15:29 +0200 Subject: [PATCH 310/626] cleanup work --- spring-security-login-and-registration/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-security-login-and-registration/pom.xml b/spring-security-login-and-registration/pom.xml index f5b62be553de..bcbe9371e2cc 100644 --- a/spring-security-login-and-registration/pom.xml +++ b/spring-security-login-and-registration/pom.xml @@ -269,7 +269,8 @@ ${maven-surefire-plugin.version} - + **/*IntegrationTest.java + **/*LiveTest.java From 33e5f14e86ee2913d11d8df5603dd9d20d70d34b Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sun, 14 Feb 2016 12:34:32 +0100 Subject: [PATCH 311/626] Example folders cleaned --- .../baeldung/server/RestEasyClientTest.java | 144 ------------------ .../com/baeldung/server/movies/batman.json | 4 - .../baeldung/server/movies/transformer.json | 4 - 3 files changed, 152 deletions(-) delete mode 100644 RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java delete mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json delete mode 100644 RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java deleted file mode 100644 index 2a13465ebcd7..000000000000 --- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.baeldung.server; - -import com.baeldung.client.ServicesInterface; -import com.baeldung.model.Movie; -import org.apache.commons.io.IOUtils; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.junit.Before; -import org.junit.Test; -import javax.naming.NamingException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Locale; - -public class RestEasyClientTest { - - Movie transformerMovie = null; - Movie batmanMovie = null; - ObjectMapper jsonMapper = null; - - @Before - public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { - - jsonMapper = new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); - jsonMapper.setDateFormat(sdf); - - try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) { - String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test is going to die ...", e); - } - - try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) { - String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); - batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); - - } catch (Exception e) { - throw new RuntimeException("Test is going to die ...", e); - } - } - - @Test - public void testListAllMovies() { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - - List movies = simple.listMovies(); - System.out.println(movies); - } - - @Test - public void testMovieByImdbId() { - - String transformerImdbId = "tt0418279"; - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(transformerMovie); - moviesResponse.close(); - - Movie movies = simple.movieByImdbId(transformerImdbId); - System.out.println(movies); - } - - @Test - public void testAddMovie() { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); - - if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - - moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); - } - - @Test - public void testDeleteMovi1e() { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); - - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println(moviesResponse.readEntity(String.class)); - throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - - moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); - } - - @Test - public void testUpdateMovie() { - - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); - ServicesInterface simple = target.proxy(ServicesInterface.class); - - Response moviesResponse = simple.addMovie(batmanMovie); - moviesResponse.close(); - batmanMovie.setTitle("Batman Begins"); - moviesResponse = simple.updateMovie(batmanMovie); - - if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { - System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); - } - - moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); - } - -} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json deleted file mode 100644 index 82aaaa8f40ba..000000000000 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/batman.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "title": "Batman", - "imdbId": "tt0096895" -} \ No newline at end of file diff --git a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json b/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json deleted file mode 100644 index 634cefc73c99..000000000000 --- a/RestEasy Example/src/test/resources/com/baeldung/server/movies/transformer.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "title": "Transformers", - "imdbId": "tt0418279" -} \ No newline at end of file From aedffc1d139ce5c54fec86d1e0d411ee09a8c590 Mon Sep 17 00:00:00 2001 From: ypatil Date: Mon, 15 Feb 2016 15:29:13 +0530 Subject: [PATCH 312/626] data folder moved under test/data. Test cases added. Code & POM updated. --- spring-apache-camel/data/file1.txt | 1 - .../data/input/.camel/file1.txt | 1 - .../data/outputLowerCase/file1.txt | 1 - .../data/outputUppperCase/file1.txt | 1 - spring-apache-camel/pom.xml | 26 +++- .../main/java/org/apache/camel/main/App.java | 4 +- .../apache/camel/processor/FileProcessor.java | 7 +- .../src/main/resources/camel-context.xml | 35 +++--- .../src/test/data/sampleInputFile/file.txt | 1 + .../java/org/apache/camel/main/AppTest.java | 117 ++++++++++++++++++ 10 files changed, 163 insertions(+), 31 deletions(-) delete mode 100644 spring-apache-camel/data/file1.txt delete mode 100644 spring-apache-camel/data/input/.camel/file1.txt delete mode 100644 spring-apache-camel/data/outputLowerCase/file1.txt delete mode 100644 spring-apache-camel/data/outputUppperCase/file1.txt create mode 100644 spring-apache-camel/src/test/data/sampleInputFile/file.txt create mode 100644 spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java diff --git a/spring-apache-camel/data/file1.txt b/spring-apache-camel/data/file1.txt deleted file mode 100644 index c8436b654b15..000000000000 --- a/spring-apache-camel/data/file1.txt +++ /dev/null @@ -1 +0,0 @@ -THIS IS UPPERCASE CONTENT. this is lowecase content. \ No newline at end of file diff --git a/spring-apache-camel/data/input/.camel/file1.txt b/spring-apache-camel/data/input/.camel/file1.txt deleted file mode 100644 index c8436b654b15..000000000000 --- a/spring-apache-camel/data/input/.camel/file1.txt +++ /dev/null @@ -1 +0,0 @@ -THIS IS UPPERCASE CONTENT. this is lowecase content. \ No newline at end of file diff --git a/spring-apache-camel/data/outputLowerCase/file1.txt b/spring-apache-camel/data/outputLowerCase/file1.txt deleted file mode 100644 index 06a9866342a2..000000000000 --- a/spring-apache-camel/data/outputLowerCase/file1.txt +++ /dev/null @@ -1 +0,0 @@ -this is uppercase content. this is lowecase content. \ No newline at end of file diff --git a/spring-apache-camel/data/outputUppperCase/file1.txt b/spring-apache-camel/data/outputUppperCase/file1.txt deleted file mode 100644 index ce07e477bc26..000000000000 --- a/spring-apache-camel/data/outputUppperCase/file1.txt +++ /dev/null @@ -1 +0,0 @@ -THIS IS UPPERCASE CONTENT. THIS IS LOWECASE CONTENT. \ No newline at end of file diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml index 5b143fedb404..fbea9b779dae 100644 --- a/spring-apache-camel/pom.xml +++ b/spring-apache-camel/pom.xml @@ -11,10 +11,19 @@ 2.16.1 4.2.4.RELEASE + 1.7 + 4.1 - + + + junit + junit + ${junit.version} + test + + org.apache.camel camel-core @@ -40,4 +49,19 @@ + + + + + maven-compiler-plugin + + true + true + ${java.version} + ${java.version} + ${java.version} + + + + diff --git a/spring-apache-camel/src/main/java/org/apache/camel/main/App.java b/spring-apache-camel/src/main/java/org/apache/camel/main/App.java index 4d0793903ed9..8674caefcae5 100644 --- a/spring-apache-camel/src/main/java/org/apache/camel/main/App.java +++ b/spring-apache-camel/src/main/java/org/apache/camel/main/App.java @@ -4,9 +4,9 @@ public class App { public static void main(final String[] args) throws Exception { - //Load application context ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml"); - Thread.sleep(5000); + // Keep main thread alive for some time to let application finish processing the input files. + Thread.sleep(5000); applicationContext.close(); } } \ No newline at end of file diff --git a/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java b/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java index 961f8778066c..a98c77feb880 100644 --- a/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java +++ b/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java @@ -6,13 +6,8 @@ public class FileProcessor implements Processor { public void process(Exchange exchange) throws Exception { - //Read file content - String originalFileContent = (String)exchange.getIn().getBody(String.class); - - //Convert file content to upper case. + String originalFileContent = exchange.getIn().getBody(String.class); String upperCaseFileContent = originalFileContent.toUpperCase(); - - //Update file content. exchange.getIn().setBody(upperCaseFileContent); } diff --git a/spring-apache-camel/src/main/resources/camel-context.xml b/spring-apache-camel/src/main/resources/camel-context.xml index d304ceb85710..75e2a61711a1 100644 --- a/spring-apache-camel/src/main/resources/camel-context.xml +++ b/spring-apache-camel/src/main/resources/camel-context.xml @@ -1,40 +1,39 @@ + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - - - + + + - - + + - + - - + + ${body.toLowerCase()} - + - - + + - .......... File content conversion completed .......... + .......... File content conversion completed .......... + - + - + diff --git a/spring-apache-camel/src/test/data/sampleInputFile/file.txt b/spring-apache-camel/src/test/data/sampleInputFile/file.txt new file mode 100644 index 000000000000..c1df3791c931 --- /dev/null +++ b/spring-apache-camel/src/test/data/sampleInputFile/file.txt @@ -0,0 +1 @@ +THIS IS UPPERCASE CONTENT. this is lowercase content. \ No newline at end of file diff --git a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java b/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java new file mode 100644 index 000000000000..75a161d8cc18 --- /dev/null +++ b/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java @@ -0,0 +1,117 @@ +package org.apache.camel.main; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Paths; + +import junit.framework.TestCase; + +import org.apache.camel.util.FileUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class AppTest extends TestCase { + + private static final String FILE_NAME = "file.txt"; + private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/"; + private static final String TEST_INPUT_DIR = "src/test/data/input/"; + private static final String UPPERCARE_OUTPUT_DIR = "src/test/data/outputUpperCase/"; + private static final String LOWERCASE_OUTPUT_DIR = "src/test/data/outputLowerCase/"; + + @Before + public void setUp() throws Exception { + // Prepare input file for test + copySampleFileToInputDirectory(); + } + + @After + public void tearDown() throws Exception { + System.out.println("Deleting the test input and output files..."); + deleteFile(TEST_INPUT_DIR); + deleteFile(LOWERCASE_OUTPUT_DIR); + deleteFile(UPPERCARE_OUTPUT_DIR); + } + + @Test + public final void testMain() throws Exception { + App.main(null); + + String inputFileContent = readFileContent(SAMPLE_INPUT_DIR+FILE_NAME); + String outputUpperCase = readFileContent(UPPERCARE_OUTPUT_DIR+FILE_NAME); + String outputLowerCase = readFileContent(LOWERCASE_OUTPUT_DIR+FILE_NAME); + + System.out.println("Input File content = ["+inputFileContent+"]"); + System.out.println("UpperCaseOutput file content = ["+outputUpperCase+"]"); + System.out.println("LowerCaseOtput file content = ["+outputLowerCase+"]"); + + assertEquals(inputFileContent.toUpperCase(), outputUpperCase); + assertEquals(inputFileContent.toLowerCase(), outputLowerCase); + } + + private String readFileContent(String path) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded); + } + + private void deleteFile(String path) { + try { + FileUtil.removeDir(new File(path)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Copy sample input file to input directory. + */ + private void copySampleFileToInputDirectory() { + File sourceFile = new File(SAMPLE_INPUT_DIR + FILE_NAME); + File destFile = new File(TEST_INPUT_DIR + FILE_NAME); + + if (!sourceFile.exists()) { + System.out.println("Sample input file not found at location = [" + SAMPLE_INPUT_DIR + FILE_NAME + "]. Please provide this file."); + } + + if (!destFile.exists()) { + try { + System.out.println("Creating input file = [" + TEST_INPUT_DIR + FILE_NAME + "]"); + + File destDir = new File(TEST_INPUT_DIR); + if(!destDir.exists()) { + destDir.mkdir(); + } + destFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + FileChannel source = null; + FileChannel destination = null; + + try { + source = new FileInputStream(sourceFile).getChannel(); + destination = new FileOutputStream(destFile).getChannel(); + if (destination != null && source != null) { + destination.transferFrom(source, 0, source.size()); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + source.close(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + destination.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} From 7fb50bfaed8280acf7c4dbdf486087dac7d2b7b0 Mon Sep 17 00:00:00 2001 From: Kevin Gilmore Date: Wed, 17 Feb 2016 11:38:29 -0600 Subject: [PATCH 313/626] Added files for RAML annotations article --- raml/annotations/api.raml | 126 ++++++++++++++++++ raml/annotations/examples/Bar.json | 6 + raml/annotations/examples/Bars.json | 19 +++ raml/annotations/examples/Error.json | 4 + raml/annotations/examples/Foo.json | 4 + raml/annotations/examples/Foos.json | 16 +++ .../extensions/en_US/additionalResources.raml | 13 ++ raml/annotations/libraries/dataTypes.raml | 19 +++ raml/annotations/libraries/resourceTypes.raml | 38 ++++++ .../libraries/securitySchemes.raml | 20 +++ raml/annotations/libraries/traits.raml | 32 +++++ .../overlays/es_ES/additionalResources.raml | 11 ++ .../overlays/es_ES/documentationItems.raml | 22 +++ 13 files changed, 330 insertions(+) create mode 100644 raml/annotations/api.raml create mode 100644 raml/annotations/examples/Bar.json create mode 100644 raml/annotations/examples/Bars.json create mode 100644 raml/annotations/examples/Error.json create mode 100644 raml/annotations/examples/Foo.json create mode 100644 raml/annotations/examples/Foos.json create mode 100644 raml/annotations/extensions/en_US/additionalResources.raml create mode 100644 raml/annotations/libraries/dataTypes.raml create mode 100644 raml/annotations/libraries/resourceTypes.raml create mode 100644 raml/annotations/libraries/securitySchemes.raml create mode 100644 raml/annotations/libraries/traits.raml create mode 100644 raml/annotations/overlays/es_ES/additionalResources.raml create mode 100644 raml/annotations/overlays/es_ES/documentationItems.raml diff --git a/raml/annotations/api.raml b/raml/annotations/api.raml new file mode 100644 index 000000000000..e0123536ebd5 --- /dev/null +++ b/raml/annotations/api.raml @@ -0,0 +1,126 @@ +#%RAML 1.0 +title: API for REST Services used in the RAML tutorials on Baeldung.com +documentation: + - title: Overview + content: | + This document defines the interface for the REST services + used in the popular RAML Tutorial series at Baeldung.com. + - title: Disclaimer + content: | + All names used in this definition are purely fictional. + Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental. + - title: Copyright + content: Copyright 2016 by Baeldung.com. All rights reserved. +uses: + mySecuritySchemes: !include libraries/securitySchemes.raml + myDataTypes: !include libraries/dataTypes.raml + myTraits: !include libraries/traits.raml + myResourceTypes: !include libraries/resourceTypes.raml +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: [ mySecuritySchemes.basicAuth ] +annotationTypes: + testCase: + allowedTargets: [ Method ] + allowMultiple: true + usage: | + Use this annotation to declare a test case + within a testSuite declaration. + You may apply this annotation multiple times + within the target testSuite. + properties: + scenario: string + setupScript?: string[] + testScript: string[] + expectedOutput?: string + cleanupScript?: string[] +/foos: + type: myResourceTypes.collection + get: + queryParameters: + name?: string + ownerName?: string + responses: + 200: + body: + example: !include examples/Foos.json + (testCase): + scenario: No Foos + setupScript: deleteAllFoosIfAny + testScript: getAllFoos + expectedOutput: "" + (testCase): + scenario: One Foo + setupScript: [ deleteAllFoosIfAny, addInputFoos ] + testScript: getAllFoos + expectedOutput: '[ { "id": 999, "name": Joe } ]' + cleanupScript: deleteInputFoos + (testCase): + scenario: Multiple Foos + setupScript: [ deleteAllFoosIfAny, addInputFoos ] + testScript: getAllFoos + expectedOutput: '[ { "id": 998, "name": "Bob" }, { "id": 999, "name": "Joe", "ownerName": "Bob" } ]' + cleanupScript: deleteInputFoos + post: + responses: + 200: + body: + example: !include examples/Foo.json + /{fooId}: + type: myResourceTypes.item + get: + responses: + 200: + body: + example: !include examples/Foo.json + put: + responses: + 200: + body: + example: !include examples/Foo.json +/foos/name/{name}: + get: + description: Get all Foos with the name {name} + responses: + 200: + body: + type: myDataTypes.Foo + 404: + body: + type: myDataTypes.Error +/foos/bar/{barId}: + get: + description: Get the Foo for the Bar with barId = {barId} + responses: + 200: + body: + example: !include examples/Foo.json +/bars: + type: myResourceTypes.collection + get: + queryParameters: + name?: string + ownerName?: string + responses: + 200: + body: + example: !include examples/Bars.json + post: + responses: + 200: + body: + example: !include examples/Bar.json + /{barId}: + type: myResourceTypes.item + get: + responses: + 200: + body: + example: !include examples/Bar.json + put: + responses: + 200: + body: + example: !include examples/Bars.json diff --git a/raml/annotations/examples/Bar.json b/raml/annotations/examples/Bar.json new file mode 100644 index 000000000000..0ee1b34edbfe --- /dev/null +++ b/raml/annotations/examples/Bar.json @@ -0,0 +1,6 @@ +{ + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 +} \ No newline at end of file diff --git a/raml/annotations/examples/Bars.json b/raml/annotations/examples/Bars.json new file mode 100644 index 000000000000..89ea87543244 --- /dev/null +++ b/raml/annotations/examples/Bars.json @@ -0,0 +1,19 @@ +[ + { + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 + }, + { + "id" : 2, + "name" : "Second Bar", + "city" : "Dallas", + "fooId" : 1 + }, + { + "id" : 3, + "name" : "Third Bar", + "fooId" : 2 + } +] \ No newline at end of file diff --git a/raml/annotations/examples/Error.json b/raml/annotations/examples/Error.json new file mode 100644 index 000000000000..dca56da7c2b7 --- /dev/null +++ b/raml/annotations/examples/Error.json @@ -0,0 +1,4 @@ +{ + "message" : "Not found", + "code" : 1001 +} \ No newline at end of file diff --git a/raml/annotations/examples/Foo.json b/raml/annotations/examples/Foo.json new file mode 100644 index 000000000000..1b1b8c891e05 --- /dev/null +++ b/raml/annotations/examples/Foo.json @@ -0,0 +1,4 @@ +{ + "id" : 1, + "name" : "First Foo" +} \ No newline at end of file diff --git a/raml/annotations/examples/Foos.json b/raml/annotations/examples/Foos.json new file mode 100644 index 000000000000..74f64689f016 --- /dev/null +++ b/raml/annotations/examples/Foos.json @@ -0,0 +1,16 @@ +[ + { + "id" : 1, + "name" : "First Foo", + "ownerName" : "Jack Robinson" + }, + { + "id" : 2, + "name" : "Second Foo" + }, + { + "id" : 3, + "name" : "Third Foo", + "ownerName" : "Chuck Norris" + } +] \ No newline at end of file diff --git a/raml/annotations/extensions/en_US/additionalResources.raml b/raml/annotations/extensions/en_US/additionalResources.raml new file mode 100644 index 000000000000..9ab0d0a2439e --- /dev/null +++ b/raml/annotations/extensions/en_US/additionalResources.raml @@ -0,0 +1,13 @@ +#%RAML 1.0 Extension +# File located at: +# /extensions/en_US/additionalResources.raml +masterRef: ../../api.raml +usage: This extension defines additional resources for version 2 of the API. +version: v2 +/foos: + /bar/{barId}: + get: + description: | + Get the foo that is related to the bar having barId = {barId} + queryParameters: + barId?: integer diff --git a/raml/annotations/libraries/dataTypes.raml b/raml/annotations/libraries/dataTypes.raml new file mode 100644 index 000000000000..8a240e62dccb --- /dev/null +++ b/raml/annotations/libraries/dataTypes.raml @@ -0,0 +1,19 @@ +#%RAML 1.0 Library +# This is the file /libraries/dataTypes.raml +usage: This library defines the data types for the API +types: + Foo: + properties: + id: integer + name: string + ownerName?: string + Bar: + properties: + id: integer + name: string + city?: string + fooId: integer + Error: + properties: + code: integer + message: string diff --git a/raml/annotations/libraries/resourceTypes.raml b/raml/annotations/libraries/resourceTypes.raml new file mode 100644 index 000000000000..fb054f1a3686 --- /dev/null +++ b/raml/annotations/libraries/resourceTypes.raml @@ -0,0 +1,38 @@ +#%RAML 1.0 Library +# This is the file /libraries/resourceTypes.raml +usage: This library defines the resource types for the API +uses: + myTraits: !include traits.raml +resourceTypes: + collection: + usage: Use this resourceType to represent a collection of items + description: A collection of <> + get: + description: | + Get all <>, + optionally filtered + is: [ myTraits.hasResponseCollection ] + post: + description: | + Create a new <> + is: [ myTraits.hasRequestItem ] + item: + usage: Use this resourceType to represent any single item + description: A single <> + get: + description: | + Get a <> + by <>Id + is: [ myTraits.hasResponseItem, myTraits.hasNotFound ] + put: + description: | + Update a <> + by <>Id + is: [ myTraits.hasRequestItem, myTraits.hasResponseItem, myTraits.hasNotFound ] + delete: + description: | + Delete a <> + by <>Id + is: [ myTraits.hasNotFound ] + responses: + 204: diff --git a/raml/annotations/libraries/securitySchemes.raml b/raml/annotations/libraries/securitySchemes.raml new file mode 100644 index 000000000000..621c6ac97512 --- /dev/null +++ b/raml/annotations/libraries/securitySchemes.raml @@ -0,0 +1,20 @@ +#%RAML 1.0 Library +# This is the file /libraries/securitySchemes.raml +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: | + Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to + access the content provided by the requested URL. diff --git a/raml/annotations/libraries/traits.raml b/raml/annotations/libraries/traits.raml new file mode 100644 index 000000000000..610747e79f2f --- /dev/null +++ b/raml/annotations/libraries/traits.raml @@ -0,0 +1,32 @@ +#%RAML 1.0 Library +# This is the file /libraries/traits.raml +usage: This library defines some basic traits +uses: + myDataTypes: !include dataTypes.raml +traits: + hasRequestItem: + usage: Use this trait for resources whose request body is a single item + body: + application/json: + type: <> + hasResponseItem: + usage: Use this trait for resources whose response body is a single item + responses: + 200: + body: + application/json: + type: <> + hasResponseCollection: + usage: Use this trait for resources whose response body is a collection of items + responses: + 200: + body: + application/json: + type: <>[] + hasNotFound: + usage: Use this trait for resources that could respond with a 404 status + responses: + 404: + body: + application/json: + type: myDataTypes.Error diff --git a/raml/annotations/overlays/es_ES/additionalResources.raml b/raml/annotations/overlays/es_ES/additionalResources.raml new file mode 100644 index 000000000000..0edd6a923111 --- /dev/null +++ b/raml/annotations/overlays/es_ES/additionalResources.raml @@ -0,0 +1,11 @@ +#%RAML 1.0 Overlay +# Archivo situado en: +# /overlays/es_ES/additionalResources.raml +masterRef: ../../api.raml +usage: | + Se trata de un español demasiado que describe los recursos adicionales + para la versión 1 del API. +/foos/bar/{barId}: + get: + description: | + Obtener el foo que se relaciona con el bar tomando barId = {barId} diff --git a/raml/annotations/overlays/es_ES/documentationItems.raml b/raml/annotations/overlays/es_ES/documentationItems.raml new file mode 100644 index 000000000000..49dd46fb59e9 --- /dev/null +++ b/raml/annotations/overlays/es_ES/documentationItems.raml @@ -0,0 +1,22 @@ +#%RAML 1.0 Overlay +# File located at (archivo situado en): +# /overlays/es_ES/documentationItems.raml +masterRef: ../../api.raml +usage: | + To provide user documentation and other descriptive text in Spanish + (Para proporcionar la documentación del usuario y otro texto descriptivo en español) +title: API para servicios REST utilizados en los tutoriales RAML en Baeldung.com +documentation: + - title: Descripción general + content: | + Este documento define la interfaz para los servicios REST + utilizados en la popular serie de RAML Tutorial en Baeldung.com + - title: Renuncia + content: | + Todos los nombres usados ​​en esta definición son pura ficción. + Cualquier similitud entre los nombres utilizados en este tutorial + y los de las personas reales, ya sea vivo o muerto, + no son más que coincidenta. + - title: Derechos de autor + content: | + Derechos de autor 2016 por Baeldung.com. Todos los derechos reservados. From eabccf2b8ff2225a135b5d7981623cd67c053bc3 Mon Sep 17 00:00:00 2001 From: ankur-singhal Date: Wed, 17 Feb 2016 23:43:27 +0530 Subject: [PATCH 314/626] Performance of GSON and Jackson Code Changes Performance of GSON and Jackson Code Changes --- gson-jackson-performance/.classpath | 14 + gson-jackson-performance/.project | 14 + gson-jackson-performance/README.md | 5 + gson-jackson-performance/log.out | 35 + .../log4j-application 100mb gson.log | 490 +++++++++++ .../log4j-application 100mb jackson.log | 370 +++++++++ .../log4j-application 10kb gson.log | 490 +++++++++++ .../log4j-application 10kb jackson.log | 370 +++++++++ ...ication complex Gson Jackson 250mb 10R.log | 151 ++++ ...ication complex Gson Jackson 250mb 50R.log | 710 ++++++++++++++++ ...lication simple Gson Jackson 100mb 10R.log | 160 ++++ ...lication simple Gson Jackson 100mb 50R.log | 760 ++++++++++++++++++ ...lication simple Gson Jackson 250mb 10R.log | 160 ++++ ...lication simple Gson Jackson 250mb 50R.log | 760 ++++++++++++++++++ gson-jackson-performance/pom.xml | 72 ++ .../data/complex/ComplexDataGeneration.java | 63 ++ .../data/complex/ComplexDataGson.java | 91 +++ .../data/complex/ComplexDataJackson.java | 95 +++ .../data/simple/SimpleDataGeneration.java | 35 + .../baeldung/data/simple/SimpleDataGson.java | 91 +++ .../data/simple/SimpleDataJackson.java | 95 +++ .../org/baeldung/data/utility/Utility.java | 90 +++ .../baeldung/pojo/complex/AddressDetails.java | 37 + .../baeldung/pojo/complex/ContactDetails.java | 25 + .../pojo/complex/CustomerAddressDetails.java | 18 + .../complex/CustomerPortfolioComplex.java | 17 + .../org/baeldung/pojo/simple/Customer.java | 36 + .../pojo/simple/CustomerPortfolioSimple.java | 16 + .../src/main/resources/log4j.properties | 16 + 29 files changed, 5286 insertions(+) create mode 100644 gson-jackson-performance/.classpath create mode 100644 gson-jackson-performance/.project create mode 100644 gson-jackson-performance/README.md create mode 100644 gson-jackson-performance/log.out create mode 100644 gson-jackson-performance/logs_Performance/log4j-application 100mb gson.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application 100mb jackson.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application 10kb gson.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application 10kb jackson.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 10R.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 50R.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 10R.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 50R.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 10R.log create mode 100644 gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 50R.log create mode 100644 gson-jackson-performance/pom.xml create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGeneration.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGson.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataJackson.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGeneration.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGson.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataJackson.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/data/utility/Utility.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/AddressDetails.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/ContactDetails.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerAddressDetails.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerPortfolioComplex.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/Customer.java create mode 100644 gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/CustomerPortfolioSimple.java create mode 100644 gson-jackson-performance/src/main/resources/log4j.properties diff --git a/gson-jackson-performance/.classpath b/gson-jackson-performance/.classpath new file mode 100644 index 000000000000..85e0397901a2 --- /dev/null +++ b/gson-jackson-performance/.classpath @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gson-jackson-performance/.project b/gson-jackson-performance/.project new file mode 100644 index 000000000000..b3b5ccad8794 --- /dev/null +++ b/gson-jackson-performance/.project @@ -0,0 +1,14 @@ + + + gson-jackson-performance + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/gson-jackson-performance/README.md b/gson-jackson-performance/README.md new file mode 100644 index 000000000000..9bbe679dfc75 --- /dev/null +++ b/gson-jackson-performance/README.md @@ -0,0 +1,5 @@ +## Performance of GSON and Jackson + +## STandalone java programs to measure the performance of both JSON API's + +## based on file size , iterations. \ No newline at end of file diff --git a/gson-jackson-performance/log.out b/gson-jackson-performance/log.out new file mode 100644 index 000000000000..076ff3892c18 --- /dev/null +++ b/gson-jackson-performance/log.out @@ -0,0 +1,35 @@ +Java HotSpot(TM) 64-Bit Server VM (25.45-b02) for windows-amd64 JRE (1.8.0_45-b15), built on Apr 30 2015 12:40:44 by "java_re" with MS VC++ 10.0 (VS2010) +Memory: 4k page, physical 8291728k(5579796k free), swap 16581620k(12609940k free) +CommandLine flags: -XX:InitialHeapSize=132667648 -XX:MaxHeapSize=2122682368 -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC +0.363: [GC (Allocation Failure) [PSYoungGen: 33280K->5096K(38400K)] 33280K->10228K(125952K), 0.0092249 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] +0.414: [GC (Allocation Failure) [PSYoungGen: 38376K->5106K(71680K)] 43508K->24102K(159232K), 0.0186113 secs] [Times: user=0.06 sys=0.00, real=0.02 secs] +0.516: [GC (Allocation Failure) [PSYoungGen: 71666K->5097K(71680K)] 90662K->52229K(159232K), 0.0445313 secs] [Times: user=0.16 sys=0.03, real=0.04 secs] +0.651: [GC (Allocation Failure) [PSYoungGen: 71657K->5109K(138240K)] 118789K->80322K(225792K), 0.0512456 secs] [Times: user=0.19 sys=0.02, real=0.06 secs] +0.702: [Full GC (Ergonomics) [PSYoungGen: 5109K->0K(138240K)] [ParOldGen: 75212K->77437K(170496K)] 80322K->77437K(308736K), [Metaspace: 7004K->7004K(1056768K)], 0.5375812 secs] [Times: user=1.48 sys=0.00, real=0.54 secs] +1.406: [GC (Allocation Failure) [PSYoungGen: 133120K->5088K(138240K)] 210557K->133918K(308736K), 0.1172537 secs] [Times: user=0.34 sys=0.03, real=0.13 secs] +1.523: [Full GC (Ergonomics) [PSYoungGen: 5088K->0K(138240K)] [ParOldGen: 128829K->133416K(284160K)] 133918K->133416K(422400K), [Metaspace: 7004K->7004K(1056768K)], 0.9853907 secs] [Times: user=2.78 sys=0.02, real=0.99 secs] +2.691: [GC (Allocation Failure) [PSYoungGen: 133120K->56497K(227840K)] 266536K->189913K(512000K), 0.1302934 secs] [Times: user=0.33 sys=0.03, real=0.13 secs] +3.015: [GC (Allocation Failure) [PSYoungGen: 222385K->71657K(237568K)] 355801K->259810K(521728K), 0.1589475 secs] [Times: user=0.50 sys=0.02, real=0.17 secs] +3.372: [GC (Allocation Failure) [PSYoungGen: 237545K->112638K(295424K)] 425698K->329655K(579584K), 0.1698426 secs] [Times: user=0.47 sys=0.00, real=0.17 secs] +3.761: [GC (Allocation Failure) [PSYoungGen: 295422K->145918K(328704K)] 512439K->406791K(612864K), 0.2285356 secs] [Times: user=0.67 sys=0.03, real=0.24 secs] +3.989: [Full GC (Ergonomics) [PSYoungGen: 145918K->121734K(328704K)] [ParOldGen: 260872K->283948K(478720K)] 406791K->405682K(807424K), [Metaspace: 7004K->7004K(1056768K)], 2.7389690 secs] [Times: user=7.89 sys=0.00, real=2.74 secs] +6.963: [GC (Allocation Failure) [PSYoungGen: 304518K->189438K(378368K)] 588466K->484050K(857088K), 0.2961369 secs] [Times: user=0.87 sys=0.06, real=0.30 secs] +7.486: [GC (Allocation Failure) [PSYoungGen: 378366K->220926K(413696K)] 672978K->563874K(892416K), 0.2904383 secs] [Times: user=0.86 sys=0.03, real=0.30 secs] +8.002: [GC (System.gc()) [PSYoungGen: 409787K->158432K(460800K)] 752736K->643074K(946176K), 0.3470548 secs] [Times: user=1.01 sys=0.05, real=0.35 secs] +8.349: [Full GC (System.gc()) [PSYoungGen: 158432K->155661K(460800K)] [ParOldGen: 484642K->484968K(485376K)] 643074K->640630K(946176K), [Metaspace: 7039K->7039K(1056768K)], 3.8112607 secs] [Times: user=10.73 sys=0.03, real=3.81 secs] +12.864: [Full GC (Ergonomics) [PSYoungGen: 385748K->319385K(460800K)] [ParOldGen: 484968K->485363K(773632K)] 870716K->804749K(1234432K), [Metaspace: 7719K->7719K(1056768K)], 2.7333253 secs] [Times: user=7.02 sys=0.02, real=2.73 secs] +15.598: [GC (Allocation Failure) [PSYoungGen: 319494K->163753K(460800K)] 805371K->805902K(1234432K), 0.2532505 secs] [Times: user=0.98 sys=0.08, real=0.25 secs] +15.851: [Full GC (Ergonomics) [PSYoungGen: 163753K->31983K(460800K)] [ParOldGen: 642148K->772967K(1150976K)] 805902K->804950K(1611776K), [Metaspace: 7720K->7720K(1056768K)], 3.1227324 secs] [Times: user=8.89 sys=0.05, real=3.12 secs] +19.257: [GC (Allocation Failure) [PSYoungGen: 262383K->169509K(460800K)] 1035350K->974460K(1611776K), 0.1370666 secs] [Times: user=0.36 sys=0.02, real=0.14 secs] +19.691: [GC (Allocation Failure) --[PSYoungGen: 273197K->273197K(460800K)] 1487836K->1656297K(1844224K), 0.1069653 secs] [Times: user=0.06 sys=0.05, real=0.10 secs] +19.798: [Full GC (Ergonomics) [PSYoungGen: 273197K->77314K(460800K)] [ParOldGen: 1383099K->1383092K(1383424K)] 1656297K->1460407K(1844224K), [Metaspace: 7720K->7720K(1056768K)], 2.2582744 secs] [Times: user=6.10 sys=0.02, real=2.26 secs] +22.056: [Full GC (Allocation Failure) [PSYoungGen: 77314K->77314K(460800K)] [ParOldGen: 1383092K->1383008K(1383424K)] 1460407K->1460322K(1844224K), [Metaspace: 7720K->7720K(1056768K)], 3.0326600 secs] [Times: user=7.74 sys=0.02, real=3.04 secs] +Heap + PSYoungGen total 460800K, used 85443K [0x00000000d5d00000, 0x0000000100000000, 0x0000000100000000) + eden space 230400K, 3% used [0x00000000d5d00000,0x00000000d64f02b8,0x00000000e3e00000) + from space 230400K, 33% used [0x00000000f1f00000,0x00000000f6a809a0,0x0000000100000000) + to space 230400K, 0% used [0x00000000e3e00000,0x00000000e3e00000,0x00000000f1f00000) + ParOldGen total 1383424K, used 1383008K [0x0000000081600000, 0x00000000d5d00000, 0x00000000d5d00000) + object space 1383424K, 99% used [0x0000000081600000,0x00000000d5c980e8,0x00000000d5d00000) + Metaspace used 7736K, capacity 7846K, committed 8064K, reserved 1056768K + class space used 849K, capacity 857K, committed 896K, reserved 1048576K diff --git a/gson-jackson-performance/logs_Performance/log4j-application 100mb gson.log b/gson-jackson-performance/logs_Performance/log4j-application 100mb gson.log new file mode 100644 index 000000000000..827fc6b8ff99 --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application 100mb gson.log @@ -0,0 +1,490 @@ +2016-02-13 19:37:16 INFO ComplexDataGson:27 - -------Round 1 +2016-02-13 19:37:18 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1278083466 +2016-02-13 19:37:19 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:37:19 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:37:27 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8332113036 +2016-02-13 19:37:27 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:37:30 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1113664562 +2016-02-13 19:37:30 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:37:31 INFO ComplexDataGson:27 - -------Round 2 +2016-02-13 19:37:33 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1000705020 +2016-02-13 19:37:33 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:37:33 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:37:42 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8658432353 +2016-02-13 19:37:42 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:37:44 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1243221682 +2016-02-13 19:37:44 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:37:45 INFO ComplexDataGson:27 - -------Round 3 +2016-02-13 19:37:47 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1008859332 +2016-02-13 19:37:48 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:37:48 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:37:56 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8392288043 +2016-02-13 19:37:56 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:37:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1277124228 +2016-02-13 19:37:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:37:59 INFO ComplexDataGson:27 - -------Round 4 +2016-02-13 19:38:01 INFO ComplexDataGson:53 - Json Generation Time(ms):: 995015515 +2016-02-13 19:38:02 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:38:02 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:38:10 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8797346582 +2016-02-13 19:38:10 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:38:13 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1649643681 +2016-02-13 19:38:13 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:38:14 INFO ComplexDataGson:27 - -------Round 5 +2016-02-13 19:38:17 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1272820685 +2016-02-13 19:38:17 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:38:17 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:38:26 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9312540240 +2016-02-13 19:38:26 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:38:28 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1257408139 +2016-02-13 19:38:28 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:38:30 INFO ComplexDataGson:27 - -------Round 6 +2016-02-13 19:38:32 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1068332478 +2016-02-13 19:38:32 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:38:32 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:38:41 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8912581452 +2016-02-13 19:38:41 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:38:43 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1264009906 +2016-02-13 19:38:43 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:38:44 INFO ComplexDataGson:27 - -------Round 7 +2016-02-13 19:38:46 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1008157075 +2016-02-13 19:38:46 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:38:46 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:38:55 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8505211268 +2016-02-13 19:38:55 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:38:57 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1251681923 +2016-02-13 19:38:57 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:38:58 INFO ComplexDataGson:27 - -------Round 8 +2016-02-13 19:39:01 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1006583609 +2016-02-13 19:39:01 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:39:01 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:39:10 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8752857286 +2016-02-13 19:39:10 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:39:12 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1414701446 +2016-02-13 19:39:12 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:39:13 INFO ComplexDataGson:27 - -------Round 9 +2016-02-13 19:39:16 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1294525120 +2016-02-13 19:39:16 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:39:16 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:39:26 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10191596918 +2016-02-13 19:39:26 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:39:29 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1658383009 +2016-02-13 19:39:29 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:39:30 INFO ComplexDataGson:27 - -------Round 10 +2016-02-13 19:39:33 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1309101589 +2016-02-13 19:39:33 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:39:33 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:39:43 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9762623354 +2016-02-13 19:39:43 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:39:45 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1260306380 +2016-02-13 19:39:45 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:39:46 INFO ComplexDataGson:39 - -------------------------------------------------------------------------- +2016-02-13 19:39:46 INFO ComplexDataGson:40 - Average Time to Generate JSON : 1124218388 +2016-02-13 19:39:46 INFO ComplexDataGson:41 - Average Time to Parse JSON To Map : 8961759053 +2016-02-13 19:39:46 INFO ComplexDataGson:42 - Average Time to Parse JSON To Actual Object : 1339014495 +2016-02-13 19:39:46 INFO ComplexDataGson:43 - -------------------------------------------------------------------------- +2016-02-13 19:41:32 INFO ComplexDataGson:27 - -------Round 1 +2016-02-13 19:41:34 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1191851136 +2016-02-13 19:41:35 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:41:35 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:41:45 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10080407033 +2016-02-13 19:41:45 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:41:48 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1379953348 +2016-02-13 19:41:48 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:41:50 INFO ComplexDataGson:27 - -------Round 2 +2016-02-13 19:41:52 INFO ComplexDataGson:53 - Json Generation Time(ms):: 956293094 +2016-02-13 19:41:52 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:41:52 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:42:01 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8813430199 +2016-02-13 19:42:01 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:42:03 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1274304543 +2016-02-13 19:42:03 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:42:04 INFO ComplexDataGson:27 - -------Round 3 +2016-02-13 19:42:06 INFO ComplexDataGson:53 - Json Generation Time(ms):: 927398321 +2016-02-13 19:42:06 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:42:06 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:42:15 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8356408992 +2016-02-13 19:42:15 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:42:17 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1322685660 +2016-02-13 19:42:17 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:42:18 INFO ComplexDataGson:27 - -------Round 4 +2016-02-13 19:42:21 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1207259733 +2016-02-13 19:42:21 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:42:21 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:42:31 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10045768675 +2016-02-13 19:42:31 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:42:33 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1245056076 +2016-02-13 19:42:33 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:42:34 INFO ComplexDataGson:27 - -------Round 5 +2016-02-13 19:42:36 INFO ComplexDataGson:53 - Json Generation Time(ms):: 915288634 +2016-02-13 19:42:36 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:42:36 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:42:45 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8618376472 +2016-02-13 19:42:45 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:42:47 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1269665068 +2016-02-13 19:42:47 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:42:49 INFO ComplexDataGson:27 - -------Round 6 +2016-02-13 19:42:50 INFO ComplexDataGson:53 - Json Generation Time(ms):: 932316093 +2016-02-13 19:42:51 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:42:51 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:43:00 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8813796130 +2016-02-13 19:43:00 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:43:02 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1313783696 +2016-02-13 19:43:02 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:43:03 INFO ComplexDataGson:27 - -------Round 7 +2016-02-13 19:43:05 INFO ComplexDataGson:53 - Json Generation Time(ms):: 915598117 +2016-02-13 19:43:05 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:43:05 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:43:14 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8961026913 +2016-02-13 19:43:14 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:43:16 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1261592864 +2016-02-13 19:43:16 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:43:17 INFO ComplexDataGson:27 - -------Round 8 +2016-02-13 19:43:19 INFO ComplexDataGson:53 - Json Generation Time(ms):: 920982875 +2016-02-13 19:43:19 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:43:19 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:43:28 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8618532792 +2016-02-13 19:43:28 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:43:30 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1245481219 +2016-02-13 19:43:30 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:43:31 INFO ComplexDataGson:27 - -------Round 9 +2016-02-13 19:43:33 INFO ComplexDataGson:53 - Json Generation Time(ms):: 913480688 +2016-02-13 19:43:34 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:43:34 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:43:42 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8243017597 +2016-02-13 19:43:42 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:43:44 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1230475265 +2016-02-13 19:43:44 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:43:45 INFO ComplexDataGson:27 - -------Round 10 +2016-02-13 19:43:47 INFO ComplexDataGson:53 - Json Generation Time(ms):: 927227001 +2016-02-13 19:43:47 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:43:47 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:43:55 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 7879612879 +2016-02-13 19:43:55 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:43:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1296596758 +2016-02-13 19:43:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:43:59 INFO ComplexDataGson:27 - -------Round 11 +2016-02-13 19:44:01 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1105414720 +2016-02-13 19:44:01 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:44:01 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:44:12 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10599177108 +2016-02-13 19:44:12 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:44:14 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1250150300 +2016-02-13 19:44:14 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:44:15 INFO ComplexDataGson:27 - -------Round 12 +2016-02-13 19:44:17 INFO ComplexDataGson:53 - Json Generation Time(ms):: 934354968 +2016-02-13 19:44:18 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:44:18 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:44:26 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8623628596 +2016-02-13 19:44:26 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:44:28 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1266831567 +2016-02-13 19:44:28 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:44:30 INFO ComplexDataGson:27 - -------Round 13 +2016-02-13 19:44:32 INFO ComplexDataGson:53 - Json Generation Time(ms):: 915319424 +2016-02-13 19:44:32 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:44:32 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:44:40 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8506292877 +2016-02-13 19:44:40 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:44:43 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1263272517 +2016-02-13 19:44:43 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:44:44 INFO ComplexDataGson:27 - -------Round 14 +2016-02-13 19:44:46 INFO ComplexDataGson:53 - Json Generation Time(ms):: 953177742 +2016-02-13 19:44:46 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:44:46 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:44:55 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8520122877 +2016-02-13 19:44:55 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:44:57 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1295778051 +2016-02-13 19:44:57 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:44:58 INFO ComplexDataGson:27 - -------Round 15 +2016-02-13 19:45:00 INFO ComplexDataGson:53 - Json Generation Time(ms):: 917475933 +2016-02-13 19:45:00 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:45:00 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:45:09 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8470522382 +2016-02-13 19:45:09 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:45:11 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1220261157 +2016-02-13 19:45:11 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:45:12 INFO ComplexDataGson:27 - -------Round 16 +2016-02-13 19:45:14 INFO ComplexDataGson:53 - Json Generation Time(ms):: 915774963 +2016-02-13 19:45:14 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:45:14 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:45:22 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 7762057680 +2016-02-13 19:45:22 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:45:24 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1231289630 +2016-02-13 19:45:24 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:45:25 INFO ComplexDataGson:27 - -------Round 17 +2016-02-13 19:45:27 INFO ComplexDataGson:53 - Json Generation Time(ms):: 914879280 +2016-02-13 19:45:27 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:45:27 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:45:36 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8748457028 +2016-02-13 19:45:36 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:45:39 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1555775737 +2016-02-13 19:45:39 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:45:40 INFO ComplexDataGson:27 - -------Round 18 +2016-02-13 19:45:42 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1093209109 +2016-02-13 19:45:43 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:45:43 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:45:52 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9098222804 +2016-02-13 19:45:52 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:45:54 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1255617562 +2016-02-13 19:45:54 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:45:55 INFO ComplexDataGson:27 - -------Round 19 +2016-02-13 19:45:57 INFO ComplexDataGson:53 - Json Generation Time(ms):: 950926099 +2016-02-13 19:45:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:45:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:46:06 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8670918236 +2016-02-13 19:46:06 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:46:08 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1280563669 +2016-02-13 19:46:08 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:46:09 INFO ComplexDataGson:27 - -------Round 20 +2016-02-13 19:46:11 INFO ComplexDataGson:53 - Json Generation Time(ms):: 933908902 +2016-02-13 19:46:12 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:46:12 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:46:21 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9708235748 +2016-02-13 19:46:21 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:46:24 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1574329688 +2016-02-13 19:46:24 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:46:25 INFO ComplexDataGson:27 - -------Round 21 +2016-02-13 19:46:28 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1066257681 +2016-02-13 19:46:28 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:46:28 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:46:37 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9000526594 +2016-02-13 19:46:37 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:46:39 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1241094778 +2016-02-13 19:46:39 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:46:40 INFO ComplexDataGson:27 - -------Round 22 +2016-02-13 19:46:42 INFO ComplexDataGson:53 - Json Generation Time(ms):: 921404072 +2016-02-13 19:46:42 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:46:42 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:46:51 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8424769102 +2016-02-13 19:46:51 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:46:53 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1230215126 +2016-02-13 19:46:53 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:46:54 INFO ComplexDataGson:27 - -------Round 23 +2016-02-13 19:46:56 INFO ComplexDataGson:53 - Json Generation Time(ms):: 913987938 +2016-02-13 19:46:56 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:46:56 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:47:06 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10028036985 +2016-02-13 19:47:06 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:47:09 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1651288202 +2016-02-13 19:47:09 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:47:10 INFO ComplexDataGson:27 - -------Round 24 +2016-02-13 19:47:12 INFO ComplexDataGson:53 - Json Generation Time(ms):: 916371822 +2016-02-13 19:47:12 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:47:12 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:47:21 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8624285851 +2016-02-13 19:47:21 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:47:23 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1258091448 +2016-02-13 19:47:23 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:47:24 INFO ComplexDataGson:27 - -------Round 25 +2016-02-13 19:47:26 INFO ComplexDataGson:53 - Json Generation Time(ms):: 915687329 +2016-02-13 19:47:27 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:47:27 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:47:35 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8610528090 +2016-02-13 19:47:35 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:47:38 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1235425406 +2016-02-13 19:47:38 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:47:39 INFO ComplexDataGson:27 - -------Round 26 +2016-02-13 19:47:41 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1088816746 +2016-02-13 19:47:41 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:47:41 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:47:52 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10322615396 +2016-02-13 19:47:52 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:47:54 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1234155501 +2016-02-13 19:47:54 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:47:55 INFO ComplexDataGson:27 - -------Round 27 +2016-02-13 19:47:57 INFO ComplexDataGson:53 - Json Generation Time(ms):: 933214540 +2016-02-13 19:47:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:47:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:48:06 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8857891864 +2016-02-13 19:48:06 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:48:08 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1286999247 +2016-02-13 19:48:08 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:48:10 INFO ComplexDataGson:27 - -------Round 28 +2016-02-13 19:48:12 INFO ComplexDataGson:53 - Json Generation Time(ms):: 944816187 +2016-02-13 19:48:12 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:48:12 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:48:20 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8230042621 +2016-02-13 19:48:20 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:48:23 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1387615409 +2016-02-13 19:48:23 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:48:24 INFO ComplexDataGson:27 - -------Round 29 +2016-02-13 19:48:26 INFO ComplexDataGson:53 - Json Generation Time(ms):: 940160923 +2016-02-13 19:48:26 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:48:26 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:48:35 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8740729045 +2016-02-13 19:48:35 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:48:37 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1315723884 +2016-02-13 19:48:37 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:48:38 INFO ComplexDataGson:27 - -------Round 30 +2016-02-13 19:48:40 INFO ComplexDataGson:53 - Json Generation Time(ms):: 949497111 +2016-02-13 19:48:41 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:48:41 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:48:49 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8546455339 +2016-02-13 19:48:49 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:48:52 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1655064756 +2016-02-13 19:48:52 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:48:53 INFO ComplexDataGson:27 - -------Round 31 +2016-02-13 19:48:56 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1209183341 +2016-02-13 19:48:56 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:48:56 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:49:07 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 10523212176 +2016-02-13 19:49:07 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:49:09 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1385741146 +2016-02-13 19:49:09 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:49:10 INFO ComplexDataGson:27 - -------Round 32 +2016-02-13 19:49:12 INFO ComplexDataGson:53 - Json Generation Time(ms):: 926668433 +2016-02-13 19:49:13 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:49:13 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:49:21 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8096297617 +2016-02-13 19:49:21 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:49:23 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1237708235 +2016-02-13 19:49:23 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:49:24 INFO ComplexDataGson:27 - -------Round 33 +2016-02-13 19:49:26 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1194291074 +2016-02-13 19:49:27 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:49:27 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:49:36 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9445080077 +2016-02-13 19:49:36 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:49:39 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1488176702 +2016-02-13 19:49:39 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:49:40 INFO ComplexDataGson:27 - -------Round 34 +2016-02-13 19:49:42 INFO ComplexDataGson:53 - Json Generation Time(ms):: 956147827 +2016-02-13 19:49:42 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:49:42 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:49:50 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8222404640 +2016-02-13 19:49:50 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:49:53 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1235773969 +2016-02-13 19:49:53 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:49:54 INFO ComplexDataGson:27 - -------Round 35 +2016-02-13 19:49:56 INFO ComplexDataGson:53 - Json Generation Time(ms):: 908857793 +2016-02-13 19:49:56 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:49:56 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:50:05 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9117024263 +2016-02-13 19:50:05 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:50:07 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1239985931 +2016-02-13 19:50:07 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:50:08 INFO ComplexDataGson:27 - -------Round 36 +2016-02-13 19:50:10 INFO ComplexDataGson:53 - Json Generation Time(ms):: 912435394 +2016-02-13 19:50:11 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:50:11 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:50:19 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8580239068 +2016-02-13 19:50:19 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:50:21 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1258180661 +2016-02-13 19:50:21 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:50:23 INFO ComplexDataGson:27 - -------Round 37 +2016-02-13 19:50:25 INFO ComplexDataGson:53 - Json Generation Time(ms):: 928991525 +2016-02-13 19:50:25 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:50:25 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:50:34 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8749988257 +2016-02-13 19:50:34 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:50:36 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1259627018 +2016-02-13 19:50:36 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:50:37 INFO ComplexDataGson:27 - -------Round 38 +2016-02-13 19:50:39 INFO ComplexDataGson:53 - Json Generation Time(ms):: 912076963 +2016-02-13 19:50:39 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:50:39 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:50:48 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8553354747 +2016-02-13 19:50:48 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:50:50 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1272567256 +2016-02-13 19:50:50 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:50:51 INFO ComplexDataGson:27 - -------Round 39 +2016-02-13 19:50:53 INFO ComplexDataGson:53 - Json Generation Time(ms):: 937653878 +2016-02-13 19:50:53 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:50:53 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:51:02 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8570808929 +2016-02-13 19:51:02 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:51:04 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1278280050 +2016-02-13 19:51:04 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:51:05 INFO ComplexDataGson:27 - -------Round 40 +2016-02-13 19:51:07 INFO ComplexDataGson:53 - Json Generation Time(ms):: 948231943 +2016-02-13 19:51:08 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:51:08 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:51:16 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8258665807 +2016-02-13 19:51:16 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:51:18 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1226364358 +2016-02-13 19:51:18 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:51:19 INFO ComplexDataGson:27 - -------Round 41 +2016-02-13 19:51:21 INFO ComplexDataGson:53 - Json Generation Time(ms):: 913137256 +2016-02-13 19:51:21 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:51:21 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:51:29 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8291304765 +2016-02-13 19:51:29 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:51:31 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1227485837 +2016-02-13 19:51:31 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:51:33 INFO ComplexDataGson:27 - -------Round 42 +2016-02-13 19:51:35 INFO ComplexDataGson:53 - Json Generation Time(ms):: 913072123 +2016-02-13 19:51:35 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:51:35 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:51:43 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8564229663 +2016-02-13 19:51:43 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:51:46 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1247028238 +2016-02-13 19:51:46 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:51:47 INFO ComplexDataGson:27 - -------Round 43 +2016-02-13 19:51:49 INFO ComplexDataGson:53 - Json Generation Time(ms):: 916980130 +2016-02-13 19:51:49 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:51:49 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:51:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8671670625 +2016-02-13 19:51:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:52:00 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1270874971 +2016-02-13 19:52:00 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:52:01 INFO ComplexDataGson:27 - -------Round 44 +2016-02-13 19:52:03 INFO ComplexDataGson:53 - Json Generation Time(ms):: 948609717 +2016-02-13 19:52:04 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:52:04 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:52:13 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8829447104 +2016-02-13 19:52:13 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:52:15 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1663932772 +2016-02-13 19:52:15 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:52:17 INFO ComplexDataGson:27 - -------Round 45 +2016-02-13 19:52:19 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1123397471 +2016-02-13 19:52:19 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:52:19 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:52:29 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 9946999145 +2016-02-13 19:52:29 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:52:32 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1236672021 +2016-02-13 19:52:32 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:52:33 INFO ComplexDataGson:27 - -------Round 46 +2016-02-13 19:52:35 INFO ComplexDataGson:53 - Json Generation Time(ms):: 912870802 +2016-02-13 19:52:35 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:52:35 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:52:43 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8255520848 +2016-02-13 19:52:43 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:52:46 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1263055011 +2016-02-13 19:52:46 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:52:47 INFO ComplexDataGson:27 - -------Round 47 +2016-02-13 19:52:49 INFO ComplexDataGson:53 - Json Generation Time(ms):: 945563840 +2016-02-13 19:52:49 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:52:49 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:52:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8534561184 +2016-02-13 19:52:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:53:00 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1230407368 +2016-02-13 19:53:00 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:53:01 INFO ComplexDataGson:27 - -------Round 48 +2016-02-13 19:53:03 INFO ComplexDataGson:53 - Json Generation Time(ms):: 936955963 +2016-02-13 19:53:03 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:53:03 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:53:12 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8602107323 +2016-02-13 19:53:12 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:53:14 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1262269462 +2016-02-13 19:53:14 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:53:15 INFO ComplexDataGson:27 - -------Round 49 +2016-02-13 19:53:17 INFO ComplexDataGson:53 - Json Generation Time(ms):: 931142113 +2016-02-13 19:53:17 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:53:17 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:53:26 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8802198431 +2016-02-13 19:53:26 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:53:29 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1268525825 +2016-02-13 19:53:29 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:53:30 INFO ComplexDataGson:27 - -------Round 50 +2016-02-13 19:53:32 INFO ComplexDataGson:53 - Json Generation Time(ms):: 930833420 +2016-02-13 19:53:32 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 100 MB +2016-02-13 19:53:32 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:53:41 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 8785328081 +2016-02-13 19:53:41 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:53:44 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1582174517 +2016-02-13 19:53:44 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:53:45 INFO ComplexDataGson:39 - -------------------------------------------------------------------------- +2016-02-13 19:53:45 INFO ComplexDataGson:40 - Average Time to Generate JSON : 966789043 +2016-02-13 19:53:45 INFO ComplexDataGson:41 - Average Time to Parse JSON To Map : 8838486733 +2016-02-13 19:53:45 INFO ComplexDataGson:42 - Average Time to Parse JSON To Actual Object : 1313279389 +2016-02-13 19:53:45 INFO ComplexDataGson:43 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application 100mb jackson.log b/gson-jackson-performance/logs_Performance/log4j-application 100mb jackson.log new file mode 100644 index 000000000000..49b5ffd43c1a --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application 100mb jackson.log @@ -0,0 +1,370 @@ +2016-02-13 20:01:02 INFO ComplexDataJackson:31 - -------Round 1 +2016-02-13 20:01:06 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 2236390565 +2016-02-13 20:01:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:11 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4683849394 +2016-02-13 20:01:14 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1071287562 +2016-02-13 20:01:15 INFO ComplexDataJackson:31 - -------Round 2 +2016-02-13 20:01:17 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 516507379 +2016-02-13 20:01:17 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:17 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:22 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4538998942 +2016-02-13 20:01:24 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 726254816 +2016-02-13 20:01:25 INFO ComplexDataJackson:31 - -------Round 3 +2016-02-13 20:01:26 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 456587379 +2016-02-13 20:01:27 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:27 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:28 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1302570482 +2016-02-13 20:01:30 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 705463037 +2016-02-13 20:01:31 INFO ComplexDataJackson:31 - -------Round 4 +2016-02-13 20:01:33 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 456497377 +2016-02-13 20:01:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:34 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1315460586 +2016-02-13 20:01:36 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 714554876 +2016-02-13 20:01:37 INFO ComplexDataJackson:31 - -------Round 5 +2016-02-13 20:01:38 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 459663651 +2016-02-13 20:01:39 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:39 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:40 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1309177380 +2016-02-13 20:01:42 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 720221485 +2016-02-13 20:01:43 INFO ComplexDataJackson:31 - -------Round 6 +2016-02-13 20:01:44 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 455687353 +2016-02-13 20:01:45 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:45 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:46 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1308595522 +2016-02-13 20:01:48 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 706818208 +2016-02-13 20:01:49 INFO ComplexDataJackson:31 - -------Round 7 +2016-02-13 20:01:50 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 453952830 +2016-02-13 20:01:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:01:55 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4143528046 +2016-02-13 20:01:57 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 719641600 +2016-02-13 20:01:58 INFO ComplexDataJackson:31 - -------Round 8 +2016-02-13 20:01:59 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 465429737 +2016-02-13 20:01:59 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:01:59 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:01 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1342607808 +2016-02-13 20:02:03 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 713900779 +2016-02-13 20:02:04 INFO ComplexDataJackson:31 - -------Round 9 +2016-02-13 20:02:05 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 456318950 +2016-02-13 20:02:06 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:02:06 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1314650958 +2016-02-13 20:02:09 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 719420542 +2016-02-13 20:02:10 INFO ComplexDataJackson:31 - -------Round 10 +2016-02-13 20:02:11 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 462624657 +2016-02-13 20:02:12 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:02:12 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:13 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1340021024 +2016-02-13 20:02:15 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 721704949 +2016-02-13 20:02:16 INFO ComplexDataJackson:43 - -------------------------------------------------------------------------- +2016-02-13 20:02:16 INFO ComplexDataJackson:44 - Average Time to Generate JSON : 641965987 +2016-02-13 20:02:16 INFO ComplexDataJackson:45 - Average Time to Parse JSON To Map : 2259946014 +2016-02-13 20:02:16 INFO ComplexDataJackson:46 - Average Time to Parse JSON To Actual Object : 751926785 +2016-02-13 20:02:16 INFO ComplexDataJackson:47 - -------------------------------------------------------------------------- +2016-02-13 20:02:29 INFO ComplexDataJackson:31 - -------Round 1 +2016-02-13 20:02:33 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 2068828281 +2016-02-13 20:02:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:02:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:38 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4407230838 +2016-02-13 20:02:41 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1326748014 +2016-02-13 20:02:42 INFO ComplexDataJackson:31 - -------Round 2 +2016-02-13 20:02:44 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 644018520 +2016-02-13 20:02:45 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:02:45 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:50 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 5663806849 +2016-02-13 20:02:52 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 714395004 +2016-02-13 20:02:53 INFO ComplexDataJackson:31 - -------Round 3 +2016-02-13 20:02:55 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 453922434 +2016-02-13 20:02:55 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:02:55 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:02:56 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1351852020 +2016-02-13 20:02:58 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 692848072 +2016-02-13 20:02:59 INFO ComplexDataJackson:31 - -------Round 4 +2016-02-13 20:03:01 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 456597642 +2016-02-13 20:03:01 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:01 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:03 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1326427084 +2016-02-13 20:03:05 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 712403893 +2016-02-13 20:03:06 INFO ComplexDataJackson:31 - -------Round 5 +2016-02-13 20:03:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 454851671 +2016-02-13 20:03:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:09 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1390244827 +2016-02-13 20:03:11 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 700532239 +2016-02-13 20:03:12 INFO ComplexDataJackson:31 - -------Round 6 +2016-02-13 20:03:13 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 447829103 +2016-02-13 20:03:14 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:14 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:15 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1300572267 +2016-02-13 20:03:17 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 695462883 +2016-02-13 20:03:18 INFO ComplexDataJackson:31 - -------Round 7 +2016-02-13 20:03:20 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 445790229 +2016-02-13 20:03:20 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:20 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:24 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4166359881 +2016-02-13 20:03:26 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 698059536 +2016-02-13 20:03:27 INFO ComplexDataJackson:31 - -------Round 8 +2016-02-13 20:03:28 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 454490872 +2016-02-13 20:03:28 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:28 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:30 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1303103786 +2016-02-13 20:03:32 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 696194352 +2016-02-13 20:03:33 INFO ComplexDataJackson:31 - -------Round 9 +2016-02-13 20:03:34 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 448600046 +2016-02-13 20:03:34 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:34 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:36 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1310695582 +2016-02-13 20:03:38 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 694635491 +2016-02-13 20:03:39 INFO ComplexDataJackson:31 - -------Round 10 +2016-02-13 20:03:40 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 448167007 +2016-02-13 20:03:40 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:40 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:42 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1460439331 +2016-02-13 20:03:44 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 835431485 +2016-02-13 20:03:45 INFO ComplexDataJackson:31 - -------Round 11 +2016-02-13 20:03:47 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 551898916 +2016-02-13 20:03:47 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:47 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:53 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 5210407849 +2016-02-13 20:03:54 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 700618294 +2016-02-13 20:03:55 INFO ComplexDataJackson:31 - -------Round 12 +2016-02-13 20:03:57 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 466824777 +2016-02-13 20:03:57 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:03:57 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:03:58 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1311879826 +2016-02-13 20:04:00 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 699696952 +2016-02-13 20:04:02 INFO ComplexDataJackson:31 - -------Round 13 +2016-02-13 20:04:03 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 456079732 +2016-02-13 20:04:03 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:03 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:05 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1351933338 +2016-02-13 20:04:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 699846956 +2016-02-13 20:04:08 INFO ComplexDataJackson:31 - -------Round 14 +2016-02-13 20:04:09 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 444370320 +2016-02-13 20:04:09 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:09 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:10 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1303638275 +2016-02-13 20:04:12 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 701946227 +2016-02-13 20:04:14 INFO ComplexDataJackson:31 - -------Round 15 +2016-02-13 20:04:15 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 531660180 +2016-02-13 20:04:16 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:16 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:21 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 5208485427 +2016-02-13 20:04:23 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 910483366 +2016-02-13 20:04:24 INFO ComplexDataJackson:31 - -------Round 16 +2016-02-13 20:04:26 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 479905545 +2016-02-13 20:04:26 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:26 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:28 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1702826909 +2016-02-13 20:04:30 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 883772734 +2016-02-13 20:04:31 INFO ComplexDataJackson:31 - -------Round 17 +2016-02-13 20:04:33 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 451210120 +2016-02-13 20:04:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:34 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1339389427 +2016-02-13 20:04:36 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 722647212 +2016-02-13 20:04:37 INFO ComplexDataJackson:31 - -------Round 18 +2016-02-13 20:04:39 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 446093790 +2016-02-13 20:04:39 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:39 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:40 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1330858920 +2016-02-13 20:04:42 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 719837790 +2016-02-13 20:04:43 INFO ComplexDataJackson:31 - -------Round 19 +2016-02-13 20:04:45 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 459770232 +2016-02-13 20:04:45 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:45 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:46 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1348367183 +2016-02-13 20:04:48 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 723020249 +2016-02-13 20:04:49 INFO ComplexDataJackson:31 - -------Round 20 +2016-02-13 20:04:51 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 455603272 +2016-02-13 20:04:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:04:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:04:55 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4300788194 +2016-02-13 20:04:57 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 721742845 +2016-02-13 20:04:58 INFO ComplexDataJackson:31 - -------Round 21 +2016-02-13 20:05:00 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 449699025 +2016-02-13 20:05:00 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:00 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:01 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1338069784 +2016-02-13 20:05:03 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 720708999 +2016-02-13 20:05:04 INFO ComplexDataJackson:31 - -------Round 22 +2016-02-13 20:05:06 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 439571367 +2016-02-13 20:05:06 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:06 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1379395964 +2016-02-13 20:05:09 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 724697929 +2016-02-13 20:05:10 INFO ComplexDataJackson:31 - -------Round 23 +2016-02-13 20:05:11 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 497673947 +2016-02-13 20:05:12 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:12 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:13 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1612324194 +2016-02-13 20:05:16 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 884663681 +2016-02-13 20:05:17 INFO ComplexDataJackson:31 - -------Round 24 +2016-02-13 20:05:18 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 503245816 +2016-02-13 20:05:19 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:19 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:24 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 5022807757 +2016-02-13 20:05:25 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 699435628 +2016-02-13 20:05:26 INFO ComplexDataJackson:31 - -------Round 25 +2016-02-13 20:05:28 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 461511072 +2016-02-13 20:05:28 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:28 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:30 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1359426447 +2016-02-13 20:05:32 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 722071275 +2016-02-13 20:05:33 INFO ComplexDataJackson:31 - -------Round 26 +2016-02-13 20:05:34 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 459509304 +2016-02-13 20:05:34 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:34 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:36 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1304302241 +2016-02-13 20:05:38 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 706119109 +2016-02-13 20:05:39 INFO ComplexDataJackson:31 - -------Round 27 +2016-02-13 20:05:40 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 443023833 +2016-02-13 20:05:41 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:41 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:42 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1308951979 +2016-02-13 20:05:44 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 693649805 +2016-02-13 20:05:45 INFO ComplexDataJackson:31 - -------Round 28 +2016-02-13 20:05:46 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 443872148 +2016-02-13 20:05:46 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:46 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:51 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4176743730 +2016-02-13 20:05:52 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 700535397 +2016-02-13 20:05:53 INFO ComplexDataJackson:31 - -------Round 29 +2016-02-13 20:05:55 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 445953655 +2016-02-13 20:05:55 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:05:55 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:05:56 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1296523334 +2016-02-13 20:05:58 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 701827802 +2016-02-13 20:05:59 INFO ComplexDataJackson:31 - -------Round 30 +2016-02-13 20:06:01 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 443719775 +2016-02-13 20:06:01 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:01 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:02 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1309741475 +2016-02-13 20:06:04 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 698006640 +2016-02-13 20:06:06 INFO ComplexDataJackson:31 - -------Round 31 +2016-02-13 20:06:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 442733694 +2016-02-13 20:06:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:09 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1322123934 +2016-02-13 20:06:10 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 698388757 +2016-02-13 20:06:11 INFO ComplexDataJackson:31 - -------Round 32 +2016-02-13 20:06:13 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 474821189 +2016-02-13 20:06:13 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:13 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:17 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4296608996 +2016-02-13 20:06:19 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 705003946 +2016-02-13 20:06:20 INFO ComplexDataJackson:31 - -------Round 33 +2016-02-13 20:06:22 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 449688760 +2016-02-13 20:06:22 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:22 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:23 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1326667485 +2016-02-13 20:06:25 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 699966170 +2016-02-13 20:06:26 INFO ComplexDataJackson:31 - -------Round 34 +2016-02-13 20:06:27 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 441669847 +2016-02-13 20:06:28 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:28 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:29 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1299277887 +2016-02-13 20:06:31 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 723641978 +2016-02-13 20:06:32 INFO ComplexDataJackson:31 - -------Round 35 +2016-02-13 20:06:34 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 454130467 +2016-02-13 20:06:34 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:34 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:35 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1316463641 +2016-02-13 20:06:37 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 722224437 +2016-02-13 20:06:38 INFO ComplexDataJackson:31 - -------Round 36 +2016-02-13 20:06:40 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 444313082 +2016-02-13 20:06:40 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:40 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:44 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4168720870 +2016-02-13 20:06:46 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 716292162 +2016-02-13 20:06:47 INFO ComplexDataJackson:31 - -------Round 37 +2016-02-13 20:06:48 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 453859275 +2016-02-13 20:06:49 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:49 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:50 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1354556045 +2016-02-13 20:06:52 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 702207944 +2016-02-13 20:06:53 INFO ComplexDataJackson:31 - -------Round 38 +2016-02-13 20:06:54 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 441460631 +2016-02-13 20:06:55 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:06:55 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:06:56 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1310969931 +2016-02-13 20:06:58 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 698961536 +2016-02-13 20:06:59 INFO ComplexDataJackson:31 - -------Round 39 +2016-02-13 20:07:01 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 452284230 +2016-02-13 20:07:01 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:01 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:02 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1362443112 +2016-02-13 20:07:04 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 714802778 +2016-02-13 20:07:05 INFO ComplexDataJackson:31 - -------Round 40 +2016-02-13 20:07:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 446338533 +2016-02-13 20:07:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:12 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4707047557 +2016-02-13 20:07:14 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 887842982 +2016-02-13 20:07:15 INFO ComplexDataJackson:31 - -------Round 41 +2016-02-13 20:07:16 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 520853950 +2016-02-13 20:07:17 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:17 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:18 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1669910838 +2016-02-13 20:07:21 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 792730003 +2016-02-13 20:07:22 INFO ComplexDataJackson:31 - -------Round 42 +2016-02-13 20:07:24 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 446619989 +2016-02-13 20:07:24 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:24 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:28 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4114083784 +2016-02-13 20:07:30 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 699097725 +2016-02-13 20:07:31 INFO ComplexDataJackson:31 - -------Round 43 +2016-02-13 20:07:32 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 446668148 +2016-02-13 20:07:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:34 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1315005047 +2016-02-13 20:07:36 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 715094891 +2016-02-13 20:07:37 INFO ComplexDataJackson:31 - -------Round 44 +2016-02-13 20:07:38 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 452608713 +2016-02-13 20:07:39 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:39 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:40 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1348105860 +2016-02-13 20:07:42 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 727506562 +2016-02-13 20:07:43 INFO ComplexDataJackson:31 - -------Round 45 +2016-02-13 20:07:45 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 458520855 +2016-02-13 20:07:45 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:45 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:46 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1331530782 +2016-02-13 20:07:48 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 726158102 +2016-02-13 20:07:49 INFO ComplexDataJackson:31 - -------Round 46 +2016-02-13 20:07:51 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 445496931 +2016-02-13 20:07:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:07:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:07:55 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4215771687 +2016-02-13 20:07:57 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 703152577 +2016-02-13 20:07:58 INFO ComplexDataJackson:31 - -------Round 47 +2016-02-13 20:07:59 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 445821809 +2016-02-13 20:08:00 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:08:00 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:08:01 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1301186100 +2016-02-13 20:08:03 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 700948698 +2016-02-13 20:08:04 INFO ComplexDataJackson:31 - -------Round 48 +2016-02-13 20:08:05 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 447174215 +2016-02-13 20:08:06 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:08:06 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:08:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1314801751 +2016-02-13 20:08:09 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 702852568 +2016-02-13 20:08:10 INFO ComplexDataJackson:31 - -------Round 49 +2016-02-13 20:08:11 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 443597403 +2016-02-13 20:08:12 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:08:12 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:08:13 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 1307441278 +2016-02-13 20:08:15 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 700476579 +2016-02-13 20:08:16 INFO ComplexDataJackson:31 - -------Round 50 +2016-02-13 20:08:17 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 464090357 +2016-02-13 20:08:18 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 100 MB +2016-02-13 20:08:18 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 20:08:22 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 4154225719 +2016-02-13 20:08:23 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 702714012 +2016-02-13 20:08:24 INFO ComplexDataJackson:43 - -------------------------------------------------------------------------- +2016-02-13 20:08:24 INFO ComplexDataJackson:44 - Average Time to Generate JSON : 494540894 +2016-02-13 20:08:24 INFO ComplexDataJackson:45 - Average Time to Parse JSON To Map : 2254690740 +2016-02-13 20:08:24 INFO ComplexDataJackson:46 - Average Time to Parse JSON To Actual Object : 738842085 +2016-02-13 20:08:24 INFO ComplexDataJackson:47 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application 10kb gson.log b/gson-jackson-performance/logs_Performance/log4j-application 10kb gson.log new file mode 100644 index 000000000000..3798f54438c6 --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application 10kb gson.log @@ -0,0 +1,490 @@ +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 1 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 29919933 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 8431031 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 6431631 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 2 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 2422174 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 1543070 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 1984794 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 3 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 7451266 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 2946400 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 1498858 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 4 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 1223325 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 447250 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 692783 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 5 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 806075 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 552647 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 620939 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 6 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 917000 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 440934 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 660808 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 7 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 799365 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 386063 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 615807 +2016-02-13 19:28:29 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:24 - -------Round 8 +2016-02-13 19:28:29 INFO ComplexDataGson:50 - Json Generation Time(ms):: 676993 +2016-02-13 19:28:29 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:29 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:29 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 1876632 +2016-02-13 19:28:29 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 380143 +2016-02-13 19:28:30 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:24 - -------Round 9 +2016-02-13 19:28:30 INFO ComplexDataGson:50 - Json Generation Time(ms):: 652913 +2016-02-13 19:28:30 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:30 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 4579078 +2016-02-13 19:28:30 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 594885 +2016-02-13 19:28:30 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:24 - -------Round 10 +2016-02-13 19:28:30 INFO ComplexDataGson:50 - Json Generation Time(ms):: 630018 +2016-02-13 19:28:30 INFO ComplexDataGson:26 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:30 INFO ComplexDataGson:27 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:60 - Generating Map from json Time(ms):: 317772 +2016-02-13 19:28:30 INFO ComplexDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:72 - Generating Actual Object from json Time(ms):: 846735 +2016-02-13 19:28:30 INFO ComplexDataGson:73 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:36 - -------------------------------------------------------------------------- +2016-02-13 19:28:30 INFO ComplexDataGson:37 - Average Time to Generate JSON : 4549906 +2016-02-13 19:28:30 INFO ComplexDataGson:38 - Average Time to Parse JSON To Map : 2152087 +2016-02-13 19:28:30 INFO ComplexDataGson:39 - Average Time to Parse JSON To Actual Object : 1432738 +2016-02-13 19:28:30 INFO ComplexDataGson:40 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:27 - -------Round 1 +2016-02-13 19:28:57 INFO ComplexDataGson:53 - Json Generation Time(ms):: 22564197 +2016-02-13 19:28:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 6382682 +2016-02-13 19:28:57 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 5925169 +2016-02-13 19:28:57 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:27 - -------Round 2 +2016-02-13 19:28:57 INFO ComplexDataGson:53 - Json Generation Time(ms):: 2213352 +2016-02-13 19:28:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 1366223 +2016-02-13 19:28:57 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1049240 +2016-02-13 19:28:57 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:27 - -------Round 3 +2016-02-13 19:28:57 INFO ComplexDataGson:53 - Json Generation Time(ms):: 4573551 +2016-02-13 19:28:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 795023 +2016-02-13 19:28:57 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:57 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 1174770 +2016-02-13 19:28:57 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 4 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 1064636 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 432249 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 537647 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 5 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 780417 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 570411 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 711336 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 6 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 865288 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 268824 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 718836 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 7 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 427907 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 430671 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 676993 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 8 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 624097 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 409748 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 643045 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 9 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 622123 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 441328 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 545937 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 10 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 603175 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 388037 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 555016 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 11 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 568832 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 360405 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 545147 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 12 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 546726 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 221059 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 541594 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 13 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 533700 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 393959 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 537253 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 14 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 456329 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 347378 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 478435 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 15 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 485935 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 336326 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 436197 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 16 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 482777 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 309878 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 926869 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 17 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 503699 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 322509 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 483566 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 18 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 564885 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 298825 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 403038 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 19 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 421986 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 128688 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 222243 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 20 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 424354 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 238427 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 396327 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 21 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 397906 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 161057 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 236060 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 22 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 417643 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 466592 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 392380 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 23 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 279482 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 134609 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 325667 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 24 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 243165 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 223033 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 337904 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 25 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 247507 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 135398 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 179216 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 26 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 235270 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 112109 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 202111 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 27 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 319746 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 114082 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 171716 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 28 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 201717 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 112504 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 165399 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 29 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 247507 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 112504 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 176058 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 30 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 226586 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 114872 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 179216 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 31 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 203295 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 98687 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 176847 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 32 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 332378 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 208822 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 340668 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 33 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 370274 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 120793 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 185137 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 34 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 308298 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 230138 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 270402 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 35 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 290929 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 206848 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 178426 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 36 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 311851 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 222243 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 174084 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 37 +2016-02-13 19:28:58 INFO ComplexDataGson:53 - Json Generation Time(ms):: 295667 +2016-02-13 19:28:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 210795 +2016-02-13 19:28:58 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 220269 +2016-02-13 19:28:58 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:58 INFO ComplexDataGson:27 - -------Round 38 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 181978 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 131451 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 170531 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 39 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 302772 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 125135 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 160663 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 40 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 287377 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 214743 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 260139 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 41 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 181189 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 114082 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 147636 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 42 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 274350 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 181189 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 224217 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 43 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 181189 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 121583 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 139346 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 44 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 181190 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 101450 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 135793 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 45 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 185531 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 101450 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 139741 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 46 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 274745 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 211980 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 137372 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 47 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 185532 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 114477 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 134214 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 48 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 206059 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 128293 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 143688 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 49 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 261324 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 189479 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 220269 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:27 - -------Round 50 +2016-02-13 19:28:59 INFO ComplexDataGson:53 - Json Generation Time(ms):: 316588 +2016-02-13 19:28:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:28:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:63 - Generating Map from json Time(ms):: 209217 +2016-02-13 19:28:59 INFO ComplexDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:75 - Generating Actual Object from json Time(ms):: 248296 +2016-02-13 19:28:59 INFO ComplexDataGson:76 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:39 - -------------------------------------------------------------------------- +2016-02-13 19:28:59 INFO ComplexDataGson:40 - Average Time to Generate JSON : 945540 +2016-02-13 19:28:59 INFO ComplexDataGson:41 - Average Time to Parse JSON To Map : 387445 +2016-02-13 19:28:59 INFO ComplexDataGson:42 - Average Time to Parse JSON To Actual Object : 473642 +2016-02-13 19:28:59 INFO ComplexDataGson:43 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application 10kb jackson.log b/gson-jackson-performance/logs_Performance/log4j-application 10kb jackson.log new file mode 100644 index 000000000000..3959c60eb20d --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application 10kb jackson.log @@ -0,0 +1,370 @@ +2016-02-13 19:58:48 INFO ComplexDataJackson:29 - -------Round 1 +2016-02-13 19:58:48 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 87235780 +2016-02-13 19:58:48 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:48 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:48 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 29891117 +2016-02-13 19:58:48 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 18692902 +2016-02-13 19:58:48 INFO ComplexDataJackson:29 - -------Round 2 +2016-02-13 19:58:48 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 1735313 +2016-02-13 19:58:48 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:48 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:48 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 1242667 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 2039268 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 3 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 1130953 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 721205 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 5425418 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 4 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 761864 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 688441 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 959238 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 5 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 636334 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 589754 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 846735 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 6 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 1905844 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 495409 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 933974 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 7 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 654098 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 474882 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 753574 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 8 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 3619051 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 515146 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 607912 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 9 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 404617 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 930816 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 498566 +2016-02-13 19:58:49 INFO ComplexDataJackson:29 - -------Round 10 +2016-02-13 19:58:49 INFO ComplexDataJackson:56 - Json Generation Time(ms):: 384879 +2016-02-13 19:58:49 INFO ComplexDataJackson:31 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:58:49 INFO ComplexDataJackson:32 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:66 - Generating Map from json Time(ms):: 270008 +2016-02-13 19:58:49 INFO ComplexDataJackson:79 - Generating Actual Object from json Time(ms):: 547516 +2016-02-13 19:58:49 INFO ComplexDataJackson:41 - -------------------------------------------------------------------------- +2016-02-13 19:58:49 INFO ComplexDataJackson:42 - Average Time to Generate JSON : 9846873 +2016-02-13 19:58:49 INFO ComplexDataJackson:43 - Average Time to Parse JSON To Map : 3581944 +2016-02-13 19:58:49 INFO ComplexDataJackson:44 - Average Time to Parse JSON To Actual Object : 3130510 +2016-02-13 19:58:49 INFO ComplexDataJackson:45 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 1 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 68404321 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 27264858 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 18062489 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 2 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 1630310 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 876340 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1223324 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 3 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 907921 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 660019 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1451884 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 4 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 838445 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 886999 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1187797 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 5 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 768970 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 577122 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 858972 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 6 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 756732 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 626465 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 878709 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 7 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 616992 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 414486 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 779628 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 8 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 519093 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 480408 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 596859 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 9 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 482382 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 552647 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 594096 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 10 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 392774 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 337904 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 966344 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 11 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 430671 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 416065 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 546726 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 12 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 353695 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 292508 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 297245 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 13 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 396722 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 341852 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 420407 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 14 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 357247 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 354089 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 410143 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 15 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 382906 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 279087 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 433039 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 16 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 728310 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 713705 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 1305037 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 17 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 318167 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 288166 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 445670 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 18 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 246718 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 287377 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 453566 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 19 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 250270 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 286587 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 469356 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 20 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 234875 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 286981 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 459487 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 21 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 255007 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 350536 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 620544 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 22 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 265666 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 309087 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 545937 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 23 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 235270 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 250270 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 411328 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 24 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 254218 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 236059 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 394353 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 25 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 203690 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 247508 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 196585 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 26 +2016-02-13 19:59:07 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 244349 +2016-02-13 19:59:07 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:07 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:07 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 243954 +2016-02-13 19:59:07 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 213953 +2016-02-13 19:59:07 INFO ComplexDataJackson:31 - -------Round 27 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 176058 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 167373 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 436986 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 28 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 287377 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 275534 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 302377 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 29 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 258560 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 164216 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 268034 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 30 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 148031 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 152373 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 201321 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 31 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 232112 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 307114 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 332378 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 32 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 325272 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 249086 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 335536 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 33 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 232507 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 262113 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 325667 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 34 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 256587 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 269613 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 313825 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 35 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 230532 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 242375 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 267244 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 36 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 223032 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 227375 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 287377 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 37 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 157899 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 159084 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 285403 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 38 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 249086 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 243165 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 312640 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 39 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 149610 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 244349 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 298429 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 40 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 190268 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 564095 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 287772 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 41 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 216322 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 166583 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 290534 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 42 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 205269 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 215532 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 279482 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 43 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 164215 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 248297 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 283823 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 44 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 211190 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 204479 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 328825 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 45 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 238822 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 240007 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 262902 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 46 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 241586 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 238033 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 281060 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 47 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 215532 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 258165 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 262113 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 48 +2016-02-13 19:59:08 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 142109 +2016-02-13 19:59:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:08 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 125924 +2016-02-13 19:59:08 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 163426 +2016-02-13 19:59:08 INFO ComplexDataJackson:31 - -------Round 49 +2016-02-13 19:59:09 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 148030 +2016-02-13 19:59:09 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:09 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:09 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 233296 +2016-02-13 19:59:09 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 225006 +2016-02-13 19:59:09 INFO ComplexDataJackson:31 - -------Round 50 +2016-02-13 19:59:09 INFO ComplexDataJackson:58 - Json Generation Time(ms):: 219086 +2016-02-13 19:59:09 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 10 KB +2016-02-13 19:59:09 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 19:59:09 INFO ComplexDataJackson:68 - Generating Map from json Time(ms):: 135004 +2016-02-13 19:59:09 INFO ComplexDataJackson:81 - Generating Actual Object from json Time(ms):: 176453 +2016-02-13 19:59:09 INFO ComplexDataJackson:43 - -------------------------------------------------------------------------- +2016-02-13 19:59:09 INFO ComplexDataJackson:44 - Average Time to Generate JSON : 1711896 +2016-02-13 19:59:09 INFO ComplexDataJackson:45 - Average Time to Parse JSON To Map : 869085 +2016-02-13 19:59:09 INFO ComplexDataJackson:46 - Average Time to Parse JSON To Actual Object : 820641 +2016-02-13 19:59:09 INFO ComplexDataJackson:47 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 10R.log b/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 10R.log new file mode 100644 index 000000000000..11e7aa481bbb --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 10R.log @@ -0,0 +1,151 @@ +2016-02-14 07:09:34 INFO ComplexDataGson:27 - -------Round 1 +2016-02-14 07:13:19 INFO ComplexDataGson:27 - -------Round 1 +2016-02-14 07:13:26 INFO ComplexDataGson:54 - Json Generation Time(ms):: 3300743982 +2016-02-14 07:13:27 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:13:27 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:13:31 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 3791867873 +2016-02-14 07:13:31 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:13:38 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2877543214 +2016-02-14 07:13:38 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:13:42 INFO ComplexDataGson:27 - -------Round 2 +2016-02-14 07:13:49 INFO ComplexDataGson:54 - Json Generation Time(ms):: 3081464563 +2016-02-14 07:13:50 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:13:50 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:13:53 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 3414915004 +2016-02-14 07:13:53 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:13:59 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2745001008 +2016-02-14 07:13:59 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:14:02 INFO ComplexDataGson:27 - -------Round 3 +2016-02-14 07:14:07 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2452611871 +2016-02-14 07:14:08 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:14:08 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:14:13 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5147569477 +2016-02-14 07:14:13 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:14:49 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 5151814203 +2016-02-14 07:14:49 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:14:53 INFO ComplexDataGson:27 - -------Round 4 +2016-02-14 07:14:58 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2499724269 +2016-02-14 07:14:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:14:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:15:23 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 23671387986 +2016-02-14 07:15:23 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:16:30 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2889390000 +2016-02-14 07:16:30 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:16:34 INFO ComplexDataGson:27 - -------Round 5 +2016-02-14 07:16:39 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2421770990 +2016-02-14 07:16:40 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:16:40 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:16:45 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4739247161 +2016-02-14 07:16:45 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:16:59 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2774260133 +2016-02-14 07:16:59 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:17:02 INFO ComplexDataGson:27 - -------Round 6 +2016-02-14 07:17:08 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2418834853 +2016-02-14 07:17:08 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:17:08 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:17:13 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4871088293 +2016-02-14 07:17:13 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:17:21 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2690487083 +2016-02-14 07:17:21 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:17:25 INFO ComplexDataGson:27 - -------Round 7 +2016-02-14 07:17:30 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2447246454 +2016-02-14 07:17:31 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:17:31 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:17:35 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4567768185 +2016-02-14 07:17:35 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:17:43 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2672816184 +2016-02-14 07:17:43 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:17:46 INFO ComplexDataGson:27 - -------Round 8 +2016-02-14 07:17:51 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2453208335 +2016-02-14 07:17:52 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:17:52 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:17:57 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5084245563 +2016-02-14 07:17:57 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:18:05 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2931465412 +2016-02-14 07:18:05 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:18:08 INFO ComplexDataGson:27 - -------Round 9 +2016-02-14 07:18:14 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2447660150 +2016-02-14 07:18:14 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:18:14 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:18:19 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4877367551 +2016-02-14 07:18:19 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:18:26 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2738904519 +2016-02-14 07:18:26 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:18:29 INFO ComplexDataGson:27 - -------Round 10 +2016-02-14 07:18:35 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2463570868 +2016-02-14 07:18:35 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:18:35 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:18:40 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4857563433 +2016-02-14 07:18:40 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:18:47 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2706159768 +2016-02-14 07:18:47 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:18:50 INFO ComplexDataGson:40 - -------------------------------------------------------------------------- +2016-02-14 07:18:52 INFO ComplexDataGson:41 - Average Time to Generate JSON : 2598683633 +2016-02-14 07:18:52 INFO ComplexDataGson:42 - Average Time to Parse JSON To Map : 6502302052 +2016-02-14 07:18:52 INFO ComplexDataGson:43 - Average Time to Parse JSON To Actual Object : 3017784152 +2016-02-14 07:18:52 INFO ComplexDataGson:44 - -------------------------------------------------------------------------- +2016-02-14 07:30:16 INFO ComplexDataJackson:31 - -------Round 1 +2016-02-14 07:30:22 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1913798065 +2016-02-14 07:30:23 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:30:23 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:30:26 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 3501212864 +2016-02-14 07:30:33 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2519328644 +2016-02-14 07:30:37 INFO ComplexDataJackson:31 - -------Round 2 +2016-02-14 07:30:41 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1122079407 +2016-02-14 07:30:42 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:30:42 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:30:44 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1650946350 +2016-02-14 07:30:48 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1493836600 +2016-02-14 07:30:51 INFO ComplexDataJackson:31 - -------Round 3 +2016-02-14 07:30:55 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1056702014 +2016-02-14 07:30:56 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:30:56 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:30:58 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1769576448 +2016-02-14 07:31:02 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1515188920 +2016-02-14 07:31:05 INFO ComplexDataJackson:31 - -------Round 4 +2016-02-14 07:31:10 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1385929835 +2016-02-14 07:31:11 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:31:11 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:31:13 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1979048349 +2016-02-14 07:31:17 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1616521550 +2016-02-14 07:31:20 INFO ComplexDataJackson:31 - -------Round 5 +2016-02-14 07:31:24 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1076380997 +2016-02-14 07:31:25 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:31:25 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:31:27 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1786553379 +2016-02-14 07:31:31 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1514234815 +2016-02-14 07:31:34 INFO ComplexDataJackson:31 - -------Round 6 +2016-02-14 07:31:39 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1068609985 +2016-02-14 07:31:39 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:31:39 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:31:42 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2419927122 +2016-02-14 07:31:47 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1525414870 +2016-02-14 07:31:50 INFO ComplexDataJackson:31 - -------Round 7 +2016-02-14 07:31:54 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1210651015 +2016-02-14 07:31:55 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:31:55 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:31:57 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2127036259 +2016-02-14 07:32:03 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2067842595 +2016-02-14 07:32:06 INFO ComplexDataJackson:31 - -------Round 8 +2016-02-14 07:32:10 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1044809437 +2016-02-14 07:32:10 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:32:10 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:32:13 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2159417841 +2016-02-14 07:32:18 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2045629724 +2016-02-14 07:32:21 INFO ComplexDataJackson:31 - -------Round 9 +2016-02-14 07:32:25 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1063275754 +2016-02-14 07:32:25 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:32:25 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:32:28 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2249796606 +2016-02-14 07:32:33 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2037722525 +2016-02-14 07:32:36 INFO ComplexDataJackson:31 - -------Round 10 +2016-02-14 07:32:40 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1046656069 +2016-02-14 07:32:40 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:32:40 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 07:32:43 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2209315582 +2016-02-14 07:32:48 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2623449380 +2016-02-14 07:32:52 INFO ComplexDataJackson:44 - -------------------------------------------------------------------------- +2016-02-14 07:32:52 INFO ComplexDataJackson:45 - Average Time to Generate JSON : 1198889257 +2016-02-14 07:32:52 INFO ComplexDataJackson:46 - Average Time to Parse JSON To Map : 2185283080 +2016-02-14 07:32:52 INFO ComplexDataJackson:47 - Average Time to Parse JSON To Actual Object : 1895916962 +2016-02-14 07:32:52 INFO ComplexDataJackson:48 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 50R.log b/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 50R.log new file mode 100644 index 000000000000..f46f494f354d --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application complex Gson Jackson 250mb 50R.log @@ -0,0 +1,710 @@ +2016-02-14 07:40:07 INFO ComplexDataGson:27 - -------Round 1 +2016-02-14 07:40:15 INFO ComplexDataGson:54 - Json Generation Time(ms):: 3797149997 +2016-02-14 07:40:16 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:40:16 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:40:19 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 3387405404 +2016-02-14 07:40:19 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:40:27 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2878285736 +2016-02-14 07:40:27 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:40:31 INFO ComplexDataGson:27 - -------Round 2 +2016-02-14 07:40:37 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2490870463 +2016-02-14 07:40:38 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:40:38 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:40:41 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 3039905087 +2016-02-14 07:40:41 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:40:47 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3045785254 +2016-02-14 07:40:47 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:40:50 INFO ComplexDataGson:27 - -------Round 3 +2016-02-14 07:40:55 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2523651926 +2016-02-14 07:40:56 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:40:56 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:41:01 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4578827448 +2016-02-14 07:41:01 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:41:23 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 8280810781 +2016-02-14 07:41:23 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:41:27 INFO ComplexDataGson:27 - -------Round 4 +2016-02-14 07:41:33 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2370172675 +2016-02-14 07:41:34 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:41:34 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:42:06 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 32830902935 +2016-02-14 07:42:06 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:42:14 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2791214171 +2016-02-14 07:42:14 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:42:17 INFO ComplexDataGson:27 - -------Round 5 +2016-02-14 07:42:23 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2517693992 +2016-02-14 07:42:24 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:42:24 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:42:29 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4962835649 +2016-02-14 07:42:29 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:42:40 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2876976750 +2016-02-14 07:42:40 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:42:44 INFO ComplexDataGson:27 - -------Round 6 +2016-02-14 07:42:50 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2983421369 +2016-02-14 07:42:51 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:42:51 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:43:05 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 13683434909 +2016-02-14 07:43:05 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:43:16 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2770234887 +2016-02-14 07:43:16 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:43:20 INFO ComplexDataGson:27 - -------Round 7 +2016-02-14 07:43:25 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2405473419 +2016-02-14 07:43:26 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:43:26 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:43:33 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 6810693016 +2016-02-14 07:43:33 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:43:42 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2768497206 +2016-02-14 07:43:42 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:43:45 INFO ComplexDataGson:27 - -------Round 8 +2016-02-14 07:43:50 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2374051075 +2016-02-14 07:43:51 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:43:51 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:43:59 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 7719104349 +2016-02-14 07:43:59 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:44:58 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 20399180345 +2016-02-14 07:44:58 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:45:02 INFO ComplexDataGson:27 - -------Round 9 +2016-02-14 07:45:07 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2533230094 +2016-02-14 07:45:08 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:45:08 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:45:44 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 35641108832 +2016-02-14 07:45:44 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:46:41 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 4185201210 +2016-02-14 07:46:41 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:46:45 INFO ComplexDataGson:27 - -------Round 10 +2016-02-14 07:46:51 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2466678325 +2016-02-14 07:46:52 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:46:52 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:47:04 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 12154237562 +2016-02-14 07:47:04 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:47:13 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2783741983 +2016-02-14 07:47:13 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:47:17 INFO ComplexDataGson:27 - -------Round 11 +2016-02-14 07:47:22 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2476994277 +2016-02-14 07:47:23 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:47:23 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:47:36 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 13312892750 +2016-02-14 07:47:36 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:48:03 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3745747872 +2016-02-14 07:48:03 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:48:08 INFO ComplexDataGson:27 - -------Round 12 +2016-02-14 07:48:14 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2477815749 +2016-02-14 07:48:14 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:48:14 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:48:19 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5183533399 +2016-02-14 07:48:19 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:48:29 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2717330745 +2016-02-14 07:48:29 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:48:33 INFO ComplexDataGson:27 - -------Round 13 +2016-02-14 07:48:38 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2483506437 +2016-02-14 07:48:39 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:48:39 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:48:48 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 9145250726 +2016-02-14 07:48:48 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:49:46 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 5718372485 +2016-02-14 07:49:46 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:49:51 INFO ComplexDataGson:27 - -------Round 14 +2016-02-14 07:49:56 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2375017418 +2016-02-14 07:49:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:49:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:50:05 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 8356615446 +2016-02-14 07:50:05 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:50:12 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2680602591 +2016-02-14 07:50:12 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:50:15 INFO ComplexDataGson:27 - -------Round 15 +2016-02-14 07:50:20 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2352459143 +2016-02-14 07:50:21 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:50:21 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:50:26 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4920213117 +2016-02-14 07:50:26 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:50:33 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2853892670 +2016-02-14 07:50:33 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:50:36 INFO ComplexDataGson:27 - -------Round 16 +2016-02-14 07:50:41 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2431161653 +2016-02-14 07:50:42 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:50:42 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:50:46 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4680718647 +2016-02-14 07:50:46 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:50:53 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3122951011 +2016-02-14 07:50:53 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:50:57 INFO ComplexDataGson:27 - -------Round 17 +2016-02-14 07:51:02 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2421268081 +2016-02-14 07:51:02 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:51:02 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:51:07 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4890545033 +2016-02-14 07:51:07 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:51:14 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3173707723 +2016-02-14 07:51:14 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:51:18 INFO ComplexDataGson:27 - -------Round 18 +2016-02-14 07:51:24 INFO ComplexDataGson:54 - Json Generation Time(ms):: 3015968746 +2016-02-14 07:51:25 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:51:25 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:51:30 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4825937003 +2016-02-14 07:51:30 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:51:36 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2780808215 +2016-02-14 07:51:36 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:51:40 INFO ComplexDataGson:27 - -------Round 19 +2016-02-14 07:51:45 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2449963505 +2016-02-14 07:51:46 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:51:46 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:51:51 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5297335332 +2016-02-14 07:51:51 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:51:57 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2769354993 +2016-02-14 07:51:57 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:52:01 INFO ComplexDataGson:27 - -------Round 20 +2016-02-14 07:52:07 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2474888297 +2016-02-14 07:52:07 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:52:07 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:52:12 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4832219815 +2016-02-14 07:52:12 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:52:19 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2738290291 +2016-02-14 07:52:19 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:52:22 INFO ComplexDataGson:27 - -------Round 21 +2016-02-14 07:52:28 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2521485548 +2016-02-14 07:52:29 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:52:29 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:52:34 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4986757780 +2016-02-14 07:52:34 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:52:41 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2767275460 +2016-02-14 07:52:41 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:52:45 INFO ComplexDataGson:27 - -------Round 22 +2016-02-14 07:52:51 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2819066808 +2016-02-14 07:52:52 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:52:52 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:52:57 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5448328064 +2016-02-14 07:52:57 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:53:04 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2726202709 +2016-02-14 07:53:04 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:53:08 INFO ComplexDataGson:27 - -------Round 23 +2016-02-14 07:53:13 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2524093649 +2016-02-14 07:53:14 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:53:14 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:53:19 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5153818734 +2016-02-14 07:53:19 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:53:26 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3535297784 +2016-02-14 07:53:26 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:53:30 INFO ComplexDataGson:27 - -------Round 24 +2016-02-14 07:53:36 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2601603625 +2016-02-14 07:53:37 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:53:37 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:53:42 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5013024319 +2016-02-14 07:53:42 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:53:49 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2825129744 +2016-02-14 07:53:49 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:53:53 INFO ComplexDataGson:27 - -------Round 25 +2016-02-14 07:53:58 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2467801778 +2016-02-14 07:53:59 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:53:59 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:54:04 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4986123024 +2016-02-14 07:54:04 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:54:11 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2805291678 +2016-02-14 07:54:11 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:54:14 INFO ComplexDataGson:27 - -------Round 26 +2016-02-14 07:54:19 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2373800804 +2016-02-14 07:54:20 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:54:20 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:54:25 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5206601294 +2016-02-14 07:54:25 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:54:32 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2715289502 +2016-02-14 07:54:32 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:54:35 INFO ComplexDataGson:27 - -------Round 27 +2016-02-14 07:54:41 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2401132374 +2016-02-14 07:54:41 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:54:41 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:54:46 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4847989607 +2016-02-14 07:54:46 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:54:53 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2784961360 +2016-02-14 07:54:53 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:54:57 INFO ComplexDataGson:27 - -------Round 28 +2016-02-14 07:55:02 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2589043530 +2016-02-14 07:55:03 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:55:03 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:55:08 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4939033522 +2016-02-14 07:55:08 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:55:15 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2813883370 +2016-02-14 07:55:15 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:55:18 INFO ComplexDataGson:27 - -------Round 29 +2016-02-14 07:55:24 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2444364004 +2016-02-14 07:55:24 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:55:24 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:55:30 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5366266642 +2016-02-14 07:55:30 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:55:36 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2712294943 +2016-02-14 07:55:36 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:55:40 INFO ComplexDataGson:27 - -------Round 30 +2016-02-14 07:55:45 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2430504792 +2016-02-14 07:55:46 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:55:46 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:55:51 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4817296757 +2016-02-14 07:55:51 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:55:57 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2742085794 +2016-02-14 07:55:57 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:56:01 INFO ComplexDataGson:27 - -------Round 31 +2016-02-14 07:56:07 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2737635009 +2016-02-14 07:56:08 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:56:08 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:56:13 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5277481080 +2016-02-14 07:56:13 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:56:20 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2757257938 +2016-02-14 07:56:20 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:56:23 INFO ComplexDataGson:27 - -------Round 32 +2016-02-14 07:56:29 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2423339719 +2016-02-14 07:56:29 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:56:29 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:56:34 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4689185204 +2016-02-14 07:56:34 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:56:41 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3093930314 +2016-02-14 07:56:41 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:56:45 INFO ComplexDataGson:27 - -------Round 33 +2016-02-14 07:56:50 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2399545487 +2016-02-14 07:56:51 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:56:51 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:56:55 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4826696105 +2016-02-14 07:56:55 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:57:02 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2978790184 +2016-02-14 07:57:02 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:57:06 INFO ComplexDataGson:27 - -------Round 34 +2016-02-14 07:57:12 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2718127741 +2016-02-14 07:57:13 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:57:13 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:57:17 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4706243059 +2016-02-14 07:57:17 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:57:25 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3105616831 +2016-02-14 07:57:25 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:57:28 INFO ComplexDataGson:27 - -------Round 35 +2016-02-14 07:57:34 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2631047886 +2016-02-14 07:57:35 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:57:35 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:57:39 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4823275612 +2016-02-14 07:57:39 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:57:48 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3703097312 +2016-02-14 07:57:48 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:57:51 INFO ComplexDataGson:27 - -------Round 36 +2016-02-14 07:57:57 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2436002054 +2016-02-14 07:57:58 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:57:58 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:58:02 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4684077163 +2016-02-14 07:58:02 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:58:09 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2743737815 +2016-02-14 07:58:09 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:58:13 INFO ComplexDataGson:27 - -------Round 37 +2016-02-14 07:58:18 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2464042197 +2016-02-14 07:58:19 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:58:19 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:58:23 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4845604539 +2016-02-14 07:58:23 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:58:30 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2730389802 +2016-02-14 07:58:30 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:58:34 INFO ComplexDataGson:27 - -------Round 38 +2016-02-14 07:58:39 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2450035744 +2016-02-14 07:58:40 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:58:40 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:58:45 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4703580879 +2016-02-14 07:58:45 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:58:51 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2761148969 +2016-02-14 07:58:51 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:58:55 INFO ComplexDataGson:27 - -------Round 39 +2016-02-14 07:59:01 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2461427780 +2016-02-14 07:59:01 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:59:01 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:59:06 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4850024928 +2016-02-14 07:59:06 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:59:13 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2769605659 +2016-02-14 07:59:13 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:59:16 INFO ComplexDataGson:27 - -------Round 40 +2016-02-14 07:59:22 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2419508689 +2016-02-14 07:59:22 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:59:22 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:59:27 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4708503388 +2016-02-14 07:59:27 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:59:34 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2737963439 +2016-02-14 07:59:34 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:59:37 INFO ComplexDataGson:27 - -------Round 41 +2016-02-14 07:59:43 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2796656957 +2016-02-14 07:59:44 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 07:59:44 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 07:59:49 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5214122035 +2016-02-14 07:59:49 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 07:59:56 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2818194809 +2016-02-14 07:59:56 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 07:59:59 INFO ComplexDataGson:27 - -------Round 42 +2016-02-14 08:00:05 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2467121627 +2016-02-14 08:00:05 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:00:05 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:00:10 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4789276352 +2016-02-14 08:00:10 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:00:19 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3489966490 +2016-02-14 08:00:19 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:00:22 INFO ComplexDataGson:27 - -------Round 43 +2016-02-14 08:00:28 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2483219849 +2016-02-14 08:00:29 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:00:29 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:00:34 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5075942431 +2016-02-14 08:00:34 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:00:41 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2818891934 +2016-02-14 08:00:41 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:00:44 INFO ComplexDataGson:27 - -------Round 44 +2016-02-14 08:00:50 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2487425891 +2016-02-14 08:00:50 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:00:50 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:00:55 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4765529489 +2016-02-14 08:00:55 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:01:03 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2788979501 +2016-02-14 08:01:03 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:01:07 INFO ComplexDataGson:27 - -------Round 45 +2016-02-14 08:01:13 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2601907186 +2016-02-14 08:01:14 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:01:14 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:01:19 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5569084670 +2016-02-14 08:01:19 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:01:26 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2955014505 +2016-02-14 08:01:26 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:01:30 INFO ComplexDataGson:27 - -------Round 46 +2016-02-14 08:01:36 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2449779158 +2016-02-14 08:01:36 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:01:36 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:01:41 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4740324033 +2016-02-14 08:01:41 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:01:48 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2783091438 +2016-02-14 08:01:48 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:01:51 INFO ComplexDataGson:27 - -------Round 47 +2016-02-14 08:01:57 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2465765273 +2016-02-14 08:01:57 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:01:57 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:02:02 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4886437678 +2016-02-14 08:02:02 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:02:10 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 3316012444 +2016-02-14 08:02:10 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:02:13 INFO ComplexDataGson:27 - -------Round 48 +2016-02-14 08:02:20 INFO ComplexDataGson:54 - Json Generation Time(ms):: 3236147401 +2016-02-14 08:02:21 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:02:21 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:02:26 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 5479380529 +2016-02-14 08:02:26 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:02:33 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2714805541 +2016-02-14 08:02:33 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:02:36 INFO ComplexDataGson:27 - -------Round 49 +2016-02-14 08:02:42 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2405275256 +2016-02-14 08:02:42 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:02:42 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:02:47 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4832263632 +2016-02-14 08:02:47 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:02:54 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2773142206 +2016-02-14 08:02:54 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:02:57 INFO ComplexDataGson:27 - -------Round 50 +2016-02-14 08:03:03 INFO ComplexDataGson:54 - Json Generation Time(ms):: 2341883841 +2016-02-14 08:03:03 INFO ComplexDataGson:29 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:03:03 INFO ComplexDataGson:30 - -------------------------------------------------------------------------- +2016-02-14 08:03:08 INFO ComplexDataGson:64 - Generating Map from json Time(ms):: 4684440727 +2016-02-14 08:03:08 INFO ComplexDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 08:03:15 INFO ComplexDataGson:76 - Generating Actual Object from json Time(ms):: 2707959030 +2016-02-14 08:03:15 INFO ComplexDataGson:77 - -------------------------------------------------------------------------- +2016-02-14 08:03:18 INFO ComplexDataGson:40 - -------------------------------------------------------------------------- +2016-02-14 08:03:18 INFO ComplexDataGson:41 - Average Time to Generate JSON : 2549404565 +2016-02-14 08:03:18 INFO ComplexDataGson:42 - Average Time to Parse JSON To Map : 6783408594 +2016-02-14 08:03:18 INFO ComplexDataGson:43 - Average Time to Parse JSON To Actual Object : 3441125908 +2016-02-14 08:03:18 INFO ComplexDataGson:44 - -------------------------------------------------------------------------- +2016-02-14 08:12:17 INFO ComplexDataJackson:31 - -------Round 1 +2016-02-14 08:12:24 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 2440775348 +2016-02-14 08:12:24 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:12:24 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:12:27 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2956427703 +2016-02-14 08:12:32 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1768665369 +2016-02-14 08:12:36 INFO ComplexDataJackson:31 - -------Round 2 +2016-02-14 08:12:40 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1076246782 +2016-02-14 08:12:40 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:12:40 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:12:42 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1699796428 +2016-02-14 08:12:46 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1435017947 +2016-02-14 08:12:49 INFO ComplexDataJackson:31 - -------Round 3 +2016-02-14 08:12:53 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1085262040 +2016-02-14 08:12:53 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:12:53 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:12:55 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1698377309 +2016-02-14 08:12:59 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1442987517 +2016-02-14 08:13:01 INFO ComplexDataJackson:31 - -------Round 4 +2016-02-14 08:13:05 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1040101277 +2016-02-14 08:13:06 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:13:06 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:13:07 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1670708624 +2016-02-14 08:13:12 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1441443262 +2016-02-14 08:13:14 INFO ComplexDataJackson:31 - -------Round 5 +2016-02-14 08:13:19 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1341135004 +2016-02-14 08:13:20 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:13:20 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:13:22 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1978411620 +2016-02-14 08:13:26 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1450048771 +2016-02-14 08:13:29 INFO ComplexDataJackson:31 - -------Round 6 +2016-02-14 08:13:32 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1071070845 +2016-02-14 08:13:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:13:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:13:35 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2355220405 +2016-02-14 08:13:41 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1639170619 +2016-02-14 08:13:43 INFO ComplexDataJackson:31 - -------Round 7 +2016-02-14 08:13:47 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1191407439 +2016-02-14 08:13:48 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:13:48 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:13:50 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 1984646667 +2016-02-14 08:13:55 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1957293386 +2016-02-14 08:13:57 INFO ComplexDataJackson:31 - -------Round 8 +2016-02-14 08:14:01 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1035984844 +2016-02-14 08:14:01 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:14:01 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:14:04 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2125148573 +2016-02-14 08:14:08 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1951296372 +2016-02-14 08:14:11 INFO ComplexDataJackson:31 - -------Round 9 +2016-02-14 08:14:15 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1037756473 +2016-02-14 08:14:15 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:14:15 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:14:17 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2125514505 +2016-02-14 08:14:22 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1948151809 +2016-02-14 08:14:25 INFO ComplexDataJackson:31 - -------Round 10 +2016-02-14 08:14:28 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1032009335 +2016-02-14 08:14:29 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:14:29 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:14:31 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2120127773 +2016-02-14 08:14:36 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1954880686 +2016-02-14 08:14:38 INFO ComplexDataJackson:31 - -------Round 11 +2016-02-14 08:14:42 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1012279825 +2016-02-14 08:14:43 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:14:43 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:14:45 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2114519980 +2016-02-14 08:14:49 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1956102826 +2016-02-14 08:14:52 INFO ComplexDataJackson:31 - -------Round 12 +2016-02-14 08:14:56 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1019135415 +2016-02-14 08:14:56 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:14:56 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:14:58 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2116012128 +2016-02-14 08:15:03 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2005033828 +2016-02-14 08:15:06 INFO ComplexDataJackson:31 - -------Round 13 +2016-02-14 08:15:09 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1030257443 +2016-02-14 08:15:10 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:15:10 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:15:12 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2146258913 +2016-02-14 08:15:17 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1975422588 +2016-02-14 08:15:19 INFO ComplexDataJackson:31 - -------Round 14 +2016-02-14 08:15:23 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1031869989 +2016-02-14 08:15:24 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:15:24 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:15:26 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2132500362 +2016-02-14 08:15:30 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1958415260 +2016-02-14 08:15:33 INFO ComplexDataJackson:31 - -------Round 15 +2016-02-14 08:15:37 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1032830806 +2016-02-14 08:15:37 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:15:37 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:15:40 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2184912648 +2016-02-14 08:15:44 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1979574943 +2016-02-14 08:15:46 INFO ComplexDataJackson:31 - -------Round 16 +2016-02-14 08:15:50 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1035782337 +2016-02-14 08:15:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:15:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:15:53 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2126135444 +2016-02-14 08:15:58 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1957399178 +2016-02-14 08:16:00 INFO ComplexDataJackson:31 - -------Round 17 +2016-02-14 08:16:04 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1042031595 +2016-02-14 08:16:05 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:16:05 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:16:07 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2127070207 +2016-02-14 08:16:12 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2462038061 +2016-02-14 08:16:15 INFO ComplexDataJackson:31 - -------Round 18 +2016-02-14 08:16:19 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1195357288 +2016-02-14 08:16:20 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:16:20 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:16:22 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2348974306 +2016-02-14 08:16:27 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1949930939 +2016-02-14 08:16:30 INFO ComplexDataJackson:31 - -------Round 19 +2016-02-14 08:16:34 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1050152353 +2016-02-14 08:16:34 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:16:34 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:16:36 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2125778986 +2016-02-14 08:16:41 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1942497437 +2016-02-14 08:16:43 INFO ComplexDataJackson:31 - -------Round 20 +2016-02-14 08:16:47 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1030772194 +2016-02-14 08:16:48 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:16:48 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:16:50 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2126496243 +2016-02-14 08:16:55 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1947109675 +2016-02-14 08:16:57 INFO ComplexDataJackson:31 - -------Round 21 +2016-02-14 08:17:01 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1028750295 +2016-02-14 08:17:02 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:17:02 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:17:04 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2124714745 +2016-02-14 08:17:08 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1955796501 +2016-02-14 08:17:11 INFO ComplexDataJackson:31 - -------Round 22 +2016-02-14 08:17:15 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1062502837 +2016-02-14 08:17:16 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:17:16 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:17:18 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2125079493 +2016-02-14 08:17:22 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1971739193 +2016-02-14 08:17:25 INFO ComplexDataJackson:31 - -------Round 23 +2016-02-14 08:17:29 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1059218533 +2016-02-14 08:17:29 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:17:29 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:17:32 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2168292568 +2016-02-14 08:17:36 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2030034016 +2016-02-14 08:17:39 INFO ComplexDataJackson:31 - -------Round 24 +2016-02-14 08:17:44 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1350753436 +2016-02-14 08:17:44 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:17:44 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:17:47 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2723882380 +2016-02-14 08:17:52 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2221258291 +2016-02-14 08:17:55 INFO ComplexDataJackson:31 - -------Round 25 +2016-02-14 08:17:59 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1023832128 +2016-02-14 08:18:00 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:18:00 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:18:02 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2157595684 +2016-02-14 08:18:06 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1956225592 +2016-02-14 08:18:09 INFO ComplexDataJackson:31 - -------Round 26 +2016-02-14 08:18:12 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1023012236 +2016-02-14 08:18:13 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:18:13 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:18:15 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2125057782 +2016-02-14 08:18:20 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1935725534 +2016-02-14 08:18:22 INFO ComplexDataJackson:31 - -------Round 27 +2016-02-14 08:18:26 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1012124294 +2016-02-14 08:18:26 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:18:26 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:18:29 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2109949982 +2016-02-14 08:18:33 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1985652090 +2016-02-14 08:18:36 INFO ComplexDataJackson:31 - -------Round 28 +2016-02-14 08:18:40 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1030921014 +2016-02-14 08:18:40 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:18:40 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:18:42 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2122576789 +2016-02-14 08:18:47 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1932141615 +2016-02-14 08:18:50 INFO ComplexDataJackson:31 - -------Round 29 +2016-02-14 08:18:53 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1021380348 +2016-02-14 08:18:54 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:18:54 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:18:56 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2144563470 +2016-02-14 08:19:01 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1958701453 +2016-02-14 08:19:03 INFO ComplexDataJackson:31 - -------Round 30 +2016-02-14 08:19:07 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1019731484 +2016-02-14 08:19:08 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:19:08 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:19:10 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2240348705 +2016-02-14 08:19:16 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2485404386 +2016-02-14 08:19:19 INFO ComplexDataJackson:31 - -------Round 31 +2016-02-14 08:19:22 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1042472529 +2016-02-14 08:19:23 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:19:23 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:19:25 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2124567109 +2016-02-14 08:19:30 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2000236849 +2016-02-14 08:19:32 INFO ComplexDataJackson:31 - -------Round 32 +2016-02-14 08:19:36 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1019639508 +2016-02-14 08:19:37 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:19:37 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:19:39 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2165450777 +2016-02-14 08:19:44 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1950601221 +2016-02-14 08:19:47 INFO ComplexDataJackson:31 - -------Round 33 +2016-02-14 08:19:50 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1016860876 +2016-02-14 08:19:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:19:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:19:53 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2119094717 +2016-02-14 08:19:57 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1948888804 +2016-02-14 08:20:00 INFO ComplexDataJackson:31 - -------Round 34 +2016-02-14 08:20:04 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1036841447 +2016-02-14 08:20:04 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:20:04 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:20:07 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2110651055 +2016-02-14 08:20:11 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1937063730 +2016-02-14 08:20:14 INFO ComplexDataJackson:31 - -------Round 35 +2016-02-14 08:20:18 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1290871331 +2016-02-14 08:20:19 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:20:19 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:20:22 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2592745083 +2016-02-14 08:20:27 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1944194064 +2016-02-14 08:20:29 INFO ComplexDataJackson:31 - -------Round 36 +2016-02-14 08:20:33 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1010976761 +2016-02-14 08:20:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:20:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:20:36 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2119356830 +2016-02-14 08:20:40 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1946314257 +2016-02-14 08:20:43 INFO ComplexDataJackson:31 - -------Round 37 +2016-02-14 08:20:46 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1030989306 +2016-02-14 08:20:47 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:20:47 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:20:49 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2116773203 +2016-02-14 08:20:54 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1950905572 +2016-02-14 08:20:56 INFO ComplexDataJackson:31 - -------Round 38 +2016-02-14 08:21:00 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1017828404 +2016-02-14 08:21:01 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:21:01 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:21:03 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2115104602 +2016-02-14 08:21:08 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1937908885 +2016-02-14 08:21:10 INFO ComplexDataJackson:31 - -------Round 39 +2016-02-14 08:21:14 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1035317324 +2016-02-14 08:21:15 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:21:15 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:21:17 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2116247398 +2016-02-14 08:21:21 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1968002902 +2016-02-14 08:21:24 INFO ComplexDataJackson:31 - -------Round 40 +2016-02-14 08:21:28 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1079234236 +2016-02-14 08:21:28 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:21:29 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:21:31 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2150258895 +2016-02-14 08:21:36 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1981606712 +2016-02-14 08:21:38 INFO ComplexDataJackson:31 - -------Round 41 +2016-02-14 08:21:42 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1024907027 +2016-02-14 08:21:43 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:21:43 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:21:45 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2132610102 +2016-02-14 08:21:49 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1951541511 +2016-02-14 08:21:52 INFO ComplexDataJackson:31 - -------Round 42 +2016-02-14 08:21:56 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1026086139 +2016-02-14 08:21:56 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:21:56 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:21:58 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2130974266 +2016-02-14 08:22:03 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1942215193 +2016-02-14 08:22:06 INFO ComplexDataJackson:31 - -------Round 43 +2016-02-14 08:22:09 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1012376932 +2016-02-14 08:22:10 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:22:10 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:22:12 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2112633874 +2016-02-14 08:22:17 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1950879123 +2016-02-14 08:22:19 INFO ComplexDataJackson:31 - -------Round 44 +2016-02-14 08:22:23 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1031510768 +2016-02-14 08:22:24 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:22:24 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:22:26 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2111779244 +2016-02-14 08:22:31 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1954917791 +2016-02-14 08:22:33 INFO ComplexDataJackson:31 - -------Round 45 +2016-02-14 08:22:37 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1011530593 +2016-02-14 08:22:37 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:22:37 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:22:40 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2112648085 +2016-02-14 08:22:44 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1950791884 +2016-02-14 08:22:47 INFO ComplexDataJackson:31 - -------Round 46 +2016-02-14 08:22:50 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1024148321 +2016-02-14 08:22:51 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:22:51 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:22:53 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2126121233 +2016-02-14 08:22:58 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1985191814 +2016-02-14 08:23:01 INFO ComplexDataJackson:31 - -------Round 47 +2016-02-14 08:23:04 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1038904795 +2016-02-14 08:23:05 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:23:05 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:23:07 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2171032910 +2016-02-14 08:23:12 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1942167823 +2016-02-14 08:23:15 INFO ComplexDataJackson:31 - -------Round 48 +2016-02-14 08:23:18 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1019919780 +2016-02-14 08:23:19 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:23:19 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:23:21 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2116935444 +2016-02-14 08:23:26 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 1966154692 +2016-02-14 08:23:28 INFO ComplexDataJackson:31 - -------Round 49 +2016-02-14 08:23:32 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1038407413 +2016-02-14 08:23:33 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:23:33 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:23:35 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2164705097 +2016-02-14 08:23:40 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2018967252 +2016-02-14 08:23:42 INFO ComplexDataJackson:31 - -------Round 50 +2016-02-14 08:23:47 INFO ComplexDataJackson:59 - Json Generation Time(ms):: 1333104642 +2016-02-14 08:23:48 INFO ComplexDataJackson:33 - Size of Complex content Jackson :: 250 MB +2016-02-14 08:23:48 INFO ComplexDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 08:23:50 INFO ComplexDataJackson:69 - Generating Map from json Time(ms):: 2717974579 +2016-02-14 08:23:56 INFO ComplexDataJackson:82 - Generating Actual Object from json Time(ms):: 2187066394 +2016-02-14 08:23:59 INFO ComplexDataJackson:44 - -------------------------------------------------------------------------- +2016-02-14 08:23:59 INFO ComplexDataJackson:45 - Average Time to Generate JSON : 1092127467 +2016-02-14 08:23:59 INFO ComplexDataJackson:46 - Average Time to Parse JSON To Map : 2158655298 +2016-02-14 08:23:59 INFO ComplexDataJackson:47 - Average Time to Parse JSON To Actual Object : 1939415512 +2016-02-14 08:23:59 INFO ComplexDataJackson:48 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 10R.log b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 10R.log new file mode 100644 index 000000000000..6d66c79825ed --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 10R.log @@ -0,0 +1,160 @@ +2016-02-13 22:32:02 INFO SimpleDataGson:25 - -------Round 1 +2016-02-13 22:32:07 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1802698961 +2016-02-13 22:32:08 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:08 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:10 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 2003962071 +2016-02-13 22:32:10 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:12 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1005873828 +2016-02-13 22:32:12 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:14 INFO SimpleDataGson:25 - -------Round 2 +2016-02-13 22:32:16 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1222128229 +2016-02-13 22:32:16 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:16 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:18 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1672580233 +2016-02-13 22:32:18 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:20 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 914391709 +2016-02-13 22:32:20 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:21 INFO SimpleDataGson:25 - -------Round 3 +2016-02-13 22:32:23 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1232757569 +2016-02-13 22:32:24 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:24 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:25 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1761755454 +2016-02-13 22:32:25 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:28 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1042478282 +2016-02-13 22:32:28 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:29 INFO SimpleDataGson:25 - -------Round 4 +2016-02-13 22:32:31 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1350677839 +2016-02-13 22:32:31 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:31 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:33 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1997474806 +2016-02-13 22:32:33 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:35 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 999789995 +2016-02-13 22:32:35 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:36 INFO SimpleDataGson:25 - -------Round 5 +2016-02-13 22:32:39 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1269646240 +2016-02-13 22:32:39 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:39 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:41 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 2061314403 +2016-02-13 22:32:41 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:44 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1455524498 +2016-02-13 22:32:44 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:45 INFO SimpleDataGson:25 - -------Round 6 +2016-02-13 22:32:47 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1304567889 +2016-02-13 22:32:47 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:47 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:49 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1370549381 +2016-02-13 22:32:49 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:51 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1153593911 +2016-02-13 22:32:51 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:52 INFO SimpleDataGson:25 - -------Round 7 +2016-02-13 22:32:54 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1258311882 +2016-02-13 22:32:55 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:32:55 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:32:56 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1423511342 +2016-02-13 22:32:56 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:32:58 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1174751932 +2016-02-13 22:32:58 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:32:59 INFO SimpleDataGson:25 - -------Round 8 +2016-02-13 22:33:02 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1233054419 +2016-02-13 22:33:02 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:33:02 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:33:03 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1644931000 +2016-02-13 22:33:03 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:33:06 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1299340655 +2016-02-13 22:33:06 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:33:07 INFO SimpleDataGson:25 - -------Round 9 +2016-02-13 22:33:09 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1250320633 +2016-02-13 22:33:09 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:33:09 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:33:11 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1876958683 +2016-02-13 22:33:11 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:33:14 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1180127985 +2016-02-13 22:33:14 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:33:15 INFO SimpleDataGson:25 - -------Round 10 +2016-02-13 22:33:18 INFO SimpleDataGson:50 - Json Generation Time(ms):: 1314250627 +2016-02-13 22:33:18 INFO SimpleDataGson:27 - Size of Simple content Gson :: 101 MB +2016-02-13 22:33:18 INFO SimpleDataGson:28 - -------------------------------------------------------------------------- +2016-02-13 22:33:20 INFO SimpleDataGson:60 - Generating Map from json Time(ms):: 1483840853 +2016-02-13 22:33:20 INFO SimpleDataGson:61 - -------------------------------------------------------------------------- +2016-02-13 22:33:22 INFO SimpleDataGson:73 - Generating Actual Object from json Time(ms):: 1179707185 +2016-02-13 22:33:22 INFO SimpleDataGson:74 - -------------------------------------------------------------------------- +2016-02-13 22:33:23 INFO SimpleDataGson:36 - -------------------------------------------------------------------------- +2016-02-13 22:33:23 INFO SimpleDataGson:37 - Average Time to Generate JSON : 1323841428 +2016-02-13 22:33:23 INFO SimpleDataGson:38 - Average Time to Parse JSON To Map : 1729687822 +2016-02-13 22:33:23 INFO SimpleDataGson:39 - Average Time to Parse JSON To Actual Object : 1140557998 +2016-02-13 22:33:23 INFO SimpleDataGson:40 - -------------------------------------------------------------------------- +2016-02-13 22:34:23 INFO SimpleDataJackson:28 - -------Round 1 +2016-02-13 22:34:28 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 3749361201 +2016-02-13 22:34:29 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:34:29 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:34:34 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 5117887111 +2016-02-13 22:34:34 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:34:36 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 1086143172 +2016-02-13 22:34:38 INFO SimpleDataJackson:28 - -------Round 2 +2016-02-13 22:34:39 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 434662538 +2016-02-13 22:34:39 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:34:39 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:34:41 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1334135590 +2016-02-13 22:34:41 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:34:43 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 771198580 +2016-02-13 22:34:44 INFO SimpleDataJackson:28 - -------Round 3 +2016-02-13 22:34:45 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 448593143 +2016-02-13 22:34:45 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:34:45 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:34:50 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 4189457425 +2016-02-13 22:34:50 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:34:52 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 887058668 +2016-02-13 22:34:53 INFO SimpleDataJackson:28 - -------Round 4 +2016-02-13 22:34:54 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 465465795 +2016-02-13 22:34:54 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:34:54 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:34:56 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1384778810 +2016-02-13 22:34:56 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:34:58 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 772597563 +2016-02-13 22:34:59 INFO SimpleDataJackson:28 - -------Round 5 +2016-02-13 22:35:01 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 431909574 +2016-02-13 22:35:01 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:01 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:02 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1414299931 +2016-02-13 22:35:02 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:04 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 758118259 +2016-02-13 22:35:05 INFO SimpleDataJackson:28 - -------Round 6 +2016-02-13 22:35:07 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 420912330 +2016-02-13 22:35:07 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:07 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:08 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1330342865 +2016-02-13 22:35:08 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:11 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 1147846006 +2016-02-13 22:35:12 INFO SimpleDataJackson:28 - -------Round 7 +2016-02-13 22:35:14 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 637133177 +2016-02-13 22:35:14 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:14 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:16 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1710650775 +2016-02-13 22:35:16 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:18 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 1022232915 +2016-02-13 22:35:20 INFO SimpleDataJackson:28 - -------Round 8 +2016-02-13 22:35:21 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 469254572 +2016-02-13 22:35:22 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:22 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:23 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1375411079 +2016-02-13 22:35:23 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:25 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 774870908 +2016-02-13 22:35:26 INFO SimpleDataJackson:28 - -------Round 9 +2016-02-13 22:35:28 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 451041361 +2016-02-13 22:35:28 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:28 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:29 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1419613220 +2016-02-13 22:35:29 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:31 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 772284924 +2016-02-13 22:35:32 INFO SimpleDataJackson:28 - -------Round 10 +2016-02-13 22:35:34 INFO SimpleDataJackson:55 - Json Generation Time(ms):: 422704085 +2016-02-13 22:35:34 INFO SimpleDataJackson:30 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:35:34 INFO SimpleDataJackson:31 - -------------------------------------------------------------------------- +2016-02-13 22:35:35 INFO SimpleDataJackson:65 - Generating Map from json Time(ms):: 1396597916 +2016-02-13 22:35:35 INFO SimpleDataJackson:66 - -------------------------------------------------------------------------- +2016-02-13 22:35:38 INFO SimpleDataJackson:78 - Generating Actual Object from json Time(ms):: 794414020 +2016-02-13 22:35:39 INFO SimpleDataJackson:41 - -------------------------------------------------------------------------- +2016-02-13 22:35:39 INFO SimpleDataJackson:42 - Average Time to Generate JSON : 793103777 +2016-02-13 22:35:39 INFO SimpleDataJackson:43 - Average Time to Parse JSON To Map : 2067317472 +2016-02-13 22:35:39 INFO SimpleDataJackson:44 - Average Time to Parse JSON To Actual Object : 878676501 +2016-02-13 22:35:39 INFO SimpleDataJackson:45 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 50R.log b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 50R.log new file mode 100644 index 000000000000..76e666651b1f --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 100mb 50R.log @@ -0,0 +1,760 @@ +2016-02-13 22:52:31 INFO SimpleDataGson:28 - -------Round 1 +2016-02-13 22:52:36 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1585839020 +2016-02-13 22:52:36 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:52:36 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:52:38 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1861804362 +2016-02-13 22:52:38 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:52:40 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1055169779 +2016-02-13 22:52:40 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:52:42 INFO SimpleDataGson:28 - -------Round 2 +2016-02-13 22:52:44 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1490347460 +2016-02-13 22:52:45 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:52:45 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:52:47 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1916539920 +2016-02-13 22:52:47 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:52:49 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1129162257 +2016-02-13 22:52:49 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:52:50 INFO SimpleDataGson:28 - -------Round 3 +2016-02-13 22:52:53 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1305021058 +2016-02-13 22:52:53 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:52:53 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:52:55 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1462674147 +2016-02-13 22:52:55 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:52:57 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 887290384 +2016-02-13 22:52:57 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:52:57 INFO SimpleDataGson:28 - -------Round 4 +2016-02-13 22:53:00 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1203500534 +2016-02-13 22:53:00 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:00 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:01 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1451261630 +2016-02-13 22:53:01 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:03 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 879235582 +2016-02-13 22:53:03 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:04 INFO SimpleDataGson:28 - -------Round 5 +2016-02-13 22:53:06 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1230461723 +2016-02-13 22:53:07 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:07 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:08 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1412145404 +2016-02-13 22:53:08 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:10 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1140904783 +2016-02-13 22:53:10 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:11 INFO SimpleDataGson:28 - -------Round 6 +2016-02-13 22:53:13 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1228443779 +2016-02-13 22:53:14 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:14 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:15 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1289356331 +2016-02-13 22:53:15 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:17 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1152567569 +2016-02-13 22:53:17 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:18 INFO SimpleDataGson:28 - -------Round 7 +2016-02-13 22:53:20 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1209992931 +2016-02-13 22:53:21 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:21 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:22 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1286039275 +2016-02-13 22:53:22 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:24 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1170658409 +2016-02-13 22:53:24 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:25 INFO SimpleDataGson:28 - -------Round 8 +2016-02-13 22:53:27 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1196618916 +2016-02-13 22:53:28 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:28 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:29 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1466708852 +2016-02-13 22:53:29 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:31 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1168917972 +2016-02-13 22:53:31 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:32 INFO SimpleDataGson:28 - -------Round 9 +2016-02-13 22:53:34 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1221654533 +2016-02-13 22:53:35 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:35 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:36 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1618379162 +2016-02-13 22:53:36 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:38 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1154904864 +2016-02-13 22:53:38 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:39 INFO SimpleDataGson:28 - -------Round 10 +2016-02-13 22:53:42 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1195265726 +2016-02-13 22:53:42 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:42 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:43 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1436078099 +2016-02-13 22:53:43 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:45 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1167637809 +2016-02-13 22:53:45 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:46 INFO SimpleDataGson:28 - -------Round 11 +2016-02-13 22:53:49 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1185569172 +2016-02-13 22:53:49 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:49 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:50 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1516646659 +2016-02-13 22:53:50 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:53:52 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1148949718 +2016-02-13 22:53:52 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:53:53 INFO SimpleDataGson:28 - -------Round 12 +2016-02-13 22:53:56 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1187248028 +2016-02-13 22:53:56 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:53:56 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:53:57 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1448880519 +2016-02-13 22:53:57 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:00 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1176675926 +2016-02-13 22:54:00 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:01 INFO SimpleDataGson:28 - -------Round 13 +2016-02-13 22:54:03 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1443600783 +2016-02-13 22:54:03 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:03 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:06 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 2164118644 +2016-02-13 22:54:06 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:08 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1488725447 +2016-02-13 22:54:08 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:09 INFO SimpleDataGson:28 - -------Round 14 +2016-02-13 22:54:12 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1435152023 +2016-02-13 22:54:12 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:12 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:14 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1460023030 +2016-02-13 22:54:14 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:16 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1178285702 +2016-02-13 22:54:16 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:17 INFO SimpleDataGson:28 - -------Round 15 +2016-02-13 22:54:19 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1180117721 +2016-02-13 22:54:19 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:19 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:21 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1515058200 +2016-02-13 22:54:21 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:23 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1144468160 +2016-02-13 22:54:23 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:24 INFO SimpleDataGson:28 - -------Round 16 +2016-02-13 22:54:26 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1192200519 +2016-02-13 22:54:26 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:26 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:28 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1461303587 +2016-02-13 22:54:28 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:30 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1144667902 +2016-02-13 22:54:30 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:31 INFO SimpleDataGson:28 - -------Round 17 +2016-02-13 22:54:33 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1189731774 +2016-02-13 22:54:33 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:33 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:35 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1517573920 +2016-02-13 22:54:35 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:37 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1155008682 +2016-02-13 22:54:37 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:38 INFO SimpleDataGson:28 - -------Round 18 +2016-02-13 22:54:40 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1193380811 +2016-02-13 22:54:40 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:40 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:42 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1445793205 +2016-02-13 22:54:42 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:44 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1166141325 +2016-02-13 22:54:44 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:45 INFO SimpleDataGson:28 - -------Round 19 +2016-02-13 22:54:47 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1205077151 +2016-02-13 22:54:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:49 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1513504082 +2016-02-13 22:54:49 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:51 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1147742582 +2016-02-13 22:54:51 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:52 INFO SimpleDataGson:28 - -------Round 20 +2016-02-13 22:54:54 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1198880420 +2016-02-13 22:54:55 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:54:55 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:54:56 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1448043261 +2016-02-13 22:54:56 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:54:58 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1173471373 +2016-02-13 22:54:58 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:54:59 INFO SimpleDataGson:28 - -------Round 21 +2016-02-13 22:55:01 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1217035603 +2016-02-13 22:55:02 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:02 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:03 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1510510720 +2016-02-13 22:55:03 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:05 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1155864098 +2016-02-13 22:55:05 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:06 INFO SimpleDataGson:28 - -------Round 22 +2016-02-13 22:55:08 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1187136316 +2016-02-13 22:55:09 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:09 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:10 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1444711995 +2016-02-13 22:55:10 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:13 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1458993925 +2016-02-13 22:55:13 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:14 INFO SimpleDataGson:28 - -------Round 23 +2016-02-13 22:55:16 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1526195184 +2016-02-13 22:55:17 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:17 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:19 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 2012367410 +2016-02-13 22:55:19 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:21 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1515431630 +2016-02-13 22:55:21 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:22 INFO SimpleDataGson:28 - -------Round 24 +2016-02-13 22:55:25 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1193182253 +2016-02-13 22:55:25 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:25 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:26 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1438591450 +2016-02-13 22:55:26 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:29 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1192834482 +2016-02-13 22:55:29 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:30 INFO SimpleDataGson:28 - -------Round 25 +2016-02-13 22:55:32 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1253599398 +2016-02-13 22:55:32 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:32 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:34 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1629483384 +2016-02-13 22:55:34 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:36 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1333719528 +2016-02-13 22:55:36 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:37 INFO SimpleDataGson:28 - -------Round 26 +2016-02-13 22:55:40 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1230578174 +2016-02-13 22:55:40 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:40 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:41 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1600000552 +2016-02-13 22:55:41 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:44 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1209411074 +2016-02-13 22:55:44 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:45 INFO SimpleDataGson:28 - -------Round 27 +2016-02-13 22:55:47 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1204880173 +2016-02-13 22:55:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:49 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1511346398 +2016-02-13 22:55:49 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:51 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1148985640 +2016-02-13 22:55:51 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:55:52 INFO SimpleDataGson:28 - -------Round 28 +2016-02-13 22:55:54 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1587746830 +2016-02-13 22:55:55 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:55:55 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:55:56 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1689343146 +2016-02-13 22:55:56 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:55:59 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1498482397 +2016-02-13 22:55:59 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:00 INFO SimpleDataGson:28 - -------Round 29 +2016-02-13 22:56:03 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1663758832 +2016-02-13 22:56:03 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:03 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:05 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1872788185 +2016-02-13 22:56:06 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:08 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1250957359 +2016-02-13 22:56:08 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:09 INFO SimpleDataGson:28 - -------Round 30 +2016-02-13 22:56:11 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1188576745 +2016-02-13 22:56:11 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:11 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:13 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1449096050 +2016-02-13 22:56:13 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:15 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1179020720 +2016-02-13 22:56:15 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:16 INFO SimpleDataGson:28 - -------Round 31 +2016-02-13 22:56:18 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1453226678 +2016-02-13 22:56:19 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:19 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:20 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1506877077 +2016-02-13 22:56:20 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:22 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1145879774 +2016-02-13 22:56:22 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:23 INFO SimpleDataGson:28 - -------Round 32 +2016-02-13 22:56:25 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1190798379 +2016-02-13 22:56:26 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:26 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:27 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1434053443 +2016-02-13 22:56:27 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:29 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1177356075 +2016-02-13 22:56:29 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:30 INFO SimpleDataGson:28 - -------Round 33 +2016-02-13 22:56:33 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1191705111 +2016-02-13 22:56:33 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:33 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:34 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1502436968 +2016-02-13 22:56:34 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:36 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1153789705 +2016-02-13 22:56:36 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:37 INFO SimpleDataGson:28 - -------Round 34 +2016-02-13 22:56:40 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1194646368 +2016-02-13 22:56:40 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:40 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:41 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1437310102 +2016-02-13 22:56:41 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:43 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1185691542 +2016-02-13 22:56:43 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:44 INFO SimpleDataGson:28 - -------Round 35 +2016-02-13 22:56:47 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1189237551 +2016-02-13 22:56:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:48 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1490416540 +2016-02-13 22:56:48 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:50 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1143874066 +2016-02-13 22:56:50 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:51 INFO SimpleDataGson:28 - -------Round 36 +2016-02-13 22:56:54 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1188084496 +2016-02-13 22:56:54 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:56:54 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:56:55 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1448132868 +2016-02-13 22:56:55 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:56:57 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1162009908 +2016-02-13 22:56:57 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:56:58 INFO SimpleDataGson:28 - -------Round 37 +2016-02-13 22:57:01 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1197328276 +2016-02-13 22:57:01 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:01 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:02 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1498333577 +2016-02-13 22:57:02 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:04 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1158750879 +2016-02-13 22:57:04 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:05 INFO SimpleDataGson:28 - -------Round 38 +2016-02-13 22:57:08 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1171911335 +2016-02-13 22:57:08 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:08 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:09 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1439759504 +2016-02-13 22:57:09 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:11 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1174249814 +2016-02-13 22:57:11 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:12 INFO SimpleDataGson:28 - -------Round 39 +2016-02-13 22:57:15 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1193157384 +2016-02-13 22:57:15 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:15 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:16 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1524814361 +2016-02-13 22:57:16 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:19 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1160014858 +2016-02-13 22:57:19 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:20 INFO SimpleDataGson:28 - -------Round 40 +2016-02-13 22:57:22 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1246414616 +2016-02-13 22:57:22 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:22 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:24 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1537631387 +2016-02-13 22:57:24 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:26 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1195739421 +2016-02-13 22:57:26 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:27 INFO SimpleDataGson:28 - -------Round 41 +2016-02-13 22:57:29 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1177802928 +2016-02-13 22:57:29 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:29 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:31 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1622097675 +2016-02-13 22:57:31 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:34 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1579197410 +2016-02-13 22:57:34 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:35 INFO SimpleDataGson:28 - -------Round 42 +2016-02-13 22:57:38 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1561412498 +2016-02-13 22:57:38 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:38 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:40 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 2263416744 +2016-02-13 22:57:40 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:43 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1524538828 +2016-02-13 22:57:43 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:44 INFO SimpleDataGson:28 - -------Round 43 +2016-02-13 22:57:46 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1210692026 +2016-02-13 22:57:46 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:46 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:48 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1532155857 +2016-02-13 22:57:48 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:50 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1145853325 +2016-02-13 22:57:50 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:51 INFO SimpleDataGson:28 - -------Round 44 +2016-02-13 22:57:53 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1238135991 +2016-02-13 22:57:54 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:57:54 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:57:55 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1515745453 +2016-02-13 22:57:55 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:57:57 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1289585678 +2016-02-13 22:57:57 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:57:58 INFO SimpleDataGson:28 - -------Round 45 +2016-02-13 22:58:01 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1255531683 +2016-02-13 22:58:01 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:01 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:03 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1723848336 +2016-02-13 22:58:03 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:05 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1152875078 +2016-02-13 22:58:05 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:06 INFO SimpleDataGson:28 - -------Round 46 +2016-02-13 22:58:08 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1184311903 +2016-02-13 22:58:08 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:08 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:10 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1442687734 +2016-02-13 22:58:10 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:12 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1166037112 +2016-02-13 22:58:12 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:13 INFO SimpleDataGson:28 - -------Round 47 +2016-02-13 22:58:15 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1182361066 +2016-02-13 22:58:15 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:15 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:17 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1538499040 +2016-02-13 22:58:17 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:19 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1152594808 +2016-02-13 22:58:19 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:20 INFO SimpleDataGson:28 - -------Round 48 +2016-02-13 22:58:22 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1189790196 +2016-02-13 22:58:22 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:22 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:24 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1436873118 +2016-02-13 22:58:24 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:26 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1165948689 +2016-02-13 22:58:26 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:27 INFO SimpleDataGson:28 - -------Round 49 +2016-02-13 22:58:29 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1187428428 +2016-02-13 22:58:29 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:29 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:31 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1504368068 +2016-02-13 22:58:31 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:33 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1247714122 +2016-02-13 22:58:33 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:34 INFO SimpleDataGson:28 - -------Round 50 +2016-02-13 22:58:36 INFO SimpleDataGson:53 - Json Generation Time(ms):: 1186676830 +2016-02-13 22:58:37 INFO SimpleDataGson:30 - Size of Simple content Gson :: 101 MB +2016-02-13 22:58:37 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 22:58:38 INFO SimpleDataGson:63 - Generating Map from json Time(ms):: 1520818736 +2016-02-13 22:58:38 INFO SimpleDataGson:64 - -------------------------------------------------------------------------- +2016-02-13 22:58:40 INFO SimpleDataGson:76 - Generating Actual Object from json Time(ms):: 1243656521 +2016-02-13 22:58:40 INFO SimpleDataGson:77 - -------------------------------------------------------------------------- +2016-02-13 22:58:41 INFO SimpleDataGson:39 - -------------------------------------------------------------------------- +2016-02-13 22:58:41 INFO SimpleDataGson:40 - Average Time to Generate JSON : 1262428946 +2016-02-13 22:58:41 INFO SimpleDataGson:41 - Average Time to Parse JSON To Map : 1555408963 +2016-02-13 22:58:41 INFO SimpleDataGson:42 - Average Time to Parse JSON To Actual Object : 1201992893 +2016-02-13 22:58:41 INFO SimpleDataGson:43 - -------------------------------------------------------------------------- +2016-02-13 22:59:20 INFO SimpleDataJackson:31 - -------Round 1 +2016-02-13 22:59:23 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1994045248 +2016-02-13 22:59:23 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:59:23 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 22:59:28 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 4419702826 +2016-02-13 22:59:28 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 22:59:30 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 871548287 +2016-02-13 22:59:31 INFO SimpleDataJackson:31 - -------Round 2 +2016-02-13 22:59:33 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 450226605 +2016-02-13 22:59:33 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:59:33 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 22:59:37 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 4073340752 +2016-02-13 22:59:37 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 22:59:39 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 807173018 +2016-02-13 22:59:40 INFO SimpleDataJackson:31 - -------Round 3 +2016-02-13 22:59:42 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 441634946 +2016-02-13 22:59:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:59:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 22:59:43 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1366655996 +2016-02-13 22:59:43 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 22:59:46 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 994427363 +2016-02-13 22:59:47 INFO SimpleDataJackson:31 - -------Round 4 +2016-02-13 22:59:48 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 513586979 +2016-02-13 22:59:49 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:59:49 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 22:59:50 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1715857087 +2016-02-13 22:59:50 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 22:59:53 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 952180402 +2016-02-13 22:59:54 INFO SimpleDataJackson:31 - -------Round 5 +2016-02-13 22:59:56 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 532706528 +2016-02-13 22:59:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 22:59:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 22:59:57 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1361951011 +2016-02-13 22:59:57 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:00 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 814924656 +2016-02-13 23:00:01 INFO SimpleDataJackson:31 - -------Round 6 +2016-02-13 23:00:02 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 438322627 +2016-02-13 23:00:02 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:02 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:04 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1357691696 +2016-02-13 23:00:04 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:06 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 787639774 +2016-02-13 23:00:07 INFO SimpleDataJackson:31 - -------Round 7 +2016-02-13 23:00:08 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 438668425 +2016-02-13 23:00:08 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:08 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:10 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1374237103 +2016-02-13 23:00:10 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:12 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 807600529 +2016-02-13 23:00:13 INFO SimpleDataJackson:31 - -------Round 8 +2016-02-13 23:00:14 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 457305594 +2016-02-13 23:00:14 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:14 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:16 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1384583805 +2016-02-13 23:00:16 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:18 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 810993376 +2016-02-13 23:00:19 INFO SimpleDataJackson:31 - -------Round 9 +2016-02-13 23:00:20 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 440303465 +2016-02-13 23:00:21 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:21 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:22 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1378739583 +2016-02-13 23:00:22 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:24 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 785994471 +2016-02-13 23:00:25 INFO SimpleDataJackson:31 - -------Round 10 +2016-02-13 23:00:26 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 442248382 +2016-02-13 23:00:27 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:27 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:28 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1338413458 +2016-02-13 23:00:28 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:30 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 783347301 +2016-02-13 23:00:31 INFO SimpleDataJackson:31 - -------Round 11 +2016-02-13 23:00:33 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 444837129 +2016-02-13 23:00:33 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:33 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:34 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1337033424 +2016-02-13 23:00:34 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:36 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 779409704 +2016-02-13 23:00:37 INFO SimpleDataJackson:31 - -------Round 12 +2016-02-13 23:00:39 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 444052373 +2016-02-13 23:00:39 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:39 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:40 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1352965001 +2016-02-13 23:00:40 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:42 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 781962924 +2016-02-13 23:00:43 INFO SimpleDataJackson:31 - -------Round 13 +2016-02-13 23:00:45 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 440353993 +2016-02-13 23:00:45 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:45 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:46 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1368178532 +2016-02-13 23:00:46 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:49 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1065239369 +2016-02-13 23:00:50 INFO SimpleDataJackson:31 - -------Round 14 +2016-02-13 23:00:52 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 615157241 +2016-02-13 23:00:52 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:52 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:00:54 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1728276604 +2016-02-13 23:00:54 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:00:56 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 998166402 +2016-02-13 23:00:57 INFO SimpleDataJackson:31 - -------Round 15 +2016-02-13 23:00:59 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 539145239 +2016-02-13 23:00:59 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:00:59 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:01 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1374288420 +2016-02-13 23:01:01 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:03 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 780897109 +2016-02-13 23:01:04 INFO SimpleDataJackson:31 - -------Round 16 +2016-02-13 23:01:05 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435791118 +2016-02-13 23:01:06 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:06 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:07 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1343672272 +2016-02-13 23:01:07 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:09 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 792992933 +2016-02-13 23:01:10 INFO SimpleDataJackson:31 - -------Round 17 +2016-02-13 23:01:11 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 438859483 +2016-02-13 23:01:12 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:12 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:13 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1382370461 +2016-02-13 23:01:13 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:16 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 951572098 +2016-02-13 23:01:16 INFO SimpleDataJackson:31 - -------Round 18 +2016-02-13 23:01:18 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 433854491 +2016-02-13 23:01:18 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:18 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:19 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1358839224 +2016-02-13 23:01:19 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:22 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 782784392 +2016-02-13 23:01:23 INFO SimpleDataJackson:31 - -------Round 19 +2016-02-13 23:01:24 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435710984 +2016-02-13 23:01:24 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:24 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:26 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1349415440 +2016-02-13 23:01:26 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:28 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 982777208 +2016-02-13 23:01:29 INFO SimpleDataJackson:31 - -------Round 20 +2016-02-13 23:01:31 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 505858237 +2016-02-13 23:01:31 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:31 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:33 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1726464717 +2016-02-13 23:01:33 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:35 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 984660544 +2016-02-13 23:01:37 INFO SimpleDataJackson:31 - -------Round 21 +2016-02-13 23:01:38 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 614672493 +2016-02-13 23:01:39 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:39 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:41 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1369641858 +2016-02-13 23:01:41 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:43 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 787754251 +2016-02-13 23:01:44 INFO SimpleDataJackson:31 - -------Round 22 +2016-02-13 23:01:45 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 433494877 +2016-02-13 23:01:46 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:46 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:47 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1349406755 +2016-02-13 23:01:47 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:49 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 797948581 +2016-02-13 23:01:50 INFO SimpleDataJackson:31 - -------Round 23 +2016-02-13 23:01:51 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 432709726 +2016-02-13 23:01:52 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:52 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:53 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1356035734 +2016-02-13 23:01:53 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:01:55 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 808091594 +2016-02-13 23:01:56 INFO SimpleDataJackson:31 - -------Round 24 +2016-02-13 23:01:58 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435182418 +2016-02-13 23:01:58 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:01:58 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:01:59 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1364351859 +2016-02-13 23:01:59 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:01 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 788939675 +2016-02-13 23:02:02 INFO SimpleDataJackson:31 - -------Round 25 +2016-02-13 23:02:04 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 439961220 +2016-02-13 23:02:04 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:04 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:05 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1352715915 +2016-02-13 23:02:06 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:08 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 792822008 +2016-02-13 23:02:09 INFO SimpleDataJackson:31 - -------Round 26 +2016-02-13 23:02:10 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 443481964 +2016-02-13 23:02:10 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:10 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:12 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1324584302 +2016-02-13 23:02:12 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:14 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 779368255 +2016-02-13 23:02:15 INFO SimpleDataJackson:31 - -------Round 27 +2016-02-13 23:02:16 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 470963035 +2016-02-13 23:02:17 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:17 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:18 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1342280001 +2016-02-13 23:02:18 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:20 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 831557303 +2016-02-13 23:02:21 INFO SimpleDataJackson:31 - -------Round 28 +2016-02-13 23:02:22 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 439997932 +2016-02-13 23:02:23 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:23 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:24 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1353183690 +2016-02-13 23:02:24 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:26 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 807440262 +2016-02-13 23:02:27 INFO SimpleDataJackson:31 - -------Round 29 +2016-02-13 23:02:29 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 442765105 +2016-02-13 23:02:29 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:29 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:30 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1384797757 +2016-02-13 23:02:30 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:32 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 796111036 +2016-02-13 23:02:33 INFO SimpleDataJackson:31 - -------Round 30 +2016-02-13 23:02:35 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 446163873 +2016-02-13 23:02:35 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:35 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:36 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1362167727 +2016-02-13 23:02:36 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:38 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 774013124 +2016-02-13 23:02:39 INFO SimpleDataJackson:31 - -------Round 31 +2016-02-13 23:02:41 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 438451709 +2016-02-13 23:02:41 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:41 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:42 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1366723892 +2016-02-13 23:02:42 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:45 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 785803808 +2016-02-13 23:02:46 INFO SimpleDataJackson:31 - -------Round 32 +2016-02-13 23:02:47 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 432899599 +2016-02-13 23:02:47 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:47 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:48 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1352116295 +2016-02-13 23:02:48 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:51 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 802779884 +2016-02-13 23:02:52 INFO SimpleDataJackson:31 - -------Round 33 +2016-02-13 23:02:53 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435379397 +2016-02-13 23:02:53 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:53 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:02:55 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1359177127 +2016-02-13 23:02:55 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:02:57 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 774916304 +2016-02-13 23:02:58 INFO SimpleDataJackson:31 - -------Round 34 +2016-02-13 23:02:59 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 437675243 +2016-02-13 23:02:59 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:02:59 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:01 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1358610665 +2016-02-13 23:03:01 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:03 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 784634964 +2016-02-13 23:03:04 INFO SimpleDataJackson:31 - -------Round 35 +2016-02-13 23:03:05 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 436069019 +2016-02-13 23:03:05 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:05 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:07 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1388644958 +2016-02-13 23:03:07 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:09 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 781348304 +2016-02-13 23:03:10 INFO SimpleDataJackson:31 - -------Round 36 +2016-02-13 23:03:11 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 436565216 +2016-02-13 23:03:11 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:11 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:13 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1373221420 +2016-02-13 23:03:13 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:15 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 778034801 +2016-02-13 23:03:16 INFO SimpleDataJackson:31 - -------Round 37 +2016-02-13 23:03:17 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 437646426 +2016-02-13 23:03:18 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:18 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:19 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1371113868 +2016-02-13 23:03:19 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:21 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 773487322 +2016-02-13 23:03:22 INFO SimpleDataJackson:31 - -------Round 38 +2016-02-13 23:03:23 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 428990029 +2016-02-13 23:03:24 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:24 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:25 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1372305608 +2016-02-13 23:03:25 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:27 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 787641353 +2016-02-13 23:03:28 INFO SimpleDataJackson:31 - -------Round 39 +2016-02-13 23:03:29 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435520716 +2016-02-13 23:03:30 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:30 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:31 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1344215838 +2016-02-13 23:03:31 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:33 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 780171564 +2016-02-13 23:03:34 INFO SimpleDataJackson:31 - -------Round 40 +2016-02-13 23:03:36 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 431967602 +2016-02-13 23:03:36 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:36 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:37 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1342673957 +2016-02-13 23:03:37 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:39 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 830946630 +2016-02-13 23:03:40 INFO SimpleDataJackson:31 - -------Round 41 +2016-02-13 23:03:42 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 439787136 +2016-02-13 23:03:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:43 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1336626046 +2016-02-13 23:03:43 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:46 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 966202984 +2016-02-13 23:03:47 INFO SimpleDataJackson:31 - -------Round 42 +2016-02-13 23:03:48 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 558927568 +2016-02-13 23:03:49 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:49 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:50 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1730400735 +2016-02-13 23:03:50 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:03:53 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1018089261 +2016-02-13 23:03:54 INFO SimpleDataJackson:31 - -------Round 43 +2016-02-13 23:03:56 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 553832969 +2016-02-13 23:03:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:03:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:03:58 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1374591980 +2016-02-13 23:03:58 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:00 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 791875011 +2016-02-13 23:04:01 INFO SimpleDataJackson:31 - -------Round 44 +2016-02-13 23:04:02 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 435538085 +2016-02-13 23:04:02 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:02 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:04 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1347747635 +2016-02-13 23:04:04 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:06 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 781452122 +2016-02-13 23:04:07 INFO SimpleDataJackson:31 - -------Round 45 +2016-02-13 23:04:08 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 430329799 +2016-02-13 23:04:08 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:08 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:10 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1355000709 +2016-02-13 23:04:10 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:12 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 783088347 +2016-02-13 23:04:13 INFO SimpleDataJackson:31 - -------Round 46 +2016-02-13 23:04:14 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 434882016 +2016-02-13 23:04:14 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:14 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:16 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1345464421 +2016-02-13 23:04:16 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:18 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 828007347 +2016-02-13 23:04:19 INFO SimpleDataJackson:31 - -------Round 47 +2016-02-13 23:04:21 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 488757026 +2016-02-13 23:04:21 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:21 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:22 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1430288745 +2016-02-13 23:04:22 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:24 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 821152573 +2016-02-13 23:04:27 INFO SimpleDataJackson:31 - -------Round 48 +2016-02-13 23:04:34 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1746328759 +2016-02-13 23:04:35 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:35 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:39 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 3671360072 +2016-02-13 23:04:39 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:43 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1560371551 +2016-02-13 23:04:45 INFO SimpleDataJackson:31 - -------Round 49 +2016-02-13 23:04:47 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 690772918 +2016-02-13 23:04:48 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:48 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:50 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 2070935956 +2016-02-13 23:04:50 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:04:53 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1102717396 +2016-02-13 23:04:54 INFO SimpleDataJackson:31 - -------Round 50 +2016-02-13 23:04:56 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 521889684 +2016-02-13 23:04:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 101 MB +2016-02-13 23:04:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-13 23:04:58 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1620059599 +2016-02-13 23:04:58 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-13 23:05:00 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 813171982 +2016-02-13 23:05:01 INFO SimpleDataJackson:44 - -------------------------------------------------------------------------- +2016-02-13 23:05:01 INFO SimpleDataJackson:45 - Average Time to Generate JSON : 522685452 +2016-02-13 23:05:01 INFO SimpleDataJackson:46 - Average Time to Parse JSON To Map : 1571262450 +2016-02-13 23:05:01 INFO SimpleDataJackson:47 - Average Time to Parse JSON To Actual Object : 852524629 +2016-02-13 23:05:01 INFO SimpleDataJackson:48 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 10R.log b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 10R.log new file mode 100644 index 000000000000..3926f450b966 --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 10R.log @@ -0,0 +1,160 @@ +2016-02-13 23:46:10 INFO SimpleDataGson:28 - -------Round 1 +2016-02-13 23:46:17 INFO SimpleDataGson:54 - Json Generation Time(ms):: 4115421919 +2016-02-13 23:46:18 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:46:18 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:46:24 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5979578577 +2016-02-13 23:46:24 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:46:37 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 8799068872 +2016-02-13 23:46:37 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:46:41 INFO SimpleDataGson:28 - -------Round 2 +2016-02-13 23:46:46 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3215032264 +2016-02-13 23:46:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:46:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:46:52 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5430384274 +2016-02-13 23:46:52 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:46:58 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3081980964 +2016-02-13 23:46:58 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:47:02 INFO SimpleDataGson:28 - -------Round 3 +2016-02-13 23:47:08 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3074217879 +2016-02-13 23:47:08 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:47:08 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:47:14 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 6177310679 +2016-02-13 23:47:14 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:47:21 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3172692933 +2016-02-13 23:47:21 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:47:24 INFO SimpleDataGson:28 - -------Round 4 +2016-02-13 23:47:31 INFO SimpleDataGson:54 - Json Generation Time(ms):: 4090244194 +2016-02-13 23:47:32 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:47:32 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:47:39 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 7408656634 +2016-02-13 23:47:39 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:47:45 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3023505579 +2016-02-13 23:47:45 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:47:48 INFO SimpleDataGson:28 - -------Round 5 +2016-02-13 23:47:54 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3196609048 +2016-02-13 23:47:55 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:47:55 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:48:31 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 36806648005 +2016-02-13 23:48:31 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:48:38 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3057928662 +2016-02-13 23:48:38 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:48:41 INFO SimpleDataGson:28 - -------Round 6 +2016-02-13 23:48:46 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3116500761 +2016-02-13 23:48:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:48:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:48:53 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5492820152 +2016-02-13 23:48:53 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:48:59 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3008170464 +2016-02-13 23:48:59 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:49:02 INFO SimpleDataGson:28 - -------Round 7 +2016-02-13 23:49:08 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3101777899 +2016-02-13 23:49:09 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:49:09 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:49:31 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 22060865577 +2016-02-13 23:49:31 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:49:37 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3004783539 +2016-02-13 23:49:37 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:49:40 INFO SimpleDataGson:28 - -------Round 8 +2016-02-13 23:49:45 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3105519701 +2016-02-13 23:49:46 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:49:46 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:50:08 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 22301662159 +2016-02-13 23:50:08 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:50:14 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2975667427 +2016-02-13 23:50:14 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:50:17 INFO SimpleDataGson:28 - -------Round 9 +2016-02-13 23:50:23 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3198289879 +2016-02-13 23:50:23 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:50:23 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:50:44 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 20094735621 +2016-02-13 23:50:44 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:50:50 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2982894448 +2016-02-13 23:50:50 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:50:53 INFO SimpleDataGson:28 - -------Round 10 +2016-02-13 23:50:58 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3078554959 +2016-02-13 23:50:59 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-13 23:50:59 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-13 23:51:21 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 21830630833 +2016-02-13 23:51:21 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-13 23:51:27 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3010499469 +2016-02-13 23:51:27 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-13 23:51:30 INFO SimpleDataGson:40 - -------------------------------------------------------------------------- +2016-02-13 23:51:30 INFO SimpleDataGson:41 - Average Time to Generate JSON : 3329216850 +2016-02-13 23:51:30 INFO SimpleDataGson:42 - Average Time to Parse JSON To Map : 15358329251 +2016-02-13 23:51:30 INFO SimpleDataGson:43 - Average Time to Parse JSON To Actual Object : 3611719235 +2016-02-13 23:51:30 INFO SimpleDataGson:44 - -------------------------------------------------------------------------- +2016-02-14 00:02:42 INFO SimpleDataJackson:31 - -------Round 1 +2016-02-14 00:02:47 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1640080750 +2016-02-14 00:02:48 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:02:48 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:02:50 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 2672981690 +2016-02-14 00:02:50 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:02:55 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1793866507 +2016-02-14 00:02:59 INFO SimpleDataJackson:31 - -------Round 2 +2016-02-14 00:03:02 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1085543552 +2016-02-14 00:03:03 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:03:03 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:03:05 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1884080700 +2016-02-14 00:03:05 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:03:09 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1622782955 +2016-02-14 00:03:11 INFO SimpleDataJackson:31 - -------Round 3 +2016-02-14 00:03:15 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1087769528 +2016-02-14 00:03:15 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:03:15 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:03:17 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1866192760 +2016-02-14 00:03:17 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:03:22 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2164019167 +2016-02-14 00:03:25 INFO SimpleDataJackson:31 - -------Round 4 +2016-02-14 00:03:29 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1518929874 +2016-02-14 00:03:30 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:03:30 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:03:32 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1863419271 +2016-02-14 00:03:32 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:03:36 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1623395996 +2016-02-14 00:03:39 INFO SimpleDataJackson:31 - -------Round 5 +2016-02-14 00:03:42 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1071791372 +2016-02-14 00:03:43 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:03:43 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:03:45 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 1861038555 +2016-02-14 00:03:45 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:03:49 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 1679350531 +2016-02-14 00:03:51 INFO SimpleDataJackson:31 - -------Round 6 +2016-02-14 00:03:55 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1046878522 +2016-02-14 00:03:55 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:03:55 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:03:58 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 3142311264 +2016-02-14 00:03:58 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:04:05 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2276167059 +2016-02-14 00:04:07 INFO SimpleDataJackson:31 - -------Round 7 +2016-02-14 00:04:11 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1128271314 +2016-02-14 00:04:12 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:04:12 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:04:14 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 2644174666 +2016-02-14 00:04:14 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:04:19 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2244204035 +2016-02-14 00:04:22 INFO SimpleDataJackson:31 - -------Round 8 +2016-02-14 00:04:25 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1049764909 +2016-02-14 00:04:26 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:04:26 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:04:29 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 3621206732 +2016-02-14 00:04:29 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:04:35 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2355619671 +2016-02-14 00:04:38 INFO SimpleDataJackson:31 - -------Round 9 +2016-02-14 00:04:42 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1104708497 +2016-02-14 00:04:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:04:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:04:47 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 5293797624 +2016-02-14 00:04:47 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:04:53 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2276509304 +2016-02-14 00:04:57 INFO SimpleDataJackson:31 - -------Round 10 +2016-02-14 00:05:01 INFO SimpleDataJackson:58 - Json Generation Time(ms):: 1187760804 +2016-02-14 00:05:01 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 00:05:01 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 00:05:05 INFO SimpleDataJackson:68 - Generating Map from json Time(ms):: 3760862932 +2016-02-14 00:05:05 INFO SimpleDataJackson:69 - -------------------------------------------------------------------------- +2016-02-14 00:05:11 INFO SimpleDataJackson:81 - Generating Actual Object from json Time(ms):: 2363176304 +2016-02-14 00:05:13 INFO SimpleDataJackson:44 - -------------------------------------------------------------------------- +2016-02-14 00:05:13 INFO SimpleDataJackson:45 - Average Time to Generate JSON : 1192149912 +2016-02-14 00:05:13 INFO SimpleDataJackson:46 - Average Time to Parse JSON To Map : 2861006619 +2016-02-14 00:05:13 INFO SimpleDataJackson:47 - Average Time to Parse JSON To Actual Object : 2039909152 +2016-02-14 00:05:13 INFO SimpleDataJackson:48 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 50R.log b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 50R.log new file mode 100644 index 000000000000..c15b4155fd92 --- /dev/null +++ b/gson-jackson-performance/logs_Performance/log4j-application simple Gson Jackson 250mb 50R.log @@ -0,0 +1,760 @@ +2016-02-14 00:11:43 INFO SimpleDataGson:28 - -------Round 1 +2016-02-14 00:11:50 INFO SimpleDataGson:54 - Json Generation Time(ms):: 4340606275 +2016-02-14 00:11:51 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:11:51 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:12:03 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 12287382597 +2016-02-14 00:12:04 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:12:17 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 6381797289 +2016-02-14 00:12:17 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:12:20 INFO SimpleDataGson:28 - -------Round 2 +2016-02-14 00:12:26 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3447057973 +2016-02-14 00:12:27 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:12:27 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:12:34 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 6964375308 +2016-02-14 00:12:34 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:12:40 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3299282232 +2016-02-14 00:12:40 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:12:44 INFO SimpleDataGson:28 - -------Round 3 +2016-02-14 00:12:49 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3187362899 +2016-02-14 00:12:50 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:12:50 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:12:56 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5988912359 +2016-02-14 00:12:56 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:13:02 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3037755534 +2016-02-14 00:13:02 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:13:05 INFO SimpleDataGson:28 - -------Round 4 +2016-02-14 00:13:11 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3119391095 +2016-02-14 00:13:11 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:13:11 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:13:17 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5743481451 +2016-02-14 00:13:17 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:13:24 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3686319782 +2016-02-14 00:13:24 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:13:28 INFO SimpleDataGson:28 - -------Round 5 +2016-02-14 00:13:34 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3934239566 +2016-02-14 00:13:35 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:13:35 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:14:09 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 33567932922 +2016-02-14 00:14:09 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:14:15 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3086910165 +2016-02-14 00:14:15 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:14:18 INFO SimpleDataGson:28 - -------Round 6 +2016-02-14 00:14:24 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3234168394 +2016-02-14 00:14:24 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:14:24 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:14:45 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 20216556381 +2016-02-14 00:14:45 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:14:51 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3030008238 +2016-02-14 00:14:51 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:14:54 INFO SimpleDataGson:28 - -------Round 7 +2016-02-14 00:15:00 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3455602658 +2016-02-14 00:15:00 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:15:00 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:15:20 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19443209589 +2016-02-14 00:15:20 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:15:26 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2945137729 +2016-02-14 00:15:26 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:15:29 INFO SimpleDataGson:28 - -------Round 8 +2016-02-14 00:15:34 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3152326775 +2016-02-14 00:15:35 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:15:35 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:15:40 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5166017769 +2016-02-14 00:15:40 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:15:47 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2933530996 +2016-02-14 00:15:47 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:15:49 INFO SimpleDataGson:28 - -------Round 9 +2016-02-14 00:15:55 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3271454180 +2016-02-14 00:15:56 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:15:56 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:16:15 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19051407844 +2016-02-14 00:16:15 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:16:21 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2955690488 +2016-02-14 00:16:21 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:16:24 INFO SimpleDataGson:28 - -------Round 10 +2016-02-14 00:16:29 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3172185290 +2016-02-14 00:16:30 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:16:30 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:16:35 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5183987817 +2016-02-14 00:16:35 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:16:42 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2976106781 +2016-02-14 00:16:42 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:16:44 INFO SimpleDataGson:28 - -------Round 11 +2016-02-14 00:16:50 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3160732507 +2016-02-14 00:16:51 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:16:51 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:16:56 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5154795125 +2016-02-14 00:16:56 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:17:02 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2901304677 +2016-02-14 00:17:02 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:17:05 INFO SimpleDataGson:28 - -------Round 12 +2016-02-14 00:17:11 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3154345113 +2016-02-14 00:17:11 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:17:12 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:17:32 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19767182825 +2016-02-14 00:17:32 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:17:38 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2936730417 +2016-02-14 00:17:38 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:17:41 INFO SimpleDataGson:28 - -------Round 13 +2016-02-14 00:17:47 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3175565109 +2016-02-14 00:17:48 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:17:48 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:17:53 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5111310238 +2016-02-14 00:17:53 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:17:59 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2914264207 +2016-02-14 00:17:59 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:18:02 INFO SimpleDataGson:28 - -------Round 14 +2016-02-14 00:18:08 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3156483456 +2016-02-14 00:18:08 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:18:08 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:18:27 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19026387623 +2016-02-14 00:18:27 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:18:33 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2898468817 +2016-02-14 00:18:33 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:18:37 INFO SimpleDataGson:28 - -------Round 15 +2016-02-14 00:18:43 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3176971986 +2016-02-14 00:18:44 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:18:44 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:19:03 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18819822277 +2016-02-14 00:19:03 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:19:09 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2944195074 +2016-02-14 00:19:09 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:19:13 INFO SimpleDataGson:28 - -------Round 16 +2016-02-14 00:19:19 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3148834846 +2016-02-14 00:19:19 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:19:19 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:19:38 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19390679087 +2016-02-14 00:19:39 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:19:45 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3183360565 +2016-02-14 00:19:45 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:19:48 INFO SimpleDataGson:28 - -------Round 17 +2016-02-14 00:19:53 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3150490019 +2016-02-14 00:19:54 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:19:54 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:19:59 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5132583526 +2016-02-14 00:19:59 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:20:07 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2966433121 +2016-02-14 00:20:07 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:20:10 INFO SimpleDataGson:28 - -------Round 18 +2016-02-14 00:20:17 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3550768946 +2016-02-14 00:20:17 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:20:17 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:20:38 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 20364043958 +2016-02-14 00:20:38 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:20:44 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2927474400 +2016-02-14 00:20:44 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:20:47 INFO SimpleDataGson:28 - -------Round 19 +2016-02-14 00:20:52 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3118286199 +2016-02-14 00:20:53 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:20:53 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:21:13 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19960982856 +2016-02-14 00:21:13 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:21:20 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3604365266 +2016-02-14 00:21:20 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:21:25 INFO SimpleDataGson:28 - -------Round 20 +2016-02-14 00:21:31 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3673000243 +2016-02-14 00:21:32 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:21:32 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:21:37 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5155220266 +2016-02-14 00:21:37 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:21:43 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2926214763 +2016-02-14 00:21:43 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:21:47 INFO SimpleDataGson:28 - -------Round 21 +2016-02-14 00:21:52 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3158473373 +2016-02-14 00:21:53 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:21:53 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:22:12 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19593056961 +2016-02-14 00:22:12 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:22:18 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2941365137 +2016-02-14 00:22:18 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:22:21 INFO SimpleDataGson:28 - -------Round 22 +2016-02-14 00:22:27 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3240733819 +2016-02-14 00:22:28 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:22:28 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:22:33 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5260135611 +2016-02-14 00:22:33 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:22:41 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3164218514 +2016-02-14 00:22:41 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:22:44 INFO SimpleDataGson:28 - -------Round 23 +2016-02-14 00:22:51 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3950377990 +2016-02-14 00:22:52 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:22:52 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:22:59 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 6942376082 +2016-02-14 00:22:59 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:23:06 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2912013756 +2016-02-14 00:23:06 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:23:09 INFO SimpleDataGson:28 - -------Round 24 +2016-02-14 00:23:14 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3162496235 +2016-02-14 00:23:15 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:23:15 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:23:34 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18938874285 +2016-02-14 00:23:34 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:23:40 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2913962225 +2016-02-14 00:23:40 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:23:43 INFO SimpleDataGson:28 - -------Round 25 +2016-02-14 00:23:48 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3180082589 +2016-02-14 00:23:49 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:23:49 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:23:54 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5144263286 +2016-02-14 00:23:54 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:24:00 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2901693502 +2016-02-14 00:24:00 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:24:03 INFO SimpleDataGson:28 - -------Round 26 +2016-02-14 00:24:09 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3219238684 +2016-02-14 00:24:09 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:24:09 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:24:28 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18842977321 +2016-02-14 00:24:28 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:24:34 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2952234483 +2016-02-14 00:24:34 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:24:37 INFO SimpleDataGson:28 - -------Round 27 +2016-02-14 00:24:43 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3272345911 +2016-02-14 00:24:43 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:24:43 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:24:49 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5632996628 +2016-02-14 00:24:49 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:24:56 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3029633229 +2016-02-14 00:24:56 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:24:59 INFO SimpleDataGson:28 - -------Round 28 +2016-02-14 00:25:04 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3169683386 +2016-02-14 00:25:05 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:25:05 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:25:23 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18181483545 +2016-02-14 00:25:23 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:25:29 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2923402589 +2016-02-14 00:25:29 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:25:32 INFO SimpleDataGson:28 - -------Round 29 +2016-02-14 00:25:37 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3212580494 +2016-02-14 00:25:38 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:25:38 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:25:59 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 21118590549 +2016-02-14 00:25:59 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:26:05 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2979127381 +2016-02-14 00:26:05 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:26:08 INFO SimpleDataGson:28 - -------Round 30 +2016-02-14 00:26:13 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3180047456 +2016-02-14 00:26:14 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:26:14 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:26:32 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18226907030 +2016-02-14 00:26:32 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:26:38 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2914835010 +2016-02-14 00:26:38 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:26:41 INFO SimpleDataGson:28 - -------Round 31 +2016-02-14 00:26:46 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3184658097 +2016-02-14 00:26:47 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:26:47 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:27:08 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 20737813285 +2016-02-14 00:27:08 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:27:14 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2930900800 +2016-02-14 00:27:14 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:27:17 INFO SimpleDataGson:28 - -------Round 32 +2016-02-14 00:27:22 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3259012163 +2016-02-14 00:27:23 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:27:23 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:27:44 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 21144334736 +2016-02-14 00:27:44 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:27:50 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2934185091 +2016-02-14 00:27:50 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:27:53 INFO SimpleDataGson:28 - -------Round 33 +2016-02-14 00:27:58 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3177588580 +2016-02-14 00:27:59 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:27:59 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:28:18 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18644949554 +2016-02-14 00:28:18 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:28:24 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2912270342 +2016-02-14 00:28:24 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:28:27 INFO SimpleDataGson:28 - -------Round 34 +2016-02-14 00:28:32 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3174772459 +2016-02-14 00:28:33 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:28:33 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:28:52 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 18805845881 +2016-02-14 00:28:52 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:28:57 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2899120150 +2016-02-14 00:28:57 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:29:00 INFO SimpleDataGson:28 - -------Round 35 +2016-02-14 00:29:06 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3385021974 +2016-02-14 00:29:07 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:29:07 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:29:12 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5143330105 +2016-02-14 00:29:12 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:29:18 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2915072648 +2016-02-14 00:29:18 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:29:21 INFO SimpleDataGson:28 - -------Round 36 +2016-02-14 00:29:27 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3176665663 +2016-02-14 00:29:27 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:29:27 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:29:33 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5483340314 +2016-02-14 00:29:33 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:29:39 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2939049553 +2016-02-14 00:29:39 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:29:43 INFO SimpleDataGson:28 - -------Round 37 +2016-02-14 00:29:49 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3838179966 +2016-02-14 00:29:50 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:29:50 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:29:56 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 6331521578 +2016-02-14 00:29:56 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:30:03 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2932029380 +2016-02-14 00:30:03 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:30:06 INFO SimpleDataGson:28 - -------Round 38 +2016-02-14 00:30:11 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3232773754 +2016-02-14 00:30:12 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:30:12 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:30:17 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5111574325 +2016-02-14 00:30:17 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:30:24 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2937454777 +2016-02-14 00:30:24 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:30:26 INFO SimpleDataGson:28 - -------Round 39 +2016-02-14 00:30:32 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3155400666 +2016-02-14 00:30:33 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:30:33 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:30:55 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 22127306948 +2016-02-14 00:30:55 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:31:01 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2945046938 +2016-02-14 00:31:01 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:31:04 INFO SimpleDataGson:28 - -------Round 40 +2016-02-14 00:31:09 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3303421545 +2016-02-14 00:31:10 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:31:10 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:31:29 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19267411185 +2016-02-14 00:31:29 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:31:35 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2978847900 +2016-02-14 00:31:35 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:31:38 INFO SimpleDataGson:28 - -------Round 41 +2016-02-14 00:31:47 INFO SimpleDataGson:54 - Json Generation Time(ms):: 6197094586 +2016-02-14 00:31:51 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:31:51 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:32:04 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 13564575996 +2016-02-14 00:32:04 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:32:14 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 4029021372 +2016-02-14 00:32:14 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:32:18 INFO SimpleDataGson:28 - -------Round 42 +2016-02-14 00:32:25 INFO SimpleDataGson:54 - Json Generation Time(ms):: 4386850044 +2016-02-14 00:32:26 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:32:26 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:32:32 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 6199628465 +2016-02-14 00:32:32 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:32:39 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3232875598 +2016-02-14 00:32:39 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:32:43 INFO SimpleDataGson:28 - -------Round 43 +2016-02-14 00:32:49 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3261124847 +2016-02-14 00:32:50 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:32:50 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:32:55 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 5414788232 +2016-02-14 00:32:55 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:33:03 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3900553079 +2016-02-14 00:33:03 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:33:06 INFO SimpleDataGson:28 - -------Round 44 +2016-02-14 00:33:13 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3806054701 +2016-02-14 00:33:13 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:33:13 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:33:33 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19901549025 +2016-02-14 00:33:33 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:33:40 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3087670842 +2016-02-14 00:33:40 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:33:43 INFO SimpleDataGson:28 - -------Round 45 +2016-02-14 00:33:49 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3496904200 +2016-02-14 00:33:50 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:33:50 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:34:09 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19760852273 +2016-02-14 00:34:09 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:34:16 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3030993526 +2016-02-14 00:34:16 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:34:18 INFO SimpleDataGson:28 - -------Round 46 +2016-02-14 00:34:24 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3224896192 +2016-02-14 00:34:25 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:34:25 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:34:46 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 21800935233 +2016-02-14 00:34:46 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:34:53 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 2988645905 +2016-02-14 00:34:53 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:34:56 INFO SimpleDataGson:28 - -------Round 47 +2016-02-14 00:35:02 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3325038261 +2016-02-14 00:35:02 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:35:02 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:35:22 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19895342820 +2016-02-14 00:35:22 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:35:29 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3399804048 +2016-02-14 00:35:29 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:35:32 INFO SimpleDataGson:28 - -------Round 48 +2016-02-14 00:35:38 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3353567383 +2016-02-14 00:35:39 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:35:39 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:36:02 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 23112502373 +2016-02-14 00:36:02 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:36:08 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3315296705 +2016-02-14 00:36:08 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:36:11 INFO SimpleDataGson:28 - -------Round 49 +2016-02-14 00:36:17 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3274835184 +2016-02-14 00:36:18 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:36:18 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:36:35 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 17724232426 +2016-02-14 00:36:35 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:36:41 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3032271715 +2016-02-14 00:36:41 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:36:45 INFO SimpleDataGson:28 - -------Round 50 +2016-02-14 00:36:50 INFO SimpleDataGson:54 - Json Generation Time(ms):: 3274908606 +2016-02-14 00:36:51 INFO SimpleDataGson:30 - Size of Simple content Gson :: 251 MB +2016-02-14 00:36:51 INFO SimpleDataGson:31 - -------------------------------------------------------------------------- +2016-02-14 00:37:10 INFO SimpleDataGson:64 - Generating Map from json Time(ms):: 19519852002 +2016-02-14 00:37:10 INFO SimpleDataGson:65 - -------------------------------------------------------------------------- +2016-02-14 00:37:17 INFO SimpleDataGson:77 - Generating Actual Object from json Time(ms):: 3261170242 +2016-02-14 00:37:17 INFO SimpleDataGson:78 - -------------------------------------------------------------------------- +2016-02-14 00:37:20 INFO SimpleDataGson:40 - -------------------------------------------------------------------------- +2016-02-14 00:37:20 INFO SimpleDataGson:41 - Average Time to Generate JSON : 3400294046 +2016-02-14 00:37:20 INFO SimpleDataGson:42 - Average Time to Parse JSON To Map : 14381392397 +2016-02-14 00:37:20 INFO SimpleDataGson:43 - Average Time to Parse JSON To Actual Object : 3135402339 +2016-02-14 00:37:20 INFO SimpleDataGson:44 - -------------------------------------------------------------------------- +2016-02-14 01:10:20 INFO SimpleDataJackson:31 - -------Round 1 +2016-02-14 01:10:26 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 2029986528 +2016-02-14 01:10:27 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:10:27 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:10:32 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 4698777983 +2016-02-14 01:10:32 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:10:37 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1658963845 +2016-02-14 01:10:41 INFO SimpleDataJackson:31 - -------Round 2 +2016-02-14 01:10:44 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1031786966 +2016-02-14 01:10:45 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:10:45 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:10:47 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1817755779 +2016-02-14 01:10:47 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:10:51 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1585730859 +2016-02-14 01:10:54 INFO SimpleDataJackson:31 - -------Round 3 +2016-02-14 01:10:57 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1055084513 +2016-02-14 01:10:58 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:10:58 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:11:00 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1829403961 +2016-02-14 01:11:00 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:11:04 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1573906621 +2016-02-14 01:11:06 INFO SimpleDataJackson:31 - -------Round 4 +2016-02-14 01:11:10 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1023955984 +2016-02-14 01:11:10 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:11:10 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:11:12 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1797498570 +2016-02-14 01:11:12 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:11:16 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1626333701 +2016-02-14 01:11:19 INFO SimpleDataJackson:31 - -------Round 5 +2016-02-14 01:11:22 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1006898985 +2016-02-14 01:11:23 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:11:23 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:11:25 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1798982027 +2016-02-14 01:11:25 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:11:29 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1667870513 +2016-02-14 01:11:32 INFO SimpleDataJackson:31 - -------Round 6 +2016-02-14 01:11:35 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1002808227 +2016-02-14 01:11:36 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:11:36 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:11:38 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1998326275 +2016-02-14 01:11:38 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:11:42 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1645837733 +2016-02-14 01:11:44 INFO SimpleDataJackson:31 - -------Round 7 +2016-02-14 01:11:48 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1003553509 +2016-02-14 01:11:48 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:11:48 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:11:50 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2018994020 +2016-02-14 01:11:50 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:11:55 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1657835265 +2016-02-14 01:11:57 INFO SimpleDataJackson:31 - -------Round 8 +2016-02-14 01:12:01 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1005108020 +2016-02-14 01:12:01 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:12:01 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:12:03 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1996226617 +2016-02-14 01:12:03 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:12:07 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1645807733 +2016-02-14 01:12:10 INFO SimpleDataJackson:31 - -------Round 9 +2016-02-14 01:12:13 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 991788482 +2016-02-14 01:12:14 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:12:14 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:12:16 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1991979539 +2016-02-14 01:12:16 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:12:20 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1657106958 +2016-02-14 01:12:22 INFO SimpleDataJackson:31 - -------Round 10 +2016-02-14 01:12:26 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1002594274 +2016-02-14 01:12:26 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:12:26 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:12:28 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2016278558 +2016-02-14 01:12:28 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:12:33 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1661181926 +2016-02-14 01:12:35 INFO SimpleDataJackson:31 - -------Round 11 +2016-02-14 01:12:39 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1000298034 +2016-02-14 01:12:39 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:12:39 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:12:41 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1993129831 +2016-02-14 01:12:41 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:12:45 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1664888991 +2016-02-14 01:12:48 INFO SimpleDataJackson:31 - -------Round 12 +2016-02-14 01:12:52 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1259261248 +2016-02-14 01:12:52 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:12:52 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:12:55 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2235383423 +2016-02-14 01:12:55 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:12:59 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1690719232 +2016-02-14 01:13:01 INFO SimpleDataJackson:31 - -------Round 13 +2016-02-14 01:13:05 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1014408644 +2016-02-14 01:13:05 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:13:05 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:13:07 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2043347909 +2016-02-14 01:13:07 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:13:12 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1663652250 +2016-02-14 01:13:14 INFO SimpleDataJackson:31 - -------Round 14 +2016-02-14 01:13:19 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1333126618 +2016-02-14 01:13:19 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:13:19 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:13:22 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2481588034 +2016-02-14 01:13:22 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:13:27 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1933185198 +2016-02-14 01:13:29 INFO SimpleDataJackson:31 - -------Round 15 +2016-02-14 01:13:33 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1020516558 +2016-02-14 01:13:33 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:13:33 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:13:35 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 1997307828 +2016-02-14 01:13:35 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:13:40 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1665160971 +2016-02-14 01:13:42 INFO SimpleDataJackson:31 - -------Round 16 +2016-02-14 01:13:46 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1047870915 +2016-02-14 01:13:46 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:13:46 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:13:48 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2007945854 +2016-02-14 01:13:48 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:13:53 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1713994673 +2016-02-14 01:13:55 INFO SimpleDataJackson:31 - -------Round 17 +2016-02-14 01:13:59 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1021864222 +2016-02-14 01:14:00 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:14:00 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:14:02 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2119751499 +2016-02-14 01:14:02 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:14:06 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1819921754 +2016-02-14 01:14:09 INFO SimpleDataJackson:31 - -------Round 18 +2016-02-14 01:14:12 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1100389181 +2016-02-14 01:14:13 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:14:13 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:14:15 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2190647586 +2016-02-14 01:14:15 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:14:20 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1918921820 +2016-02-14 01:14:23 INFO SimpleDataJackson:31 - -------Round 19 +2016-02-14 01:14:27 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1095955782 +2016-02-14 01:14:27 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:14:27 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:14:29 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2203353688 +2016-02-14 01:14:29 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:14:34 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2183651493 +2016-02-14 01:14:37 INFO SimpleDataJackson:31 - -------Round 20 +2016-02-14 01:14:41 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1346518000 +2016-02-14 01:14:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:14:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:14:44 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2305701995 +2016-02-14 01:14:44 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:14:49 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1834727512 +2016-02-14 01:14:52 INFO SimpleDataJackson:31 - -------Round 21 +2016-02-14 01:14:56 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1054845297 +2016-02-14 01:14:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:14:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:14:58 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2085967115 +2016-02-14 01:14:58 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:15:04 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2635661561 +2016-02-14 01:15:07 INFO SimpleDataJackson:31 - -------Round 22 +2016-02-14 01:15:11 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1221064781 +2016-02-14 01:15:11 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:15:11 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:15:13 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2105141139 +2016-02-14 01:15:13 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:15:19 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2733167908 +2016-02-14 01:15:22 INFO SimpleDataJackson:31 - -------Round 23 +2016-02-14 01:15:27 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1667984199 +2016-02-14 01:15:28 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:15:28 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:15:30 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2661075740 +2016-02-14 01:15:30 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:15:35 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1807353417 +2016-02-14 01:15:38 INFO SimpleDataJackson:31 - -------Round 24 +2016-02-14 01:15:42 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1088799421 +2016-02-14 01:15:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:15:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:15:44 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2133273543 +2016-02-14 01:15:44 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:15:49 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1796471834 +2016-02-14 01:15:52 INFO SimpleDataJackson:31 - -------Round 25 +2016-02-14 01:15:56 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1061435591 +2016-02-14 01:15:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:15:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:15:59 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2772566377 +2016-02-14 01:15:59 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:16:04 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2127388266 +2016-02-14 01:16:07 INFO SimpleDataJackson:31 - -------Round 26 +2016-02-14 01:16:13 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1570076001 +2016-02-14 01:16:13 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:16:13 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:16:16 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 3026015772 +2016-02-14 01:16:16 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:16:22 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2328930067 +2016-02-14 01:16:25 INFO SimpleDataJackson:31 - -------Round 27 +2016-02-14 01:16:29 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1047895784 +2016-02-14 01:16:29 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:16:29 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:16:32 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2165248408 +2016-02-14 01:16:32 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:16:37 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1919710920 +2016-02-14 01:16:40 INFO SimpleDataJackson:31 - -------Round 28 +2016-02-14 01:16:44 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1461024502 +2016-02-14 01:16:45 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:16:45 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:16:48 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2548823636 +2016-02-14 01:16:48 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:16:53 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1884536633 +2016-02-14 01:16:56 INFO SimpleDataJackson:31 - -------Round 29 +2016-02-14 01:16:59 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1075140796 +2016-02-14 01:17:00 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:17:00 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:17:02 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2158603245 +2016-02-14 01:17:02 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:17:07 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1728481872 +2016-02-14 01:17:09 INFO SimpleDataJackson:31 - -------Round 30 +2016-02-14 01:17:13 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1122247876 +2016-02-14 01:17:14 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:17:14 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:17:17 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2610826477 +2016-02-14 01:17:17 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:17:22 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2207052069 +2016-02-14 01:17:25 INFO SimpleDataJackson:31 - -------Round 31 +2016-02-14 01:17:29 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1052980909 +2016-02-14 01:17:30 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:17:30 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:17:32 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2052367868 +2016-02-14 01:17:32 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:17:36 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1718415440 +2016-02-14 01:17:39 INFO SimpleDataJackson:31 - -------Round 32 +2016-02-14 01:17:43 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1055489524 +2016-02-14 01:17:43 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:17:43 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:17:45 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2063065499 +2016-02-14 01:17:45 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:17:50 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1710515377 +2016-02-14 01:17:53 INFO SimpleDataJackson:31 - -------Round 33 +2016-02-14 01:17:57 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1129909512 +2016-02-14 01:17:57 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:17:57 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:17:59 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2102819240 +2016-02-14 01:17:59 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:18:04 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1730105070 +2016-02-14 01:18:07 INFO SimpleDataJackson:31 - -------Round 34 +2016-02-14 01:18:11 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1101129726 +2016-02-14 01:18:11 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:18:11 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:18:13 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2206549951 +2016-02-14 01:18:13 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:18:18 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1903037219 +2016-02-14 01:18:21 INFO SimpleDataJackson:31 - -------Round 35 +2016-02-14 01:18:26 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1386136343 +2016-02-14 01:18:27 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:18:27 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:18:29 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2646813152 +2016-02-14 01:18:29 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:18:35 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2271873400 +2016-02-14 01:18:38 INFO SimpleDataJackson:31 - -------Round 36 +2016-02-14 01:18:41 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1072219672 +2016-02-14 01:18:42 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:18:42 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:18:44 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2116882876 +2016-02-14 01:18:44 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:18:49 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1785044316 +2016-02-14 01:18:52 INFO SimpleDataJackson:31 - -------Round 37 +2016-02-14 01:18:56 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1060936236 +2016-02-14 01:18:56 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:18:56 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:18:59 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2095196685 +2016-02-14 01:18:59 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:19:03 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1748247622 +2016-02-14 01:19:06 INFO SimpleDataJackson:31 - -------Round 38 +2016-02-14 01:19:10 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1086578972 +2016-02-14 01:19:11 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:19:11 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:19:13 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2089427069 +2016-02-14 01:19:13 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:19:17 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1754304218 +2016-02-14 01:19:20 INFO SimpleDataJackson:31 - -------Round 39 +2016-02-14 01:19:24 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1100743269 +2016-02-14 01:19:25 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:19:25 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:19:27 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2122292877 +2016-02-14 01:19:27 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:19:32 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1843712339 +2016-02-14 01:19:35 INFO SimpleDataJackson:31 - -------Round 40 +2016-02-14 01:19:38 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1098107940 +2016-02-14 01:19:39 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:19:39 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:19:41 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2207965512 +2016-02-14 01:19:41 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:19:46 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1741791936 +2016-02-14 01:19:48 INFO SimpleDataJackson:31 - -------Round 41 +2016-02-14 01:19:52 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1064537903 +2016-02-14 01:19:53 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:19:53 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:19:55 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2320554730 +2016-02-14 01:19:55 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:20:00 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 2170266821 +2016-02-14 01:20:03 INFO SimpleDataJackson:31 - -------Round 42 +2016-02-14 01:20:07 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1157553613 +2016-02-14 01:20:08 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:20:08 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:20:10 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2269739005 +2016-02-14 01:20:10 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:20:15 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1772026365 +2016-02-14 01:20:18 INFO SimpleDataJackson:31 - -------Round 43 +2016-02-14 01:20:22 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1136483621 +2016-02-14 01:20:22 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:20:22 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:20:24 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2159793800 +2016-02-14 01:20:24 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:20:29 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1784084293 +2016-02-14 01:20:32 INFO SimpleDataJackson:31 - -------Round 44 +2016-02-14 01:20:36 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1173644668 +2016-02-14 01:20:37 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:20:37 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:20:39 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2320150509 +2016-02-14 01:20:39 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:20:44 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1940564196 +2016-02-14 01:20:47 INFO SimpleDataJackson:31 - -------Round 45 +2016-02-14 01:20:51 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1265839699 +2016-02-14 01:20:52 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:20:52 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:20:54 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2558040573 +2016-02-14 01:20:54 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:20:59 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1758794065 +2016-02-14 01:21:02 INFO SimpleDataJackson:31 - -------Round 46 +2016-02-14 01:21:06 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1181087613 +2016-02-14 01:21:06 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:21:06 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:21:09 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2079106420 +2016-02-14 01:21:09 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:21:13 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1790406553 +2016-02-14 01:21:16 INFO SimpleDataJackson:31 - -------Round 47 +2016-02-14 01:21:20 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1106377880 +2016-02-14 01:21:21 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:21:21 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:21:23 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2087174645 +2016-02-14 01:21:23 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:21:27 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1880122182 +2016-02-14 01:21:30 INFO SimpleDataJackson:31 - -------Round 48 +2016-02-14 01:21:34 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1059543570 +2016-02-14 01:21:35 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:21:35 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:21:37 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2060372538 +2016-02-14 01:21:37 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:21:41 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1789722458 +2016-02-14 01:21:44 INFO SimpleDataJackson:31 - -------Round 49 +2016-02-14 01:21:48 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1144693560 +2016-02-14 01:21:49 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:21:49 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:21:51 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2089575493 +2016-02-14 01:21:51 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:21:55 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1759762378 +2016-02-14 01:21:58 INFO SimpleDataJackson:31 - -------Round 50 +2016-02-14 01:22:02 INFO SimpleDataJackson:59 - Json Generation Time(ms):: 1074021689 +2016-02-14 01:22:03 INFO SimpleDataJackson:33 - Size of Simple content Jackson :: 251 MB +2016-02-14 01:22:03 INFO SimpleDataJackson:34 - -------------------------------------------------------------------------- +2016-02-14 01:22:05 INFO SimpleDataJackson:69 - Generating Map from json Time(ms):: 2073524704 +2016-02-14 01:22:05 INFO SimpleDataJackson:70 - -------------------------------------------------------------------------- +2016-02-14 01:22:09 INFO SimpleDataJackson:82 - Generating Actual Object from json Time(ms):: 1845090005 +2016-02-14 01:22:12 INFO SimpleDataJackson:45 - -------------------------------------------------------------------------- +2016-02-14 01:22:12 INFO SimpleDataJackson:46 - Average Time to Generate JSON : 1145446097 +2016-02-14 01:22:12 INFO SimpleDataJackson:47 - Average Time to Parse JSON To Map : 2230626711 +2016-02-14 01:22:12 INFO SimpleDataJackson:48 - Average Time to Parse JSON To Actual Object : 1846720796 +2016-02-14 01:22:12 INFO SimpleDataJackson:49 - -------------------------------------------------------------------------- diff --git a/gson-jackson-performance/pom.xml b/gson-jackson-performance/pom.xml new file mode 100644 index 000000000000..1a65ed54a084 --- /dev/null +++ b/gson-jackson-performance/pom.xml @@ -0,0 +1,72 @@ + + 4.0.0 + + org.baeldung + gson-jackson-performance + 0.0.1-SNAPSHOT + jar + + gson-jackson-performance + http://maven.apache.org + + + UTF-8 + + + + gson-jackson-performance + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + + + com.google.code.gson + gson + 2.5 + + + + com.fasterxml.jackson.core + jackson-databind + 2.7.1-1 + + + + junit + junit + 3.8.1 + test + + + + log4j + log4j + 1.2.17 + + + + + + + diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGeneration.java b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGeneration.java new file mode 100644 index 000000000000..1596c029b5dd --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGeneration.java @@ -0,0 +1,63 @@ +package org.baeldung.data.complex; + +import java.util.ArrayList; +import java.util.List; + +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.complex.AddressDetails; +import org.baeldung.pojo.complex.ContactDetails; +import org.baeldung.pojo.complex.CustomerAddressDetails; +import org.baeldung.pojo.complex.CustomerPortfolioComplex; + +/** + * + * This class is responsible for generating data for complex type object + */ + +public class ComplexDataGeneration { + + public static CustomerPortfolioComplex generateData() { + List customerAddressDetailsList = new ArrayList(); + for (int i = 0; i < 600000; i++) { + CustomerAddressDetails customerAddressDetails = new CustomerAddressDetails(); + customerAddressDetails.setAge(20); + customerAddressDetails.setFirstName(Utility.generateRandomName()); + customerAddressDetails.setLastName(Utility.generateRandomName()); + + List addressDetailsList = new ArrayList(); + customerAddressDetails.setAddressDetails(addressDetailsList); + + for (int j = 0; j < 2; j++) { + AddressDetails addressDetails = new AddressDetails(); + addressDetails.setZipcode(Utility.generateRandomZip()); + addressDetails.setAddress(Utility.generateRandomAddress()); + + List contactDetailsList = new ArrayList(); + addressDetails.setContactDetails(contactDetailsList); + + for (int k = 0; k < 2; k++) { + ContactDetails contactDetails = new ContactDetails(); + contactDetails.setLandline(Utility.generateRandomPhone()); + contactDetails.setMobile(Utility.generateRandomPhone()); + contactDetailsList.add(contactDetails); + contactDetails = null; + } + + addressDetailsList.add(addressDetails); + addressDetails = null; + contactDetailsList = null; + } + customerAddressDetailsList.add(customerAddressDetails); + customerAddressDetails = null; + + if (i % 6000 == 0) { + Runtime.getRuntime().gc(); + } + } + + CustomerPortfolioComplex customerPortfolioComplex = new CustomerPortfolioComplex(); + customerPortfolioComplex.setCustomerAddressDetailsList(customerAddressDetailsList); + customerAddressDetailsList = null; + return customerPortfolioComplex; + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGson.java b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGson.java new file mode 100644 index 000000000000..23ce668d1722 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataGson.java @@ -0,0 +1,91 @@ +package org.baeldung.data.complex; + +import java.util.Map; + +import org.apache.log4j.Logger; +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.complex.CustomerPortfolioComplex; + +import com.google.gson.Gson; + +/** + * + * This class is responsible for performing functions for Complex type + * GSON like + * Java to Json + * Json to Map + * Json to Java Object + */ + +public class ComplexDataGson { + + private static final Logger logger = Logger.getLogger(ComplexDataGson.class); + + static Gson gson = new Gson(); + + static long generateJsonAvgTime = 0L; + + static long parseJsonToMapAvgTime = 0L; + + static long parseJsonToActualObjectAvgTime = 0L; + + public static void main(String[] args) { + CustomerPortfolioComplex customerPortfolioComplex = ComplexDataGeneration.generateData(); + int j = 50; + for (int i = 0; i < j; i++) { + logger.info("-------Round " + (i + 1)); + String jsonStr = generateJson(customerPortfolioComplex); + logger.info("Size of Complex content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length)); + logger.info("--------------------------------------------------------------------------"); + parseJsonToMap(jsonStr); + parseJsonToActualObject(jsonStr); + jsonStr = null; + } + + generateJsonAvgTime = generateJsonAvgTime / j; + parseJsonToMapAvgTime = parseJsonToMapAvgTime / j; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j; + + logger.info("--------------------------------------------------------------------------"); + logger.info("Average Time to Generate JSON : " + generateJsonAvgTime); + logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime); + logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime); + logger.info("--------------------------------------------------------------------------"); + } + + private static String generateJson(CustomerPortfolioComplex customerPortfolioComplex) { + Runtime.getRuntime().gc(); + long startParsTime = System.nanoTime(); + String json = gson.toJson(customerPortfolioComplex); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + generateJsonAvgTime = generateJsonAvgTime + elapsedTime; + logger.info("Json Generation Time(ms):: " + elapsedTime); + return json; + } + + private static void parseJsonToMap(String jsonStr) { + long startParsTime = System.nanoTime(); + Map parsedMap = gson.fromJson(jsonStr , Map.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime; + logger.info("Generating Map from json Time(ms):: " + elapsedTime); + logger.info("--------------------------------------------------------------------------"); + parsedMap = null; + Runtime.getRuntime().gc(); + } + + private static void parseJsonToActualObject(String jsonStr) { + long startParsTime = System.nanoTime(); + CustomerPortfolioComplex customerPortfolioComplex = gson.fromJson(jsonStr , CustomerPortfolioComplex.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime; + logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime); + logger.info("--------------------------------------------------------------------------"); + customerPortfolioComplex = null; + Runtime.getRuntime().gc(); + + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataJackson.java b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataJackson.java new file mode 100644 index 000000000000..6447060856ba --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/complex/ComplexDataJackson.java @@ -0,0 +1,95 @@ +package org.baeldung.data.complex; + +import java.io.IOException; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.complex.CustomerPortfolioComplex; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * + * This class is responsible for performing functions for Complex type + * Jackson like + * Java to Json + * Json to Map + * Json to Java Object + */ + +public class ComplexDataJackson { + + private static final Logger logger = Logger.getLogger(ComplexDataJackson.class); + + static ObjectMapper mapper = new ObjectMapper(); + + static long generateJsonAvgTime = 0L; + + static long parseJsonToMapAvgTime = 0L; + + static long parseJsonToActualObjectAvgTime = 0L; + + public static void main(String[] args) throws IOException { + CustomerPortfolioComplex customerPortfolioComplex = ComplexDataGeneration.generateData(); + int j = 50; + for (int i = 0; i < j; i++) { + logger.info("-------Round " + (i + 1)); + String jsonStr = generateJson(customerPortfolioComplex); + logger.info("Size of Complex content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length)); + logger.info("--------------------------------------------------------------------------"); + parseJsonToMap(jsonStr); + parseJsonToActualObject(jsonStr); + jsonStr = null; + } + + generateJsonAvgTime = generateJsonAvgTime / j; + parseJsonToMapAvgTime = parseJsonToMapAvgTime / j; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j; + + logger.info("--------------------------------------------------------------------------"); + logger.info("Average Time to Generate JSON : " + generateJsonAvgTime); + logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime); + logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime); + logger.info("--------------------------------------------------------------------------"); + } + + private static String generateJson(CustomerPortfolioComplex customerPortfolioComplex) + throws JsonProcessingException { + Runtime.getRuntime().gc(); + long startParsTime = System.nanoTime(); + String json = mapper.writeValueAsString(customerPortfolioComplex); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + generateJsonAvgTime = generateJsonAvgTime + elapsedTime; + logger.info("Json Generation Time(ms):: " + elapsedTime); + return json; + } + + private static void parseJsonToMap(String jsonStr) throws JsonParseException , JsonMappingException , IOException { + long startParsTime = System.nanoTime(); + Map parsedMap = mapper.readValue(jsonStr , Map.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime; + logger.info("Generating Map from json Time(ms):: " + elapsedTime); + parsedMap = null; + Runtime.getRuntime().gc(); + + } + + private static void parseJsonToActualObject(String jsonStr) throws JsonParseException , JsonMappingException , + IOException { + long startParsTime = System.nanoTime(); + CustomerPortfolioComplex customerPortfolioComplex = mapper.readValue(jsonStr , CustomerPortfolioComplex.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime; + logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime); + customerPortfolioComplex = null; + Runtime.getRuntime().gc(); + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGeneration.java b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGeneration.java new file mode 100644 index 000000000000..69cf87e7b2c3 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGeneration.java @@ -0,0 +1,35 @@ +package org.baeldung.data.simple; + +import java.util.ArrayList; +import java.util.List; + +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.simple.Customer; +import org.baeldung.pojo.simple.CustomerPortfolioSimple; + +/** + * + * This class is responsible for generating data for simple type object + */ + +public class SimpleDataGeneration { + + public static CustomerPortfolioSimple generateData() { + List customerList = new ArrayList(); + for (int i = 0; i < 1; i++) { + Customer customer = new Customer(); + customer.setAge(20); + customer.setFirstName(Utility.generateRandomName()); + customer.setLastName(Utility.generateRandomName()); + + customerList.add(customer); + customer = null; + + } + + CustomerPortfolioSimple customerPortfolioSimple = new CustomerPortfolioSimple(); + customerPortfolioSimple.setCustomerLists(customerList); + customerList = null; + return customerPortfolioSimple; + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGson.java b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGson.java new file mode 100644 index 000000000000..b41aab53e788 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataGson.java @@ -0,0 +1,91 @@ +package org.baeldung.data.simple; + +import java.util.Map; + +import org.apache.log4j.Logger; +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.simple.CustomerPortfolioSimple; + +import com.google.gson.Gson; + +/** + * + * This class is responsible for performing functions for Simple type + * GSON like + * Java to Json + * Json to Map + * Json to Java Object + */ + +public class SimpleDataGson { + + private static final Logger logger = Logger.getLogger(SimpleDataGson.class); + + static Gson gson = new Gson(); + + static long generateJsonAvgTime = 0L; + + static long parseJsonToMapAvgTime = 0L; + + static long parseJsonToActualObjectAvgTime = 0L; + + public static void main(String[] args) { + CustomerPortfolioSimple customerPortfolioSimple = SimpleDataGeneration.generateData(); + String jsonStr = null; + int j = 5; + for (int i = 0; i < j; i++) { + logger.info("-------Round " + (i + 1)); + jsonStr = generateJson(customerPortfolioSimple); + logger.info("Size of Simple content Gson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length)); + logger.info("--------------------------------------------------------------------------"); + parseJsonToMap(jsonStr); + parseJsonToActualObject(jsonStr); + jsonStr = null; + } + generateJsonAvgTime = generateJsonAvgTime / j; + parseJsonToMapAvgTime = parseJsonToMapAvgTime / j; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j; + + logger.info("--------------------------------------------------------------------------"); + logger.info("Average Time to Generate JSON : " + generateJsonAvgTime); + logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime); + logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime); + logger.info("--------------------------------------------------------------------------"); + } + + private static String generateJson(CustomerPortfolioSimple customerPortfolioSimple) { + Runtime.getRuntime().gc(); + long startParsTime = System.nanoTime(); + String json = gson.toJson(customerPortfolioSimple); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + generateJsonAvgTime = generateJsonAvgTime + elapsedTime; + logger.info("Json Generation Time(ms):: " + elapsedTime); + return json; + } + + private static void parseJsonToMap(String jsonStr) { + long startParsTime = System.nanoTime(); + Map parsedMap = gson.fromJson(jsonStr , Map.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime; + logger.info("Generating Map from json Time(ms):: " + elapsedTime); + logger.info("--------------------------------------------------------------------------"); + parsedMap = null; + Runtime.getRuntime().gc(); + + } + + private static void parseJsonToActualObject(String jsonStr) { + long startParsTime = System.nanoTime(); + CustomerPortfolioSimple customerPortfolioSimple = gson.fromJson(jsonStr , CustomerPortfolioSimple.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime; + logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime); + logger.info("--------------------------------------------------------------------------"); + customerPortfolioSimple = null; + Runtime.getRuntime().gc(); + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataJackson.java b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataJackson.java new file mode 100644 index 000000000000..9280a2a6e989 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/simple/SimpleDataJackson.java @@ -0,0 +1,95 @@ +package org.baeldung.data.simple; + +import java.io.IOException; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.baeldung.data.utility.Utility; +import org.baeldung.pojo.simple.CustomerPortfolioSimple; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * + * This class is responsible for performing functions for Simple type + * GSON like + * Java to Json + * Json to Map + * Json to Java Object + */ + +public class SimpleDataJackson { + + private static final Logger logger = Logger.getLogger(SimpleDataJackson.class); + + static ObjectMapper mapper = new ObjectMapper(); + + static long generateJsonAvgTime = 0L; + + static long parseJsonToMapAvgTime = 0L; + + static long parseJsonToActualObjectAvgTime = 0L; + + public static void main(String[] args) throws IOException { + CustomerPortfolioSimple customerPortfolioSimple = SimpleDataGeneration.generateData(); + int j = 50; + for (int i = 0; i < j; i++) { + logger.info("-------Round " + (i + 1)); + String jsonStr = generateJson(customerPortfolioSimple); + logger.info("Size of Simple content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length)); + logger.info("--------------------------------------------------------------------------"); + + parseJsonToMap(jsonStr); + parseJsonToActualObject(jsonStr); + jsonStr = null; + } + + generateJsonAvgTime = generateJsonAvgTime / j; + parseJsonToMapAvgTime = parseJsonToMapAvgTime / j; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j; + + logger.info("--------------------------------------------------------------------------"); + logger.info("Average Time to Generate JSON : " + generateJsonAvgTime); + logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime); + logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime); + logger.info("--------------------------------------------------------------------------"); + } + + private static String generateJson(CustomerPortfolioSimple customerPortfolioSimple) throws JsonProcessingException { + Runtime.getRuntime().gc(); + long startParsTime = System.nanoTime(); + String json = mapper.writeValueAsString(customerPortfolioSimple); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + generateJsonAvgTime = generateJsonAvgTime + elapsedTime; + logger.info("Json Generation Time(ms):: " + elapsedTime); + return json; + } + + private static void parseJsonToMap(String jsonStr) throws JsonParseException , JsonMappingException , IOException { + long startParsTime = System.nanoTime(); + Map parsedMap = mapper.readValue(jsonStr , Map.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime; + logger.info("Generating Map from json Time(ms):: " + elapsedTime); + logger.info("--------------------------------------------------------------------------"); + parsedMap = null; + Runtime.getRuntime().gc(); + } + + private static void parseJsonToActualObject(String jsonStr) throws JsonParseException , JsonMappingException , + IOException { + long startParsTime = System.nanoTime(); + CustomerPortfolioSimple customerPortfolioSimple = mapper.readValue(jsonStr , CustomerPortfolioSimple.class); + long endParsTime = System.nanoTime(); + long elapsedTime = endParsTime - startParsTime; + parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime; + logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime); + customerPortfolioSimple = null; + Runtime.getRuntime().gc(); + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/data/utility/Utility.java b/gson-jackson-performance/src/main/java/org/baeldung/data/utility/Utility.java new file mode 100644 index 000000000000..852fc5692940 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/data/utility/Utility.java @@ -0,0 +1,90 @@ +package org.baeldung.data.utility; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.Random; + +public class Utility { + + public static String generateRandomName() { + char[] chars = "abcdefghijklmnopqrstuvwxyz ".toCharArray(); + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < 8; i++) { + char c = chars[random.nextInt(chars.length)]; + sb.append(c); + } + return sb.toString(); + } + + public static String generateRandomAddress() { + char[] chars = "abcdefghijklmnopqrstuvwxyz ".toCharArray(); + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < 30; i++) { + char c = chars[random.nextInt(chars.length)]; + sb.append(c); + } + return sb.toString(); + } + + public static String generateRandomZip() { + char[] chars = "1234567890".toCharArray(); + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < 8; i++) { + char c = chars[random.nextInt(chars.length)]; + sb.append(c); + } + return sb.toString(); + } + + public static String generateRandomPhone() { + char[] chars = "1234567890".toCharArray(); + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < 10; i++) { + char c = chars[random.nextInt(chars.length)]; + sb.append(c); + } + return sb.toString(); + } + + public static String readFile(String fileName , Class clazz) throws IOException { + String dir = clazz.getResource("/").getFile(); + dir = dir + "/" + fileName; + + BufferedReader br = new BufferedReader(new FileReader(dir)); + try { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + return sb.toString(); + } finally { + br.close(); + } + } + + public static String bytesIntoMB(long bytes) { + long kilobyte = 1024; + long megabyte = kilobyte * 1024; + + if ((bytes >= 0) && (bytes < kilobyte)) { + return bytes + " B"; + + } else if ((bytes >= kilobyte) && (bytes < megabyte)) { + return (bytes / kilobyte) + " KB"; + + } else if ((bytes >= megabyte)) { + return (bytes / megabyte) + " MB"; + } + + return null; + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/AddressDetails.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/AddressDetails.java new file mode 100644 index 000000000000..67908c599ae2 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/AddressDetails.java @@ -0,0 +1,37 @@ +package org.baeldung.pojo.complex; + +import java.util.List; + +public class AddressDetails { + + private String address; + + private String zipcode; + + private List contactDetails; + + public String getZipcode() { + return zipcode; + } + + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + public List getContactDetails() { + return contactDetails; + } + + public void setContactDetails(List contactDetails) { + this.contactDetails = contactDetails; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/ContactDetails.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/ContactDetails.java new file mode 100644 index 000000000000..fa848c8d84e3 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/ContactDetails.java @@ -0,0 +1,25 @@ +package org.baeldung.pojo.complex; + +public class ContactDetails { + + private String mobile; + + private String landline; + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getLandline() { + return landline; + } + + public void setLandline(String landline) { + this.landline = landline; + } + +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerAddressDetails.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerAddressDetails.java new file mode 100644 index 000000000000..921b7e126bd2 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerAddressDetails.java @@ -0,0 +1,18 @@ +package org.baeldung.pojo.complex; + +import java.util.List; + +import org.baeldung.pojo.simple.Customer; + +public class CustomerAddressDetails extends Customer { + + private List addressDetails; + + public List getAddressDetails() { + return addressDetails; + } + + public void setAddressDetails(List addressDetails) { + this.addressDetails = addressDetails; + } +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerPortfolioComplex.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerPortfolioComplex.java new file mode 100644 index 000000000000..407cc49bea69 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/complex/CustomerPortfolioComplex.java @@ -0,0 +1,17 @@ +package org.baeldung.pojo.complex; + +import java.util.List; + +public class CustomerPortfolioComplex { + + private List customerAddressDetailsList; + + public List getCustomerAddressDetailsList() { + return customerAddressDetailsList; + } + + public void setCustomerAddressDetailsList(List customerAddressDetailsList) { + this.customerAddressDetailsList = customerAddressDetailsList; + } + +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/Customer.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/Customer.java new file mode 100644 index 000000000000..bb88b55ef341 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/Customer.java @@ -0,0 +1,36 @@ +package org.baeldung.pojo.simple; + + +public class Customer { + + private String firstName; + + private String lastName; + + private int age; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + +} diff --git a/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/CustomerPortfolioSimple.java b/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/CustomerPortfolioSimple.java new file mode 100644 index 000000000000..ccd17e1a56a6 --- /dev/null +++ b/gson-jackson-performance/src/main/java/org/baeldung/pojo/simple/CustomerPortfolioSimple.java @@ -0,0 +1,16 @@ +package org.baeldung.pojo.simple; + +import java.util.List; + +public class CustomerPortfolioSimple { + + private List customerLists; + + public List getCustomerLists() { + return customerLists; + } + + public void setCustomerLists(List customerLists) { + this.customerLists = customerLists; + } +} diff --git a/gson-jackson-performance/src/main/resources/log4j.properties b/gson-jackson-performance/src/main/resources/log4j.properties new file mode 100644 index 000000000000..371cbc90481e --- /dev/null +++ b/gson-jackson-performance/src/main/resources/log4j.properties @@ -0,0 +1,16 @@ +# Root logger option +log4j.rootLogger=DEBUG, file + +# Redirect log messages to console +# log4j.appender.stdout=org.apache.log4j.ConsoleAppender +# log4j.appender.stdout.Target=System.out +# log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +# log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Redirect log messages to a log file, support file rolling. +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=log4j-application.log +log4j.appender.file.MaxFileSize=5MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file From 90d7b0236b928daa11787d543a33878946e60d2f Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Wed, 17 Feb 2016 23:37:16 +0100 Subject: [PATCH 315/626] Folder renamed e client code reverted --- {RestEasy Example => resteasy}/pom.xml | 0 .../baeldung/client/ServicesInterface.java | 0 .../main/java/com/baeldung/model/Movie.java | 0 .../com/baeldung/server/MovieCrudService.java | 0 .../com/baeldung/server/RestEasyServices.java | 0 .../main/webapp/WEB-INF/classes/logback.xml | 0 .../WEB-INF/jboss-deployment-structure.xml | 0 .../src/main/webapp/WEB-INF/jboss-web.xml | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../baeldung/server/RestEasyClientTest.java | 144 ++++++++++++++++++ .../com/baeldung/server/movies/batman.json | 4 + .../baeldung/server/movies/transformer.json | 4 + 12 files changed, 152 insertions(+) rename {RestEasy Example => resteasy}/pom.xml (100%) rename {RestEasy Example => resteasy}/src/main/java/com/baeldung/client/ServicesInterface.java (100%) rename {RestEasy Example => resteasy}/src/main/java/com/baeldung/model/Movie.java (100%) rename {RestEasy Example => resteasy}/src/main/java/com/baeldung/server/MovieCrudService.java (100%) rename {RestEasy Example => resteasy}/src/main/java/com/baeldung/server/RestEasyServices.java (100%) rename {RestEasy Example => resteasy}/src/main/webapp/WEB-INF/classes/logback.xml (100%) rename {RestEasy Example => resteasy}/src/main/webapp/WEB-INF/jboss-deployment-structure.xml (100%) rename {RestEasy Example => resteasy}/src/main/webapp/WEB-INF/jboss-web.xml (100%) rename {RestEasy Example => resteasy}/src/main/webapp/WEB-INF/web.xml (100%) create mode 100644 resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java create mode 100644 resteasy/src/test/resources/com/baeldung/server/movies/batman.json create mode 100644 resteasy/src/test/resources/com/baeldung/server/movies/transformer.json diff --git a/RestEasy Example/pom.xml b/resteasy/pom.xml similarity index 100% rename from RestEasy Example/pom.xml rename to resteasy/pom.xml diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java similarity index 100% rename from RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java rename to resteasy/src/main/java/com/baeldung/client/ServicesInterface.java diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/resteasy/src/main/java/com/baeldung/model/Movie.java similarity index 100% rename from RestEasy Example/src/main/java/com/baeldung/model/Movie.java rename to resteasy/src/main/java/com/baeldung/model/Movie.java diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/resteasy/src/main/java/com/baeldung/server/MovieCrudService.java similarity index 100% rename from RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java rename to resteasy/src/main/java/com/baeldung/server/MovieCrudService.java diff --git a/RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java b/resteasy/src/main/java/com/baeldung/server/RestEasyServices.java similarity index 100% rename from RestEasy Example/src/main/java/com/baeldung/server/RestEasyServices.java rename to resteasy/src/main/java/com/baeldung/server/RestEasyServices.java diff --git a/RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml b/resteasy/src/main/webapp/WEB-INF/classes/logback.xml similarity index 100% rename from RestEasy Example/src/main/webapp/WEB-INF/classes/logback.xml rename to resteasy/src/main/webapp/WEB-INF/classes/logback.xml diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml similarity index 100% rename from RestEasy Example/src/main/webapp/WEB-INF/jboss-deployment-structure.xml rename to resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml diff --git a/RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml b/resteasy/src/main/webapp/WEB-INF/jboss-web.xml similarity index 100% rename from RestEasy Example/src/main/webapp/WEB-INF/jboss-web.xml rename to resteasy/src/main/webapp/WEB-INF/jboss-web.xml diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/resteasy/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from RestEasy Example/src/main/webapp/WEB-INF/web.xml rename to resteasy/src/main/webapp/WEB-INF/web.xml diff --git a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java new file mode 100644 index 000000000000..2a13465ebcd7 --- /dev/null +++ b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -0,0 +1,144 @@ +package com.baeldung.server; + +import com.baeldung.client.ServicesInterface; +import com.baeldung.model.Movie; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.junit.Before; +import org.junit.Test; +import javax.naming.NamingException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + +public class RestEasyClientTest { + + Movie transformerMovie = null; + Movie batmanMovie = null; + ObjectMapper jsonMapper = null; + + @Before + public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException { + + jsonMapper = new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); + jsonMapper.setDateFormat(sdf); + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/transformer.json")) { + String transformerMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + transformerMovie = jsonMapper.readValue(transformerMovieAsString, Movie.class); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Test is going to die ...", e); + } + + try (InputStream inputStream = new RestEasyClientTest().getClass().getResourceAsStream("./movies/batman.json")) { + String batmanMovieAsString = String.format(IOUtils.toString(inputStream, StandardCharsets.UTF_8)); + batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class); + + } catch (Exception e) { + throw new RuntimeException("Test is going to die ...", e); + } + } + + @Test + public void testListAllMovies() { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + + List movies = simple.listMovies(); + System.out.println(movies); + } + + @Test + public void testMovieByImdbId() { + + String transformerImdbId = "tt0418279"; + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(transformerMovie); + moviesResponse.close(); + + Movie movies = simple.movieByImdbId(transformerImdbId); + System.out.println(movies); + } + + @Test + public void testAddMovie() { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.addMovie(transformerMovie); + + if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + } + + @Test + public void testDeleteMovi1e() { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println(moviesResponse.readEntity(String.class)); + throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + } + + @Test + public void testUpdateMovie() { + + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response moviesResponse = simple.addMovie(batmanMovie); + moviesResponse.close(); + batmanMovie.setTitle("Batman Begins"); + moviesResponse = simple.updateMovie(batmanMovie); + + if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { + System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); + } + + moviesResponse.close(); + System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + } + +} \ No newline at end of file diff --git a/resteasy/src/test/resources/com/baeldung/server/movies/batman.json b/resteasy/src/test/resources/com/baeldung/server/movies/batman.json new file mode 100644 index 000000000000..82aaaa8f40ba --- /dev/null +++ b/resteasy/src/test/resources/com/baeldung/server/movies/batman.json @@ -0,0 +1,4 @@ +{ + "title": "Batman", + "imdbId": "tt0096895" +} \ No newline at end of file diff --git a/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json b/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json new file mode 100644 index 000000000000..634cefc73c99 --- /dev/null +++ b/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json @@ -0,0 +1,4 @@ +{ + "title": "Transformers", + "imdbId": "tt0418279" +} \ No newline at end of file From 6d9aee71bbbd62fe285f99f32e7bf8cb5a735638 Mon Sep 17 00:00:00 2001 From: Alex V Date: Thu, 18 Feb 2016 01:33:05 +0200 Subject: [PATCH 316/626] ExecutorService tutorial --- .../java8/Java8ExecutorServiceTest.java | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 core-java-8/src/test/java/com/baeldung/java8/Java8ExecutorServiceTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8ExecutorServiceTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8ExecutorServiceTest.java new file mode 100644 index 000000000000..1609ae98a4a7 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8ExecutorServiceTest.java @@ -0,0 +1,155 @@ +package com.baeldung.java8; + + +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; +import static org.junit.Assert.*; + + +public class Java8ExecutorServiceTest { + + private Runnable runnableTask; + private Callable callableTask; + private List> callableTasks; + + @Before + public void init() { + + runnableTask = () -> { + try { + TimeUnit.MILLISECONDS.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }; + + callableTask = () -> { + TimeUnit.MILLISECONDS.sleep(300); + return "Task's execution"; + }; + + callableTasks = new ArrayList<>(); + callableTasks.add(callableTask); + callableTasks.add(callableTask); + callableTasks.add(callableTask); + } + + @Test + public void creationSubmittingTaskShuttingDown_whenShutDown_thenCorrect() { + + ExecutorService executorService = Executors.newFixedThreadPool(10); + executorService.submit(runnableTask); + executorService.submit(callableTask); + executorService.shutdown(); + + assertTrue(executorService.isShutdown()); + } + + @Test + public void creationSubmittingTasksShuttingDownNow_whenShutDownAfterAwating_thenCorrect() { + + ExecutorService threadPoolExecutor = + new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>()); + + for (int i = 0; i < 100; i++) { + threadPoolExecutor.submit(callableTask); + } + + List notExecutedTasks = smartShutdown(threadPoolExecutor); + + assertTrue(threadPoolExecutor.isShutdown()); + assertFalse(notExecutedTasks.isEmpty()); + assertTrue(notExecutedTasks.size() > 0 && notExecutedTasks.size() < 98); + } + + private List smartShutdown(ExecutorService executorService) { + + List notExecutedTasks = new ArrayList<>(); + executorService.shutdown(); + try { + if (!executorService.awaitTermination(800, TimeUnit.MILLISECONDS)) { + notExecutedTasks = executorService.shutdownNow(); + } + } catch (InterruptedException e) { + notExecutedTasks = executorService.shutdownNow(); + } + return notExecutedTasks; + } + + @Test + public void submittingTasks_whenExecutedOneAndAll_thenCorrect() { + + ExecutorService executorService = Executors.newFixedThreadPool(10); + + String result = null; + List> futures = new ArrayList<>(); + try { + result = executorService.invokeAny(callableTasks); + futures = executorService.invokeAll(callableTasks); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + + assertEquals("Task's execution", result); + assertTrue(futures.size() == 3); + } + + @Test + public void submittingTaskShuttingDown_whenGetExpectedResult_thenCorrect() { + + ExecutorService executorService = Executors.newFixedThreadPool(10); + + Future future = executorService.submit(callableTask); + String result = null; + try { + result = future.get(); + result = future.get(200, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + } + + executorService.shutdown(); + + assertEquals("Task's execution", result); + } + + @Test + public void submittingTask_whenCanceled_thenCorrect() { + + ExecutorService executorService = Executors.newFixedThreadPool(10); + + Future future = executorService.submit(callableTask); + + boolean canceled = future.cancel(true); + boolean isCancelled = future.isCancelled(); + + executorService.shutdown(); + + assertTrue(canceled); + assertTrue(isCancelled); + } + + @Test + public void submittingTaskScheduling_whenExecuted_thenCorrect() { + + ScheduledExecutorService executorService = Executors + .newSingleThreadScheduledExecutor(); + + Future resultFuture = executorService.schedule(callableTask, 1, TimeUnit.SECONDS); + String result = null; + try { + result = resultFuture.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + + executorService.shutdown(); + + assertEquals("Task's execution", result); + } +} From e58f0b0e43182616c1d3b1124778b1f6dfea8cdf Mon Sep 17 00:00:00 2001 From: David Morley Date: Thu, 18 Feb 2016 07:21:46 -0600 Subject: [PATCH 317/626] Refactor package name to conform to standard --- json-path/pom.xml | 2 +- .../baeldung/jsonpath/introduction/ChangingPasswordTest.java | 2 +- .../baeldung/jsonpath/introduction/LoggingInTest.java | 2 +- .../baeldung/jsonpath/introduction/OperationTest.java | 2 +- .../baeldung/jsonpath/introduction/RegisteringAccountTest.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename json-path/src/test/java/{org => com}/baeldung/jsonpath/introduction/ChangingPasswordTest.java (98%) rename json-path/src/test/java/{org => com}/baeldung/jsonpath/introduction/LoggingInTest.java (97%) rename json-path/src/test/java/{org => com}/baeldung/jsonpath/introduction/OperationTest.java (98%) rename json-path/src/test/java/{org => com}/baeldung/jsonpath/introduction/RegisteringAccountTest.java (97%) diff --git a/json-path/pom.xml b/json-path/pom.xml index b51f59c41107..ca37447a50f7 100644 --- a/json-path/pom.xml +++ b/json-path/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - org.baeldung + com.baeldung json-path 0.0.1-SNAPSHOT json-path diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/ChangingPasswordTest.java similarity index 98% rename from json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java rename to json-path/src/test/java/com/baeldung/jsonpath/introduction/ChangingPasswordTest.java index 24f8500d3dea..9f616e1a325a 100644 --- a/json-path/src/test/java/org/baeldung/jsonpath/introduction/ChangingPasswordTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/ChangingPasswordTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jsonpath.introduction; +package com.baeldung.jsonpath.introduction; import static org.junit.Assert.*; diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/LoggingInTest.java similarity index 97% rename from json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java rename to json-path/src/test/java/com/baeldung/jsonpath/introduction/LoggingInTest.java index 1ab7dad88ec8..9f0be349c953 100644 --- a/json-path/src/test/java/org/baeldung/jsonpath/introduction/LoggingInTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/LoggingInTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jsonpath.introduction; +package com.baeldung.jsonpath.introduction; import static org.junit.Assert.*; diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationTest.java similarity index 98% rename from json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java rename to json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationTest.java index 9347a7f75499..d90fafb7cbd7 100644 --- a/json-path/src/test/java/org/baeldung/jsonpath/introduction/OperationTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jsonpath.introduction; +package com.baeldung.jsonpath.introduction; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; diff --git a/json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/RegisteringAccountTest.java similarity index 97% rename from json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java rename to json-path/src/test/java/com/baeldung/jsonpath/introduction/RegisteringAccountTest.java index 6e5cba63b0d3..04bb04528ab3 100644 --- a/json-path/src/test/java/org/baeldung/jsonpath/introduction/RegisteringAccountTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/RegisteringAccountTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jsonpath.introduction; +package com.baeldung.jsonpath.introduction; import static org.junit.Assert.*; From 54b0d4c0498a8e09405f3b3f23f9163c3fd2c3dd Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Thu, 18 Feb 2016 18:08:58 +0100 Subject: [PATCH 318/626] CleanUp --- .../src/main/java/com/baeldung/client/ServicesInterface.java | 2 +- .../src/test/java/com/baeldung/server/RestEasyClientTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java b/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java index 3d03c16fafd4..19ad0c1ec34c 100644 --- a/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java +++ b/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java @@ -31,6 +31,6 @@ public interface ServicesInterface { @DELETE @Path("/deletemovie") - Response deleteMovie(@QueryParam("imdbId") String imdbID); + Response deleteMovie(@QueryParam("imdbId") String imdbId); } diff --git a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java index 2a13465ebcd7..680affe042fa 100644 --- a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -102,7 +102,7 @@ public void testAddMovie() { } @Test - public void testDeleteMovi1e() { + public void testDeleteMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); From 66eb5d7270fc9d7eac0a13a0a76c6612bea2d713 Mon Sep 17 00:00:00 2001 From: sameira Date: Thu, 18 Feb 2016 22:48:42 +0530 Subject: [PATCH 319/626] Added publish subscribe example using redis --- spring-data-redis/pom.xml | 124 +++++++++--------- .../spring/data/redis/config/RedisConfig.java | 31 ++++- .../data/redis/queue/MessagePublisher.java | 7 + .../redis/queue/RedisMessagePublisher.java | 28 ++++ .../redis/queue/RedisMessageSubscriber.java | 19 +++ .../data/redis/repo/StudentRepository.java | 4 +- .../data/redis/RedisMessageListenerTest.java | 51 +++++++ 7 files changed, 198 insertions(+), 66 deletions(-) create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessageSubscriber.java create mode 100644 spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java diff --git a/spring-data-redis/pom.xml b/spring-data-redis/pom.xml index 98da69934c3f..3f9eb705f4c4 100644 --- a/spring-data-redis/pom.xml +++ b/spring-data-redis/pom.xml @@ -1,76 +1,76 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.baeldung - sprint-data-redis - 0.0.1-SNAPSHOT - jar + org.baeldung + sprint-data-redis + 0.0.1-SNAPSHOT + jar - - UTF-8 - 4.2.2.RELEASE - 1.6.2.RELEASE - 0.8.0 - + + UTF-8 + 4.2.2.RELEASE + 1.6.2.RELEASE + 0.8.0 + - - - org.springframework.data - spring-data-redis - ${spring-data-redis} - + + + org.springframework.data + spring-data-redis + ${spring-data-redis} + - - cglib - cglib-nodep - 2.2 - + + cglib + cglib-nodep + 2.2 + - - log4j - log4j - 1.2.16 - + + log4j + log4j + 1.2.16 + - - redis.clients - jedis - 2.5.1 - jar - + + redis.clients + jedis + 2.5.1 + jar + - - org.springframework - spring-core - ${spring.version} - + + org.springframework + spring-core + ${spring.version} + - - org.springframework - spring-context - ${spring.version} - + + org.springframework + spring-context + ${spring.version} + - - junit - junit - 4.12 - test - + + junit + junit + 4.12 + test + - - org.springframework - spring-test - ${spring.version} - test - + + org.springframework + spring-test + ${spring.version} + test + - - com.lordofthejars - nosqlunit-redis - ${nosqlunit.version} - + + com.lordofthejars + nosqlunit-redis + ${nosqlunit.version} + - + diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java index a7e75a438a75..0b64afe56cc9 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java @@ -1,10 +1,16 @@ package org.baeldung.spring.data.redis.config; +import org.baeldung.spring.data.redis.queue.RedisMessageSubscriber; +import org.baeldung.spring.data.redis.queue.RedisMessagePublisher; +import org.baeldung.spring.data.redis.queue.MessagePublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; @Configuration @ComponentScan("org.baeldung.spring.data.redis") @@ -17,8 +23,31 @@ JedisConnectionFactory jedisConnectionFactory() { @Bean public RedisTemplate redisTemplate() { - final RedisTemplate< String, Object> template = new RedisTemplate(); + final RedisTemplate template = new RedisTemplate(); template.setConnectionFactory(jedisConnectionFactory()); return template; } + + @Bean + MessageListenerAdapter messageListener() { + return new MessageListenerAdapter(new RedisMessageSubscriber()); + } + + @Bean + RedisMessageListenerContainer redisContainer() { + final RedisMessageListenerContainer container = new RedisMessageListenerContainer(); + container.setConnectionFactory(jedisConnectionFactory()); + container.addMessageListener(messageListener(), topic()); + return container; + } + + @Bean + MessagePublisher redisPublisher() { + return new RedisMessagePublisher(redisTemplate(), topic()); + } + + @Bean + ChannelTopic topic() { + return new ChannelTopic("pubsub:queue"); + } } diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java new file mode 100644 index 000000000000..a05f524f600c --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java @@ -0,0 +1,7 @@ +package org.baeldung.spring.data.redis.queue; + + +public interface MessagePublisher { + + void publish(String message); +} diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java new file mode 100644 index 000000000000..4eb7f69cdbda --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java @@ -0,0 +1,28 @@ +package org.baeldung.spring.data.redis.queue; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.stereotype.Service; + +@Service +public class RedisMessagePublisher implements MessagePublisher { + + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private ChannelTopic topic; + + public RedisMessagePublisher() { + } + + public RedisMessagePublisher(RedisTemplate redisTemplate, + ChannelTopic topic) { + this.redisTemplate = redisTemplate; + this.topic = topic; + } + + public void publish(String message) { + redisTemplate.convertAndSend(topic.getTopic(), message); + } +} diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessageSubscriber.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessageSubscriber.java new file mode 100644 index 000000000000..4bc60849fb66 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessageSubscriber.java @@ -0,0 +1,19 @@ +package org.baeldung.spring.data.redis.queue; + +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class RedisMessageSubscriber implements MessageListener { + + public static List messageList = new ArrayList(); + + public void onMessage(final Message message, final byte[] pattern) { + messageList.add(message.toString()); + System.out.println("Message received: " + message.toString()); + } +} \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java index 9e5502f8e0e7..2a1f6afcce20 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -1,15 +1,13 @@ package org.baeldung.spring.data.redis.repo; import org.baeldung.spring.data.redis.model.Student; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; import java.util.Map; public interface StudentRepository { void saveStudent(Student person); - + void updateStudent(Student student); Student findStudent(String id); diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java new file mode 100644 index 000000000000..7308424a9080 --- /dev/null +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java @@ -0,0 +1,51 @@ +package org.baeldung.spring.data.redis; + +import org.baeldung.spring.data.redis.config.RedisConfig; +import org.baeldung.spring.data.redis.queue.RedisMessageSubscriber; +import org.baeldung.spring.data.redis.queue.RedisMessagePublisher; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.UUID; + +import static org.junit.Assert.assertTrue; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = RedisConfig.class) +public class RedisMessageListenerTest { + + + @Autowired + private RedisMessagePublisher redisMessagePublisher; + + @Test + public void testOnMessage() throws Exception { + String message = "Message " + UUID.randomUUID(); + redisMessagePublisher.publish(message); + Thread.sleep(100); + assertTrue(RedisMessageSubscriber.messageList.get(0).contains(message)); + } + + public void testOnPMessage() throws Exception { + + } + + public void testOnSubscribe() throws Exception { + + } + + public void testOnUnsubscribe() throws Exception { + + } + + public void testOnPUnsubscribe() throws Exception { + + } + + public void testOnPSubscribe() throws Exception { + + } +} \ No newline at end of file From a304aa9860f60268bdbf33f2ff8fa428fd642f2f Mon Sep 17 00:00:00 2001 From: sameira Date: Thu, 18 Feb 2016 22:49:50 +0530 Subject: [PATCH 320/626] Refined the test case --- .../data/redis/RedisMessageListenerTest.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java index 7308424a9080..19612e0029f9 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java @@ -28,24 +28,4 @@ public void testOnMessage() throws Exception { Thread.sleep(100); assertTrue(RedisMessageSubscriber.messageList.get(0).contains(message)); } - - public void testOnPMessage() throws Exception { - - } - - public void testOnSubscribe() throws Exception { - - } - - public void testOnUnsubscribe() throws Exception { - - } - - public void testOnPUnsubscribe() throws Exception { - - } - - public void testOnPSubscribe() throws Exception { - - } } \ No newline at end of file From 2ccdd4ecbb16184a03ed095df8a020748b3a325b Mon Sep 17 00:00:00 2001 From: sameira Date: Thu, 18 Feb 2016 22:51:35 +0530 Subject: [PATCH 321/626] Refined the test case --- .../baeldung/spring/data/redis/queue/MessagePublisher.java | 2 +- .../spring/data/redis/queue/RedisMessagePublisher.java | 6 +++--- .../spring/data/redis/RedisMessageListenerTest.java | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java index a05f524f600c..e1f2e3d4b239 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/MessagePublisher.java @@ -3,5 +3,5 @@ public interface MessagePublisher { - void publish(String message); + void publish(final String message); } diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java index 4eb7f69cdbda..58e789daabf2 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/queue/RedisMessagePublisher.java @@ -16,13 +16,13 @@ public class RedisMessagePublisher implements MessagePublisher { public RedisMessagePublisher() { } - public RedisMessagePublisher(RedisTemplate redisTemplate, - ChannelTopic topic) { + public RedisMessagePublisher(final RedisTemplate redisTemplate, + final ChannelTopic topic) { this.redisTemplate = redisTemplate; this.topic = topic; } - public void publish(String message) { + public void publish(final String message) { redisTemplate.convertAndSend(topic.getTopic(), message); } } diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java index 19612e0029f9..f355e7f63ab6 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/RedisMessageListenerTest.java @@ -17,7 +17,6 @@ @ContextConfiguration(classes = RedisConfig.class) public class RedisMessageListenerTest { - @Autowired private RedisMessagePublisher redisMessagePublisher; From 54a1235d175827af25d7089f644549365fbb9ff9 Mon Sep 17 00:00:00 2001 From: David Morley Date: Thu, 18 Feb 2016 21:31:51 -0600 Subject: [PATCH 322/626] Clean up Apache Camel example --- spring-apache-camel/README.md | 4 +- .../baeldung}/camel/main/App.java | 22 +- .../camel/processor/FileProcessor.java | 14 ++ .../apache/camel/processor/FileProcessor.java | 14 -- .../src/main/resources/camel-context.xml | 49 ++--- .../src/test/data/sampleInputFile/file.txt | 2 +- .../java/org/apache/camel/main/AppTest.java | 206 +++++++++--------- 7 files changed, 155 insertions(+), 156 deletions(-) rename spring-apache-camel/src/main/java/{org/apache => com/baeldung}/camel/main/App.java (63%) create mode 100644 spring-apache-camel/src/main/java/com/baeldung/camel/processor/FileProcessor.java delete mode 100644 spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index 28b95bdf8975..f6ae77b2a5c2 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -23,6 +23,6 @@ To build this application execute following maven command in ApacheCamelFileProc mvn clean install -To run this application you can either run our main class org.apache.camel.main.App from your IDE or you can execute following maven command: +To run this application you can either run our main class App from your IDE or you can execute following maven command: -mvn exec:java -Dexec.mainClass="org.apache.camel.main.App" \ No newline at end of file +mvn exec:java -Dexec.mainClass="App" \ No newline at end of file diff --git a/spring-apache-camel/src/main/java/org/apache/camel/main/App.java b/spring-apache-camel/src/main/java/com/baeldung/camel/main/App.java similarity index 63% rename from spring-apache-camel/src/main/java/org/apache/camel/main/App.java rename to spring-apache-camel/src/main/java/com/baeldung/camel/main/App.java index 8674caefcae5..ac0605a215ea 100644 --- a/spring-apache-camel/src/main/java/org/apache/camel/main/App.java +++ b/spring-apache-camel/src/main/java/com/baeldung/camel/main/App.java @@ -1,12 +1,12 @@ -package org.apache.camel.main; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class App { - public static void main(final String[] args) throws Exception { - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml"); - // Keep main thread alive for some time to let application finish processing the input files. - Thread.sleep(5000); - applicationContext.close(); - } +package com.baeldung.camel.main; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class App { + public static void main(final String[] args) throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml"); + // Keep main thread alive for some time to let application finish processing the input files. + Thread.sleep(5000); + applicationContext.close(); + } } \ No newline at end of file diff --git a/spring-apache-camel/src/main/java/com/baeldung/camel/processor/FileProcessor.java b/spring-apache-camel/src/main/java/com/baeldung/camel/processor/FileProcessor.java new file mode 100644 index 000000000000..971dd206cd2d --- /dev/null +++ b/spring-apache-camel/src/main/java/com/baeldung/camel/processor/FileProcessor.java @@ -0,0 +1,14 @@ +package com.baeldung.camel.processor; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; + +public class FileProcessor implements Processor { + + public void process(Exchange exchange) throws Exception { + String originalFileContent = exchange.getIn().getBody(String.class); + String upperCaseFileContent = originalFileContent.toUpperCase(); + exchange.getIn().setBody(upperCaseFileContent); + } + +} diff --git a/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java b/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java deleted file mode 100644 index a98c77feb880..000000000000 --- a/spring-apache-camel/src/main/java/org/apache/camel/processor/FileProcessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.apache.camel.processor; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; - -public class FileProcessor implements Processor { - - public void process(Exchange exchange) throws Exception { - String originalFileContent = exchange.getIn().getBody(String.class); - String upperCaseFileContent = originalFileContent.toUpperCase(); - exchange.getIn().setBody(upperCaseFileContent); - } - -} diff --git a/spring-apache-camel/src/main/resources/camel-context.xml b/spring-apache-camel/src/main/resources/camel-context.xml index 75e2a61711a1..0c10e0ecef92 100644 --- a/spring-apache-camel/src/main/resources/camel-context.xml +++ b/spring-apache-camel/src/main/resources/camel-context.xml @@ -1,40 +1,39 @@ - + - + - - + + - - + + - - + + - - - ${body.toLowerCase()} - + + + ${body.toLowerCase()} + - - + + - - - .......... File content conversion completed .......... - - - + + + .......... File content conversion completed .......... + + - + - + - + \ No newline at end of file diff --git a/spring-apache-camel/src/test/data/sampleInputFile/file.txt b/spring-apache-camel/src/test/data/sampleInputFile/file.txt index c1df3791c931..e057427864d9 100644 --- a/spring-apache-camel/src/test/data/sampleInputFile/file.txt +++ b/spring-apache-camel/src/test/data/sampleInputFile/file.txt @@ -1 +1 @@ -THIS IS UPPERCASE CONTENT. this is lowercase content. \ No newline at end of file +This is data that will be processed by a Camel route! \ No newline at end of file diff --git a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java b/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java index 75a161d8cc18..87b20369f383 100644 --- a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java +++ b/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java @@ -1,5 +1,12 @@ package org.apache.camel.main; +import com.baeldung.camel.main.App; +import junit.framework.TestCase; +import org.apache.camel.util.FileUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -8,110 +15,103 @@ import java.nio.file.Files; import java.nio.file.Paths; -import junit.framework.TestCase; +public class AppTest extends TestCase { -import org.apache.camel.util.FileUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + private static final String FILE_NAME = "file.txt"; + private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/"; + private static final String TEST_INPUT_DIR = "src/test/data/input/"; + private static final String UPPERCASE_OUTPUT_DIR = "src/test/data/outputUpperCase/"; + private static final String LOWERCASE_OUTPUT_DIR = "src/test/data/outputLowerCase/"; -public class AppTest extends TestCase { + @Before + public void setUp() throws Exception { + // Prepare input file for test + copySampleFileToInputDirectory(); + } + + @After + public void tearDown() throws Exception { + System.out.println("Deleting the test input and output files..."); + deleteFile(TEST_INPUT_DIR); + deleteFile(LOWERCASE_OUTPUT_DIR); + deleteFile(UPPERCASE_OUTPUT_DIR); + } + + @Test + public final void testMain() throws Exception { + App.main(null); + + String inputFileContent = readFileContent(SAMPLE_INPUT_DIR + FILE_NAME); + String outputUpperCase = readFileContent(UPPERCASE_OUTPUT_DIR + FILE_NAME); + String outputLowerCase = readFileContent(LOWERCASE_OUTPUT_DIR + FILE_NAME); + + System.out.println("Input File content = [" + inputFileContent + "]"); + System.out.println("UpperCaseOutput file content = [" + outputUpperCase + "]"); + System.out.println("LowerCaseOtput file content = [" + outputLowerCase + "]"); + + assertEquals(inputFileContent.toUpperCase(), outputUpperCase); + assertEquals(inputFileContent.toLowerCase(), outputLowerCase); + } + + private String readFileContent(String path) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded); + } + + private void deleteFile(String path) { + try { + FileUtil.removeDir(new File(path)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Copy sample input file to input directory. + */ + private void copySampleFileToInputDirectory() { + File sourceFile = new File(SAMPLE_INPUT_DIR + FILE_NAME); + File destFile = new File(TEST_INPUT_DIR + FILE_NAME); + + if (!sourceFile.exists()) { + System.out.println("Sample input file not found at location = [" + SAMPLE_INPUT_DIR + FILE_NAME + "]. Please provide this file."); + } + + if (!destFile.exists()) { + try { + System.out.println("Creating input file = [" + TEST_INPUT_DIR + FILE_NAME + "]"); + + File destDir = new File(TEST_INPUT_DIR); + if (!destDir.exists()) { + destDir.mkdir(); + } + destFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + FileChannel source = null; + FileChannel destination = null; - private static final String FILE_NAME = "file.txt"; - private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/"; - private static final String TEST_INPUT_DIR = "src/test/data/input/"; - private static final String UPPERCARE_OUTPUT_DIR = "src/test/data/outputUpperCase/"; - private static final String LOWERCASE_OUTPUT_DIR = "src/test/data/outputLowerCase/"; - - @Before - public void setUp() throws Exception { - // Prepare input file for test - copySampleFileToInputDirectory(); - } - - @After - public void tearDown() throws Exception { - System.out.println("Deleting the test input and output files..."); - deleteFile(TEST_INPUT_DIR); - deleteFile(LOWERCASE_OUTPUT_DIR); - deleteFile(UPPERCARE_OUTPUT_DIR); - } - - @Test - public final void testMain() throws Exception { - App.main(null); - - String inputFileContent = readFileContent(SAMPLE_INPUT_DIR+FILE_NAME); - String outputUpperCase = readFileContent(UPPERCARE_OUTPUT_DIR+FILE_NAME); - String outputLowerCase = readFileContent(LOWERCASE_OUTPUT_DIR+FILE_NAME); - - System.out.println("Input File content = ["+inputFileContent+"]"); - System.out.println("UpperCaseOutput file content = ["+outputUpperCase+"]"); - System.out.println("LowerCaseOtput file content = ["+outputLowerCase+"]"); - - assertEquals(inputFileContent.toUpperCase(), outputUpperCase); - assertEquals(inputFileContent.toLowerCase(), outputLowerCase); - } - - private String readFileContent(String path) throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded); - } - - private void deleteFile(String path) { - try { - FileUtil.removeDir(new File(path)); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Copy sample input file to input directory. - */ - private void copySampleFileToInputDirectory() { - File sourceFile = new File(SAMPLE_INPUT_DIR + FILE_NAME); - File destFile = new File(TEST_INPUT_DIR + FILE_NAME); - - if (!sourceFile.exists()) { - System.out.println("Sample input file not found at location = [" + SAMPLE_INPUT_DIR + FILE_NAME + "]. Please provide this file."); - } - - if (!destFile.exists()) { - try { - System.out.println("Creating input file = [" + TEST_INPUT_DIR + FILE_NAME + "]"); - - File destDir = new File(TEST_INPUT_DIR); - if(!destDir.exists()) { - destDir.mkdir(); - } - destFile.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } - FileChannel source = null; - FileChannel destination = null; - - try { - source = new FileInputStream(sourceFile).getChannel(); - destination = new FileOutputStream(destFile).getChannel(); - if (destination != null && source != null) { - destination.transferFrom(source, 0, source.size()); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - source.close(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - destination.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + try { + source = new FileInputStream(sourceFile).getChannel(); + destination = new FileOutputStream(destFile).getChannel(); + if (destination != null && source != null) { + destination.transferFrom(source, 0, source.size()); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + source.close(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + destination.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } From 90853626d29edd3516e9d83bcd9726de36494054 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 19 Feb 2016 17:25:54 +0100 Subject: [PATCH 323/626] Add form tag example --- .../spring/controller/PersonController.java | 43 +++++----- .../java/org/baeldung/spring/form/Person.java | 22 ++++- .../spring/validator/PersonValidator.java | 22 +++++ .../main/webapp/WEB-INF/view/personForm.jsp | 15 +++- .../main/webapp/WEB-INF/view/personResume.jsp | 65 --------------- .../main/webapp/WEB-INF/view/personView.jsp | 80 +++++++++++++++++++ 6 files changed, 158 insertions(+), 89 deletions(-) create mode 100644 spring-mvc-xml/src/main/java/org/baeldung/spring/validator/PersonValidator.java delete mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp create mode 100644 spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java index d5b68c7516c2..0d89a29b9d5a 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/controller/PersonController.java @@ -8,6 +8,8 @@ import javax.validation.Valid; import org.baeldung.spring.form.Person; +import org.baeldung.spring.validator.PersonValidator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; @@ -20,6 +22,9 @@ @Controller public class PersonController { + @Autowired + PersonValidator validator; + @RequestMapping(value = "/person", method = RequestMethod.GET) public ModelAndView showForm(final Model model) { @@ -31,6 +36,8 @@ public ModelAndView showForm(final Model model) { public String submit(@Valid @ModelAttribute("person") final Person person, final BindingResult result, final ModelMap modelMap, final Model model) { + validator.validate(person, result); + if (result.hasErrors()) { initData(model); @@ -39,28 +46,28 @@ public String submit(@Valid @ModelAttribute("person") final Person person, final modelMap.addAttribute("person", person); - return "personResume"; + return "personView"; } private void initData(final Model model) { - final List favouriteLanguage = new ArrayList(); - favouriteLanguage.add("Java"); - favouriteLanguage.add("C++"); - favouriteLanguage.add("Perl"); - model.addAttribute("favouriteLanguage", favouriteLanguage); - - final List job = new ArrayList(); - job.add("Full time"); - job.add("Part time"); - model.addAttribute("job", job); - - final Map country = new LinkedHashMap(); - country.put("US", "United Stated"); - country.put("IT", "Italy"); - country.put("UK", "United Kingdom"); - country.put("FR", "Grance"); - model.addAttribute("country", country); + final List favouriteLanguageItem = new ArrayList(); + favouriteLanguageItem.add("Java"); + favouriteLanguageItem.add("C++"); + favouriteLanguageItem.add("Perl"); + model.addAttribute("favouriteLanguageItem", favouriteLanguageItem); + + final List jobItem = new ArrayList(); + jobItem.add("Full time"); + jobItem.add("Part time"); + model.addAttribute("jobItem", jobItem); + + final Map countryItems = new LinkedHashMap(); + countryItems.put("US", "United Stated"); + countryItems.put("IT", "Italy"); + countryItems.put("UK", "United Kingdom"); + countryItems.put("FR", "Grance"); + model.addAttribute("countryItems", countryItems); final List fruit = new ArrayList(); fruit.add("Banana"); diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java index 3db8cc4377cf..bf313b4d7d4a 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/form/Person.java @@ -9,8 +9,9 @@ public class Person { private long id; - @NotEmpty private String name; + private String email; + private String dateOfBirth; @NotEmpty private String password; @@ -18,7 +19,7 @@ public class Person { private String country; private String book; private String job; - boolean receiveNewsletter; + private boolean receiveNewsletter; private String[] hobbies; private List favouriteLanguage; private List fruit; @@ -45,6 +46,22 @@ public void setName(final String name) { this.name = name; } + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(final String dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + public String getPassword() { return password; } @@ -132,5 +149,4 @@ public MultipartFile getFile() { public void setFile(final MultipartFile file) { this.file = file; } - } diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/validator/PersonValidator.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/validator/PersonValidator.java new file mode 100644 index 000000000000..068a9fee7f90 --- /dev/null +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/validator/PersonValidator.java @@ -0,0 +1,22 @@ +package org.baeldung.spring.validator; + +import org.baeldung.spring.form.Person; +import org.springframework.stereotype.Component; +import org.springframework.validation.Errors; +import org.springframework.validation.ValidationUtils; +import org.springframework.validation.Validator; + +@Component +public class PersonValidator implements Validator { + + @Override + public boolean supports(final Class calzz) { + return Person.class.isAssignableFrom(calzz); + } + + @Override + public void validate(final Object obj, final Errors errors) { + + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required.name"); + } +} \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp index 9ef02efbae59..9b0a78899cde 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp @@ -28,6 +28,15 @@ + + E-mail + + + + + Date of birth + + Password @@ -43,13 +52,13 @@ Job - + Country - + @@ -82,7 +91,7 @@ Favourite languages - + diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp deleted file mode 100644 index 857738c54584..000000000000 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personResume.jsp +++ /dev/null @@ -1,65 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - -Spring MVC Form Handling - - - -

Submitted Person Information

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Id :${person.id}
Name :${person.name}
Password :${person.password}
Sex :${person.sex}
Job :${person.job}
Country :${person.country}
Fruit :[]
Book :${person.book}
Receive Newsletter :${person.receiveNewsletter}
Hobbies :[]
Favourite Languages :[]
Notes :${person.notes}
File :${person.file.originalFilename}
- - \ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp new file mode 100644 index 000000000000..8893314d2067 --- /dev/null +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp @@ -0,0 +1,80 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + Spring MVC Form Handling + + + +

Submitted Person Information

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id :${person.id}
Name :${person.name}
Date of birth :${person.dateOfBirth}
Password :${person.password}
Sex :${person.sex}
Job :${person.job}
Country :${person.country}
Fruit :[]
Book :${person.book}
Receive Newsletter :${person.receiveNewsletter}
Hobbies :[]
Favourite Languages :[]
Notes :${person.notes}
+ +

Submitted File

+ + + + + + + + + + + + +
OriginalFileName :${person.file.originalFilename}
Type :${person.file.contentType}
+ + \ No newline at end of file From 2f1270d047690d6a58b5a2073bea24c062db0427 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Fri, 19 Feb 2016 19:50:19 +0100 Subject: [PATCH 324/626] HttpClient with Connection Pool --- .../baeldung/server/RestEasyClientTest.java | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java index 680affe042fa..9a292bf3c361 100644 --- a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -3,11 +3,15 @@ import com.baeldung.client.ServicesInterface; import com.baeldung.model.Movie; import org.apache.commons.io.IOUtils; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; +import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; import org.junit.Before; import org.junit.Test; import javax.naming.NamingException; @@ -21,6 +25,7 @@ public class RestEasyClientTest { + public static final UriBuilder FULL_PATH = UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"); Movie transformerMovie = null; Movie batmanMovie = null; ObjectMapper jsonMapper = null; @@ -54,7 +59,7 @@ public void setup() throws ClassNotFoundException, IllegalAccessException, Insta public void testListAllMovies() { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ResteasyWebTarget target = client.target(FULL_PATH); ServicesInterface simple = target.proxy(ServicesInterface.class); Response moviesResponse = simple.addMovie(transformerMovie); @@ -72,7 +77,7 @@ public void testMovieByImdbId() { String transformerImdbId = "tt0418279"; ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ResteasyWebTarget target = client.target(FULL_PATH); ServicesInterface simple = target.proxy(ServicesInterface.class); Response moviesResponse = simple.addMovie(transformerMovie); @@ -86,7 +91,7 @@ public void testMovieByImdbId() { public void testAddMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ResteasyWebTarget target = client.target(FULL_PATH); ServicesInterface simple = target.proxy(ServicesInterface.class); Response moviesResponse = simple.addMovie(batmanMovie); @@ -98,14 +103,44 @@ public void testAddMovie() { } moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + moviesResponse.getStatus()); + } + + @Test + public void testAddMovieMultiConnection() { + + PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); + CloseableHttpClient httpClient = HttpClients.custom() + .setConnectionManager(cm) + .build(); + ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient); + ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build(); + ResteasyWebTarget target = client.target(FULL_PATH); + ServicesInterface simple = target.proxy(ServicesInterface.class); + + Response batmanResponse = simple.addMovie(batmanMovie); + Response transformerResponse = simple.addMovie(transformerMovie); + + if (batmanResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Batman Movie creation Failed : HTTP error code : " + batmanResponse.getStatus()); + } + if (batmanResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { + System.out.println("Batman Movie creation Failed : HTTP error code : " + batmanResponse.getStatus()); + } + + batmanResponse.close(); + transformerResponse.close(); + cm.close(); + + + } @Test public void testDeleteMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ResteasyWebTarget target = client.target(FULL_PATH); ServicesInterface simple = target.proxy(ServicesInterface.class); Response moviesResponse = simple.addMovie(batmanMovie); @@ -118,14 +153,14 @@ public void testDeleteMovie() { } moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + moviesResponse.getStatus()); } @Test public void testUpdateMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest")); + ResteasyWebTarget target = client.target(FULL_PATH); ServicesInterface simple = target.proxy(ServicesInterface.class); Response moviesResponse = simple.addMovie(batmanMovie); @@ -138,7 +173,7 @@ public void testUpdateMovie() { } moviesResponse.close(); - System.out.println("Response Code: " + Response.Status.OK.getStatusCode()); + System.out.println("Response Code: " + moviesResponse.getStatus()); } } \ No newline at end of file From e00f62fb033e312e4a63bb17a971984583c32d42 Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Fri, 19 Feb 2016 20:04:06 +0100 Subject: [PATCH 325/626] cleanUp --- .../baeldung/server/RestEasyClientTest.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java index 9a292bf3c361..ef18b0f23fdd 100644 --- a/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java +++ b/resteasy/src/test/java/com/baeldung/server/RestEasyClientTest.java @@ -60,14 +60,14 @@ public void testListAllMovies() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); + Response moviesResponse = proxy.addMovie(transformerMovie); moviesResponse.close(); - moviesResponse = simple.addMovie(batmanMovie); + moviesResponse = proxy.addMovie(batmanMovie); moviesResponse.close(); - List movies = simple.listMovies(); + List movies = proxy.listMovies(); System.out.println(movies); } @@ -78,12 +78,12 @@ public void testMovieByImdbId() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(transformerMovie); + Response moviesResponse = proxy.addMovie(transformerMovie); moviesResponse.close(); - Movie movies = simple.movieByImdbId(transformerImdbId); + Movie movies = proxy.movieByImdbId(transformerImdbId); System.out.println(movies); } @@ -92,11 +92,11 @@ public void testAddMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(batmanMovie); + Response moviesResponse = proxy.addMovie(batmanMovie); moviesResponse.close(); - moviesResponse = simple.addMovie(transformerMovie); + moviesResponse = proxy.addMovie(transformerMovie); if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); @@ -116,10 +116,10 @@ public void testAddMovieMultiConnection() { ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient); ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response batmanResponse = simple.addMovie(batmanMovie); - Response transformerResponse = simple.addMovie(transformerMovie); + Response batmanResponse = proxy.addMovie(batmanMovie); + Response transformerResponse = proxy.addMovie(transformerMovie); if (batmanResponse.getStatus() != Response.Status.CREATED.getStatusCode()) { System.out.println("Batman Movie creation Failed : HTTP error code : " + batmanResponse.getStatus()); @@ -141,11 +141,11 @@ public void testDeleteMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(batmanMovie); + Response moviesResponse = proxy.addMovie(batmanMovie); moviesResponse.close(); - moviesResponse = simple.deleteMovie(batmanMovie.getImdbId()); + moviesResponse = proxy.deleteMovie(batmanMovie.getImdbId()); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { System.out.println(moviesResponse.readEntity(String.class)); @@ -161,12 +161,12 @@ public void testUpdateMovie() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(FULL_PATH); - ServicesInterface simple = target.proxy(ServicesInterface.class); + ServicesInterface proxy = target.proxy(ServicesInterface.class); - Response moviesResponse = simple.addMovie(batmanMovie); + Response moviesResponse = proxy.addMovie(batmanMovie); moviesResponse.close(); batmanMovie.setTitle("Batman Begins"); - moviesResponse = simple.updateMovie(batmanMovie); + moviesResponse = proxy.updateMovie(batmanMovie); if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) { System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus()); From 95bc7e515d37107a12b9d3e6b1f792bd15889ecb Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 19 Feb 2016 22:12:57 +0200 Subject: [PATCH 326/626] oauth multiple resources authorization --- .../config/OAuth2ResourceServerConfig.java | 26 +++++++--- .../web/controller/BarController.java | 41 +++++++++++++++ .../web/controller/FooController.java | 16 +++++- .../main/java/org/baeldung/web/dto/Bar.java | 36 +++++++++++++ .../OAuth2AuthorizationServerConfig.java | 6 +-- .../baeldung/config/ServerSecurityConfig.java | 3 +- .../.project | 6 +-- .../src/main/resources/templates/header.html | 50 +++++++++++++++++-- .../src/main/resources/templates/index.html | 40 ++++++++++++--- 9 files changed, 198 insertions(+), 26 deletions(-) create mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java create mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Bar.java diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java index c5e33739ae39..52bfeb42330a 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java @@ -7,12 +7,13 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; +import org.springframework.http.HttpMethod; import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; -import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler; +import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; import org.springframework.security.oauth2.provider.token.TokenStore; import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore; @@ -20,14 +21,25 @@ @PropertySource({ "classpath:persistence.properties" }) @EnableResourceServer @EnableGlobalMethodSecurity(prePostEnabled = true) -public class OAuth2ResourceServerConfig extends GlobalMethodSecurityConfiguration { - +public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter { @Autowired private Environment env; @Override - protected MethodSecurityExpressionHandler createExpressionHandler() { - return new OAuth2MethodSecurityExpressionHandler(); + public void configure(HttpSecurity http) throws Exception { + // @formatter:off + http + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) + .and() + .requestMatchers().antMatchers("/foos/**","/bars/**") + .and() + .authorizeRequests() + .antMatchers(HttpMethod.GET,"/foos/**").access("#oauth2.hasScope('read')") + .antMatchers(HttpMethod.POST,"/foos/**").access("#oauth2.hasScope('write')") + .antMatchers(HttpMethod.GET,"/bars/**").access("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") + .antMatchers(HttpMethod.POST,"/bars/**").access("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") + ; + // @formatter:on } @Bean diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java new file mode 100644 index 000000000000..a716635f6d1c --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java @@ -0,0 +1,41 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import org.baeldung.web.dto.Bar; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +@Controller +public class BarController { + + public BarController() { + super(); + } + + // API - read + // @PreAuthorize("#oauth2.hasScope('read')") + @RequestMapping(method = RequestMethod.GET, value = "/bars/{id}") + @ResponseBody + public Bar findById(@PathVariable final long id) { + return new Bar(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); + } + + // API - write + // @PreAuthorize("#oauth2.hasScope('write')") + @RequestMapping(method = RequestMethod.POST, value = "/bars") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + public Bar create(@RequestBody final Bar bar) { + bar.setId(Long.parseLong(randomNumeric(2))); + return bar; + } + +} diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java index 8dfa19bd8487..a1275670f09e 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java @@ -4,12 +4,14 @@ import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import org.baeldung.web.dto.Foo; -import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; @Controller public class FooController { @@ -19,11 +21,21 @@ public FooController() { } // API - read - @PreAuthorize("#oauth2.hasScope('read')") + // @PreAuthorize("#oauth2.hasScope('read')") @RequestMapping(method = RequestMethod.GET, value = "/foos/{id}") @ResponseBody public Foo findById(@PathVariable final long id) { return new Foo(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); } + // API - write + // @PreAuthorize("#oauth2.hasScope('write')") + @RequestMapping(method = RequestMethod.POST, value = "/foos") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + public Foo create(@RequestBody final Foo foo) { + foo.setId(Long.parseLong(randomNumeric(2))); + return foo; + } + } diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Bar.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Bar.java new file mode 100644 index 000000000000..adbb2aa2ad21 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Bar.java @@ -0,0 +1,36 @@ +package org.baeldung.web.dto; + +public class Bar { + private long id; + private String name; + + public Bar() { + super(); + } + + public Bar(final long id, final String name) { + super(); + + this.id = id; + this.name = name; + } + + // + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java index c2f6ca41aefa..a0f8baa4bc32 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java @@ -47,10 +47,10 @@ public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws public void configure(ClientDetailsServiceConfigurer clients) throws Exception { // @formatter:off clients.jdbc(dataSource()) - .withClient("clientId") + .withClient("sampleClientId") .authorizedGrantTypes("implicit") - .scopes("read") - .autoApprove(true) + .scopes("read","write") + .autoApprove(false) .and() .withClient("clientIdPassword") .secret("secret") diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java index 3e1a8a8ccb02..46870f3fc3bb 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java @@ -12,8 +12,7 @@ public class ServerSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication().withUser("john").password("123").roles("USER"); - + auth.inMemoryAuthentication().withUser("john").password("123").roles("USER").and().withUser("tom").password("111").roles("ADMIN"); } @Override diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/.project b/spring-security-oauth/spring-security-oauth-ui-implicit/.project index c9fc2aa8f0e1..b96a26c60dd6 100644 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/.project +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/.project @@ -26,17 +26,17 @@ - org.eclipse.m2e.core.maven2Builder + org.springframework.ide.eclipse.core.springbuilder - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html index a62bce9747db..8cd7be67c396 100644 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html @@ -11,9 +11,9 @@ @@ -34,9 +34,21 @@ }).hashPrefix('!'); }); +app.config(['$httpProvider', function ($httpProvider) { + $httpProvider.interceptors.push(function ($q,$rootScope) { + return { + 'responseError': function (responseError) { + $rootScope.message = responseError.statusText; + console.log("error here"); + console.log(responseError); + return $q.reject(responseError); + } + }; + }); +}]); -app.controller('mainCtrl', function($scope,$resource,$http) { +app.controller('mainCtrl', function($scope,$resource,$http,$rootScope) { $scope.$on('oauth:login', function(event, token) { $http.defaults.headers.common.Authorization= 'Bearer ' + token.access_token; @@ -49,6 +61,38 @@ $scope.getFoo = function(){ $scope.foo = $scope.foos.get({fooId:$scope.foo.id}); } + + $scope.createFoo = function(){ + if($scope.foo.name.length==0) + { + $rootScope.message = "Foo name can not be empty"; + return; + } + $scope.foo.id = null; + $scope.foo = $scope.foos.save($scope.foo, function(){ + $rootScope.message = "Foo Created Successfully"; + }); + } + + // bar + $scope.bar = {id:0 , name:"sample bar"}; + $scope.bars = $resource("http://localhost:8081/spring-security-oauth-resource/bars/:barId",{barId:'@id'}); + + $scope.getBar = function(){ + $scope.bar = $scope.bars.get({barId:$scope.bar.id}); + } + + $scope.createBar = function(){ + if($scope.bar.name.length==0) + { + $rootScope.message = "Bar name can not be empty"; + return; + } + $scope.bar.id = null; + $scope.bar = $scope.bars.save($scope.bar, function(){ + $rootScope.message = "Bar Created Successfully"; + }); + } }); /*]]>*/ diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html index c98ed493bd86..c50781caf160 100755 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html @@ -10,19 +10,47 @@
-

Foo Details

+
{{message}}
+

Foo Details

+
- - {{foo.id}} + +
- -{{foo.name}} + +
+
+ +
+
+
+
+
+

Bar Details

+
+
+ + +
+ +
+ + +
+ + +
From f8258e92210dbd61dae5aeb010360dff577c77f7 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 21 Feb 2016 12:58:42 +0200 Subject: [PATCH 327/626] oauth2 live test --- .../baeldung/config/MethodSecurityConfig.java | 16 ++++++ .../config/OAuth2ResourceServerConfig.java | 2 - .../web/controller/BarController.java | 4 +- .../OAuth2AuthorizationServerConfig.java | 2 +- .../spring-security-oauth-ui-password/pom.xml | 40 +++++++++++++ .../baeldung/live/AuthorizationLiveTest.java | 57 +++++++++++++++++++ 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/MethodSecurityConfig.java create mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/MethodSecurityConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/MethodSecurityConfig.java new file mode 100644 index 000000000000..c0a7f86207bd --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/MethodSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; +import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler; + +@Configuration +@EnableGlobalMethodSecurity(prePostEnabled = true) +public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration { + @Override + protected MethodSecurityExpressionHandler createExpressionHandler() { + return new OAuth2MethodSecurityExpressionHandler(); + } +} \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java index 52bfeb42330a..c2db6748f16c 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java @@ -9,7 +9,6 @@ import org.springframework.core.env.Environment; import org.springframework.http.HttpMethod; import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; @@ -20,7 +19,6 @@ @Configuration @PropertySource({ "classpath:persistence.properties" }) @EnableResourceServer -@EnableGlobalMethodSecurity(prePostEnabled = true) public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter { @Autowired private Environment env; diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java index a716635f6d1c..1f42f9dafd35 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java @@ -21,7 +21,7 @@ public BarController() { } // API - read - // @PreAuthorize("#oauth2.hasScope('read')") + // @PreAuthorize("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") @RequestMapping(method = RequestMethod.GET, value = "/bars/{id}") @ResponseBody public Bar findById(@PathVariable final long id) { @@ -29,7 +29,7 @@ public Bar findById(@PathVariable final long id) { } // API - write - // @PreAuthorize("#oauth2.hasScope('write')") + // @PreAuthorize("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") @RequestMapping(method = RequestMethod.POST, value = "/bars") @ResponseStatus(HttpStatus.CREATED) @ResponseBody diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java index a0f8baa4bc32..caae7760d3d7 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java @@ -55,7 +55,7 @@ public void configure(ClientDetailsServiceConfigurer clients) throws Exception { .withClient("clientIdPassword") .secret("secret") .authorizedGrantTypes("password","authorization_code", "refresh_token") - .scopes("read"); + .scopes("read","write"); // @formatter:on } diff --git a/spring-security-oauth/spring-security-oauth-ui-password/pom.xml b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml index a2bf3d07bb7c..4a42081f787e 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/pom.xml +++ b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml @@ -22,8 +22,48 @@ org.springframework.boot spring-boot-starter-thymeleaf + + + + + + org.springframework + spring-test + test + + + + junit + junit + test + + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + com.jayway.restassured + rest-assured + ${rest-assured.version} + test + + + commons-logging + commons-logging + + + + spring-security-oauth-ui-password diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java new file mode 100644 index 000000000000..456245daffe1 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java @@ -0,0 +1,57 @@ +package org.baeldung.live; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import com.jayway.restassured.RestAssured; +import com.jayway.restassured.response.Response; + +public class AuthorizationLiveTest { + + private String obtainAccessToken(String username, String password) { + final Map params = new HashMap(); + params.put("grant_type", "password"); + params.put("client_id", "clientIdPassword"); + params.put("username", username); + params.put("password", password); + final Response response = RestAssured.given().auth().preemptive().basic("clientIdPassword", "secret").and().with().params(params).when().post("http://localhost:8081/spring-security-oauth-server/oauth/token"); + return response.jsonPath().getString("access_token"); + } + + @Test + public void givenUser_whenAccessFoosResource_thenOk() { + final String accessToken = obtainAccessToken("john", "123"); + final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(200, response.getStatusCode()); + assertNotNull(response.jsonPath().get("name")); + } + + @Test + public void givenUser_whenAccessBarssResource_thenUnauthorized() { + final String accessToken = obtainAccessToken("john", "123"); + final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(403, response.getStatusCode()); + } + + @Test + public void givenAdmin_whenAccessFoosResource_thenOk() { + final String accessToken = obtainAccessToken("tom", "111"); + final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(200, response.getStatusCode()); + assertNotNull(response.jsonPath().get("name")); + } + + @Test + public void givenAdmin_whenAccessBarssResource_thenOk() { + final String accessToken = obtainAccessToken("tom", "111"); + final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(200, response.getStatusCode()); + assertNotNull(response.jsonPath().get("name")); + } + +} From 04f794a255506f6f2ef0018f6957cbee15889eae Mon Sep 17 00:00:00 2001 From: joetaras Date: Sun, 21 Feb 2016 20:03:37 +0100 Subject: [PATCH 328/626] zip and unzip --- .../java/com/baeldung/unzip/UnzipFile.java | 31 +++++++++++++++++++ .../main/java/com/baeldung/zip/ZipFile.java | 29 +++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 core-java-8/src/main/java/com/baeldung/unzip/UnzipFile.java create mode 100644 core-java-8/src/main/java/com/baeldung/zip/ZipFile.java diff --git a/core-java-8/src/main/java/com/baeldung/unzip/UnzipFile.java b/core-java-8/src/main/java/com/baeldung/unzip/UnzipFile.java new file mode 100644 index 000000000000..d0b4274731a7 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/unzip/UnzipFile.java @@ -0,0 +1,31 @@ +package com.baeldung.unzip; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +public class UnzipFile { + public static void main(String[] args) throws FileNotFoundException, IOException { + String fileZip = "/opt/zipped/cities.zip"; + byte[] buffer = new byte[1024]; + ZipInputStream zis = new ZipInputStream(new FileInputStream(fileZip)); + ZipEntry zipEntry = zis.getNextEntry(); + while(zipEntry != null){ + String fileName = zipEntry.getName(); + File newFile = new File("/opt/unzipped/" + fileName); + FileOutputStream fos = new FileOutputStream(newFile); + int len; + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + fos.close(); + zipEntry = zis.getNextEntry(); + } + zis.closeEntry(); + zis.close(); + } +} \ No newline at end of file diff --git a/core-java-8/src/main/java/com/baeldung/zip/ZipFile.java b/core-java-8/src/main/java/com/baeldung/zip/ZipFile.java new file mode 100644 index 000000000000..dccd3f2347b9 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/zip/ZipFile.java @@ -0,0 +1,29 @@ +package com.baeldung.zip; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipFile { + public static void main(String[] args) throws FileNotFoundException, IOException { + String sourceFile = "/opt/photos/photo.png"; + FileOutputStream fos = new FileOutputStream("/opt/zipped/cities.zip"); + ZipOutputStream zipOut = new ZipOutputStream(fos); + File fileToZip = new File(sourceFile); + FileInputStream fis = new FileInputStream(fileToZip); + ZipEntry zipEntry = new ZipEntry(fileToZip.getName()); + zipOut.putNextEntry(zipEntry); + byte[] bytes = new byte[1024]; + int length; + while((length = fis.read(bytes)) >= 0) { + zipOut.write(bytes, 0, length); + } + zipOut.close(); + fis.close(); + fos.close(); + } +} \ No newline at end of file From 87392e16b6dfbe2a16a4733a42e1611c7a0c5172 Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 23 Feb 2016 21:44:57 +0200 Subject: [PATCH 329/626] modify oauth scopes --- .../config/OAuth2ResourceServerConfig.java | 12 +-- .../web/controller/BarController.java | 4 +- .../web/controller/BazController.java | 41 ++++++++++ .../web/controller/FooController.java | 4 +- .../main/java/org/baeldung/web/dto/Baz.java | 36 +++++++++ .../OAuth2AuthorizationServerConfig.java | 12 ++- .../src/main/resources/templates/header.html | 22 +++++- .../src/main/resources/templates/index.html | 23 ++++++ .../src/main/resources/templates/header.html | 4 +- .../baeldung/live/AuthorizationLiveTest.java | 75 +++++++++++++------ 10 files changed, 196 insertions(+), 37 deletions(-) create mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java create mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java index c2db6748f16c..8fe4cda6a1f5 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java @@ -29,13 +29,15 @@ public void configure(HttpSecurity http) throws Exception { http .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) .and() - .requestMatchers().antMatchers("/foos/**","/bars/**") + .requestMatchers().antMatchers("/foos/**","/bars/**","/bazes/**") .and() .authorizeRequests() - .antMatchers(HttpMethod.GET,"/foos/**").access("#oauth2.hasScope('read')") - .antMatchers(HttpMethod.POST,"/foos/**").access("#oauth2.hasScope('write')") - .antMatchers(HttpMethod.GET,"/bars/**").access("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") - .antMatchers(HttpMethod.POST,"/bars/**").access("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") + .antMatchers(HttpMethod.GET,"/foos/**").access("#oauth2.hasScope('foo') and #oauth2.hasScope('read')") + .antMatchers(HttpMethod.POST,"/foos/**").access("#oauth2.hasScope('foo') and #oauth2.hasScope('write')") + .antMatchers(HttpMethod.GET,"/bars/**").access("#oauth2.hasScope('bar') and #oauth2.hasScope('read')") + .antMatchers(HttpMethod.POST,"/bars/**").access("#oauth2.hasScope('bar') and #oauth2.hasScope('write')") + .antMatchers(HttpMethod.GET,"/bazes/**").access("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") + .antMatchers(HttpMethod.POST,"/bazes/**").access("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") ; // @formatter:on } diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java index 1f42f9dafd35..938cf18129a4 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java @@ -21,7 +21,7 @@ public BarController() { } // API - read - // @PreAuthorize("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") + // @PreAuthorize("#oauth2.hasScope('bar') and #oauth2.hasScope('read')") @RequestMapping(method = RequestMethod.GET, value = "/bars/{id}") @ResponseBody public Bar findById(@PathVariable final long id) { @@ -29,7 +29,7 @@ public Bar findById(@PathVariable final long id) { } // API - write - // @PreAuthorize("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") + // @PreAuthorize("#oauth2.hasScope('bar') and #oauth2.hasScope('write')") @RequestMapping(method = RequestMethod.POST, value = "/bars") @ResponseStatus(HttpStatus.CREATED) @ResponseBody diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java new file mode 100644 index 000000000000..880f41de0783 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java @@ -0,0 +1,41 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import org.baeldung.web.dto.Baz; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +@Controller +public class BazController { + + public BazController() { + super(); + } + + // API - read + // @PreAuthorize("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") + @RequestMapping(method = RequestMethod.GET, value = "/bazes/{id}") + @ResponseBody + public Baz findById(@PathVariable final long id) { + return new Baz(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); + } + + // API - write + // @PreAuthorize("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") + @RequestMapping(method = RequestMethod.POST, value = "/bazes") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + public Baz create(@RequestBody final Baz baz) { + baz.setId(Long.parseLong(randomNumeric(2))); + return baz; + } + +} diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java index a1275670f09e..d9ef1baa317d 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/FooController.java @@ -21,7 +21,7 @@ public FooController() { } // API - read - // @PreAuthorize("#oauth2.hasScope('read')") + // @PreAuthorize("#oauth2.hasScope('foo') and #oauth2.hasScope('read')") @RequestMapping(method = RequestMethod.GET, value = "/foos/{id}") @ResponseBody public Foo findById(@PathVariable final long id) { @@ -29,7 +29,7 @@ public Foo findById(@PathVariable final long id) { } // API - write - // @PreAuthorize("#oauth2.hasScope('write')") + // @PreAuthorize("#oauth2.hasScope('foo') and #oauth2.hasScope('write')") @RequestMapping(method = RequestMethod.POST, value = "/foos") @ResponseStatus(HttpStatus.CREATED) @ResponseBody diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java new file mode 100644 index 000000000000..69a6bf2e6a50 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java @@ -0,0 +1,36 @@ +package org.baeldung.web.dto; + +public class Baz { + private long id; + private String name; + + public Baz() { + super(); + } + + public Baz(final long id, final String name) { + super(); + + this.id = id; + this.name = name; + } + + // + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java index caae7760d3d7..c7c90d177a63 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfig.java @@ -49,13 +49,19 @@ public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.jdbc(dataSource()) .withClient("sampleClientId") .authorizedGrantTypes("implicit") - .scopes("read","write") + .scopes("read","write","foo","bar") .autoApprove(false) .and() - .withClient("clientIdPassword") + .withClient("fooClientIdPassword") .secret("secret") .authorizedGrantTypes("password","authorization_code", "refresh_token") - .scopes("read","write"); + .scopes("foo","read","write") + .and() + .withClient("barClientIdPassword") + .secret("secret") + .authorizedGrantTypes("password","authorization_code", "refresh_token") + .scopes("bar","read","write") + ; // @formatter:on } diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html index 8cd7be67c396..d3cf521c0a12 100644 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html @@ -13,7 +13,7 @@ site="http://localhost:8081/spring-security-oauth-server" client-id="sampleClientId" redirect-uri="http://localhost:8081/spring-security-oauth-ui-implicit/" - scope="read write" + scope="read write foo bar" template="oauthTemp"> @@ -94,6 +94,26 @@ }); } + // baz + $scope.baz = {id:0 , name:"sample baz"}; + $scope.bazes = $resource("http://localhost:8081/spring-security-oauth-resource/bazes/:bazId",{bazId:'@id'}); + + $scope.getBaz = function(){ + $scope.baz = $scope.bazes.get({bazId:$scope.baz.id}); + } + + $scope.createBaz = function(){ + if($scope.baz.name.length==0) + { + $rootScope.message = "Baz name can not be empty"; + return; + } + $scope.baz.id = null; + $scope.baz = $scope.bazes.save($scope.baz, function(){ + $rootScope.message = "Baz Created Successfully"; + }); + } + }); /*]]>*/ diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html index c50781caf160..0b4c7563ce84 100755 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html @@ -50,8 +50,31 @@

Bar Details

Get Bar Create Bar + +
+
+
+
+
+

Baz Details

+
+
+ + +
+
+ +
+ + +
+ + \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html index 0bfe086bf11b..cafba4eb655d 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html @@ -28,8 +28,8 @@ $scope.foo = $scope.foos.get({fooId:$scope.foo.id}); } - $scope.data = {grant_type:"password", username: "", password: "", client_id: "clientIdPassword"}; - $scope.encoded = btoa("clientIdPassword:secret"); + $scope.data = {grant_type:"password", username: "", password: "", client_id: "fooClientIdPassword"}; + $scope.encoded = btoa("fooClientIdPassword:secret"); var isLoginPage = window.location.href.indexOf("login") != -1; if(isLoginPage){ diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java index 456245daffe1..5827be548b76 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java @@ -13,45 +13,76 @@ public class AuthorizationLiveTest { - private String obtainAccessToken(String username, String password) { + private String obtainAccessToken(String clientId, String username, String password) { final Map params = new HashMap(); params.put("grant_type", "password"); - params.put("client_id", "clientIdPassword"); + params.put("client_id", clientId); params.put("username", username); params.put("password", password); - final Response response = RestAssured.given().auth().preemptive().basic("clientIdPassword", "secret").and().with().params(params).when().post("http://localhost:8081/spring-security-oauth-server/oauth/token"); + final Response response = RestAssured.given().auth().preemptive().basic(clientId, "secret").and().with().params(params).when().post("http://localhost:8081/spring-security-oauth-server/oauth/token"); return response.jsonPath().getString("access_token"); } @Test - public void givenUser_whenAccessFoosResource_thenOk() { - final String accessToken = obtainAccessToken("john", "123"); - final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); - assertEquals(200, response.getStatusCode()); - assertNotNull(response.jsonPath().get("name")); + public void givenUser_whenUseFooClient_thenOkForFooResourceOnly() { + final String accessToken = obtainAccessToken("fooClientIdPassword", "john", "123"); + + final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(200, fooResponse.getStatusCode()); + assertNotNull(fooResponse.jsonPath().get("name")); + + final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(403, barResponse.getStatusCode()); + + final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); + assertEquals(403, bazResponse.getStatusCode()); } @Test - public void givenUser_whenAccessBarssResource_thenUnauthorized() { - final String accessToken = obtainAccessToken("john", "123"); - final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); - assertEquals(403, response.getStatusCode()); + public void givenUser_whenUseBarClient_thenOkForBarResourceOnly() { + final String accessToken = obtainAccessToken("barClientIdPassword", "john", "123"); + + final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(200, barResponse.getStatusCode()); + assertNotNull(barResponse.jsonPath().get("name")); + + final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(403, fooResponse.getStatusCode()); + + final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); + assertEquals(403, bazResponse.getStatusCode()); } @Test - public void givenAdmin_whenAccessFoosResource_thenOk() { - final String accessToken = obtainAccessToken("tom", "111"); - final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); - assertEquals(200, response.getStatusCode()); - assertNotNull(response.jsonPath().get("name")); + public void givenAdmin_whenUseFooClient_thenOkForFooAndBazResourceOnly() { + final String accessToken = obtainAccessToken("fooClientIdPassword", "tom", "111"); + + final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(200, fooResponse.getStatusCode()); + assertNotNull(fooResponse.jsonPath().get("name")); + + final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); + assertEquals(200, bazResponse.getStatusCode()); + assertNotNull(bazResponse.jsonPath().get("name")); + + final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(403, barResponse.getStatusCode()); } @Test - public void givenAdmin_whenAccessBarssResource_thenOk() { - final String accessToken = obtainAccessToken("tom", "111"); - final Response response = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); - assertEquals(200, response.getStatusCode()); - assertNotNull(response.jsonPath().get("name")); + public void givenAdmin_whenUseBarClient_thenOkForBarAndBazResourceOnly() { + final String accessToken = obtainAccessToken("barClientIdPassword", "tom", "111"); + + final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(200, barResponse.getStatusCode()); + assertNotNull(barResponse.jsonPath().get("name")); + + final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); + assertEquals(200, bazResponse.getStatusCode()); + assertNotNull(bazResponse.jsonPath().get("name")); + + final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(403, fooResponse.getStatusCode()); } } From 595c1c2b1128de279db5f0ebd2ac5713e225139b Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 24 Feb 2016 00:06:52 +0200 Subject: [PATCH 330/626] minor cleanup --- .../baeldung/config/ResourceServerWebConfig.java | 2 +- .../spring-security-oauth-server/.springBeans | 16 ++++++++++++++++ ....java => AuthorizationServerApplication.java} | 4 ++-- ...ecurityConfig.java => WebSecurityConfig.java} | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 spring-security-oauth/spring-security-oauth-server/.springBeans rename spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/{ServerApplication.java => AuthorizationServerApplication.java} (65%) rename spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/{ServerSecurityConfig.java => WebSecurityConfig.java} (94%) diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java index c040c8ac425a..81b2d242ac08 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java @@ -9,5 +9,5 @@ @EnableWebMvc @ComponentScan({ "org.baeldung.web.controller" }) public class ResourceServerWebConfig extends WebMvcConfigurerAdapter { - + // } diff --git a/spring-security-oauth/spring-security-oauth-server/.springBeans b/spring-security-oauth/spring-security-oauth-server/.springBeans new file mode 100644 index 000000000000..18656ebe2e5c --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-server/.springBeans @@ -0,0 +1,16 @@ + + + 1 + + + + + + + java:org.baeldung.config.AuthorizationServerApplication + + + + + + diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerApplication.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthorizationServerApplication.java similarity index 65% rename from spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerApplication.java rename to spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthorizationServerApplication.java index 4b1ff2c7ada7..73b8fc1976a3 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerApplication.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthorizationServerApplication.java @@ -5,10 +5,10 @@ import org.springframework.boot.context.web.SpringBootServletInitializer; @SpringBootApplication -public class ServerApplication extends SpringBootServletInitializer { +public class AuthorizationServerApplication extends SpringBootServletInitializer { public static void main(String[] args) { - SpringApplication.run(ServerApplication.class, args); + SpringApplication.run(AuthorizationServerApplication.class, args); } } \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/WebSecurityConfig.java similarity index 94% rename from spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java rename to spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/WebSecurityConfig.java index 46870f3fc3bb..f8218a0c0380 100644 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java +++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/WebSecurityConfig.java @@ -8,7 +8,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration -public class ServerSecurityConfig extends WebSecurityConfigurerAdapter { +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { From 11461268feeb62bf76064ec60e681d826c0a0c14 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 24 Feb 2016 01:10:50 +0200 Subject: [PATCH 331/626] remove oauth extra resource --- .../config/OAuth2ResourceServerConfig.java | 6 +-- .../web/controller/BarController.java | 2 +- .../web/controller/BazController.java | 41 ----------------- .../main/java/org/baeldung/web/dto/Baz.java | 36 --------------- .../src/main/resources/templates/header.html | 19 -------- .../src/main/resources/templates/index.html | 22 --------- .../baeldung/live/AuthorizationLiveTest.java | 46 ++++++------------- 7 files changed, 17 insertions(+), 155 deletions(-) delete mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java delete mode 100644 spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java index 8fe4cda6a1f5..7809278ad826 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfig.java @@ -29,15 +29,13 @@ public void configure(HttpSecurity http) throws Exception { http .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) .and() - .requestMatchers().antMatchers("/foos/**","/bars/**","/bazes/**") + .requestMatchers().antMatchers("/foos/**","/bars/**") .and() .authorizeRequests() .antMatchers(HttpMethod.GET,"/foos/**").access("#oauth2.hasScope('foo') and #oauth2.hasScope('read')") .antMatchers(HttpMethod.POST,"/foos/**").access("#oauth2.hasScope('foo') and #oauth2.hasScope('write')") .antMatchers(HttpMethod.GET,"/bars/**").access("#oauth2.hasScope('bar') and #oauth2.hasScope('read')") - .antMatchers(HttpMethod.POST,"/bars/**").access("#oauth2.hasScope('bar') and #oauth2.hasScope('write')") - .antMatchers(HttpMethod.GET,"/bazes/**").access("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") - .antMatchers(HttpMethod.POST,"/bazes/**").access("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") + .antMatchers(HttpMethod.POST,"/bars/**").access("#oauth2.hasScope('bar') and #oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") ; // @formatter:on } diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java index 938cf18129a4..72163ff9ff2e 100644 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java +++ b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BarController.java @@ -29,7 +29,7 @@ public Bar findById(@PathVariable final long id) { } // API - write - // @PreAuthorize("#oauth2.hasScope('bar') and #oauth2.hasScope('write')") + // @PreAuthorize("#oauth2.hasScope('bar') and #oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") @RequestMapping(method = RequestMethod.POST, value = "/bars") @ResponseStatus(HttpStatus.CREATED) @ResponseBody diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java deleted file mode 100644 index 880f41de0783..000000000000 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/controller/BazController.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.baeldung.web.controller; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; - -import org.baeldung.web.dto.Baz; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@Controller -public class BazController { - - public BazController() { - super(); - } - - // API - read - // @PreAuthorize("#oauth2.hasScope('read') and hasRole('ROLE_ADMIN')") - @RequestMapping(method = RequestMethod.GET, value = "/bazes/{id}") - @ResponseBody - public Baz findById(@PathVariable final long id) { - return new Baz(Long.parseLong(randomNumeric(2)), randomAlphabetic(4)); - } - - // API - write - // @PreAuthorize("#oauth2.hasScope('write') and hasRole('ROLE_ADMIN')") - @RequestMapping(method = RequestMethod.POST, value = "/bazes") - @ResponseStatus(HttpStatus.CREATED) - @ResponseBody - public Baz create(@RequestBody final Baz baz) { - baz.setId(Long.parseLong(randomNumeric(2))); - return baz; - } - -} diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java deleted file mode 100644 index 69a6bf2e6a50..000000000000 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/web/dto/Baz.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.baeldung.web.dto; - -public class Baz { - private long id; - private String name; - - public Baz() { - super(); - } - - public Baz(final long id, final String name) { - super(); - - this.id = id; - this.name = name; - } - - // - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - -} \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html index d3cf521c0a12..aa891bc28998 100644 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html @@ -94,25 +94,6 @@ }); } - // baz - $scope.baz = {id:0 , name:"sample baz"}; - $scope.bazes = $resource("http://localhost:8081/spring-security-oauth-resource/bazes/:bazId",{bazId:'@id'}); - - $scope.getBaz = function(){ - $scope.baz = $scope.bazes.get({bazId:$scope.baz.id}); - } - - $scope.createBaz = function(){ - if($scope.baz.name.length==0) - { - $rootScope.message = "Baz name can not be empty"; - return; - } - $scope.baz.id = null; - $scope.baz = $scope.bazes.save($scope.baz, function(){ - $rootScope.message = "Baz Created Successfully"; - }); - } }); /*]]>*/ diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html index 0b4c7563ce84..2996af04f08c 100755 --- a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html +++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html @@ -51,28 +51,6 @@

Bar Details

Create Bar -
-
-
-
-
-

Baz Details

-
-
- - -
- -
- - -
- - -
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java index 5827be548b76..e5e9d8428fc6 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/test/java/org/baeldung/live/AuthorizationLiveTest.java @@ -7,6 +7,7 @@ import java.util.Map; import org.junit.Test; +import org.springframework.http.MediaType; import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; @@ -33,56 +34,37 @@ public void givenUser_whenUseFooClient_thenOkForFooResourceOnly() { final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); assertEquals(403, barResponse.getStatusCode()); - - final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); - assertEquals(403, bazResponse.getStatusCode()); } @Test - public void givenUser_whenUseBarClient_thenOkForBarResourceOnly() { + public void givenUser_whenUseBarClient_thenOkForBarResourceReadOnly() { final String accessToken = obtainAccessToken("barClientIdPassword", "john", "123"); - final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); - assertEquals(200, barResponse.getStatusCode()); - assertNotNull(barResponse.jsonPath().get("name")); - final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); assertEquals(403, fooResponse.getStatusCode()); - final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); - assertEquals(403, bazResponse.getStatusCode()); - } + final Response barReadResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); + assertEquals(200, barReadResponse.getStatusCode()); + assertNotNull(barReadResponse.jsonPath().get("name")); - @Test - public void givenAdmin_whenUseFooClient_thenOkForFooAndBazResourceOnly() { - final String accessToken = obtainAccessToken("fooClientIdPassword", "tom", "111"); - - final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); - assertEquals(200, fooResponse.getStatusCode()); - assertNotNull(fooResponse.jsonPath().get("name")); - - final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); - assertEquals(200, bazResponse.getStatusCode()); - assertNotNull(bazResponse.jsonPath().get("name")); - - final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); - assertEquals(403, barResponse.getStatusCode()); + final Response barWritResponse = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken).body("{\"id\":1,\"name\":\"MyBar\"}").post("http://localhost:8081/spring-security-oauth-resource/bars"); + assertEquals(403, barWritResponse.getStatusCode()); } @Test - public void givenAdmin_whenUseBarClient_thenOkForBarAndBazResourceOnly() { + public void givenAdmin_whenUseBarClient_thenOkForBarResourceReadWrite() { final String accessToken = obtainAccessToken("barClientIdPassword", "tom", "111"); + final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); + assertEquals(403, fooResponse.getStatusCode()); + final Response barResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bars/1"); assertEquals(200, barResponse.getStatusCode()); assertNotNull(barResponse.jsonPath().get("name")); - final Response bazResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/bazes/1"); - assertEquals(200, bazResponse.getStatusCode()); - assertNotNull(bazResponse.jsonPath().get("name")); - - final Response fooResponse = RestAssured.given().header("Authorization", "Bearer " + accessToken).get("http://localhost:8081/spring-security-oauth-resource/foos/1"); - assertEquals(403, fooResponse.getStatusCode()); + final Response barWritResponse = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken).body("{\"id\":1,\"name\":\"MyBar\"}").post("http://localhost:8081/spring-security-oauth-resource/bars"); + assertEquals(201, barWritResponse.getStatusCode()); + assertEquals("MyBar", barWritResponse.jsonPath().get("name")); } } From 3b5c46bbbf9b0c99344ff0973807ebc9d406c8ab Mon Sep 17 00:00:00 2001 From: "giuseppe.bueti" Date: Fri, 26 Feb 2016 16:43:11 +0100 Subject: [PATCH 332/626] JPA Stored Procedure --- persistence-jpa/pom.xml | 81 +++++++++++++++++++ .../main/java/com/baeldung/jpa/model/Car.java | 59 ++++++++++++++ .../baeldung/jpa/model/QueryParameter.java | 27 +++++++ .../main/resources/META-INF/persistence.xml | 20 +++++ .../config/database/create_database.sql | 34 ++++++++ .../resources/config/database/insert_cars.sql | 4 + .../storedprocedure/StoredProcedureTest.java | 66 +++++++++++++++ .../src/test/resources/persistence.xml | 21 +++++ 8 files changed, 312 insertions(+) create mode 100644 persistence-jpa/pom.xml create mode 100644 persistence-jpa/src/main/java/com/baeldung/jpa/model/Car.java create mode 100644 persistence-jpa/src/main/java/com/baeldung/jpa/model/QueryParameter.java create mode 100644 persistence-jpa/src/main/resources/META-INF/persistence.xml create mode 100644 persistence-jpa/src/main/resources/config/database/create_database.sql create mode 100644 persistence-jpa/src/main/resources/config/database/insert_cars.sql create mode 100644 persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java create mode 100644 persistence-jpa/src/test/resources/persistence.xml diff --git a/persistence-jpa/pom.xml b/persistence-jpa/pom.xml new file mode 100644 index 000000000000..66f0264f2c57 --- /dev/null +++ b/persistence-jpa/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + com.baeldung + jpa-storedprocedure + 1.0 + jar + + + 7.0 + 11.2.0.4 + 5.1.0.Final + + + + JpaStoredProcedure + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + maven-assembly-plugin + + + + jar-with-dependencies + + + + + + + + + + + + javax + javaee-api + ${jee.version} + provided + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + + + com.oracle + ojdbc6 + ${oracle.version} + + + + + + junit + junit + 4.4 + + + + commons-io + commons-io + 2.4 + + + + + \ No newline at end of file diff --git a/persistence-jpa/src/main/java/com/baeldung/jpa/model/Car.java b/persistence-jpa/src/main/java/com/baeldung/jpa/model/Car.java new file mode 100644 index 000000000000..d57cff200ee1 --- /dev/null +++ b/persistence-jpa/src/main/java/com/baeldung/jpa/model/Car.java @@ -0,0 +1,59 @@ +package com.baeldung.jpa.model; + +import javax.persistence.*; + +/** + * Created by Giuseppe Bueti on 22/02/2016. + */ + +@Entity +@Table(name = "CAR") +@NamedStoredProcedureQueries({ + @NamedStoredProcedureQuery(name = "findByModelProcedure", procedureName = "FIND_CAR_BY_MODEL", resultClasses = { Car.class }, parameters = { @StoredProcedureParameter(name = "p_model", type = String.class, mode = ParameterMode.IN), + @StoredProcedureParameter(name = "data", type = Car.class, mode = ParameterMode.REF_CURSOR) }), + @NamedStoredProcedureQuery(name = "findByYearProcedure", procedureName = "FIND_CAR_BY_YEAR", resultClasses = { Car.class }, parameters = { @StoredProcedureParameter(name = "p_year", type = Integer.class, mode = ParameterMode.IN), + @StoredProcedureParameter(name = "data", type = Car.class, mode = ParameterMode.REF_CURSOR) }) }) +public class Car { + + private long id; + private String model; + private Integer year; + + public Car(String model, Integer year) { + this.model = model; + this.year = year; + } + + public Car() { + } + + @Id + @SequenceGenerator(name = "CarIdSequence", sequenceName = "SEQ_CAR_ID", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CarIdSequence") + @Column(name = "ID", unique = true, nullable = false, scale = 0) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "MODEL") + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + @Column(name = "YEAR") + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } +} diff --git a/persistence-jpa/src/main/java/com/baeldung/jpa/model/QueryParameter.java b/persistence-jpa/src/main/java/com/baeldung/jpa/model/QueryParameter.java new file mode 100644 index 000000000000..326886842d88 --- /dev/null +++ b/persistence-jpa/src/main/java/com/baeldung/jpa/model/QueryParameter.java @@ -0,0 +1,27 @@ +package com.baeldung.jpa.model; + +import java.util.HashMap; +import java.util.Map; + +public class QueryParameter { + + private Map parameters = null; + + private QueryParameter(String name, Object value) { + this.parameters = new HashMap<>(); + this.parameters.put(name, value); + } + + public static QueryParameter with(String name, Object value) { + return new QueryParameter(name, value); + } + + public QueryParameter and(String name, Object value) { + this.parameters.put(name, value); + return this; + } + + public Map parameters() { + return this.parameters; + } +} \ No newline at end of file diff --git a/persistence-jpa/src/main/resources/META-INF/persistence.xml b/persistence-jpa/src/main/resources/META-INF/persistence.xml new file mode 100644 index 000000000000..9c5adbac2aa9 --- /dev/null +++ b/persistence-jpa/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,20 @@ + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.model.Car + + + + + + + + + + \ No newline at end of file diff --git a/persistence-jpa/src/main/resources/config/database/create_database.sql b/persistence-jpa/src/main/resources/config/database/create_database.sql new file mode 100644 index 000000000000..d84007b74dd4 --- /dev/null +++ b/persistence-jpa/src/main/resources/config/database/create_database.sql @@ -0,0 +1,34 @@ +CREATE TABLESPACE JPA DATAFILE 'C:\oraclexe\app\oracle\oradata\XE\JPA.DBF' SIZE 100M AUTOEXTEND ON MAXSIZE 2048M; + +--DROP USER JPA CASCADE; +CREATE USER JPA IDENTIFIED BY JPA DEFAULT TABLESPACE JPA; +ALTER USER JPA QUOTA UNLIMITED ON "JPA" ACCOUNT UNLOCK; + +GRANT CREATE SESSION TO "JPA"; +GRANT ALTER SESSION TO "JPA"; +GRANT CREATE TABLE TO "JPA"; +GRANT CREATE TRIGGER TO "JPA"; +GRANT CREATE VIEW TO "JPA"; +GRANT CREATE DIMENSION TO "JPA"; +GRANT CREATE CLUSTER TO "JPA"; +GRANT CREATE INDEXTYPE TO "JPA"; +GRANT CREATE ROLE TO "JPA"; +GRANT CREATE SEQUENCE TO "JPA"; +GRANT CREATE TYPE TO "JPA"; +GRANT CREATE MATERIALIZED VIEW TO "JPA"; +GRANT CREATE PROCEDURE TO "JPA"; +GRANT CREATE SYNONYM TO "JPA"; + +CREATE SEQUENCE SEQ_CAR_ID INCREMENT BY 1 START WITH 1 MAXVALUE 999999999999999 MINVALUE 1; + +CREATE TABLE CAR +( + ID NUMBER NOT NULL, + MODEL VARCHAR2(50) NOT NULL, + YEAR NUMBER(4) NOT NULL +); + +ALTER TABLE CAR ADD CONSTRAINT CAR_PK PRIMARY KEY ( ID ); + +commit; + diff --git a/persistence-jpa/src/main/resources/config/database/insert_cars.sql b/persistence-jpa/src/main/resources/config/database/insert_cars.sql new file mode 100644 index 000000000000..5fef151c708d --- /dev/null +++ b/persistence-jpa/src/main/resources/config/database/insert_cars.sql @@ -0,0 +1,4 @@ +INSERT INTO CAR (ID, MODEL, YEAR) VALUES ('123456', 'Camaro', '2012'); +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('12112', 'Fiat Panda', '2000') +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('111000', 'Fiat Punto', '2007') +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('3382', 'Citroen C3', '2009') diff --git a/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java b/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java new file mode 100644 index 000000000000..61d4aca85ea6 --- /dev/null +++ b/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java @@ -0,0 +1,66 @@ +package com.baeldung.jpa.storedprocedure; + +import com.baeldung.jpa.model.Car; +import org.junit.*; + +import javax.persistence.*; + +/** + * Created by Giuseppe Bueti on 23/02/2016. + */ +public class StoredProcedureTest { + + private static EntityManagerFactory factory = null; + private static EntityManager entityManager = null; + + @BeforeClass + public static void init() { + factory = Persistence.createEntityManagerFactory("jpa-db"); + entityManager = factory.createEntityManager(); + } + + @Before + public void setup() { + } + + @Test + public void createCarTest() { + EntityTransaction transaction = entityManager.getTransaction(); + try { + transaction.begin(); + Car car = new Car("Ford Mustang", 2015); + entityManager.persist(car); + transaction.commit(); + } catch (Exception e) { + System.out.println(e.getCause()); + if (transaction.isActive()) { + transaction.rollback(); + } + } + } + + @Test + public void findCarsByYear() { + final StoredProcedureQuery findByYearProcedure = entityManager.createNamedStoredProcedureQuery("findByYearProcedure"); + StoredProcedureQuery storedProcedure = findByYearProcedure.setParameter("p_year", 2015); + storedProcedure.getResultList().forEach(c -> Assert.assertEquals(new Integer(2015), ((Car) c).getYear())); + } + + @Test + public void findCarsByModel() { + final StoredProcedureQuery findByModelProcedure = entityManager.createNamedStoredProcedureQuery("findByModelProcedure"); + StoredProcedureQuery storedProcedure = findByModelProcedure.setParameter("p_model", "Camaro"); + storedProcedure.getResultList().forEach(c -> Assert.assertEquals("Camaro", ((Car) c).getModel())); + } + + @AfterClass + public static void destroy() { + + if (entityManager != null) { + entityManager.close(); + } + if (factory != null) { + factory.close(); + } + } +} diff --git a/persistence-jpa/src/test/resources/persistence.xml b/persistence-jpa/src/test/resources/persistence.xml new file mode 100644 index 000000000000..9a5d8acc3618 --- /dev/null +++ b/persistence-jpa/src/test/resources/persistence.xml @@ -0,0 +1,21 @@ + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.model.Car + + + + + + + + + + + From f8b8a5d7bb8e08bb1dd5c259bae7358cfc585f13 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 27 Feb 2016 20:37:56 +0200 Subject: [PATCH 333/626] oauth refresh token --- .../spring-security-oauth-ui-password/pom.xml | 8 +- .../baeldung/config/CustomPostZuulFilter.java | 70 +++++++++++++++++ .../baeldung/config/CustomPreZuulFilter.java | 52 +++++++++++++ .../org/baeldung/config/HomeController.java | 20 +++++ .../org/baeldung/config/UiApplication.java | 2 + .../src/main/resources/application.properties | 2 - .../src/main/resources/application.yml | 13 ++++ .../src/main/resources/templates/header.html | 77 +++++++++++-------- .../src/main/resources/templates/login.html | 5 +- spring-zuul/spring-zuul-ui/.project | 6 +- 10 files changed, 214 insertions(+), 41 deletions(-) create mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPostZuulFilter.java create mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPreZuulFilter.java create mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/HomeController.java delete mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties create mode 100644 spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.yml diff --git a/spring-security-oauth/spring-security-oauth-ui-password/pom.xml b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml index 4a42081f787e..e8b2aa3d0d70 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/pom.xml +++ b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml @@ -17,11 +17,17 @@ org.springframework.boot spring-boot-starter-web - + org.springframework.boot spring-boot-starter-thymeleaf + + + org.springframework.cloud + spring-cloud-starter-zuul + 1.0.4.RELEASE + diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPostZuulFilter.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPostZuulFilter.java new file mode 100644 index 000000000000..319bd2f783fa --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPostZuulFilter.java @@ -0,0 +1,70 @@ +package org.baeldung.config; + +import java.io.InputStream; + +import javax.servlet.http.Cookie; + +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.map.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import com.netflix.zuul.ZuulFilter; +import com.netflix.zuul.context.RequestContext; + +@Component +public class CustomPostZuulFilter extends ZuulFilter { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public Object run() { + final RequestContext ctx = RequestContext.getCurrentContext(); + logger.info("in zuul filter " + ctx.getRequest().getRequestURI()); + if (ctx.getRequest().getRequestURI().contains("oauth/token")) { + + final ObjectMapper mapper = new ObjectMapper(); + JsonNode json; + try { + final InputStream is = ctx.getResponseDataStream(); + final String responseBody = IOUtils.toString(is, "UTF-8"); + + ctx.setResponseBody(responseBody); + + if (responseBody.contains("refresh_token")) { + json = mapper.readTree(responseBody); + final String refreshToken = json.get("refresh_token").getTextValue(); + final Cookie cookie = new Cookie("refreshToken", refreshToken); + cookie.setHttpOnly(true); + cookie.setPath(ctx.getRequest().getContextPath() + "/refreshToken"); + cookie.setMaxAge(2592000); // 30 days + ctx.getResponse().addCookie(cookie); + + logger.info("refresh token = " + refreshToken); + } + } catch (final Exception e) { + logger.error("Error occured in zuul post filter", e); + } + + } + return null; + } + + @Override + public boolean shouldFilter() { + return true; + } + + @Override + public int filterOrder() { + return 10; + } + + @Override + public String filterType() { + return "post"; + } + +} diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPreZuulFilter.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPreZuulFilter.java new file mode 100644 index 000000000000..e0e38b203089 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/CustomPreZuulFilter.java @@ -0,0 +1,52 @@ +package org.baeldung.config; + +import java.io.UnsupportedEncodingException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.crypto.codec.Base64; +import org.springframework.stereotype.Component; + +import com.netflix.zuul.ZuulFilter; +import com.netflix.zuul.context.RequestContext; + +@Component +public class CustomPreZuulFilter extends ZuulFilter { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public Object run() { + final RequestContext ctx = RequestContext.getCurrentContext(); + logger.info("in zuul filter " + ctx.getRequest().getRequestURI()); + if (ctx.getRequest().getRequestURI().contains("oauth/token")) { + byte[] encoded; + try { + encoded = Base64.encode("fooClientIdPassword:secret".getBytes("UTF-8")); + ctx.addZuulRequestHeader("Authorization", "Basic " + new String(encoded)); + logger.info("pre filter"); + logger.info(ctx.getRequest().getHeader("Authorization")); + } catch (final UnsupportedEncodingException e) { + logger.error("Error occured in pre filter", e); + } + + } + return null; + } + + @Override + public boolean shouldFilter() { + return true; + } + + @Override + public int filterOrder() { + return 111110; + } + + @Override + public String filterType() { + return "pre"; + } + +} diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/HomeController.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/HomeController.java new file mode 100644 index 000000000000..a56407a58e21 --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/HomeController.java @@ -0,0 +1,20 @@ +package org.baeldung.config; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; + +@Controller +public class HomeController { + + @RequestMapping(method = RequestMethod.GET, value = "/refreshToken") + @ResponseStatus(HttpStatus.OK) + public void getRefreshToken(@CookieValue(value = "refreshToken", defaultValue = "") String cookie, HttpServletResponse response) { + response.addHeader("refreshToken", cookie); + } +} diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java index 8f491516aa76..60c92d9eef29 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java @@ -3,7 +3,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; +@EnableZuulProxy @SpringBootApplication public class UiApplication extends SpringBootServletInitializer { diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties deleted file mode 100644 index e76a58768041..000000000000 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -server.contextPath=/spring-security-oauth-ui-password -server.port=8081 \ No newline at end of file diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.yml b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.yml new file mode 100644 index 000000000000..9c9e9000e75d --- /dev/null +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.yml @@ -0,0 +1,13 @@ +server: + port: 8081 +zuul: + routes: + foos: + path: /foos/** + url: http://localhost:8081/spring-security-oauth-resource/foos + bars: + path: /bars/** + url: http://localhost:8081/spring-security-oauth-resource/bars + oauth: + path: /oauth/** + url: http://localhost:8081/spring-security-oauth-server/oauth diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html index cafba4eb655d..92a771de12cd 100644 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html @@ -21,52 +21,63 @@ var app = angular.module('myApp', ["ngResource","ngRoute","ngCookies"]); app.controller('mainCtrl', function($scope,$resource,$http,$httpParamSerializer,$cookies) { - $scope.foo = {id:0 , name:"sample foo"}; - $scope.foos = $resource("http://localhost:8081/spring-security-oauth-resource/foos/:fooId",{fooId:'@id'}); + $scope.foo = {id:0 , name:"sample foo"}; + $scope.foos = $resource("foos/:fooId",{fooId:'@id'}); - $scope.getFoo = function(){ - $scope.foo = $scope.foos.get({fooId:$scope.foo.id}); - } - - $scope.data = {grant_type:"password", username: "", password: "", client_id: "fooClientIdPassword"}; - $scope.encoded = btoa("fooClientIdPassword:secret"); + $scope.getFoo = function(){ + $scope.foo = $scope.foos.get({fooId:$scope.foo.id}); + } + $scope.loginData = {grant_type:"password", username: "", password: "", client_id: "fooClientIdPassword"}; + $scope.refreshData = {grant_type:"refresh_token", refresh_token:""}; + var isLoginPage = window.location.href.indexOf("login") != -1; if(isLoginPage){ - if($cookies.get("access_token")){ + if($cookies.get("access_token")){ window.location.href = "index"; - }else{ - $http.defaults.headers.common.Authorization= 'Basic ' + $scope.encoded; } }else{ - if($cookies.get("access_token")){ - $http.defaults.headers.common.Authorization= 'Bearer ' + $cookies.get("access_token"); - }else{ - window.location.href = "login"; - } - + if($cookies.get("access_token")){ + $http.defaults.headers.common.Authorization= 'Bearer ' + $cookies.get("access_token"); + }else{ + refreshAccessToken(); + } } $scope.login = function() { - var req = { + $scope.obtainAccessToken($scope.loginData); + } + + function refreshAccessToken(){ + $http.get("refreshToken"). + success(function(data, status, headers, config) { + if(headers("refreshToken") && headers("refreshToken").length>0){ + $scope.refreshData.refresh_token = headers("refreshToken"); + $scope.obtainAccessToken($scope.refreshData); + }else{ + window.location.href = "login"; + } + }); + } + + $scope.obtainAccessToken = function(params){ + var req = { method: 'POST', - url: "http://localhost:8081/spring-security-oauth-server/oauth/token", - headers: { - "Authorization": "Basic " + $scope.encoded, - "Content-type": "application/x-www-form-urlencoded; charset=utf-8" - }, - data: $httpParamSerializer($scope.data) + url: "oauth/token", + headers: {"Content-type": "application/x-www-form-urlencoded; charset=utf-8"}, + data: $httpParamSerializer(params) } $http(req).then( - function(data){ - $http.defaults.headers.common.Authorization= 'Bearer ' + data.data.access_token; - $cookies.put("access_token", data.data.access_token); - window.location.href="index"; - },function(){ - console.log("error"); - }); - } - + function(data){ + $http.defaults.headers.common.Authorization= 'Bearer ' + data.data.access_token; + var expireDate = new Date (new Date().getTime() + (1000 * data.data.expires_in)); + $cookies.put("access_token", data.data.access_token, {'expires': expireDate}); + window.location.href="index"; + },function(){ + console.log("error"); + window.location.href = "login"; + }); + } }); /*]]>*/ diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html index 4d105cec6c35..e1e6e3e6e0c1 100755 --- a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html +++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html @@ -15,16 +15,17 @@

Login

- +
- +
Login +
diff --git a/spring-zuul/spring-zuul-ui/.project b/spring-zuul/spring-zuul-ui/.project index ec0f2cde815b..d87aec6becd7 100644 --- a/spring-zuul/spring-zuul-ui/.project +++ b/spring-zuul/spring-zuul-ui/.project @@ -21,17 +21,17 @@ - org.eclipse.m2e.core.maven2Builder + org.springframework.ide.eclipse.core.springbuilder - org.springframework.ide.eclipse.core.springbuilder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder From 50fc18b7d2e67ce4fd51c13ecbc9dff7552897b0 Mon Sep 17 00:00:00 2001 From: sghosh Date: Sun, 28 Feb 2016 17:40:14 +0530 Subject: [PATCH 334/626] more queries using QueryDSL --- .../src/main/java/org/baeldung/dao/PersonDao.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/querydsl/src/main/java/org/baeldung/dao/PersonDao.java b/querydsl/src/main/java/org/baeldung/dao/PersonDao.java index cc193de44b34..17be05bff8d4 100644 --- a/querydsl/src/main/java/org/baeldung/dao/PersonDao.java +++ b/querydsl/src/main/java/org/baeldung/dao/PersonDao.java @@ -2,11 +2,22 @@ import org.baeldung.entity.Person; +import javax.persistence.Tuple; import java.util.List; +import java.util.Map; public interface PersonDao { public Person save(Person person); public List findPersonsByFirstnameQueryDSL(String firstname); + + public List findPersonsByFirstnameAndSurnameQueryDSL(String firstname, String surname); + + public List findPersonsByFirstnameInDescendingOrderQueryDSL(String firstname); + + public int findMaxAge(); + + public Map findMaxAgeByName(); + } \ No newline at end of file From 1ff8bc970dcd7bd3d0d1b94928e1f492c35fbb7f Mon Sep 17 00:00:00 2001 From: sghosh Date: Sun, 28 Feb 2016 18:04:44 +0530 Subject: [PATCH 335/626] more queries using QueryDSL --- .../java/org/baeldung/dao/PersonDaoImpl.java | 40 ++++++++++++++++ .../main/java/org/baeldung/entity/Person.java | 15 ++++++ .../java/org/baeldung/dao/PersonDaoTest.java | 46 +++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java b/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java index 82ee4c16cd0d..209ff699af4c 100644 --- a/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java +++ b/querydsl/src/main/java/org/baeldung/dao/PersonDaoImpl.java @@ -1,13 +1,18 @@ package org.baeldung.dao; +import com.mysema.query.group.GroupBy; import com.mysema.query.jpa.impl.JPAQuery; +import com.mysema.query.jpa.impl.JPAQueryFactory; import org.baeldung.entity.Person; import org.baeldung.entity.QPerson; import org.springframework.stereotype.Repository; +import javax.inject.Provider; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import javax.persistence.Tuple; import java.util.List; +import java.util.Map; @Repository public class PersonDaoImpl implements PersonDao { @@ -20,6 +25,7 @@ public Person save(Person person) { return person; } + @Override public List findPersonsByFirstnameQueryDSL(String firstname) { JPAQuery query = new JPAQuery(em); QPerson person = QPerson.person; @@ -27,4 +33,38 @@ public List findPersonsByFirstnameQueryDSL(String firstname) { return query.from(person).where(person.firstname.eq(firstname)).list(person); } + @Override + public List findPersonsByFirstnameAndSurnameQueryDSL(String firstname, String surname) { + JPAQuery query = new JPAQuery(em); + QPerson person = QPerson.person; + + return query.from(person).where(person.firstname.eq(firstname).and( + person.surname.eq(surname))).list(person); + } + + @Override + public List findPersonsByFirstnameInDescendingOrderQueryDSL(String firstname) { + JPAQuery query = new JPAQuery(em); + QPerson person = QPerson.person; + + return query.from(person).where(person.firstname.eq(firstname)).orderBy( + person.surname.desc()).list(person); + } + + @Override + public int findMaxAge() { + JPAQuery query = new JPAQuery(em); + QPerson person = QPerson.person; + + return query.from(person).list(person.age.max()).get(0); + } + + @Override + public Map findMaxAgeByName() { + JPAQuery query = new JPAQuery(em); + QPerson person = QPerson.person; + + return query.from(person).transform(GroupBy.groupBy(person.firstname).as(GroupBy.max(person.age))); + } + } \ No newline at end of file diff --git a/querydsl/src/main/java/org/baeldung/entity/Person.java b/querydsl/src/main/java/org/baeldung/entity/Person.java index d9b0a5a97d0d..056b2eb79cab 100644 --- a/querydsl/src/main/java/org/baeldung/entity/Person.java +++ b/querydsl/src/main/java/org/baeldung/entity/Person.java @@ -15,6 +15,9 @@ public class Person { @Column private String surname; + @Column + private int age; + Person() { } @@ -23,6 +26,11 @@ public Person(String firstname, String surname) { this.surname = surname; } + public Person(String firstname, String surname, int age) { + this(firstname, surname); + this.age = age; + } + public Long getId() { return id; } @@ -47,4 +55,11 @@ public void setSurname(String surname) { this.surname = surname; } + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } } \ No newline at end of file diff --git a/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java b/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java index 29d4dd98e926..da3a95b7f8f4 100644 --- a/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java +++ b/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java @@ -10,6 +10,8 @@ import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; +import java.util.Map; + @ContextConfiguration("/test-context.xml") @RunWith(SpringJUnit4ClassRunner.class) @@ -30,4 +32,48 @@ public void testCreation() { Person personFromDb = personDao.findPersonsByFirstnameQueryDSL("Kent").get(0); Assert.assertEquals(person.getId(), personFromDb.getId()); } + + @Test + public void testMultipleFilter() { + personDao.save(new Person("Erich", "Gamma")); + Person person = personDao.save(new Person("Ralph", "Beck")); + Person person2 = personDao.save(new Person("Ralph", "Johnson")); + + Person personFromDb = personDao.findPersonsByFirstnameAndSurnameQueryDSL("Ralph", "Johnson").get(0); + Assert.assertNotSame(person.getId(), personFromDb.getId()); + Assert.assertEquals(person2.getId(), personFromDb.getId()); + } + + @Test + public void testOrdering() { + Person person = personDao.save(new Person("Kent", "Gamma")); + personDao.save(new Person("Ralph", "Johnson")); + Person person2 = personDao.save(new Person("Kent", "Zivago")); + + Person personFromDb = personDao.findPersonsByFirstnameInDescendingOrderQueryDSL("Kent").get(0); + Assert.assertNotSame(person.getId(), personFromDb.getId()); + Assert.assertEquals(person2.getId(), personFromDb.getId()); + } + + @Test + public void testMaxAge() { + personDao.save(new Person("Kent", "Gamma", 20)); + personDao.save(new Person("Ralph", "Johnson", 35)); + personDao.save(new Person("Kent", "Zivago", 30)); + + int maxAge = personDao.findMaxAge(); + Assert.assertTrue(maxAge == 35); + } + + @Test + public void testMaxAgeByName() { + personDao.save(new Person("Kent", "Gamma", 20)); + personDao.save(new Person("Ralph", "Johnson", 35)); + personDao.save(new Person("Kent", "Zivago", 30)); + + Map maxAge = personDao.findMaxAgeByName(); + Assert.assertTrue(maxAge.size() == 2); + Assert.assertSame(35, maxAge.get("Ralph")); + Assert.assertSame(30, maxAge.get("Kent")); + } } \ No newline at end of file From 202a99786a68802645105390e5ca3868360c5a9f Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 27 Feb 2016 10:52:54 +0100 Subject: [PATCH 336/626] Stored Procedure added. Added TestCase without using NamedStoredProcedure --- .../config/database/FIND_CAR_BY_YEAR_PROCEDURE.sql | 7 +++++++ .../src/main/resources/config/database/insert_cars.sql | 7 ++++--- .../jpa/storedprocedure/StoredProcedureTest.java | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 persistence-jpa/src/main/resources/config/database/FIND_CAR_BY_YEAR_PROCEDURE.sql diff --git a/persistence-jpa/src/main/resources/config/database/FIND_CAR_BY_YEAR_PROCEDURE.sql b/persistence-jpa/src/main/resources/config/database/FIND_CAR_BY_YEAR_PROCEDURE.sql new file mode 100644 index 000000000000..f9230aad4269 --- /dev/null +++ b/persistence-jpa/src/main/resources/config/database/FIND_CAR_BY_YEAR_PROCEDURE.sql @@ -0,0 +1,7 @@ +create or replace PROCEDURE FIND_CAR_BY_YEAR ( p_year IN NUMBER, data OUT SYS_REFCURSOR ) AS + BEGIN + OPEN data FOR + SELECT ID, MODEL, YEAR + FROM CAR + WHERE YEAR = p_year; + END FIND_CAR_BY_YEAR; \ No newline at end of file diff --git a/persistence-jpa/src/main/resources/config/database/insert_cars.sql b/persistence-jpa/src/main/resources/config/database/insert_cars.sql index 5fef151c708d..4879ffc79e33 100644 --- a/persistence-jpa/src/main/resources/config/database/insert_cars.sql +++ b/persistence-jpa/src/main/resources/config/database/insert_cars.sql @@ -1,4 +1,5 @@ INSERT INTO CAR (ID, MODEL, YEAR) VALUES ('123456', 'Camaro', '2012'); -INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('12112', 'Fiat Panda', '2000') -INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('111000', 'Fiat Punto', '2007') -INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('3382', 'Citroen C3', '2009') +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('12112', 'Fiat Panda', '2000'); +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('111000', 'Fiat Punto', '2007'); +INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('3382', 'Citroen C3', '2009'); +commit; \ No newline at end of file diff --git a/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java b/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java index 61d4aca85ea6..e6880c4d76dd 100644 --- a/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java +++ b/persistence-jpa/src/test/java/com/baeldung/jpa/storedprocedure/StoredProcedureTest.java @@ -53,6 +53,16 @@ public void findCarsByModel() { storedProcedure.getResultList().forEach(c -> Assert.assertEquals("Camaro", ((Car) c).getModel())); } + @Test + public void findCarsByYearNoNamedStored() { + StoredProcedureQuery findByYearProcedure = + entityManager.createStoredProcedureQuery("FIND_CAR_BY_YEAR", Car.class) + .registerStoredProcedureParameter("p_year", Integer.class, ParameterMode.IN) + .registerStoredProcedureParameter("data", Void.class, ParameterMode.REF_CURSOR).setParameter("p_year", 2015); + + findByYearProcedure.getResultList().forEach(c -> Assert.assertEquals(new Integer(2015), ((Car) c).getYear())); + } + @AfterClass public static void destroy() { From 24786192029922ce3e5ad392e88cd3b3f86d5df8 Mon Sep 17 00:00:00 2001 From: Giuseppe Bueti Date: Sat, 27 Feb 2016 11:03:32 +0100 Subject: [PATCH 337/626] Modified persistence xsd reference --- .../src/main/resources/META-INF/persistence.xml | 10 +++++----- persistence-jpa/src/test/resources/persistence.xml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/persistence-jpa/src/main/resources/META-INF/persistence.xml b/persistence-jpa/src/main/resources/META-INF/persistence.xml index 9c5adbac2aa9..e8623116200c 100644 --- a/persistence-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-jpa/src/main/resources/META-INF/persistence.xml @@ -1,9 +1,9 @@ - + org.hibernate.jpa.HibernatePersistenceProvider diff --git a/persistence-jpa/src/test/resources/persistence.xml b/persistence-jpa/src/test/resources/persistence.xml index 9a5d8acc3618..fc6c7273b2f0 100644 --- a/persistence-jpa/src/test/resources/persistence.xml +++ b/persistence-jpa/src/test/resources/persistence.xml @@ -1,9 +1,9 @@ - + org.hibernate.jpa.HibernatePersistenceProvider From ac458df0c7cbf275cd2a1c1f6703d4c83898fe30 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:02:46 +0200 Subject: [PATCH 338/626] Update README.md --- spring-data-redis/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-redis/README.md b/spring-data-redis/README.md index b9b2e5d93d89..89eae99f0534 100644 --- a/spring-data-redis/README.md +++ b/spring-data-redis/README.md @@ -1,7 +1,7 @@ ## Spring Data Redis ### Relevant Articles: -- [Introduction to Spring Data Redis] +- [Introduction to Spring Data Redis](http://www.baeldung.com/spring-data-redis-tutorial) ### Build the Project with Tests Running ``` From 1259a0c41ed74d4b7b69577a3b40ceb6f3783267 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:09:52 +0200 Subject: [PATCH 339/626] Create ========= --- raml/modularization/========= | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 raml/modularization/========= diff --git a/raml/modularization/========= b/raml/modularization/========= new file mode 100644 index 000000000000..bb1839f3618c --- /dev/null +++ b/raml/modularization/========= @@ -0,0 +1,6 @@ +========= + +## Modular RAML + +### Relevant Articles: +- [Modular RAML Using Includes, Libraries, Overlays and Extensions](http://www.baeldung.com/modular-raml-includes-overlays-libraries-extensions) From b8f0d8a077df29b7a645b7d73ba2e714c119e609 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:10:16 +0200 Subject: [PATCH 340/626] Rename ========= to README.md --- raml/modularization/{========= => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename raml/modularization/{========= => README.md} (100%) diff --git a/raml/modularization/========= b/raml/modularization/README.md similarity index 100% rename from raml/modularization/========= rename to raml/modularization/README.md From bea7d842c2e6fac36c360687fb58bf356e74074e Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:11:36 +0200 Subject: [PATCH 341/626] Update README.md --- raml/modularization/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raml/modularization/README.md b/raml/modularization/README.md index bb1839f3618c..de0e047ea6a9 100644 --- a/raml/modularization/README.md +++ b/raml/modularization/README.md @@ -1,6 +1,6 @@ ========= -## Modular RAML +## Modular RESTful API Modeling Language ### Relevant Articles: - [Modular RAML Using Includes, Libraries, Overlays and Extensions](http://www.baeldung.com/modular-raml-includes-overlays-libraries-extensions) From f76c47ee8f3ccd1d384b6563946f5ad29a8587e3 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:19:33 +0200 Subject: [PATCH 342/626] Update README.md --- spring-data-elasticsearch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-elasticsearch/README.md b/spring-data-elasticsearch/README.md index 0dae92e0e750..e94f99f58702 100644 --- a/spring-data-elasticsearch/README.md +++ b/spring-data-elasticsearch/README.md @@ -1,5 +1,5 @@ ## Spring Data Elasticsearch - +- [Introduction to Spring Data Elasticsearch](http://www.baeldung.com/spring-data-elasticsearch-tutorial) ### Build the Project with Tests Running ``` mvn clean install From cff3d8665f8a8c8863ee72386a8a65eb860f041c Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:19:56 +0200 Subject: [PATCH 343/626] Update README.md --- spring-data-elasticsearch/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-elasticsearch/README.md b/spring-data-elasticsearch/README.md index e94f99f58702..74d9e4f6428c 100644 --- a/spring-data-elasticsearch/README.md +++ b/spring-data-elasticsearch/README.md @@ -1,5 +1,6 @@ ## Spring Data Elasticsearch - [Introduction to Spring Data Elasticsearch](http://www.baeldung.com/spring-data-elasticsearch-tutorial) + ### Build the Project with Tests Running ``` mvn clean install From 2c7262dac54e0821e8b5e7b4273f09139322815a Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:23:59 +0200 Subject: [PATCH 344/626] Create README.md --- guava19/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 guava19/README.md diff --git a/guava19/README.md b/guava19/README.md new file mode 100644 index 000000000000..5602ad83f649 --- /dev/null +++ b/guava19/README.md @@ -0,0 +1,7 @@ +========= + +## Guava 19 + + +### Relevant Articles: +[Guava 19: What’s New?](http://www.baeldung.com/whats-new-in-guava-19) From 72ac8a9d4137907a0601a9529f3849c5ef7590f8 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:26:19 +0200 Subject: [PATCH 345/626] Create README.md --- resteasy/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 resteasy/README.md diff --git a/resteasy/README.md b/resteasy/README.md new file mode 100644 index 000000000000..67550d77d0eb --- /dev/null +++ b/resteasy/README.md @@ -0,0 +1,7 @@ +========= + +## A Guide to RESTEasy + + +### Relevant Articles: +- [A Guide to RESTEasy](http://www.baeldung.com/resteasy-tutorial) From b189d03388f13aee01bc2e2f8dbb955655a45706 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:27:08 +0200 Subject: [PATCH 346/626] Update README.md --- guava19/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava19/README.md b/guava19/README.md index 5602ad83f649..be9f2d72a493 100644 --- a/guava19/README.md +++ b/guava19/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: -[Guava 19: What’s New?](http://www.baeldung.com/whats-new-in-guava-19) +- [Guava 19: What’s New?](http://www.baeldung.com/whats-new-in-guava-19) From 31a5c6ea5c96502bcbf89a9f1728e61e9b871f4b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:29:53 +0200 Subject: [PATCH 347/626] Create README.md --- raml/annotations/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 raml/annotations/README.md diff --git a/raml/annotations/README.md b/raml/annotations/README.md new file mode 100644 index 000000000000..4142b3335305 --- /dev/null +++ b/raml/annotations/README.md @@ -0,0 +1,7 @@ +========= + +## Define Custom RAML + + +### Relevant Articles: +- [Define Custom RAML Properties Using Annotations](http://www.baeldung.com/raml-custom-properties-with-annotations) From f02faf32a7410f1d721a19a8335a37444cae6c1b Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:31:47 +0200 Subject: [PATCH 348/626] Update README.md --- resteasy/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/resteasy/README.md b/resteasy/README.md index 67550d77d0eb..722f1dfe933e 100644 --- a/resteasy/README.md +++ b/resteasy/README.md @@ -5,3 +5,4 @@ ### Relevant Articles: - [A Guide to RESTEasy](http://www.baeldung.com/resteasy-tutorial) +- [RESTEasy Client API](http://www.baeldung.com/resteasy-client-tutorial) From 7cffb8a17ca97005f5ad5804db8bfd118613057a Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:34:23 +0200 Subject: [PATCH 349/626] Update README.md --- spring-apache-camel/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index f6ae77b2a5c2..d9f380055b76 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -15,6 +15,7 @@ This article will demonstrate how to configure and use Apache Camel with Spring
  • Spring 4.2.4
  • Apache Camel 2.16.1
  • +
  • Using Apache Camel with Spring

Build and Run Application

@@ -25,4 +26,4 @@ To build this application execute following maven command in ApacheCamelFileProc To run this application you can either run our main class App from your IDE or you can execute following maven command: -mvn exec:java -Dexec.mainClass="App" \ No newline at end of file +mvn exec:java -Dexec.mainClass="App" From 95046958487bb7ba84406c69cbaaaf223e6be642 Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:34:55 +0200 Subject: [PATCH 350/626] Update README.md --- spring-apache-camel/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index d9f380055b76..5b24c63cbc3d 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -15,7 +15,6 @@ This article will demonstrate how to configure and use Apache Camel with Spring
  • Spring 4.2.4
  • Apache Camel 2.16.1
  • -
  • Using Apache Camel with Spring

Build and Run Application

From bf9e0b607f46121669249cbcda1275f7bc713e6f Mon Sep 17 00:00:00 2001 From: MichelLeBon Date: Tue, 1 Mar 2016 02:38:43 +0200 Subject: [PATCH 351/626] Update README.md --- core-java-8/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index 8bef3a1be0d4..b03d24c34e03 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -8,3 +8,4 @@ - [Java – Try with Resources](http://www.baeldung.com/java-try-with-resources) - [Lambda Expressions and Functional Interfaces: Tips and Best Practices](http://www.baeldung.com/java-8-lambda-expressions-tips) - [The Double Colon Operator in Java 8](http://www.baeldung.com/java-8-double-colon-operator) +- [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial) From 87e391661d5336f06d2eb19010aadbc772ee8a32 Mon Sep 17 00:00:00 2001 From: Eugen Date: Tue, 1 Mar 2016 11:38:37 +0200 Subject: [PATCH 352/626] Update README.md --- spring-apache-camel/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index 5b24c63cbc3d..4015760f7d4a 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -3,7 +3,7 @@ This article will demonstrate how to configure and use Apache Camel with Spring Framework. -

Relevant Article

+

Relevant Articles