1 5 package org.exoplatform.services.portal.test; 6 7 import java.io.InputStream ; 8 import java.net.URL ; 9 import org.exoplatform.services.portal.impl.*; 10 import org.exoplatform.services.portal.impl.converter.*; 11 import org.exoplatform.services.portal.model.*; 12 import org.exoplatform.services.portletcontainer.pci.model.ExoPortletPreferences; 13 import org.exoplatform.services.portletcontainer.pci.model.Preference; 14 import org.exoplatform.test.BasicTestCase; 15 16 import com.thoughtworks.xstream.XStream; 17 import com.thoughtworks.xstream.io.xml.XppDriver; 18 19 26 public class TestConverter extends BasicTestCase { 27 private XStream xstream_ ; 28 29 public TestConverter(String name) { 30 super(name); 31 } 32 33 public void setUp() throws Exception { 34 xstream_ = new XStream(new XppDriver()); 35 xstream_.alias("user-portal-config", Backup.class); 36 xstream_.alias("portal-config", PortalConfig.class); 37 xstream_.alias("page-set", PageSet.class); 38 xstream_.alias("page", Page.class); 39 xstream_.alias("container", Container.class); 40 xstream_.alias("portlet", Portlet.class); 41 xstream_.alias("body", Body.class); 42 xstream_.alias("node", NodeImpl.class); 43 xstream_.registerConverter(new PortletConverter()); 44 xstream_.registerConverter(new ExoPortletPreferencesConverter()); 45 xstream_.registerConverter(new PreferenceConverter()); 46 } 47 48 public void testConverter() throws Exception { 49 Portlet portlet = new Portlet() ; 50 portlet.setRenderer("renderer") ; 51 portlet.setDecorator("decorator") ; 52 Preference pref = new Preference() ; 53 pref.setName("test") ; 54 pref.addValue("test") ; 55 ExoPortletPreferences prefs = new ExoPortletPreferences() ; 56 prefs.put(pref.getName(), pref) ; 57 portlet.setPortletPreferences(prefs) ; 58 String xml = xstream_.toXML(portlet); 59 System.out.println(xml) ; 60 portlet = (Portlet) xstream_.fromXML(xml) ; 61 assertEquals("Expect renderer value", "renderer", portlet.getRenderer()) ; 62 assertEquals("Expect decorator value", "decorator", portlet.getDecorator()) ; 63 } 64 65 public void testParser() throws Exception { 66 71 } 72 protected String getDescription() { 73 return "Test Converter" ; 74 } 75 } | Popular Tags |