KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > adminapi > UserHandlerTest


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;
19
20 import java.io.IOException JavaDoc;
21 import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
22 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
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 AappTest {
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, updateSampleUserEntrySet(getSampleUserEntrySet()));
53             
54             //delete
55
UserEntrySet uesDelete = deleteSampleUser();
56             assertNotNull(uesDelete);
57             assertNotNull(uesCreate.getEntries());
58             assertEquals(uesCreate.getEntries().length, 1);
59             assertEquals(uesDelete, uesUpdate);
60         } catch (IOException JavaDoc ioe) {
61             ioe.printStackTrace();
62             fail(ioe.getMessage());
63         } catch (JDOMException je) {
64             je.printStackTrace();
65             fail(je.getMessage());
66         } catch (MissingElementException mee) {
67             mee.printStackTrace();
68             fail(mee.getMessage());
69         } catch (UnexpectedRootElementException uree) {
70             uree.printStackTrace();
71             fail(uree.getMessage());
72         } finally {
73             try {
74                 delete(getSampleUserEntry().getHref(), getUser(), getPassword());
75             } catch (Exception JavaDoc e) {
76                 e.printStackTrace();
77             }
78         }
79     }
80 }
81
Popular Tags