BAEL-406 (#902)
* 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:
parent
d61e7ec8e8
commit
5226c5f414
@ -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>
|
|
37
jaxb/pom.xml
37
jaxb/pom.xml
@ -139,35 +139,14 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- schemagen -->
|
<!-- schemagen -->
|
||||||
<!--
|
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId>
|
||||||
<plugin>
|
<version>${jaxb2-maven-plugin.version}</version> <executions> <execution>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<id>schemagen</id> <goals> <goal>schemagen</goal> </goals> </execution> </executions>
|
||||||
<artifactId>jaxb2-maven-plugin</artifactId>
|
<configuration> <sources> <source>src/main/java/com/baeldung/jaxb/gen</source>
|
||||||
<version>${jaxb2-maven-plugin.version}</version>
|
</sources> <outputDirectory>src/main/resources</outputDirectory> <clearOutputDir>false</clearOutputDir>
|
||||||
<executions>
|
<transformSchemas> <transformSchema> <uri>http://www.baeldung.com/jaxb/gen</uri>
|
||||||
<execution>
|
<toPrefix>user</toPrefix> <toFile>gen-schema.xsd</toFile> </transformSchema>
|
||||||
<id>schemagen</id>
|
</transformSchemas> </configuration> </plugin> -->
|
||||||
<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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,16 @@
|
|||||||
package com.baeldung.jaxb.test;
|
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.apache.commons.io.FileUtils;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -8,15 +18,7 @@ import org.junit.FixMethodOrder;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import com.baeldung.jaxb.Book;
|
||||||
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;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class JaxbTest {
|
public class JaxbTest {
|
||||||
@ -37,18 +39,19 @@ public class JaxbTest {
|
|||||||
public void marshal() throws JAXBException, IOException {
|
public void marshal() throws JAXBException, IOException {
|
||||||
Marshaller marshaller = context.createMarshaller();
|
Marshaller marshaller = context.createMarshaller();
|
||||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||||
marshaller.marshal(book, new File("./book.xml"));
|
marshaller.marshal(book, new File(this.getClass().getResource("/").getPath() + "/book.xml"));
|
||||||
String sampleBookXML = FileUtils.readFileToString(new File("./sample_book.xml"), "UTF-8");
|
File sampleBookFile = new File(this.getClass().getResource("/sample_book.xml").getFile());
|
||||||
String marshallerBookXML = FileUtils.readFileToString(new File("./book.xml"), "UTF-8");
|
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);
|
Assert.assertEquals(sampleBookXML, marshallerBookXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unMashal() throws JAXBException, IOException {
|
public void unMashal() throws JAXBException, IOException {
|
||||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
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);
|
Assert.assertEquals(book, unMarshallerbook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user