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;
19:
20: import java.io.IOException;
21: import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
22: import org.apache.roller.webservices.adminapi.sdk.UserEntry;
23: import org.apache.roller.webservices.adminapi.sdk.UserEntrySet;
24: import org.jdom.JDOMException;
25:
26: /**
27: *
28: * @author jtb
29: */
30: public class UserHandlerTest extends HandlerBaseTest {
31: public void testHandler() {
32: try {
33: //create
34: UserEntrySet uesCreate = createSampleUser();
35: assertNotNull(uesCreate);
36: assertNotNull(uesCreate.getEntries());
37: assertEquals(uesCreate.getEntries().length, 1);
38: assertEquals(uesCreate, getSampleUserEntrySet());
39:
40: //get
41: UserEntrySet uesFetch = fetchSampleUser();
42: assertNotNull(uesFetch);
43: assertNotNull(uesFetch.getEntries());
44: assertEquals(uesFetch.getEntries().length, 1);
45: assertEquals(uesFetch, uesCreate);
46:
47: //update
48: UserEntrySet uesUpdate = updateSampleUser();
49: assertNotNull(uesUpdate);
50: assertNotNull(uesUpdate.getEntries());
51: assertEquals(uesUpdate.getEntries().length, 1);
52: assertEquals(uesUpdate,
53: updateSampleUserEntrySet(getSampleUserEntrySet()));
54:
55: //delete
56: UserEntrySet uesDelete = deleteSampleUser(true);
57: assertNotNull(uesDelete);
58: assertNotNull(uesCreate.getEntries());
59: assertEquals(uesCreate.getEntries().length, 1);
60: assertEquals(uesDelete, uesUpdate);
61: } catch (IOException ioe) {
62: ioe.printStackTrace();
63: fail(ioe.getMessage());
64: } catch (JDOMException je) {
65: je.printStackTrace();
66: fail(je.getMessage());
67: } catch (UnexpectedRootElementException uree) {
68: uree.printStackTrace();
69: fail(uree.getMessage());
70: }
71: }
72:
73: public void testEnabled() {
74: try {
75: UserEntrySet ues = createSampleUser();
76: UserEntry ue = (UserEntry) ues.getEntries()[0];
77: assertEquals(Boolean.TRUE, ue.getEnabled());
78:
79: ues = updateSampleUser();
80: ue = (UserEntry) ues.getEntries()[0];
81: assertEquals(Boolean.FALSE, ue.getEnabled());
82:
83: ues = fetchSampleUser();
84: ue = (UserEntry) ues.getEntries()[0];
85: assertEquals(Boolean.FALSE, ue.getEnabled());
86: } catch (IOException ioe) {
87: fail(ioe.getMessage());
88: ioe.printStackTrace();
89: } catch (JDOMException je) {
90: fail(je.getMessage());
91: je.printStackTrace();
92: } catch (UnexpectedRootElementException uree) {
93: fail(uree.getMessage());
94: uree.printStackTrace();
95: }
96: }
97:
98: }
|