From 87153e86a3340d3ace31efb4330e60cc937d34f2 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Tue, 3 Mar 2015 15:13:49 +0100 Subject: Throw exception for missing payload serializer. Change-Id: I3578fa59bfcb45f5893a16fa2d45c9ea460be198 diff --git a/src/com/isode/stroke/serializer/StanzaSerializer.java b/src/com/isode/stroke/serializer/StanzaSerializer.java index 14d0ccc..589d2e8 100644 --- a/src/com/isode/stroke/serializer/StanzaSerializer.java +++ b/src/com/isode/stroke/serializer/StanzaSerializer.java @@ -1,9 +1,5 @@ /* - * Copyright (c) 2010, Isode Limited, London, England. - * All rights reserved. - */ -/* - * Copyright (c) 2010, Remko Tronçon. + * Copyright (c) 2010-2015, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.serializer; @@ -50,6 +46,7 @@ public abstract class StanzaSerializer implements ElementSerializer { } else { /*TODO: port*/ assert false; + throw new UnsupportedOperationException("No serializer for payload: " + payload.getClass().getSimpleName()); //std::cerr << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl; } } diff --git a/test/com/isode/stroke/serializer/payloadserializers/ForwardedSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/ForwardedSerializerTest.java index 281be2e..5be9316 100644 --- a/test/com/isode/stroke/serializer/payloadserializers/ForwardedSerializerTest.java +++ b/test/com/isode/stroke/serializer/payloadserializers/ForwardedSerializerTest.java @@ -1,16 +1,12 @@ /* -* Copyright (c) 2014 Kevin Smith and Remko Tronçon -* All rights reserved. -*/ - -/* -* Copyright (c) 2014, Isode Limited, London, England. +* Copyright (c) 2014-2015, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.serializer.payloadserializers; import org.junit.Test; + import com.isode.stroke.base.DateTime; import com.isode.stroke.elements.Delay; import com.isode.stroke.elements.Forwarded; @@ -18,7 +14,9 @@ import com.isode.stroke.elements.IQ; import com.isode.stroke.elements.Message; import com.isode.stroke.elements.Payload; import com.isode.stroke.elements.Presence; +import com.isode.stroke.elements.Subject; import com.isode.stroke.jid.JID; + import static org.junit.Assert.assertEquals; public class ForwardedSerializerTest { @@ -27,7 +25,7 @@ public class ForwardedSerializerTest { public void testSerializeIQ() { ForwardedSerializer serializer = new ForwardedSerializer(serializers_); - IQ iq = IQ.createResult(JID.fromString("juliet@capulet.lit/balcony"), JID.fromString("romeo@montague.lit/orchard"), "id0", new Payload()); + IQ iq = IQ.createResult(JID.fromString("juliet@capulet.lit/balcony"), JID.fromString("romeo@montague.lit/orchard"), "id0", new Subject("text")); Forwarded forwarded = new Forwarded(); forwarded.setStanza(iq); @@ -36,7 +34,7 @@ public class ForwardedSerializerTest { String expectedResult = "" + "" - + "" + + "text" + ""; assertEquals(expectedResult, serializer.serialize(forwarded)); -- cgit v0.10.2-6-g49f6