-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
xstream/src/test/com/thoughtworks/xstream/converters/extended/AtomicBooleanFieldsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.thoughtworks.xstream.converters.extended; | ||
|
||
import com.thoughtworks.acceptance.AbstractAcceptanceTest; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class AtomicBooleanFieldsTest extends AbstractAcceptanceTest { | ||
|
||
public static class Musican { | ||
public String name; | ||
public String genre; | ||
public AtomicBoolean alive; | ||
|
||
public Musican(final String name, final String genre, final AtomicBoolean alive) { | ||
this.name = name; | ||
this.genre = genre; | ||
this.alive = alive; | ||
} | ||
} | ||
|
||
public void testAtomicBooleanFields() { | ||
final List<Musican> jazzIcons = new ArrayList<>(); | ||
jazzIcons.add(new Musican("Miles Davis", "jazz", new AtomicBoolean(false))); | ||
jazzIcons.add(new Musican("Wynton Marsalis", "jazz", new AtomicBoolean(true))); | ||
|
||
xstream.alias("musician", Musican.class); | ||
|
||
final String expectedXml = | ||
"<list>\n" | ||
+ " <musician>\n" | ||
+ " <name>Miles Davis</name>\n" | ||
+ " <genre>jazz</genre>\n" | ||
+ " <alive>\n" | ||
+ " <value>0</value>\n" | ||
+ " </alive>\n" | ||
+ " </musician>\n" | ||
+ " <musician>\n" | ||
+ " <name>Wynton Marsalis</name>\n" | ||
+ " <genre>jazz</genre>\n" | ||
+ " <alive>\n" | ||
+ " <value>1</value>\n" | ||
+ " </alive>\n" | ||
+ " </musician>\n" | ||
+ "</list>"; | ||
|
||
assertBothWays(jazzIcons, expectedXml); | ||
} | ||
} |