01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
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,
41: getEndpointUrl());
42:
43: assertEquals(wes1, wes2);
44: } catch (UnexpectedRootElementException uree) {
45: fail(uree.getMessage());
46: }
47: }
48:
49: public void testStreamMarshal() {
50: try {
51: WeblogEntrySet wes1 = getSampleWeblogEntrySet();
52: String s = wes1.toString();
53: InputStream stream = new ByteArrayInputStream(s
54: .getBytes("UTF-8"));
55:
56: WeblogEntrySet wes2 = new WeblogEntrySet(stream,
57: getEndpointUrl());
58:
59: assertEquals(wes1, wes2);
60: } catch (UnexpectedRootElementException uree) {
61: fail(uree.getMessage());
62: } catch (IOException ioe) {
63: fail(ioe.getMessage());
64: } catch (JDOMException je) {
65: fail(je.getMessage());
66: }
67: }
68: }
|