Skip to content

Commit

Permalink
Reformat JaxbTest
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit committed Dec 22, 2016
1 parent 6886ebc commit ba89722
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions jaxb/src/test/java/com/baeldung/jaxb/test/JaxbTest.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package com.baeldung.jaxb.test;

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 com.baeldung.jaxb.Book;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

import com.baeldung.jaxb.Book;
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;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class JaxbTest {
Book book;
JAXBContext context;
private Book book;
private JAXBContext context;

@Before
public void before() throws JAXBException {
Expand All @@ -42,13 +40,15 @@ public void marshal() throws JAXBException, IOException {
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");

Assert.assertEquals(sampleBookXML, marshallerBookXML);
}

@Test
public void unMashal() throws JAXBException, IOException {
Unmarshaller unmarshaller = context.createUnmarshaller();
Book unMarshallerbook = (Book) unmarshaller.unmarshal(new FileReader("./book.xml"));

Assert.assertEquals(book, unMarshallerbook);
}
}

0 comments on commit ba89722

Please sign in to comment.