* Change text/xml to application/xml

* Revert "Change text/xml to application/xml"

This reverts commit b61b82cd2a31831c43df1993d36997c762e21907.

* Apache CXF Aegis data bindings

* remove else condition

* remove else condition

* spring retry introduction

* remove else condition

* remove spring retry, format code

* BAEL-315 Removing the unnecessary version on spring session. Renaming the module from spring-cloud-integration to spring-could-bootstrap

* add unit test

* BAEL-40: Add NDC and JBoss Logging to the demo application (#880)

* Add NDC and JBoss Logging to the demo application

* NDC for Log4j, Log4j2 and JBoss Logging

* Simplify NDC example by making it a single operation instead of two

* Make NDC example as RestController, Use JBoss Logging only as a logging bridge

* Fix merge conflicts in pull request - log-mdc pom.xml updated

* Simulated Annealing algorithm (#900)

* @Async and Spring Security

* @Async with SecurityContext propagated

* Spring and @Async

* Simulated Annealing algorithm

* Simulated Annealing algorithm

* Rebase

* Rebase

* create intelliJ formatter

* fix intelliJ formatter

* add unit test

* BAEL-36 BAEL-282 Getting file size using Java and apache commons IO api. Also grep in Java (#890)

* BAL-36 File size api in java and apache commons IO

* BAEL-36 Getting file size using Java and commons IO api.

* BAEL-282 Added support for grep functionality.

* BAEL-282 Rename the text file extension.

* maven fix and small formatting work

* BAEL-35: Added test methods using Apache Commons Collections4

* Created README.md and added relevant articles (#901)

* Added relevant articles

* Added relevant articles

* Added relevant articles

* Created README.md and added relevant articles

* Created README.md and added relevant articles

* Added relevant articles

* Added relevant articles

* Created README.md and added relevant articles

* Created README.md and added relevant articles

* Created README.md and added relevant articles

* Added relevant articles

* Created README.md and added relevant articles

* Added relevant articles

* Added relevant articles

* Update README.md

* Added relevant articles

* Added relevant articles

* Added relevant articles

* Update README.md

* Added relevant articles

* Update README.md

* Created README.md and added relevant articles

* Added relevant articles

* Added relevant articles

* Added relevant articles

* Added relevant articles

* Created README.md and added relevant articles

* Update README.md

* Refactor EJBClient.java

* BAEL-282 - Grep in Java after code review (#903)

* BAEL-242 Package refactoring after code review for article Grep in Java

* BAEL-282 Updated readme file

* Update README.md

* maven cleanup work

* maven cleanup work

* Pull Request for "A Guide to Rolling File Appenders" article. (#876)

* First test with log4j rolling appenders

* small fix

* Log4j rolling appender

* First set up with rolling file on log4j 2

* Added logback code.

* log4j2 more detailed example

* log4j2 more detailed example

* Improved names and examples

* Fixed configurations

* improved configs

* formatted

* Final fix

* fixed formatting

* Formatting fix

* Fix sample apps to avoid try / catch

* Fix request to replace files

* Fix end lines

* maven work

* init

* cleanup work

* cleanup work

* Update README.md

* set default timezone

* Simulated Annnealing fixes (#907)

* @Async and Spring Security

* @Async with SecurityContext propagated

* Spring and @Async

* Simulated Annealing algorithm

* Simulated Annealing algorithm

* Rebase

* Rebase

* Nashorn (#896)

* Simulated Annealing fix (#910)

* @Async and Spring Security

* @Async with SecurityContext propagated

* Spring and @Async

* Simulated Annealing algorithm

* Simulated Annealing algorithm

* Rebase

* Rebase

* SA further fixes

* change tab to space in xml files and add equal, hashcode, toString using apache commons lang

* BAEL-315 Adding test class for demonstrating features of Spring Session and Spring Cloud

* add integration profile

* add live profile

* add integration profile

* add integration profile

* add integration profile

* BAEL-127: Spring Security - @PreFilter and @PostFilter (#911)

* BAEL-127: simple app with filters

* removed data rest dependency, final adjustments

* added first live test for the rest api

* move filters code to new module

* moved to root of module, create service layer, standard pom

* added spring-security-core module to root pom

* Modified code to reflect the code from the article

* Merge changes from branch

* BAEL-315 - skipping live test

* adding missing modules to parent pom

* Advanced Camel article (#905)

* - changed test package name from org.baeldung to com.baeldung
- streams are added where neccessary
- format fixes

* Adding Java config for Content Based File Router

* Adding Java config for Content Based File Router

* Code for Map (#909)

* made changes to java reflection

* removed redundant method makeSound in Animal abstract class

* added project for play-framework article

* added project for regex

* changed regex project from own model to core-java

* added project for routing in play

* made changes to regex project

* refactored code for REST API with Play project

* refactored student store indexing to zero base

* added unit tests, removed bad names

* added NIO Selector project under core-java module

* requested changes made

* added project for nio2

* standardized exception based tests

* fixed exception based tests

* removed redundant files

* added network interface project

* used UUID other than timestamps

* fixed network interface tests

* removed filetest change

* made changes to NIO2 FileTest names

* added project for asyncronous channel apis

* added project for NIO2 advanced filesystems APIS

* merge conflicts

* merged changes to asyncfiletest with future get API

* removed while loops from async client and server

* added project for java8 optional

* fixed merge conflicts in spring-core

* fixed optional

* fixed optional

* fixed asyncechotest

* shifted optional to own package

* made additional tests to demo filter API

* added code for Map

* change unit test package dir

* minor maven cleanup

* Reformat JaxbTest

* Added demonstration of @JsonFormat and associated test. (#906)

* remove duplicate test

* rename tests

* delete bool.xml file

* remove jaxb

* spring retry introduction

* remove else condition

* remove spring retry, format code
This commit is contained in:
Tuan 2016-12-24 00:41:51 +07:00 committed by Zeger Hendrikse
parent d61e7ec8e8
commit 5226c5f414
5 changed files with 169 additions and 233 deletions

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book id="1">
<title>Book1</title>
<date>2016-12-16T17:28:49.718Z</date>
</book>

View File

@ -1,188 +1,167 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>jaxb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jaxb</name>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>jaxb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jaxb</name>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
<!-- utils -->
<dependency>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
<version>3.0.2</version>
</dependency>
<!-- utils -->
<dependency>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
</dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<build>
<finalName>jaxb</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<versionRange>[${jaxb2-maven-plugin.version},)</versionRange>
<goals>
<goal>schemagen</goal>
<goal>xjc</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<build>
<finalName>jaxb</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<!-- xjc -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2-maven-plugin.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<xjbSources>
<xjbSource>src/main/resources/global.xjb</xjbSource>
</xjbSources>
<sources>
<source>src/main/resources/user.xsd</source>
</sources>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<versionRange>[${jaxb2-maven-plugin.version},)</versionRange>
<goals>
<goal>schemagen</goal>
<goal>xjc</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!-- schemagen -->
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2-maven-plugin.version}</version>
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/java/com/baeldung/jaxb/gen</source>
</sources>
<outputDirectory>src/main/resources</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<transformSchemas>
<transformSchema>
<uri>http://www.baeldung.com/jaxb/gen</uri>
<toPrefix>user</toPrefix>
<toFile>gen-schema.xsd</toFile>
</transformSchema>
</transformSchemas>
</configuration>
</plugin>
-->
</plugins>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<properties>
<!-- jaxb -->
<jaxb.version>2.2.11</jaxb.version>
<!-- xjc -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2-maven-plugin.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<xjbSources>
<xjbSource>src/main/resources/global.xjb</xjbSource>
</xjbSources>
<sources>
<source>src/main/resources/user.xsd</source>
</sources>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.7</logback.version>
<!-- schemagen -->
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2-maven-plugin.version}</version> <executions> <execution>
<id>schemagen</id> <goals> <goal>schemagen</goal> </goals> </execution> </executions>
<configuration> <sources> <source>src/main/java/com/baeldung/jaxb/gen</source>
</sources> <outputDirectory>src/main/resources</outputDirectory> <clearOutputDir>false</clearOutputDir>
<transformSchemas> <transformSchema> <uri>http://www.baeldung.com/jaxb/gen</uri>
<toPrefix>user</toPrefix> <toFile>gen-schema.xsd</toFile> </transformSchema>
</transformSchemas> </configuration> </plugin> -->
</plugins>
</build>
<!-- maven plugins -->
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<jaxb2-maven-plugin.version>2.3</jaxb2-maven-plugin.version>
<junit.version>4.12</junit.version>
</properties>
<properties>
<!-- jaxb -->
<jaxb.version>2.2.11</jaxb.version>
</project>
<!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.7</logback.version>
<!-- maven plugins -->
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<jaxb2-maven-plugin.version>2.3</jaxb2-maven-plugin.version>
<junit.version>4.12</junit.version>
</properties>
</project>

View File

@ -1,41 +0,0 @@
package com.baeldung.jaxb;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.TimeZone;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
public class Main {
public static void marshal() throws JAXBException, IOException {
Book book = new Book();
book.setId(1L);
book.setName("Book1");
book.setAuthor("Author1");
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
book.setDate(new Date(1481909329718L));
JAXBContext context = JAXBContext.newInstance(Book.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(book, new File("./book.xml"));
}
public static Book unMashal() throws JAXBException, IOException {
JAXBContext context = JAXBContext.newInstance(Book.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
Book book = (Book) unmarshaller.unmarshal(new FileReader("./book.xml"));
return book;
}
public static void main(String[] args) throws JAXBException, IOException {
marshal();
Book book = unMashal();
System.out.println(book.toString());
}
}

View File

@ -1,6 +1,16 @@
package com.baeldung.jaxb.test;
import com.baeldung.jaxb.Book;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.TimeZone;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
@ -8,15 +18,7 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.TimeZone;
import com.baeldung.jaxb.Book;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class JaxbTest {
@ -37,18 +39,19 @@ public class JaxbTest {
public void marshal() throws JAXBException, IOException {
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(book, new File("./book.xml"));
String sampleBookXML = FileUtils.readFileToString(new File("./sample_book.xml"), "UTF-8");
String marshallerBookXML = FileUtils.readFileToString(new File("./book.xml"), "UTF-8");
marshaller.marshal(book, new File(this.getClass().getResource("/").getPath() + "/book.xml"));
File sampleBookFile = new File(this.getClass().getResource("/sample_book.xml").getFile());
File bookFile = new File(this.getClass().getResource("/book.xml").getFile());
String sampleBookXML = FileUtils.readFileToString(sampleBookFile, "UTF-8");
String marshallerBookXML = FileUtils.readFileToString(bookFile, "UTF-8");
Assert.assertEquals(sampleBookXML, marshallerBookXML);
}
@Test
public void unMashal() throws JAXBException, IOException {
Unmarshaller unmarshaller = context.createUnmarshaller();
Book unMarshallerbook = (Book) unmarshaller.unmarshal(new FileReader("./book.xml"));
String bookFile = this.getClass().getResource("/book.xml").getFile();
Book unMarshallerbook = (Book) unmarshaller.unmarshal(new FileReader(bookFile));
Assert.assertEquals(book, unMarshallerbook);
}
}