/transform/src/test/java/org/switchyard/transform/MessageTransformerTest.java

https://github.com/lincolnthree/switchyard-core · Java · 51 lines · 21 code · 9 blank · 21 comment · 0 complexity · 745abd0b80a9d77257dd1e20e6512fed MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
  4. * as indicated by the @author tags. All rights reserved.
  5. * See the copyright.txt in the distribution for a
  6. * full listing of individual contributors.
  7. *
  8. * This copyrighted material is made available to anyone wishing to use,
  9. * modify, copy, or redistribute it subject to the terms and conditions
  10. * of the GNU Lesser General Public License, v. 2.1.
  11. * This program is distributed in the hope that it will be useful, but WITHOUT A
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
  14. * You should have received a copy of the GNU Lesser General Public License,
  15. * v.2.1 along with this distribution; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. package org.switchyard.transform;
  20. import org.junit.Assert;
  21. import org.junit.Test;
  22. import org.switchyard.internal.DefaultMessage;
  23. import org.switchyard.internal.transform.BaseTransformerRegistry;
  24. import javax.xml.namespace.QName;
  25. import java.io.IOException;
  26. /**
  27. * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
  28. */
  29. public class MessageTransformerTest {
  30. @Test
  31. public void test() throws IOException {
  32. final QName A = new QName("a");
  33. final QName B = new QName("b");
  34. BaseTransformerRegistry xformReg = new BaseTransformerRegistry();
  35. TransformSequence transSequence = TransformSequence.from(A).to(B);
  36. DefaultMessage message = new DefaultMessage().setContent(A);
  37. Message2MessageTransformer transformer = new Message2MessageTransformer();
  38. xformReg.addTransformer(transformer, A, B);
  39. transSequence.apply(message, xformReg);
  40. Assert.assertEquals(message, transformer.getMessage());
  41. }
  42. }