KickJava   Java API By Example, From Geeks To Geeks.

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


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.MemberEntrySet;
22 import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
23 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
24 import org.jdom.JDOMException;
25
26 public class MemberHandlerTest extends AappTest {
27     public void testHandler() {
28         try {
29             createSampleUser();
30             createSampleWeblog();
31             
32             //create
33
MemberEntrySet mesCreate = createSampleMember();
34             assertNotNull(mesCreate);
35             assertNotNull(mesCreate.getEntries());
36             assertEquals(mesCreate.getEntries().length, 1);
37             assertEquals(mesCreate, getSampleMemberEntrySet());
38             
39             //get
40
MemberEntrySet mesFetch = fetchSampleMember();
41             assertNotNull(mesFetch);
42             assertNotNull(mesFetch.getEntries());
43             assertEquals(mesFetch.getEntries().length, 1);
44             assertEquals(mesFetch, mesCreate);
45             
46             //update
47
MemberEntrySet mesUpdate = updateSampleMember();
48             assertNotNull(mesUpdate);
49             assertNotNull(mesUpdate.getEntries());
50             assertEquals(mesUpdate.getEntries().length, 1);
51             assertEquals(mesUpdate, updateSampleMemberEntrySet(getSampleMemberEntrySet()));
52             
53             //delete
54
MemberEntrySet mesDelete = deleteSampleMember();
55             assertNotNull(mesDelete);
56             assertNotNull(mesCreate.getEntries());
57             assertEquals(mesCreate.getEntries().length, 1);
58             assertEquals(mesDelete, mesUpdate);
59             
60             deleteSampleWeblog();
61             deleteSampleUser();
62         } catch (IOException JavaDoc ioe) {
63             ioe.printStackTrace();
64             fail(ioe.getMessage());
65         } catch (JDOMException je) {
66             je.printStackTrace();
67             fail(je.getMessage());
68         } catch (MissingElementException mee) {
69             mee.printStackTrace();
70             fail(mee.getMessage());
71         } catch (UnexpectedRootElementException uree) {
72             uree.printStackTrace();
73             fail(uree.getMessage());
74         } finally {
75             try {
76                 delete(getSampleMemberEntry().getHref(), getUser(), getPassword());
77                 delete(getSampleWeblogEntry().getHref(), getUser(), getPassword());
78                 delete(getSampleUserEntry().getHref(), getUser(), getPassword());
79             } catch (Exception JavaDoc e) {
80                 // nothing
81
}
82         }
83     }
84 }
85
86
Popular Tags