Skip to content

Commit

Permalink
Omit atribute for real field name. Closes #199.
Browse files Browse the repository at this point in the history
  • Loading branch information
joehni committed Apr 20, 2020
1 parent b275132 commit ce95902
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xstream/src/test/com/thoughtworks/acceptance/AliasTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004, 2005, 2006 Joe Walnes.
* Copyright (C) 2006, 2007, 2008, 2009, 2013, 2014, 2018, 2019 XStream Committers.
* Copyright (C) 2006, 2007, 2008, 2009, 2013, 2014, 2018, 2019, 2020 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
Expand Down Expand Up @@ -103,6 +103,18 @@ public void testForFieldAsAttribute() {
assertBothWays(software, xml);
}

public void testOmitAliasesAttributeWithRealName() {
xstream.alias("software", Software.class);
xstream.useAttributeFor(String.class);
xstream.aliasAttribute("id", "name");
xstream.aliasAttribute("name", "foo");
xstream.omitField(Software.class, "foo");

final String xml = "<software vendor=\"walness\" name=\"xstream\"/>";
assertEquals(new Software("walness", null), xstream.fromXML(xml));
assertEquals(new Software("walness", "xstream"), xstream.fromXML(xml.replace("name", "id")));
}

public void testForReferenceSystemAttribute() {
final List<Software> list = new ArrayList<>();
final Software software = new Software("walness", "xstream");
Expand Down

0 comments on commit ce95902

Please sign in to comment.