diff --git a/xstream/src/test/com/thoughtworks/acceptance/OmitFieldsTest.java b/xstream/src/test/com/thoughtworks/acceptance/OmitFieldsTest.java
index 84d461c0a..f02b928ef 100644
--- a/xstream/src/test/com/thoughtworks/acceptance/OmitFieldsTest.java
+++ b/xstream/src/test/com/thoughtworks/acceptance/OmitFieldsTest.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2010, 2012, 2013, 2014, 2018, 2020, 2021 XStream Committers.
+ * Copyright (C) 2006, 2007, 2010, 2012, 2013, 2014, 2018, 2020, 2021, 2024 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -548,4 +548,35 @@ public void testReferencedElementsCanBeIgnored() {
final Wrapper out = xstream.fromXML(expectedXml);
assertEquals("junit", out.member.name);
}
+
+ public void testOmitFormerOuterClass() {
+ final Thing in = new Thing();
+ in.alwaysIgnore = "a";
+ in.sometimesIgnore = "b";
+ in.neverIgnore = "c";
+
+ final String expectedXml = ""
+ + "\n"
+ + " b\n"
+ + " c\n"
+ + "";
+
+ xstream.alias("thing", Thing.class);
+ xstream.aliasField("outer-class", Thing.class, "alwaysIgnore");
+
+ final String actualXml = xstream.toXML(in);
+ assertEquals(expectedXml, actualXml);
+
+ final String legacyXml = ""
+ + "\n"
+ + " \n"
+ + " some value"
+ + " \n"
+ + " b\n"
+ + " c\n"
+ + "";
+
+ final Thing out = xstream.fromXML(legacyXml);
+ assertEquals(in, out);
+ }
}