KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > adminapi > sdk > WeblogEntryTest


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.webservices.adminapi.sdk;
19
20 import org.jdom.Document;
21 import java.io.InputStream JavaDoc;
22 import java.io.ByteArrayInputStream JavaDoc;
23 import java.io.IOException JavaDoc;
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 JavaDoc s = wes1.toString();
54             InputStream JavaDoc stream = new ByteArrayInputStream JavaDoc(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 JavaDoc ioe) {
64             fail(ioe.getMessage());
65         } catch (JDOMException je) {
66             fail(je.getMessage());
67         }
68     }
69 }
70
Popular Tags