KickJava   Java API By Example, From Geeks To Geeks.

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


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.WeblogEntrySet;
24 import org.jdom.JDOMException;
25
26 public class WeblogHandlerTest extends AappTest {
27     public void testHandler() {
28         try {
29             createSampleUser();
30             
31             //create
32
WeblogEntrySet wesCreate = createSampleWeblog();
33             assertNotNull(wesCreate);
34             assertNotNull(wesCreate.getEntries());
35             assertEquals(wesCreate.getEntries().length, 1);
36             assertEquals(wesCreate, getSampleWeblogEntrySet());
37             
38             //get
39
WeblogEntrySet wesFetch = fetchSampleWeblog();
40             assertNotNull(wesFetch);
41             assertNotNull(wesFetch.getEntries());
42             assertEquals(wesFetch.getEntries().length, 1);
43             assertEquals(wesFetch, wesCreate);
44             
45             //update
46
WeblogEntrySet wesUpdate = updateSampleWeblog();
47             assertNotNull(wesUpdate);
48             assertNotNull(wesUpdate.getEntries());
49             assertEquals(wesUpdate.getEntries().length, 1);
50             assertEquals(wesUpdate, updateSampleWeblogEntrySet(getSampleWeblogEntrySet()));
51             
52             //delete
53
WeblogEntrySet wesDelete = deleteSampleWeblog();
54             assertNotNull(wesDelete);
55             assertNotNull(wesCreate.getEntries());
56             assertEquals(wesCreate.getEntries().length, 1);
57             assertEquals(wesDelete, wesUpdate);
58             
59             deleteSampleUser();
60         } catch (IOException JavaDoc ioe) {
61             fail(ioe.getMessage());
62             ioe.printStackTrace();
63         } catch (JDOMException je) {
64             fail(je.getMessage());
65             je.printStackTrace();
66         } catch (MissingElementException mee) {
67             fail(mee.getMessage());
68             mee.printStackTrace();
69         } catch (UnexpectedRootElementException uree) {
70             fail(uree.getMessage());
71             uree.printStackTrace();
72         } finally {
73             try {
74                 delete(getSampleWeblogEntry().getHref(), getUser(), getPassword());
75                 delete(getSampleUserEntry().getHref(), getUser(), getPassword());
76             } catch (Exception JavaDoc e) {
77                 // nothing
78
}
79         }
80     }
81 }
82
Popular Tags