1 18 package org.apache.roller.webservices.adminapi.sdk; 19 20 import org.jdom.Document; 21 import java.io.InputStream ; 22 import java.io.ByteArrayInputStream ; 23 import java.io.IOException ; 24 import org.apache.roller.webservices.adminapi.AappTest; 25 import org.jdom.JDOMException; 26 27 public class WeblogEntryTest extends AappTest { 28 public void testEquals() { 29 WeblogEntrySet wes1 = getSampleWeblogEntrySet(); 30 WeblogEntrySet wes2 = getSampleWeblogEntrySet(); 31 32 assertEquals(wes1, wes2); 33 } 34 35 public void testDocumentMarshal() { 36 try { 37 WeblogEntrySet wes1 = getSampleWeblogEntrySet(); 38 Document d = wes1.toDocument(); 39 40 WeblogEntrySet wes2 = new WeblogEntrySet(d, getEndpointUrl()); 41 42 assertEquals(wes1, wes2); 43 } catch (MissingElementException mee) { 44 fail(mee.getMessage()); 45 } catch (UnexpectedRootElementException uree) { 46 fail(uree.getMessage()); 47 } 48 } 49 50 public void testStreamMarshal() { 51 try { 52 WeblogEntrySet wes1 = getSampleWeblogEntrySet(); 53 String s = wes1.toString(); 54 InputStream stream = new ByteArrayInputStream (s.getBytes("UTF-8")); 55 56 WeblogEntrySet wes2 = new WeblogEntrySet(stream, getEndpointUrl()); 57 58 assertEquals(wes1, wes2); 59 } catch (MissingElementException mee) { 60 fail(mee.getMessage()); 61 } catch (UnexpectedRootElementException uree) { 62 fail(uree.getMessage()); 63 } catch (IOException ioe) { 64 fail(ioe.getMessage()); 65 } catch (JDOMException je) { 66 fail(je.getMessage()); 67 } 68 } 69 } 70 | Popular Tags |