Skip to content

Commit ce2891e

Browse files
committed
Clean up formatting
1 parent 44c327d commit ce2891e

4 files changed

Lines changed: 91 additions & 94 deletions

File tree

‎xstream/pom.xml‎

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>org.baeldung</groupId>
5-
<artifactId>xstream-introduction</artifactId>
6-
<version>0.0.1-SNAPSHOT</version>
7-
<name>xstream-introduction</name>
8-
<description>An Introduction To XStream</description>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.baeldung</groupId>
5+
<artifactId>xstream-introduction</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<name>xstream-introduction</name>
8+
<description>An Introduction To XStream</description>
99

10-
<dependencies>
11-
<dependency>
12-
<groupId>com.thoughtworks.xstream</groupId>
13-
<artifactId>xstream</artifactId>
14-
<version>1.4.5</version>
15-
</dependency>
10+
<dependencies>
11+
<dependency>
12+
<groupId>com.thoughtworks.xstream</groupId>
13+
<artifactId>xstream</artifactId>
14+
<version>1.4.5</version>
15+
</dependency>
1616

17-
<dependency>
18-
<groupId>org.codehaus.jettison</groupId>
19-
<artifactId>jettison</artifactId>
20-
<version>1.3.7</version>
21-
</dependency>
22-
23-
<dependency>
24-
<groupId>junit</groupId>
25-
<artifactId>junit</artifactId>
26-
<version>4.12</version>
27-
</dependency>
28-
29-
<dependency>
30-
<groupId>log4j</groupId>
31-
<artifactId>log4j</artifactId>
32-
<version>1.2.17</version>
33-
</dependency>
34-
</dependencies>
17+
<dependency>
18+
<groupId>org.codehaus.jettison</groupId>
19+
<artifactId>jettison</artifactId>
20+
<version>1.3.7</version>
21+
</dependency>
3522

36-
<build>
37-
<plugins>
38-
<plugin>
39-
<groupId>org.apache.maven.plugins</groupId>
40-
<artifactId>maven-compiler-plugin</artifactId>
41-
<version>3.5.1</version>
42-
<configuration>
43-
<source>1.8</source>
44-
<target>1.8</target>
45-
</configuration>
46-
</plugin>
47-
</plugins>
48-
</build>
23+
<dependency>
24+
<groupId>junit</groupId>
25+
<artifactId>junit</artifactId>
26+
<version>4.12</version>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>log4j</groupId>
31+
<artifactId>log4j</artifactId>
32+
<version>1.2.17</version>
33+
</dependency>
34+
</dependencies>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-compiler-plugin</artifactId>
41+
<version>3.5.1</version>
42+
<configuration>
43+
<source>1.8</source>
44+
<target>1.8</target>
45+
</configuration>
46+
</plugin>
47+
</plugins>
48+
</build>
4949

5050
</project>

‎xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
public class SimpleXstreamInitializer {
88

9-
public XStream getXstreamInstance() {
10-
XStream xtreamInstance = new XStream();
11-
return xtreamInstance;
12-
}
9+
public XStream getXstreamInstance() {
10+
XStream xtreamInstance = new XStream();
11+
return xtreamInstance;
12+
}
1313

14-
public XStream getXstreamJettisonMappedInstance() {
15-
XStream xstreamInstance = new XStream(new JettisonMappedXmlDriver());
16-
return xstreamInstance;
17-
}
14+
public XStream getXstreamJettisonMappedInstance() {
15+
XStream xstreamInstance = new XStream(new JettisonMappedXmlDriver());
16+
return xstreamInstance;
17+
}
1818

19-
public XStream getXstreamJsonHierarchicalInstance() {
20-
XStream xstreamInstance = new XStream(new JsonHierarchicalStreamDriver());
21-
return xstreamInstance;
22-
}
19+
public XStream getXstreamJsonHierarchicalInstance() {
20+
XStream xstreamInstance = new XStream(new JsonHierarchicalStreamDriver());
21+
return xstreamInstance;
22+
}
2323
}

‎xstream/src/main/resources/log4j.properties‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Root logger option
22
log4j.rootLogger=DEBUG, file
3-
43
# Redirect log messages to console
54
# log4j.appender.stdout=org.apache.log4j.ConsoleAppender
65
# log4j.appender.stdout.Target=System.out
76
# log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
87
# log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
9-
108
# Redirect log messages to a log file, support file rolling.
119
log4j.appender.file=org.apache.log4j.RollingFileAppender
1210
log4j.appender.file.File=D:\\Test\\xstream-application.log
Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
package com.baeldung.test;
22

3-
import org.junit.Assert;
4-
import org.junit.Before;
5-
import org.junit.Test;
6-
73
import com.baeldung.initializer.SimpleXstreamInitializer;
84
import com.baeldung.pojo.ContactDetails;
95
import com.baeldung.pojo.Customer;
106
import com.baeldung.utility.SimpleDataGeneration;
117
import com.thoughtworks.xstream.XStream;
8+
import org.junit.Assert;
9+
import org.junit.Before;
10+
import org.junit.Test;
1211

1312
public class XStreamJettisonTest {
1413

15-
private Customer customer = null;
16-
17-
private String dataJson = null;
18-
19-
private XStream xstream = null;
20-
21-
@Before
22-
public void dataSetup() {
23-
SimpleXstreamInitializer simpleXstreamInitializer = new SimpleXstreamInitializer();
24-
xstream = simpleXstreamInitializer.getXstreamJettisonMappedInstance();
25-
xstream.processAnnotations(Customer.class);
26-
}
27-
28-
@Test
29-
public void convertObjectToJson() {
30-
customer = SimpleDataGeneration.generateData();
31-
xstream.alias("customer" , Customer.class);
32-
xstream.alias("contactDetails" , ContactDetails.class);
33-
xstream.aliasField("fn" , Customer.class , "firstName");
34-
dataJson = xstream.toXML(customer);
35-
System.out.println(dataJson);
36-
Assert.assertNotNull(dataJson);
37-
}
38-
39-
@Test
40-
public void convertJsonToObject() {
41-
customer = SimpleDataGeneration.generateData();
42-
dataJson = xstream.toXML(customer);
43-
customer = (Customer) xstream.fromXML(dataJson);
44-
System.out.println(customer);
45-
Assert.assertNotNull(customer);
46-
}
14+
private Customer customer = null;
15+
16+
private String dataJson = null;
17+
18+
private XStream xstream = null;
19+
20+
@Before
21+
public void dataSetup() {
22+
SimpleXstreamInitializer simpleXstreamInitializer = new SimpleXstreamInitializer();
23+
xstream = simpleXstreamInitializer.getXstreamJettisonMappedInstance();
24+
xstream.processAnnotations(Customer.class);
25+
}
26+
27+
@Test
28+
public void convertObjectToJson() {
29+
customer = SimpleDataGeneration.generateData();
30+
xstream.alias("customer", Customer.class);
31+
xstream.alias("contactDetails", ContactDetails.class);
32+
xstream.aliasField("fn", Customer.class, "firstName");
33+
dataJson = xstream.toXML(customer);
34+
System.out.println(dataJson);
35+
Assert.assertNotNull(dataJson);
36+
}
37+
38+
@Test
39+
public void convertJsonToObject() {
40+
customer = SimpleDataGeneration.generateData();
41+
dataJson = xstream.toXML(customer);
42+
customer = (Customer) xstream.fromXML(dataJson);
43+
System.out.println(customer);
44+
Assert.assertNotNull(customer);
45+
}
4746

4847
}

0 commit comments

Comments
 (0)