From 96182a2bf2a716f3c521a3381c7caa4129029ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Gonz=C3=A1lez?= Date: Sat, 25 Jun 2016 17:11:51 +0200 Subject: [PATCH 01/33] Just setting encoding for module on mock comparison. (#461) * Add new module for mocks comparison. * Add sources for testing. * Changes on testCase. * Enter some tests for mockito. * More tests for Mockito. * Even more tests. * Add the rest of the mocking libraries. * Javadoc on test. * Test bare bones for EasyMock. * Fist kind of test and setup. * Add tests using EasyMock with a change on LoginService. * Create LoginControllerTest.java * Test setup * [JMockit] No method called test. * [JMockit] Two methods called test. * [JMockit] One method called test. * [JMockit] Exception mock test * [JMockit] Mocked object to pass around test. * [JMockit] Custom matcher test. * [JMockit] Partial mocking test. * [JMockit] Fix with IDE. * Not stubs. Mocks. MOCKS!!! * Remove unnecesary import. --- mock-comparisons/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mock-comparisons/pom.xml b/mock-comparisons/pom.xml index 97e24c61cd..c5424d262d 100644 --- a/mock-comparisons/pom.xml +++ b/mock-comparisons/pom.xml @@ -12,6 +12,8 @@ 1.10.19 3.4 1.24 + + UTF-8 3.3 From a661e0e3c921d46c55406520be04d9c9bb0aa574 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sat, 25 Jun 2016 17:23:52 +0200 Subject: [PATCH 02/33] Add additional AssertJ examples --- core-java-8/pom.xml | 6 ++ .../com/baeldung/date_migration/NewApi.java | 54 ----------- .../com/baeldung/date_migration/OldApi.java | 68 -------------- .../baeldung/dateapi/ConversionExample.java} | 4 +- .../baeldung/dateapi/JavaUtilTimeTest.java | 89 +++++++++++++++++++ 5 files changed, 97 insertions(+), 124 deletions(-) delete mode 100644 core-java-8/src/main/java/com/baeldung/date_migration/NewApi.java delete mode 100644 core-java-8/src/main/java/com/baeldung/date_migration/OldApi.java rename core-java-8/src/{main/java/com/baeldung/date_migration/Conversion.java => test/java/com/baeldung/dateapi/ConversionExample.java} (91%) create mode 100644 core-java-8/src/test/java/com/baeldung/dateapi/JavaUtilTimeTest.java diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index f99d85f564..8c9bb36f7d 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -63,6 +63,12 @@ test + + org.assertj + assertj-core + 3.4.1 + + org.mockito mockito-core diff --git a/core-java-8/src/main/java/com/baeldung/date_migration/NewApi.java b/core-java-8/src/main/java/com/baeldung/date_migration/NewApi.java deleted file mode 100644 index 0abf7f7864..0000000000 --- a/core-java-8/src/main/java/com/baeldung/date_migration/NewApi.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.date_migration; - -import java.text.ParseException; -import java.time.*; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; - -public class NewApi { - public void currentTime() { - ZonedDateTime now = ZonedDateTime.now(); - } - - public void specificTime() { - LocalDate birthDay = LocalDate.of(1990, Month.DECEMBER, 15); - } - - public void extractMonth() { - Month month = LocalDateTime.now().getMonth(); - } - - public void subtractTime() { - LocalDateTime fiveHoursBefore = LocalDateTime.now().minusHours(5); - } - - public void alterField() { - LocalDateTime inJune = LocalDateTime.now().withMonth(Month.JUNE.getValue()); - } - - public void truncate() { - LocalTime truncated = LocalTime.now().truncatedTo(ChronoUnit.HOURS); - } - - public void convertTimeZone() { - ZonedDateTime centralEastern = LocalDateTime.now().atZone(ZoneId.of("CET")); - } - - public void getTimeSpan() { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime hourLater = LocalDateTime.now().plusHours(1); - Duration span = Duration.between(now, hourLater); - } - - public void formatAndParse() throws ParseException { - LocalDate now = LocalDate.now(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - String formattedDate = now.format(formatter); - LocalDate parsedDate = LocalDate.parse(formattedDate, formatter); - } - - public void daysInMonth() { - int daysInMonth = YearMonth.of(1990, 2).lengthOfMonth(); - } - -} diff --git a/core-java-8/src/main/java/com/baeldung/date_migration/OldApi.java b/core-java-8/src/main/java/com/baeldung/date_migration/OldApi.java deleted file mode 100644 index de4edf99e9..0000000000 --- a/core-java-8/src/main/java/com/baeldung/date_migration/OldApi.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.date_migration; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -public class OldApi { - public void currentTime() { - Date now = new Date(); - } - - public void specificTime () { - Date birthDay = new GregorianCalendar(1990, Calendar.DECEMBER, 15).getTime(); - } - - public void extractMonth() { - int month = new GregorianCalendar().get(Calendar.MONTH); - } - - public void subtractTime() { - GregorianCalendar calendar = new GregorianCalendar(); - calendar.add(Calendar.HOUR_OF_DAY, -5); - Date fiveHoursBefore = calendar.getTime(); - } - - public void alterField() { - GregorianCalendar calendar = new GregorianCalendar(); - calendar.set(Calendar.MONTH, Calendar.JUNE); - Date inJune = calendar.getTime(); - } - - public void truncate() { - Calendar now = Calendar.getInstance(); - now.set(Calendar.MINUTE, 0); - now.set(Calendar.SECOND, 0); - now.set(Calendar.MILLISECOND, 0); - Date truncated = now.getTime(); - } - - public void convertTimeZone() { - GregorianCalendar calendar = new GregorianCalendar(); - calendar.setTimeZone(TimeZone.getTimeZone("CET")); - Date centralEastern = calendar.getTime(); - } - - public void getTimeSpan() { - GregorianCalendar calendar = new GregorianCalendar(); - Date now = new Date(); - calendar.add(Calendar.HOUR, 1); - Date hourLater = calendar.getTime(); - long elapsed = hourLater.getTime() - now.getTime(); - } - - public void formatAndParse() throws ParseException { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date now = new Date(); - String formattedDate = dateFormat.format(now); - Date parsedDate = dateFormat.parse(formattedDate); - } - - public void daysInMonth() { - Calendar calendar = new GregorianCalendar(1990, Calendar.FEBRUARY, 20); - int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); - } -} diff --git a/core-java-8/src/main/java/com/baeldung/date_migration/Conversion.java b/core-java-8/src/test/java/com/baeldung/dateapi/ConversionExample.java similarity index 91% rename from core-java-8/src/main/java/com/baeldung/date_migration/Conversion.java rename to core-java-8/src/test/java/com/baeldung/dateapi/ConversionExample.java index c672b7ee44..a543c80eaf 100644 --- a/core-java-8/src/main/java/com/baeldung/date_migration/Conversion.java +++ b/core-java-8/src/test/java/com/baeldung/dateapi/ConversionExample.java @@ -1,4 +1,4 @@ -package com.baeldung.date_migration; +package com.baeldung.dateapi; import java.time.Instant; import java.time.ZoneId; @@ -7,7 +7,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; -public class Conversion { +public class ConversionExample { public static void main(String[] args) { Instant instantFromCalendar = GregorianCalendar.getInstance().toInstant(); ZonedDateTime zonedDateTimeFromCalendar = new GregorianCalendar().toZonedDateTime(); diff --git a/core-java-8/src/test/java/com/baeldung/dateapi/JavaUtilTimeTest.java b/core-java-8/src/test/java/com/baeldung/dateapi/JavaUtilTimeTest.java new file mode 100644 index 0000000000..4bce40c2d9 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/dateapi/JavaUtilTimeTest.java @@ -0,0 +1,89 @@ +package com.baeldung.dateapi; + +import org.junit.Test; + +import java.text.ParseException; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; + +import static org.assertj.core.api.Assertions.assertThat; + +public class JavaUtilTimeTest { + + @Test + public void currentTime() { + final LocalDate now = LocalDate.now(); + + System.out.println(now); + // there is not much to test here + } + + @Test + public void specificTime() { + LocalDate birthDay = LocalDate.of(1990, Month.DECEMBER, 15); + + System.out.println(birthDay); + // there is not much to test here + } + + @Test + public void extractMonth() { + Month month = LocalDate.of(1990, Month.DECEMBER, 15).getMonth(); + + assertThat(month).isEqualTo(Month.DECEMBER); + } + + @Test + public void subtractTime() { + LocalDateTime fiveHoursBefore = LocalDateTime.of(1990, Month.DECEMBER, 15, 15, 0).minusHours(5); + + assertThat(fiveHoursBefore.getHour()).isEqualTo(10); + } + + @Test + public void alterField() { + LocalDateTime inJune = LocalDateTime.of(1990, Month.DECEMBER, 15, 15, 0).with(Month.JUNE); + + assertThat(inJune.getMonth()).isEqualTo(Month.JUNE); + } + + @Test + public void truncate() { + LocalTime truncated = LocalTime.of(15, 12, 34).truncatedTo(ChronoUnit.HOURS); + + assertThat(truncated).isEqualTo(LocalTime.of(15, 0, 0)); + } + + @Test + public void getTimeSpan() { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime hourLater = now.plusHours(1); + Duration span = Duration.between(now, hourLater); + + assertThat(span).isEqualTo(Duration.ofHours(1)); + } + + @Test + public void formatAndParse() throws ParseException { + LocalDate someDate = LocalDate.of(2016, 12, 7); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formattedDate = someDate.format(formatter); + LocalDate parsedDate = LocalDate.parse(formattedDate, formatter); + + assertThat(formattedDate).isEqualTo("2016-12-07"); + assertThat(parsedDate).isEqualTo(someDate); + } + + @Test + public void daysInMonth() { + int daysInMonth = YearMonth.of(1990, 2).lengthOfMonth(); + + assertThat(daysInMonth).isEqualTo(28); + } +} From 330c8680c938e54abf6606b9a9af9db4943c8911 Mon Sep 17 00:00:00 2001 From: Raquel Garrido Date: Sun, 26 Jun 2016 11:55:42 +0200 Subject: [PATCH 03/33] XML libraries support (#463) * dom4j * added more parsers * StaxParser * Jaxb binding * Jaxb binding * Finish article --- xml/pom.xml | 200 ++++++++---------- .../java/com/baeldung/xml/DefaultParser.java | 10 +- .../java/com/baeldung/xml/Dom4JParser.java | 131 ++++++++++++ .../java/com/baeldung/xml/JDomParser.java | 62 ++++++ .../java/com/baeldung/xml/JaxbParser.java | 69 ++++++ .../main/java/com/baeldung/xml/JaxenDemo.java | 57 +++++ .../java/com/baeldung/xml/StaxParser.java | 120 +++++++++++ .../com/baeldung/xml/binding/Tutorial.java | 61 ++++++ .../com/baeldung/xml/binding/Tutorials.java | 23 ++ .../java/com/baeldung/xml/model/Tutorial.java | 49 +++++ .../com/baeldung/xml/DefaultParserTest.java | 11 +- .../com/baeldung/xml/Dom4JParserTest.java | 88 ++++++++ .../java/com/baeldung/xml/JDomParserTest.java | 38 ++++ .../java/com/baeldung/xml/JaxbParserTest.java | 46 ++++ .../java/com/baeldung/xml/JaxenDemoTest.java | 25 +++ .../java/com/baeldung/xml/StaxParserTest.java | 28 +++ xml/src/test/resources/example.xml | 20 +- xml/src/test/resources/example_namespace.xml | 20 +- xml/src/test/resources/example_new.xml | 10 + xml/src/test/resources/example_updated.xml | 32 +++ 20 files changed, 957 insertions(+), 143 deletions(-) create mode 100644 xml/src/main/java/com/baeldung/xml/Dom4JParser.java create mode 100644 xml/src/main/java/com/baeldung/xml/JDomParser.java create mode 100644 xml/src/main/java/com/baeldung/xml/JaxbParser.java create mode 100644 xml/src/main/java/com/baeldung/xml/JaxenDemo.java create mode 100644 xml/src/main/java/com/baeldung/xml/StaxParser.java create mode 100644 xml/src/main/java/com/baeldung/xml/binding/Tutorial.java create mode 100644 xml/src/main/java/com/baeldung/xml/binding/Tutorials.java create mode 100644 xml/src/main/java/com/baeldung/xml/model/Tutorial.java create mode 100644 xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java create mode 100644 xml/src/test/java/com/baeldung/xml/JDomParserTest.java create mode 100644 xml/src/test/java/com/baeldung/xml/JaxbParserTest.java create mode 100644 xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java create mode 100644 xml/src/test/java/com/baeldung/xml/StaxParserTest.java create mode 100644 xml/src/test/resources/example_new.xml create mode 100644 xml/src/test/resources/example_updated.xml diff --git a/xml/pom.xml b/xml/pom.xml index fc158901e6..9d88bd75eb 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -1,139 +1,117 @@ - 4.0.0 - com.baeldung - xml - 0.1-SNAPSHOT + 4.0.0 + com.baeldung + xml + 0.1-SNAPSHOT - xml + xml - - + + + + dom4j + dom4j + 1.6.1 + + + jaxen + jaxen + 1.1.6 + - - com.google.guava - guava - ${guava.version} - - - commons-io - commons-io - 2.4 - + + org.jdom + jdom2 + 2.0.6 + - - org.apache.commons - commons-collections4 - 4.0 - + + xerces + xercesImpl + 2.9.1 + - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - + + + commons-io + commons-io + 2.4 + - - junit - junit - ${junit.version} - test - + + org.apache.commons + commons-collections4 + 4.0 + - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + - - org.mockito - mockito-core - ${mockito.version} - test - - + - - xml - - - src/main/resources - true - - + + junit + junit + ${junit.version} + test + - + - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - - + + xml + + + src/main/resources + true + + - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - + - + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + - + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + - - - 4.3.11.Final - 5.1.38 + - - 2.7.2 + - - 1.7.13 - 1.1.3 + - - 5.1.3.Final + + 19.0 + 3.4 - - 19.0 - 3.4 + + 4.12 - - 1.3 - 4.12 - 1.10.19 + + 3.5.1 + 2.6 + 2.19.1 + 2.7 + 1.4.18 - 4.4.1 - 4.5 - - 2.9.0 - - - 3.5.1 - 2.6 - 2.19.1 - 2.7 - 1.4.18 - - + diff --git a/xml/src/main/java/com/baeldung/xml/DefaultParser.java b/xml/src/main/java/com/baeldung/xml/DefaultParser.java index 89326f45c9..1f2a7418fb 100644 --- a/xml/src/main/java/com/baeldung/xml/DefaultParser.java +++ b/xml/src/main/java/com/baeldung/xml/DefaultParser.java @@ -39,7 +39,7 @@ public class DefaultParser { XPath xPath = XPathFactory.newInstance().newXPath(); - String expression = "/Tutorials/Tutorial"; + String expression = "/tutorials/tutorial"; nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); @@ -60,7 +60,7 @@ public class DefaultParser { XPath xPath = XPathFactory.newInstance().newXPath(); - String expression = "/Tutorials/Tutorial[@tutId=" + "'" + id + "'" + "]"; + String expression = "/tutorials/tutorial[@tutId=" + "'" + id + "'" + "]"; node = (Node) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODE); @@ -83,7 +83,7 @@ public class DefaultParser { XPath xPath = XPathFactory.newInstance().newXPath(); - String expression = "//Tutorial[descendant::title[text()=" + "'" + name + "'" + "]]"; + String expression = "//tutorial[descendant::title[text()=" + "'" + name + "'" + "]]"; nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); @@ -107,7 +107,7 @@ public class DefaultParser { XPath xPath = XPathFactory.newInstance().newXPath(); - String expression = "//Tutorial[number(translate(date, '/', '')) > " + date + "]"; + String expression = "//tutorial[number(translate(date, '/', '')) > " + date + "]"; nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); @@ -151,7 +151,7 @@ public class DefaultParser { } }); - String expression = "/bdn:Tutorials/bdn:Tutorial"; + String expression = "/bdn:tutorials/bdn:tutorial"; nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); diff --git a/xml/src/main/java/com/baeldung/xml/Dom4JParser.java b/xml/src/main/java/com/baeldung/xml/Dom4JParser.java new file mode 100644 index 0000000000..d9058ba236 --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/Dom4JParser.java @@ -0,0 +1,131 @@ +package com.baeldung.xml; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.Node; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.SAXReader; +import org.dom4j.io.XMLWriter; + +public class Dom4JParser { + + private File file; + + public Dom4JParser(File file) { + this.file = file; + } + + public Element getRootElement() { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + return document.getRootElement(); + } catch (DocumentException e) { + e.printStackTrace(); + return null; + } + } + + public List getFirstElementList() { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + return document.getRootElement().elements(); + } catch (DocumentException e) { + e.printStackTrace(); + return null; + } + } + + public Node getNodeById(String id) { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + List elements = document.selectNodes("//*[@tutId='" + id + "']"); + return elements.get(0); + } catch (DocumentException e) { + e.printStackTrace(); + return null; + } + } + + public Node getElementsListByTitle(String name) { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + List elements = document + .selectNodes("//tutorial[descendant::title[text()=" + "'" + name + "'" + "]]"); + return elements.get(0); + } catch (DocumentException e) { + e.printStackTrace(); + return null; + } + } + + public void generateModifiedDocument() { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + List nodes = document.selectNodes("/tutorials/tutorial"); + for (Node node : nodes) { + Element element = (Element) node; + Iterator iterator = element.elementIterator("title"); + while (iterator.hasNext()) { + Element title = (Element) iterator.next(); + title.setText(title.getText() + " updated"); + } + } + XMLWriter writer = new XMLWriter(new FileWriter(new File("src/test/resources/example_updated.xml"))); + writer.write(document); + writer.close(); + } catch (DocumentException e) { + e.printStackTrace(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void generateNewDocument() { + try { + Document document = DocumentHelper.createDocument(); + Element root = document.addElement("XMLTutorials"); + Element tutorialElement = root.addElement("tutorial").addAttribute("tutId", "01"); + tutorialElement.addAttribute("type", "xml"); + + tutorialElement.addElement("title").addText("XML with Dom4J"); + + tutorialElement.addElement("description").addText("XML handling with Dom4J"); + + tutorialElement.addElement("date").addText("14/06/2016"); + + tutorialElement.addElement("author").addText("Dom4J tech writer"); + + OutputFormat format = OutputFormat.createPrettyPrint(); + XMLWriter writer = new XMLWriter(new FileWriter(new File("src/test/resources/example_new.xml")), format); + writer.write(document); + writer.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + +} diff --git a/xml/src/main/java/com/baeldung/xml/JDomParser.java b/xml/src/main/java/com/baeldung/xml/JDomParser.java new file mode 100644 index 0000000000..08676b44f8 --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/JDomParser.java @@ -0,0 +1,62 @@ +package com.baeldung.xml; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.filter.Filters; +import org.jdom2.input.SAXBuilder; +import org.jdom2.xpath.XPathExpression; +import org.jdom2.xpath.XPathFactory; + + +public class JDomParser { + + private File file; + + public JDomParser(File file) { + this.file = file; + } + + public List getAllTitles() { + try { + SAXBuilder builder = new SAXBuilder(); + Document doc = builder.build(this.getFile()); + Element tutorials = doc.getRootElement(); + List titles = tutorials.getChildren("tutorial"); + return titles; + } catch (JDOMException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + + public Element getNodeById(String id) { + try { + SAXBuilder builder = new SAXBuilder(); + Document document = (Document) builder.build(file); + String filter = "//*[@tutId='" + id + "']"; + XPathFactory xFactory = XPathFactory.instance(); + XPathExpression expr = xFactory.compile(filter, Filters.element()); + List node = expr.evaluate(document); + + return node.get(0); + } catch (JDOMException | IOException e ) { + e.printStackTrace(); + return null; + } + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + +} diff --git a/xml/src/main/java/com/baeldung/xml/JaxbParser.java b/xml/src/main/java/com/baeldung/xml/JaxbParser.java new file mode 100644 index 0000000000..9c06ec5fba --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/JaxbParser.java @@ -0,0 +1,69 @@ +package com.baeldung.xml; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import com.baeldung.xml.binding.Tutorial; +import com.baeldung.xml.binding.Tutorials; + +public class JaxbParser { + + private File file; + + public JaxbParser(File file) { + this.file = file; + } + + public Tutorials getFullDocument() { + try { + JAXBContext jaxbContext = JAXBContext.newInstance(Tutorials.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + Tutorials tutorials = (Tutorials) jaxbUnmarshaller.unmarshal(this.getFile()); + return tutorials; + } catch (JAXBException e) { + e.printStackTrace(); + return null; + } + } + + public void createNewDocument() { + Tutorials tutorials = new Tutorials(); + tutorials.setTutorial(new ArrayList()); + Tutorial tut = new Tutorial(); + tut.setTutId("01"); + tut.setType("XML"); + tut.setTitle("XML with Jaxb"); + tut.setDescription("XML Binding with Jaxb"); + tut.setDate(new Date()); + tut.setAuthor("Jaxb author"); + tutorials.getTutorial().add(tut); + + try { + JAXBContext jaxbContext = JAXBContext.newInstance(Tutorials.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal(tutorials, file); + + } catch (JAXBException e) { + e.printStackTrace(); + } + + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + +} diff --git a/xml/src/main/java/com/baeldung/xml/JaxenDemo.java b/xml/src/main/java/com/baeldung/xml/JaxenDemo.java new file mode 100644 index 0000000000..0c2dca0573 --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/JaxenDemo.java @@ -0,0 +1,57 @@ +package com.baeldung.xml; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.jaxen.JaxenException; +import org.jaxen.XPath; +import org.jaxen.dom.DOMXPath; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +public class JaxenDemo { + + private File file; + + public JaxenDemo(File file) { + this.file = file; + } + + public List getAllTutorial(){ + try { + FileInputStream fileIS = new FileInputStream(this.getFile()); + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder builder = builderFactory.newDocumentBuilder(); + + Document xmlDocument = builder.parse(fileIS); + + String expression = "/tutorials/tutorial"; + + XPath path = new DOMXPath(expression); + List result = path.selectNodes(xmlDocument); + return result; + + } catch (SAXException | IOException | ParserConfigurationException | JaxenException e) { + e.printStackTrace(); + return null; + } + + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + +} diff --git a/xml/src/main/java/com/baeldung/xml/StaxParser.java b/xml/src/main/java/com/baeldung/xml/StaxParser.java new file mode 100644 index 0000000000..6f83e022f8 --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/StaxParser.java @@ -0,0 +1,120 @@ +package com.baeldung.xml; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.Characters; +import javax.xml.stream.events.EndElement; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import com.baeldung.xml.model.Tutorial; + +public class StaxParser { + + private File file; + + public StaxParser(File file) { + this.file = file; + } + + public List getAllTutorial() { + boolean bTitle = false; + boolean bDescription = false; + boolean bDate = false; + boolean bAuthor = false; + List tutorials = new ArrayList(); + try { + XMLInputFactory factory = XMLInputFactory.newInstance(); + XMLEventReader eventReader = factory.createXMLEventReader(new FileReader(this.getFile())); + Tutorial current = null; + while (eventReader.hasNext()) { + XMLEvent event = eventReader.nextEvent(); + switch (event.getEventType()) { + case XMLStreamConstants.START_ELEMENT: + StartElement startElement = event.asStartElement(); + String qName = startElement.getName().getLocalPart(); + if (qName.equalsIgnoreCase("tutorial")) { + current = new Tutorial(); + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) { + Attribute currentAt = attributes.next(); + if (currentAt.getName().toString().equalsIgnoreCase("tutId")) { + current.setTutId(currentAt.getValue()); + } else if (currentAt.getName().toString().equalsIgnoreCase("type")) { + current.setType(currentAt.getValue()); + } + } + } else if (qName.equalsIgnoreCase("title")) { + bTitle = true; + } else if (qName.equalsIgnoreCase("description")) { + bDescription = true; + } else if (qName.equalsIgnoreCase("date")) { + bDate = true; + } else if (qName.equalsIgnoreCase("author")) { + bAuthor = true; + } + break; + case XMLStreamConstants.CHARACTERS: + Characters characters = event.asCharacters(); + if (bTitle) { + if (current != null) { + current.setTitle(characters.getData()); + } + bTitle = false; + } + if (bDescription) { + if (current != null) { + current.setDescription(characters.getData()); + } + bDescription = false; + } + if (bDate) { + if (current != null) { + current.setDate(characters.getData()); + } + bDate = false; + } + if (bAuthor) { + if (current != null) { + current.setAuthor(characters.getData()); + } + bAuthor = false; + } + break; + case XMLStreamConstants.END_ELEMENT: + EndElement endElement = event.asEndElement(); + if (endElement.getName().getLocalPart().equalsIgnoreCase("tutorial")) { + if(current != null){ + tutorials.add(current); + } + } + break; + } + } + + } catch (FileNotFoundException | XMLStreamException e) { + e.printStackTrace(); + } + + return tutorials; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + +} diff --git a/xml/src/main/java/com/baeldung/xml/binding/Tutorial.java b/xml/src/main/java/com/baeldung/xml/binding/Tutorial.java new file mode 100644 index 0000000000..c4668a9f77 --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/binding/Tutorial.java @@ -0,0 +1,61 @@ +package com.baeldung.xml.binding; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +public class Tutorial { + + private String tutId; + private String type; + private String title; + private String description; + private Date date; + private String author; + + + public String getTutId() { + return tutId; + } + + @XmlAttribute + public void setTutId(String tutId) { + this.tutId = tutId; + } + public String getType() { + return type; + } + @XmlAttribute + public void setType(String type) { + this.type = type; + } + public String getTitle() { + return title; + } + @XmlElement + public void setTitle(String title) { + this.title = title; + } + public String getDescription() { + return description; + } + @XmlElement + public void setDescription(String description) { + this.description = description; + } + public Date getDate() { + return date; + } + @XmlElement + public void setDate(Date date) { + this.date = date; + } + public String getAuthor() { + return author; + } + @XmlElement + public void setAuthor(String author) { + this.author = author; + } +} diff --git a/xml/src/main/java/com/baeldung/xml/binding/Tutorials.java b/xml/src/main/java/com/baeldung/xml/binding/Tutorials.java new file mode 100644 index 0000000000..ab6669c0ad --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/binding/Tutorials.java @@ -0,0 +1,23 @@ +package com.baeldung.xml.binding; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Tutorials { + + private List tutorial; + + public List getTutorial() { + return tutorial; + } + + @XmlElement + public void setTutorial(List tutorial) { + this.tutorial = tutorial; + } + + +} diff --git a/xml/src/main/java/com/baeldung/xml/model/Tutorial.java b/xml/src/main/java/com/baeldung/xml/model/Tutorial.java new file mode 100644 index 0000000000..40a3f858cf --- /dev/null +++ b/xml/src/main/java/com/baeldung/xml/model/Tutorial.java @@ -0,0 +1,49 @@ +package com.baeldung.xml.model; + +public class Tutorial { + + private String tutId; + private String type; + private String title; + private String description; + private String date; + private String author; + + + public String getTutId() { + return tutId; + } + public void setTutId(String tutId) { + this.tutId = tutId; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public String getAuthor() { + return author; + } + public void setAuthor(String author) { + this.author = author; + } +} diff --git a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java index 451917a5da..734e7a93cb 100644 --- a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java @@ -8,9 +8,6 @@ import org.junit.Test; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -/** - * Unit test for simple App. - */ public class DefaultParserTest { final String fileName = "src/test/resources/example.xml"; @@ -29,7 +26,7 @@ public class DefaultParserTest { } @Test - public void getNodeListByTitle() { + public void getNodeListByTitleTest() { parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("XML"); @@ -47,7 +44,7 @@ public class DefaultParserTest { } @Test - public void getNodeById() { + public void getNodeByIdTest() { parser = new DefaultParser(new File(fileName)); Node node = parser.getNodeById("03"); @@ -56,7 +53,7 @@ public class DefaultParserTest { } @Test - public void getNodeListByDate(){ + public void getNodeListByDateTest(){ parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("04022016"); for (int i = 0; null != list && i < list.getLength(); i++) { @@ -73,7 +70,7 @@ public class DefaultParserTest { } @Test - public void getNodeListWithNamespace(){ + public void getNodeListWithNamespaceTest(){ parser = new DefaultParser(new File(fileNameSpace)); NodeList list = parser.getAllTutorials(); assertNotNull(list); diff --git a/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java new file mode 100644 index 0000000000..277eca8355 --- /dev/null +++ b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java @@ -0,0 +1,88 @@ +package com.baeldung.xml; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.List; + +import org.dom4j.Element; +import org.dom4j.Node; +import org.junit.Test; + +public class Dom4JParserTest { + + final String fileName = "src/test/resources/example.xml"; + + Dom4JParser parser; + + @Test + public void getRootElementTest() { + parser = new Dom4JParser(new File(fileName)); + Element root = parser.getRootElement(); + + assertNotNull(root); + assertTrue(root.elements().size() == 4); + } + + @Test + public void getFirstElementListTest() { + parser = new Dom4JParser(new File(fileName)); + List firstList = parser.getFirstElementList(); + + assertNotNull(firstList); + assertTrue(firstList.size() == 4); + assertTrue(firstList.get(0).attributeValue("type").equals("java")); + } + + @Test + public void getElementByIdTest() { + parser = new Dom4JParser(new File(fileName)); + Node element = parser.getNodeById("03"); + + String type = element.valueOf("@type"); + assertEquals("android", type); + } + + @Test + public void getElementsListByTitleTest() { + parser = new Dom4JParser(new File(fileName)); + Node element = parser.getElementsListByTitle("XML"); + + assertEquals("java", element.valueOf("@type")); + assertEquals("02", element.valueOf("@tutId")); + assertEquals("XML", element.selectSingleNode("title").getText()); + assertEquals("title", element.selectSingleNode("title").getName()); + } + + @Test + public void generateModifiedDocumentTest() { + parser = new Dom4JParser(new File(fileName)); + parser.generateModifiedDocument(); + + File generatedFile = new File("src/test/resources/example_updated.xml"); + assertTrue(generatedFile.exists()); + + parser.setFile(generatedFile); + Node element = parser.getNodeById("02"); + + assertEquals("XML updated", element.selectSingleNode("title").getText()); + + } + + @Test + public void generateNewDocumentTest() { + parser = new Dom4JParser(new File(fileName)); + parser.generateNewDocument(); + + File newFile = new File("src/test/resources/example_new.xml"); + assertTrue(newFile.exists()); + + parser.setFile(newFile); + Node element = parser.getNodeById("01"); + + assertEquals("XML with Dom4J", element.selectSingleNode("title").getText()); + + } +} diff --git a/xml/src/test/java/com/baeldung/xml/JDomParserTest.java b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java new file mode 100644 index 0000000000..981458469f --- /dev/null +++ b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java @@ -0,0 +1,38 @@ +package com.baeldung.xml; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.List; + +import org.jdom2.Element; +import org.junit.Test; + +public class JDomParserTest { + + final String fileName = "src/test/resources/example.xml"; + + JDomParser parser; + + @Test + public void getFirstElementListTest() { + parser = new JDomParser(new File(fileName)); + List firstList = parser.getAllTitles(); + + assertNotNull(firstList); + assertTrue(firstList.size() == 4); + assertTrue(firstList.get(0).getAttributeValue("type").equals("java")); + } + + @Test + public void getElementByIdTest() { + parser = new JDomParser(new File(fileName)); + Element el = parser.getNodeById("03"); + + String type = el.getAttributeValue("type"); + assertEquals("android", type); + } + +} diff --git a/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java new file mode 100644 index 0000000000..4d6ddf5f65 --- /dev/null +++ b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java @@ -0,0 +1,46 @@ +package com.baeldung.xml; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.dom4j.Node; +import org.junit.Test; + +import com.baeldung.xml.binding.Tutorials; + +public class JaxbParserTest { + + + final String fileName = "src/test/resources/example.xml"; + + JaxbParser parser; + + @Test + public void getFullDocumentTest(){ + parser = new JaxbParser(new File(fileName)); + Tutorials tutorials = parser.getFullDocument(); + + assertNotNull(tutorials); + assertTrue(tutorials.getTutorial().size() == 4); + assertTrue(tutorials.getTutorial().get(0).getType().equalsIgnoreCase("java")); + } + + @Test + public void createNewDocumentTest(){ + File newFile = new File("src/test/resources/example_new.xml"); + parser = new JaxbParser(newFile); + parser.createNewDocument(); + + + assertTrue(newFile.exists()); + + Tutorials tutorials = parser.getFullDocument(); + + assertNotNull(tutorials); + assertTrue(tutorials.getTutorial().size() == 1); + assertTrue(tutorials.getTutorial().get(0).getTitle().equalsIgnoreCase("XML with Jaxb")); + } +} diff --git a/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java new file mode 100644 index 0000000000..2521fcaf8a --- /dev/null +++ b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java @@ -0,0 +1,25 @@ +package com.baeldung.xml; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.List; + +import org.junit.Test; + +public class JaxenDemoTest { + + final String fileName = "src/test/resources/example.xml"; + + JaxenDemo jaxenDemo; + + @Test + public void getFirstLevelNodeListTest() { + jaxenDemo = new JaxenDemo(new File(fileName)); + List list = jaxenDemo.getAllTutorial(); + + assertNotNull(list); + assertTrue(list.size() == 4); + } +} diff --git a/xml/src/test/java/com/baeldung/xml/StaxParserTest.java b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java new file mode 100644 index 0000000000..3188777a79 --- /dev/null +++ b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java @@ -0,0 +1,28 @@ +package com.baeldung.xml; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.List; + +import org.junit.Test; + +import com.baeldung.xml.model.Tutorial; + +public class StaxParserTest { + + final String fileName = "src/test/resources/example.xml"; + + StaxParser parser; + + @Test + public void getAllTutorialsTest(){ + parser = new StaxParser(new File(fileName)); + List tutorials = parser.getAllTutorial(); + + assertNotNull(tutorials); + assertTrue(tutorials.size() == 4); + assertTrue(tutorials.get(0).getType().equalsIgnoreCase("java")); + } +} diff --git a/xml/src/test/resources/example.xml b/xml/src/test/resources/example.xml index d546dd137b..0993b6240a 100644 --- a/xml/src/test/resources/example.xml +++ b/xml/src/test/resources/example.xml @@ -1,24 +1,24 @@ - - + + Guava Introduction to Guava 04/04/2016 GuavaAuthor - - + + XML Introduction to XPath 04/05/2016 XMLAuthor - - + + Android Introduction to Android 04/03/2016 AndroidAuthor - - + + Spring Introduction to Spring 04/02/2016 @@ -28,5 +28,5 @@
Spring MVC
Spring Batch
-
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/xml/src/test/resources/example_namespace.xml b/xml/src/test/resources/example_namespace.xml index 26131302ea..f1a880951a 100644 --- a/xml/src/test/resources/example_namespace.xml +++ b/xml/src/test/resources/example_namespace.xml @@ -1,24 +1,24 @@ - - + + Guava Introduction to Guava 04/04/2016 GuavaAuthor - - + + XML Introduction to XPath 04/05/2016 XMLAuthor - - + + Android Introduction to Android 04/03/2016 AndroidAuthor - - + + Spring Introduction to Spring 04/02/2016 @@ -28,5 +28,5 @@
Spring MVC
Spring Batch
-
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/xml/src/test/resources/example_new.xml b/xml/src/test/resources/example_new.xml new file mode 100644 index 0000000000..020760fdd3 --- /dev/null +++ b/xml/src/test/resources/example_new.xml @@ -0,0 +1,10 @@ + + + + + XML with Dom4J + XML handling with Dom4J + 14/06/2016 + Dom4J tech writer + + diff --git a/xml/src/test/resources/example_updated.xml b/xml/src/test/resources/example_updated.xml new file mode 100644 index 0000000000..962ca0c889 --- /dev/null +++ b/xml/src/test/resources/example_updated.xml @@ -0,0 +1,32 @@ + + + + Guava updated + Introduction to Guava + 04/04/2016 + GuavaAuthor + + + XML updated + Introduction to XPath + 04/05/2016 + XMLAuthor + + + Android updated + Introduction to Android + 04/03/2016 + AndroidAuthor + + + Spring updated + Introduction to Spring + 04/02/2016 + SpringAuthor + +
Spring Core
+
Spring MVC
+
Spring Batch
+
+
+
\ No newline at end of file From 40ed303abc75817d344c7cd736c828a846c88f74 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 26 Jun 2016 11:59:31 +0200 Subject: [PATCH 04/33] Refactor xml examples --- .../com/baeldung/xml/DefaultParserTest.java | 20 +++++++------ .../com/baeldung/xml/Dom4JParserTest.java | 30 +++++++++---------- .../java/com/baeldung/xml/JDomParserTest.java | 16 +++++----- .../java/com/baeldung/xml/JaxbParserTest.java | 15 ++++------ .../java/com/baeldung/xml/JaxenDemoTest.java | 10 +++---- .../java/com/baeldung/xml/StaxParserTest.java | 13 ++++---- 6 files changed, 51 insertions(+), 53 deletions(-) diff --git a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java index 734e7a93cb..7408e41b92 100644 --- a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java @@ -1,20 +1,22 @@ package com.baeldung.xml; -import static org.junit.Assert.*; - -import java.io.File; - import org.junit.Test; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.io.File; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class DefaultParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - final String fileNameSpace = "src/test/resources/example_namespace.xml"; + private final String fileNameSpace = "src/test/resources/example_namespace.xml"; - DefaultParser parser; + private DefaultParser parser; @Test public void getFirstLevelNodeListTest() { @@ -30,7 +32,7 @@ public class DefaultParserTest { parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("XML"); - for (int i = 0; null != list && i < list.getLength(); i++) { + for (int i = 0; i < list.getLength(); i++) { Node nod = list.item(i); assertEquals("java", nod.getAttributes().getNamedItem("type").getTextContent()); assertEquals("02", nod.getAttributes().getNamedItem("tutId").getTextContent()); @@ -56,7 +58,7 @@ public class DefaultParserTest { public void getNodeListByDateTest(){ parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("04022016"); - for (int i = 0; null != list && i < list.getLength(); i++) { + for (int i = 0; i < list.getLength(); i++) { Node nod = list.item(i); assertEquals("java", nod.getAttributes().getNamedItem("type").getTextContent()); assertEquals("04", nod.getAttributes().getNamedItem("tutId").getTextContent()); diff --git a/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java index 277eca8355..77e5fcdcda 100644 --- a/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java @@ -1,25 +1,25 @@ package com.baeldung.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.List; - import org.dom4j.Element; import org.dom4j.Node; import org.junit.Test; +import java.io.File; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class Dom4JParserTest { - final String fileName = "src/test/resources/example.xml"; + private static final String FILE_NAME = "src/test/resources/example.xml"; - Dom4JParser parser; + private Dom4JParser parser; @Test public void getRootElementTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Element root = parser.getRootElement(); assertNotNull(root); @@ -28,7 +28,7 @@ public class Dom4JParserTest { @Test public void getFirstElementListTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); List firstList = parser.getFirstElementList(); assertNotNull(firstList); @@ -38,7 +38,7 @@ public class Dom4JParserTest { @Test public void getElementByIdTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Node element = parser.getNodeById("03"); String type = element.valueOf("@type"); @@ -47,7 +47,7 @@ public class Dom4JParserTest { @Test public void getElementsListByTitleTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Node element = parser.getElementsListByTitle("XML"); assertEquals("java", element.valueOf("@type")); @@ -58,7 +58,7 @@ public class Dom4JParserTest { @Test public void generateModifiedDocumentTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); parser.generateModifiedDocument(); File generatedFile = new File("src/test/resources/example_updated.xml"); @@ -73,7 +73,7 @@ public class Dom4JParserTest { @Test public void generateNewDocumentTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); parser.generateNewDocument(); File newFile = new File("src/test/resources/example_new.xml"); diff --git a/xml/src/test/java/com/baeldung/xml/JDomParserTest.java b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java index 981458469f..e4034c48f0 100644 --- a/xml/src/test/java/com/baeldung/xml/JDomParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java @@ -1,20 +1,20 @@ package com.baeldung.xml; +import org.jdom2.Element; +import org.junit.Test; + +import java.io.File; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.io.File; -import java.util.List; - -import org.jdom2.Element; -import org.junit.Test; - public class JDomParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JDomParser parser; + private JDomParser parser; @Test public void getFirstElementListTest() { diff --git a/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java index 4d6ddf5f65..6e1a201b59 100644 --- a/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java @@ -1,22 +1,19 @@ package com.baeldung.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import com.baeldung.xml.binding.Tutorials; +import org.junit.Test; import java.io.File; -import org.dom4j.Node; -import org.junit.Test; - -import com.baeldung.xml.binding.Tutorials; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class JaxbParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JaxbParser parser; + private JaxbParser parser; @Test public void getFullDocumentTest(){ diff --git a/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java index 2521fcaf8a..8a88484f11 100644 --- a/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java +++ b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java @@ -1,18 +1,18 @@ package com.baeldung.xml; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.Test; import java.io.File; import java.util.List; -import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class JaxenDemoTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JaxenDemo jaxenDemo; + private JaxenDemo jaxenDemo; @Test public void getFirstLevelNodeListTest() { diff --git a/xml/src/test/java/com/baeldung/xml/StaxParserTest.java b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java index 3188777a79..d1080c88ac 100644 --- a/xml/src/test/java/com/baeldung/xml/StaxParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java @@ -1,20 +1,19 @@ package com.baeldung.xml; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import com.baeldung.xml.model.Tutorial; +import org.junit.Test; import java.io.File; import java.util.List; -import org.junit.Test; - -import com.baeldung.xml.model.Tutorial; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class StaxParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - StaxParser parser; + private StaxParser parser; @Test public void getAllTutorialsTest(){ From 6d897e664b78f0771224f78b38238eb11b3c1704 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:14:10 +0300 Subject: [PATCH 05/33] Update README.md --- httpclient/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpclient/README.md b/httpclient/README.md index e06c57da71..a848edfea6 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -1,7 +1,9 @@ ========= - ## HttpClient 4.x Cookbooks and Examples +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + ### Relevant Articles: From d232553cbf0a34ea30277600106f3f9d91992a80 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:16:18 +0300 Subject: [PATCH 06/33] Update README.md --- jackson/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jackson/README.md b/jackson/README.md index 53b9c7c31d..68765de686 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -2,6 +2,9 @@ ## Jackson Cookbooks and Examples +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + ### 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) From 594ab38b16d5a4bd66c2b4405c05c59af65f6e23 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:20:19 +0300 Subject: [PATCH 07/33] Update README.md --- rest-testing/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest-testing/README.md b/rest-testing/README.md index db7f0c8a86..54a2e98dda 100644 --- a/rest-testing/README.md +++ b/rest-testing/README.md @@ -2,6 +2,8 @@ ## REST Testing and Examples +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Test a REST API with Java](http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/) From 49e996888f586ecf25d29917c93a3f32d73e70de Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:21:06 +0300 Subject: [PATCH 08/33] Update README.md --- spring-all/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-all/README.md b/spring-all/README.md index 977b8b7357..3188d0a42c 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -2,6 +2,9 @@ ## Spring General Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + This project is used to replicate Spring Exceptions only. From 92d44e3dcdbe415532864ac12434d26f5c04a219 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:21:31 +0300 Subject: [PATCH 09/33] Update README.md --- spring-all/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-all/README.md b/spring-all/README.md index 3188d0a42c..47c947a414 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -2,11 +2,10 @@ ## Spring General Example Project -###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring - This project is used to replicate Spring Exceptions only. +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### 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 From 862c13eb9244f0f57bc927adceb8038fb390c9ea Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:22:26 +0300 Subject: [PATCH 10/33] Update README.md --- spring-data-rest/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-data-rest/README.md b/spring-data-rest/README.md index d9be83113b..7dc439206b 100644 --- a/spring-data-rest/README.md +++ b/spring-data-rest/README.md @@ -1,3 +1,6 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + # About this project This project contains examples from the [Introduction to Spring Data REST](http://www.baeldung.com/spring-data-rest-intro) article from Baeldung. From 413ccc79c268aef96df59eba9b3024555a13f40f Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:24:40 +0300 Subject: [PATCH 11/33] Update README.md --- spring-katharsis/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-katharsis/README.md b/spring-katharsis/README.md index ec0141f41a..cf2a001760 100644 --- a/spring-katharsis/README.md +++ b/spring-katharsis/README.md @@ -2,5 +2,8 @@ ## Java Web Application +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + ### Relevant Articles: - [JSON API in a Java Web Application](http://www.baeldung.com/json-api-java-spring-web-app) From 7d1d6327174b6be40435eaa2748cc0dcdc923799 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:26:30 +0300 Subject: [PATCH 12/33] Create README.MD --- raml/README.MD | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 raml/README.MD diff --git a/raml/README.MD b/raml/README.MD new file mode 100644 index 0000000000..2a87b46021 --- /dev/null +++ b/raml/README.MD @@ -0,0 +1,2 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring From 779b8ecfd64ca93367ea0fbc86c964c39e5f7a4b Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:27:04 +0300 Subject: [PATCH 13/33] Create README.MD --- spring-boot/README.MD | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-boot/README.MD diff --git a/spring-boot/README.MD b/spring-boot/README.MD new file mode 100644 index 0000000000..2a87b46021 --- /dev/null +++ b/spring-boot/README.MD @@ -0,0 +1,2 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring From 46d5938ab63335c214e0903020a176b38cf2784d Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:27:43 +0300 Subject: [PATCH 14/33] Update README.md --- spring-mvc-java/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index e5264b0370..951d80033e 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -2,6 +2,8 @@ ## Spring MVC with Java Configuration Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) From 2d65d5227434b6b8ba63dedd60edfaedd20dd72c Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:28:30 +0300 Subject: [PATCH 15/33] Update README.md --- spring-mvc-no-xml/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-mvc-no-xml/README.md b/spring-mvc-no-xml/README.md index 5ffe2385b5..208cb35f78 100644 --- a/spring-mvc-no-xml/README.md +++ b/spring-mvc-no-xml/README.md @@ -2,6 +2,8 @@ ## Spring MVC with NO XML Configuration Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- \ No newline at end of file +- From 1f2666090c39959d0782d90c302979bcbe7d4f54 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:29:00 +0300 Subject: [PATCH 16/33] Update README.md --- spring-mvc-xml/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 2409ec8174..ce823a9682 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,5 +1,8 @@ ========= +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + ## Spring MVC with XML Configuration Example Project - access a sample jsp page at: `http://localhost:8080/spring-mvc-xml/sample.html` From 96e903feebb8e4441530558ec4775e9061bd819e Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:29:36 +0300 Subject: [PATCH 17/33] Create README.MD --- spring-rest-docs/README.MD | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-rest-docs/README.MD diff --git a/spring-rest-docs/README.MD b/spring-rest-docs/README.MD new file mode 100644 index 0000000000..2a87b46021 --- /dev/null +++ b/spring-rest-docs/README.MD @@ -0,0 +1,2 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring From 7d7c5f3d8a86249177f0dce8ee0806a0d7c22cc4 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:30:06 +0300 Subject: [PATCH 18/33] Update README.md --- spring-rest/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-rest/README.md b/spring-rest/README.md index 9d373962c4..7d993b38b8 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -2,6 +2,8 @@ ## Spring REST Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) From 89cae684875290955a524217bedc6f224d2785e7 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:30:45 +0300 Subject: [PATCH 19/33] Update README.md --- spring-security-basic-auth/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-security-basic-auth/README.md b/spring-security-basic-auth/README.md index 95e45ae519..f3c29e1777 100644 --- a/spring-security-basic-auth/README.md +++ b/spring-security-basic-auth/README.md @@ -2,6 +2,8 @@ ## Spring Security with Basic Authentication Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Article: - [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) @@ -9,4 +11,4 @@ ### Notes -- the project includes both views as well as a REST layer \ No newline at end of file +- the project includes both views as well as a REST layer From 134a4a0e1ae2415491596fbdb3172fde3b2e8c16 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:31:19 +0300 Subject: [PATCH 20/33] Create README.MD --- spring-security-client/README.MD | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-security-client/README.MD diff --git a/spring-security-client/README.MD b/spring-security-client/README.MD new file mode 100644 index 0000000000..2a87b46021 --- /dev/null +++ b/spring-security-client/README.MD @@ -0,0 +1,2 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring From 4e183efda376f63d89dc25e8565e6927eee2f401 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:32:12 +0300 Subject: [PATCH 21/33] Create README.MD --- spring-scurity-custom-permission/README.MD | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-scurity-custom-permission/README.MD diff --git a/spring-scurity-custom-permission/README.MD b/spring-scurity-custom-permission/README.MD new file mode 100644 index 0000000000..8fb14fa522 --- /dev/null +++ b/spring-scurity-custom-permission/README.MD @@ -0,0 +1,2 @@ +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity From f0e103b1911e8eb808f6d4d955a055a2cf350646 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:32:45 +0300 Subject: [PATCH 22/33] Update README.md --- spring-security-mvc-custom/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 17f32e4a2f..cbf5fc6a97 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -2,6 +2,8 @@ ## Spring Security Login Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) From 915fa89f8949c6ca5966ad93df3cee64d6dbaa50 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:33:11 +0300 Subject: [PATCH 23/33] Update README.md --- spring-security-rest-custom/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index f19af32d41..38dc638e8d 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -2,6 +2,9 @@ ## Spring Security for REST Example Project +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + ### Relevant Articles: - [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) - [Retrieve User Information in Spring Security](http://www.baeldung.com/get-user-in-spring-security) From 5b80cbd556d8bd95afa08e09daada41310ce9559 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:33:40 +0300 Subject: [PATCH 24/33] Update README.md --- spring-security-mvc-digest-auth/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-mvc-digest-auth/README.md b/spring-security-mvc-digest-auth/README.md index 3b93a84505..21835266bf 100644 --- a/spring-security-mvc-digest-auth/README.md +++ b/spring-security-mvc-digest-auth/README.md @@ -2,6 +2,8 @@ ## Spring Security with Digest Authentication Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Article: - [Spring Security Digest Authentication](http://www.baeldung.com/spring-security-digest-authentication) From 71e18a28a09e8d447ad21c0650b6398ca4535177 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:34:22 +0300 Subject: [PATCH 25/33] Update README.md --- spring-security-mvc-ldap/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-mvc-ldap/README.md b/spring-security-mvc-ldap/README.md index 686f611f99..1eb3b75405 100644 --- a/spring-security-mvc-ldap/README.md +++ b/spring-security-mvc-ldap/README.md @@ -1,6 +1,8 @@ ## Spring Security with LDAP Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Article: - [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) From 2018411b14a8e10f7b64aed233403a1c74f7e378 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:35:04 +0300 Subject: [PATCH 26/33] Update README.md --- spring-security-mvc-login/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-security-mvc-login/README.md b/spring-security-mvc-login/README.md index 256078f4b6..448c25d27b 100644 --- a/spring-security-mvc-login/README.md +++ b/spring-security-mvc-login/README.md @@ -2,11 +2,13 @@ ## Spring Security Login Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: - [Spring Security Form Login](http://www.baeldung.com/spring-security-login) - [Spring Security Logout](http://www.baeldung.com/spring-security-logout) -- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) +- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) ### Build the Project From 4c912d8a5107e8c11837efa3ae5fb698547779c8 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:35:35 +0300 Subject: [PATCH 27/33] Update README.md --- spring-security-mvc-persisted-remember-me/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-mvc-persisted-remember-me/README.md b/spring-security-mvc-persisted-remember-me/README.md index df83fd3d77..0d5f4f5f0e 100644 --- a/spring-security-mvc-persisted-remember-me/README.md +++ b/spring-security-mvc-persisted-remember-me/README.md @@ -2,6 +2,8 @@ ## Spring Security Persisted Remember Me Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: - [Spring Security Persisted Remember Me](http://www.baeldung.com/spring-security-persistent-remember-me) From ed9a36bd31738271a47b89cfc7f575edb1280fdb Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:36:02 +0300 Subject: [PATCH 28/33] Update README.md --- spring-security-mvc-session/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-security-mvc-session/README.md b/spring-security-mvc-session/README.md index 0df728688a..28f216c130 100644 --- a/spring-security-mvc-session/README.md +++ b/spring-security-mvc-session/README.md @@ -2,9 +2,11 @@ ## Spring Security Login Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: -- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) +- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) - [Spring Security Session Management](http://www.baeldung.com/spring-security-session) From 4162c4671e9bff40e950cd19e3850617ab6bb234 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:36:31 +0300 Subject: [PATCH 29/33] Update README.md --- spring-security-rest-basic-auth/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md index 723bcebbdd..9621773d91 100644 --- a/spring-security-rest-basic-auth/README.md +++ b/spring-security-rest-basic-auth/README.md @@ -2,6 +2,8 @@ ## REST API with Basic Authentication - Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: - [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1) From e3fc9bca7de968c634819edfbed483fdcf6b0d5e Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:36:58 +0300 Subject: [PATCH 30/33] Update README.md --- spring-security-rest-digest-auth/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-rest-digest-auth/README.md b/spring-security-rest-digest-auth/README.md index 06e847edad..4fdc934fe5 100644 --- a/spring-security-rest-digest-auth/README.md +++ b/spring-security-rest-digest-auth/README.md @@ -2,6 +2,8 @@ ## REST API with Digest Authentication - Example Project +###The Course +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: - [RestTemplate with Digest Authentication](http://www.baeldung.com/resttemplate-digest-authentication) From 9b7cf1152d2709df58b0e8bab9503ded68343d55 Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:37:34 +0300 Subject: [PATCH 31/33] Update README.md --- spring-security-rest-full/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index 72e8636df1..ca18ebe79a 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -2,8 +2,9 @@ ## REST Example Project with Spring Security -### The Course - The "REST With Spring" Classes: http://bit.ly/restwithspring +### Courses +The "REST With Spring" Classes: http://bit.ly/restwithspring +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: - [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) From ea0907bd383cd5fbcfcf111fbba084932f34852c Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:38:19 +0300 Subject: [PATCH 32/33] 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 ca18ebe79a..947d32e87c 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -4,6 +4,7 @@ ### Courses The "REST With Spring" Classes: http://bit.ly/restwithspring + The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### Relevant Articles: From a79e7b7ea24ba8285a858d1ef06d52165b86969b Mon Sep 17 00:00:00 2001 From: m0cacin0 Date: Tue, 28 Jun 2016 12:38:51 +0300 Subject: [PATCH 33/33] Update README.md --- spring-security-rest/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index 290cd491e0..87f14a9047 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -2,6 +2,10 @@ ## Spring Security for REST Example Project +### Courses +The "REST With Spring" Classes: http://bit.ly/restwithspring + +The "Learn Spring Security" Classes: http://bit.ly/learnspringsecurity ### 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/)