001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: package org.apache.roller.webservices.adminapi;
019:
020: import java.io.IOException;
021: import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
022: import org.apache.roller.webservices.adminapi.sdk.WeblogEntry;
023: import org.apache.roller.webservices.adminapi.sdk.WeblogEntrySet;
024: import org.jdom.JDOMException;
025:
026: public class WeblogHandlerTest extends HandlerBaseTest {
027: public void testHandler() {
028: try {
029: createSampleUser();
030:
031: //create
032: WeblogEntrySet wesCreate = createSampleWeblog();
033: assertNotNull(wesCreate);
034: assertNotNull(wesCreate.getEntries());
035: assertEquals(wesCreate.getEntries().length, 1);
036: assertEquals(wesCreate, getSampleWeblogEntrySet());
037:
038: //get
039: WeblogEntrySet wesFetch = fetchSampleWeblog();
040: assertNotNull(wesFetch);
041: assertNotNull(wesFetch.getEntries());
042: assertEquals(wesFetch.getEntries().length, 1);
043: assertEquals(wesFetch, wesCreate);
044:
045: //update
046: WeblogEntrySet wesUpdate = updateSampleWeblog();
047: assertNotNull(wesUpdate);
048: assertNotNull(wesUpdate.getEntries());
049: assertEquals(wesUpdate.getEntries().length, 1);
050: assertEquals(
051: wesUpdate,
052: updateSampleWeblogEntrySet(getSampleWeblogEntrySet()));
053:
054: //delete
055: WeblogEntrySet wesDelete = deleteSampleWeblog(true);
056: assertNotNull(wesDelete);
057: assertNotNull(wesCreate.getEntries());
058: assertEquals(wesCreate.getEntries().length, 1);
059: assertEquals(wesDelete, wesUpdate);
060: } catch (IOException ioe) {
061: fail(ioe.getMessage());
062: ioe.printStackTrace();
063: } catch (JDOMException je) {
064: fail(je.getMessage());
065: je.printStackTrace();
066: } catch (UnexpectedRootElementException uree) {
067: fail(uree.getMessage());
068: uree.printStackTrace();
069: } finally {
070: try {
071: deleteSampleWeblog(false);
072: deleteSampleUser(false);
073: } catch (Exception e) {
074: e.printStackTrace();
075: }
076: }
077: }
078:
079: public void testEnabled() {
080: try {
081: createSampleUser();
082: WeblogEntrySet wes = createSampleWeblog();
083: WeblogEntry we = (WeblogEntry) wes.getEntries()[0];
084: assertEquals(we.getEnabled(), Boolean.TRUE);
085:
086: wes = updateSampleWeblog();
087: we = (WeblogEntry) wes.getEntries()[0];
088: assertEquals(Boolean.FALSE, we.getEnabled());
089:
090: wes = fetchSampleWeblog();
091: we = (WeblogEntry) wes.getEntries()[0];
092: assertEquals(Boolean.FALSE, we.getEnabled());
093: } catch (IOException ioe) {
094: fail(ioe.getMessage());
095: ioe.printStackTrace();
096: } catch (JDOMException je) {
097: fail(je.getMessage());
098: je.printStackTrace();
099: } catch (UnexpectedRootElementException uree) {
100: fail(uree.getMessage());
101: uree.printStackTrace();
102: }
103: }
104: }
|