"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/hudson/util/XStream2Test.java" between
jenkins-jenkins-2.302.tar.gz and jenkins-jenkins-2.303.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

XStream2Test.java  (jenkins-jenkins-2.302):XStream2Test.java  (jenkins-jenkins-2.303)
skipping to change at line 31 skipping to change at line 31
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package hudson.util; package hudson.util;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.thoughtworks.xstream.XStreamException; import com.thoughtworks.xstream.XStreamException;
import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.mapper.CannotResolveClassException; import com.thoughtworks.xstream.mapper.CannotResolveClassException;
import hudson.model.Result; import hudson.model.Result;
import hudson.model.Run; import hudson.model.Run;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
skipping to change at line 287 skipping to change at line 287
public int x,y; public int x,y;
} }
public static class Foo2 { public static class Foo2 {
ConcurrentHashMap<String,String> m = new ConcurrentHashMap<>(); ConcurrentHashMap<String,String> m = new ConcurrentHashMap<>();
} }
@Issue("SECURITY-105") @Issue("SECURITY-105")
@Test @Test
public void dynamicProxyBlocked() { public void dynamicProxyBlocked() {
try { assertThrows(XStreamException.class, () -> ((Runnable) new XStream2().fr
((Runnable) new XStream2().fromXML("<dynamic-proxy><interface>java.l omXML("<dynamic-proxy><interface>java.lang.Runnable</interface><handler class='j
ang.Runnable</interface><handler class='java.beans.EventHandler'><target class=' ava.beans.EventHandler'><target class='" + Hacked.class.getName() + "'/><action>
" + Hacked.class.getName() + "'/><action>oops</action></handler></dynamic-proxy> oops</action></handler></dynamic-proxy>")).run());
")).run();
} catch (XStreamException x) {
// good
}
assertFalse("should never have run that", Hacked.tripped); assertFalse("should never have run that", Hacked.tripped);
} }
public static final class Hacked { public static final class Hacked {
static boolean tripped; static boolean tripped;
public void oops() { public void oops() {
tripped = true; tripped = true;
} }
} }
skipping to change at line 530 skipping to change at line 526
return listDefaultNull; return listDefaultNull;
} }
public void setListDefaultNull(List<String> listDefaultNull) { public void setListDefaultNull(List<String> listDefaultNull) {
this.listDefaultNull = listDefaultNull; this.listDefaultNull = listDefaultNull;
} }
} }
@Issue("SECURITY-503") @Issue("SECURITY-503")
@Test @Test
public void crashXstream() throws Exception { public void crashXstream() {
try { assertThrows(XStreamException.class, () -> new XStream2().fromXML("<void
new XStream2().fromXML("<void/>"); />"));
fail("expected to throw ConversionException, but why are we still al
ive?");
} catch (XStreamException ex) {
// pass
}
} }
@Test @Test
public void annotations() throws Exception { public void annotations() throws Exception {
assertEquals("not registered, so sorry", "<hudson.util.XStream2Test_-C1/ >", Jenkins.XSTREAM2.toXML(new C1())); assertEquals("not registered, so sorry", "<hudson.util.XStream2Test_-C1/ >", Jenkins.XSTREAM2.toXML(new C1()));
assertEquals("manually registered", "<C-2/>", Jenkins.XSTREAM2.toXML(new C2())); assertEquals("manually registered", "<C-2/>", Jenkins.XSTREAM2.toXML(new C2()));
assertEquals("manually processed", "<C-3/>", Jenkins.XSTREAM2.toXML(new C3())); assertEquals("manually processed", "<C-3/>", Jenkins.XSTREAM2.toXML(new C3()));
try { assertThrows(CannotResolveClassException.class, () -> Jenkins.XSTREAM2.f
Jenkins.XSTREAM2.fromXML("<C-4/>"); romXML("<C-4/>"));
fail("this could never have worked anyway");
} catch (CannotResolveClassException x) {
// OK
}
Jenkins.XSTREAM2.processAnnotations(C5.class); Jenkins.XSTREAM2.processAnnotations(C5.class);
assertThat("can deserialize from annotations so long as the processing h appened at some point", Jenkins.XSTREAM2.fromXML("<C-5/>"), instanceOf(C5.class) ); assertThat("can deserialize from annotations so long as the processing h appened at some point", Jenkins.XSTREAM2.fromXML("<C-5/>"), instanceOf(C5.class) );
} }
@XStreamAlias("C-1") @XStreamAlias("C-1")
public static final class C1 {} public static final class C1 {}
public static final class C2 { public static final class C2 {
static { static {
Jenkins.XSTREAM2.alias("C-2", C2.class); Jenkins.XSTREAM2.alias("C-2", C2.class);
} }
} }
 End of changes. 5 change blocks. 
23 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)