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 UserEntryTest extends AappTest {
28: public void testEquals() {
29: UserEntrySet ues1 = getSampleUserEntrySet();
30: UserEntrySet ues2 = getSampleUserEntrySet();
31:
32: assertEquals(ues1, ues2);
33: }
34:
35: public void testDocumentMarshal() {
36: try {
37: UserEntrySet ues1 = getSampleUserEntrySet();
38: Document d = ues1.toDocument();
39:
40: UserEntrySet ues2 = new UserEntrySet(d, getEndpointUrl());
41:
42: assertEquals(ues1, ues2);
43: } catch (UnexpectedRootElementException uree) {
44: fail(uree.getMessage());
45: }
46: }
47:
48: public void testStreamMarshal() {
49: try {
50: UserEntrySet ues1 = getSampleUserEntrySet();
51: String s = ues1.toString();
52: InputStream stream = new ByteArrayInputStream(s
53: .getBytes("UTF-8"));
54:
55: UserEntrySet ues2 = new UserEntrySet(stream,
56: getEndpointUrl());
57:
58: assertEquals(ues1, ues2);
59: } catch (UnexpectedRootElementException uree) {
60: fail(uree.getMessage());
61: } catch (IOException ioe) {
62: fail(ioe.getMessage());
63: } catch (JDOMException je) {
64: fail(je.getMessage());
65: }
66: }
67: }
|