roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r405263 - in /incubator/roller/trunk: ./ custom/ src/org/apache/roller/webservices/adminapi/ tests/org/apache/roller/webservices/ tests/org/apache/roller/webservices/adminapi/ tests/org/apache/roller/webservices/adminapi/sdk/
Date Tue, 09 May 2006 01:24:21 GMT
Author: snoopdave
Date: Mon May  8 18:24:18 2006
New Revision: 405263

URL: http://svn.apache.org/viewcvs?rev=405263&view=rev
Log:
Patch 4.5 from Jeff Blattman

Added:
    incubator/roller/trunk/tests/org/apache/roller/webservices/
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java
    incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java
Modified:
    incubator/roller/trunk/build.xml
    incubator/roller/trunk/custom/custom-gen-web.xmlf
    incubator/roller/trunk/custom/custom-src-web.xmlf
    incubator/roller/trunk/properties.xmlf
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
    incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java

Modified: incubator/roller/trunk/build.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/build.xml?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/build.xml (original)
+++ incubator/roller/trunk/build.xml Mon May  8 18:24:18 2006
@@ -309,6 +309,18 @@
 
 </target>
 
+<!-- build standalone aapp-sdk.jar, for external consumption -->
+<target name="aapp-sdk" depends="build">
+    <jar destfile="${ro.build}/lib/aapp-sdk.jar">
+      <manifest>
+        <attribute name="Manifest-Version" value="${ro.version}"/>
+      </manifest>
+      <fileset dir="${build.compile_web}">
+        <include name="org/apache/roller/webservices/adminapi/sdk/*"/>
+      </fileset>
+    </jar>
+</target>
+
 <!-- For versions of Resin before 2.1.9 we have to turn the
     HttpServletResponseWrapper into a CauchoResponseWrapper. We have
     to do away with the original or there will be compile errors. -->

Modified: incubator/roller/trunk/custom/custom-gen-web.xmlf
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/custom/custom-gen-web.xmlf?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/custom/custom-gen-web.xmlf (original)
+++ incubator/roller/trunk/custom/custom-gen-web.xmlf Mon May  8 18:24:18 2006
@@ -1,8 +1,3 @@
-
-<!--  Include experimental protocols in build
-<fileset dir="${basedir}/sandbox/atomadminprotocol/src" includes="**/*Servlet.java" />
--->
-
 <!--  Custom classes to include in Struts and web generation, for example:
 <fileset dir="${basedir}/custom/src" includes="**/*Data.java" />
 <fileset dir="${basedir}/sandbox/planetroller/src" includes="**/*Data.java" />

Modified: incubator/roller/trunk/custom/custom-src-web.xmlf
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/custom/custom-src-web.xmlf?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/custom/custom-src-web.xmlf (original)
+++ incubator/roller/trunk/custom/custom-src-web.xmlf Mon May  8 18:24:18 2006
@@ -1,9 +1,3 @@
-
-<!--  Include experimental Atom Protocol impl. in build. 
-<src path="${basedir}/sandbox/atomadminprotocol/src" />
--->
-
-
 <!-- Exampe: custom classes to include in front-end compilation
  Your classes must be under the package org.roller.presentation.
 <src dir="${basedir}/sandbox/planetroller/src" />

Modified: incubator/roller/trunk/properties.xmlf
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/properties.xmlf?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/properties.xmlf (original)
+++ incubator/roller/trunk/properties.xmlf Mon May  8 18:24:18 2006
@@ -88,10 +88,6 @@
     <include name="commons-httpclient*.jar"/>
 </fileset>
 
-<fileset id="commons-httpclient.jar" dir="${ro.tools}/lib">
-    <include name="commons-httpclient*.jar"/>
-</fileset>
-
 <fileset id="struts.jars" dir="${tools.struts}/lib">
     <include name="*.jar"/>
 </fileset>
@@ -182,7 +178,6 @@
        </fileset>
     </path>
     <path>
-       <fileset refid="commons-httpclient.jar"/>
        <fileset dir="${build.stage_web}/WEB-INF/lib">
           <include name="*.jar"/>
        </fileset>

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
Mon May  8 18:24:18 2006
@@ -216,7 +216,7 @@
                 UserEntry entry = (UserEntry)c.getEntries()[i];
                 UserData ud = mgr.getUserByUsername(entry.getName());
                 if (ud == null) {
-                    throw new NotFoundException("ERROR: Uknown user: " + entry.getName());
+                    throw new NotFoundException("ERROR: Unknown user: " + entry.getName());
                 }
                 updateUserData(ud, entry);
                 
@@ -257,7 +257,7 @@
             UserData ud = mgr.getUserByUsername(getUri().getEntryId());
             
             if (ud == null) {
-                throw new NotFoundException("ERROR: Uknown user: " + getUri().getEntryId());
+                throw new NotFoundException("ERROR: Unknown user: " + getUri().getEntryId());
             }
             // don't allow deletion of the currently authenticated user
             if (ud.getUserName().equals(getUserName())) {

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java?rev=405263&r1=405262&r2=405263&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
Mon May  8 18:24:18 2006
@@ -261,7 +261,7 @@
                 WeblogEntry entry = (WeblogEntry)c.getEntries()[i];
                 WebsiteData wd = mgr.getWebsiteByHandle(entry.getHandle());
                 if (wd == null) {
-                    throw new NotFoundException("ERROR: Uknown weblog: " + entry.getHandle());
+                    throw new NotFoundException("ERROR: Unknown weblog: " + entry.getHandle());
                 }
                 updateWebsiteData(wd, entry);
                 websiteDatas.add(wd);
@@ -308,7 +308,7 @@
             
             WebsiteData wd = mgr.getWebsiteByHandle(handle);
             if (wd == null) {
-                throw new NotFoundException("ERROR: Uknown weblog handle: " + handle);
+                throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
             }
             
             WebsiteData[] wds = new WebsiteData[] { wd };

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/AappTest.java Mon
May  8 18:24:18 2006
@@ -0,0 +1,479 @@
+package org.apache.roller.webservices.adminapi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.util.Base64;
+import org.apache.roller.webservices.adminapi.sdk.MemberEntry;
+import org.apache.roller.webservices.adminapi.sdk.MemberEntrySet;
+import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
+import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
+import org.apache.roller.webservices.adminapi.sdk.UserEntry;
+import org.apache.roller.webservices.adminapi.sdk.UserEntrySet;
+import org.apache.roller.webservices.adminapi.sdk.WeblogEntry;
+import org.apache.roller.webservices.adminapi.sdk.WeblogEntrySet;
+import org.jdom.JDOMException;
+
+public class AappTest extends TestCase {
+    public static class HttpResponse {
+        private int status;
+        private InputStream responseBody;
+        
+        public HttpResponse(int status) {
+            this(status, null);
+        }
+        
+        public HttpResponse(int status, InputStream responseBody) {
+            this.status = status;
+            this.responseBody = responseBody;
+        }
+        
+        public int getStatus() {
+            return status;
+        }
+        
+        public InputStream getResponseBody() {
+            return responseBody;
+        }
+    }
+    
+    private static final Date sampleDate = new Date();
+    private static final String DEFAULT_ENDPOINT_URL = "http://localhost:8080/roller/aapp";
+    private static final String DEFAULT_USER = "jtb";
+    private static final String DEFAULT_PASSWORD = "iplanet";
+    
+    protected static String getEndpointUrl() {
+        String endpoint = System.getProperty("aapp.endpoint");
+        if (endpoint == null) {
+            endpoint = DEFAULT_ENDPOINT_URL;
+        }
+        
+        System.err.println("endpoint=" + endpoint);
+        return endpoint;
+    }
+
+    protected static String getUser() {
+        String user = System.getProperties().getProperty("aapp.user");
+        if (user == null) {
+            user = DEFAULT_USER;
+        }
+        
+        System.err.println("user=" + user);
+        return user;
+    }
+
+    protected static String getPassword() {
+        String password = System.getProperties().getProperty("aapp.password");
+        if (password == null) {
+            password = DEFAULT_PASSWORD;
+        }
+        
+        System.err.println("password=" + password);        
+        return password;
+    }
+
+    protected static UserEntry getSampleUserEntry() {
+        UserEntry ue = new UserEntry("foo", getEndpointUrl());
+        ue.setEmailAddress("foo@bar.org");
+        ue.setFullName("Foo Bar");
+        ue.setLocale(Locale.getDefault());
+        ue.setTimezone(TimeZone.getDefault());
+        ue.setPassword("foo");
+        
+        return ue;
+    }
+
+    protected static MemberEntry getSampleMemberEntry() {
+        MemberEntry me = new MemberEntry("fooblog", "foo", getEndpointUrl());
+        me.setPermission(MemberEntry.Permissions.AUTHOR);
+        return me;
+    }
+    
+    protected static UserEntry updateSampleUserEntry(UserEntry ue) {
+        UserEntry ueUpdate = new UserEntry(ue.getName(), getEndpointUrl());
+        ueUpdate.setEmailAddress("billy@bob.org");
+        ueUpdate.setFullName("Billy Bob");
+        ueUpdate.setLocale(new Locale("ms", "MY"));
+        ueUpdate.setTimezone(TimeZone.getTimeZone("Asia/Kuala_Lumpur"));
+        ueUpdate.setPassword("billy");
+        
+        return ueUpdate;
+    }
+
+    protected static WeblogEntry updateSampleWeblogEntry(WeblogEntry we) {
+        WeblogEntry weUpdate = new WeblogEntry(we.getHandle(), getEndpointUrl());
+        weUpdate.setEmailAddress("billy@bob.org");
+        weUpdate.setName("Billy Bob Weblog Name");
+        weUpdate.setLocale(new Locale("ms", "MY"));
+        weUpdate.setTimezone(TimeZone.getTimeZone("Asia/Kuala_Lumpur"));
+        weUpdate.setDescription("Billy Bob Weblog Description");
+        weUpdate.setCreatingUser(we.getCreatingUser());
+        
+        return weUpdate;
+    }
+
+    protected static MemberEntry updateSampleMemberEntry(MemberEntry me) {
+        MemberEntry meUpdate = new MemberEntry(me.getHandle(), me.getName(), getEndpointUrl());
+        meUpdate.setPermission(MemberEntry.Permissions.LIMITED);
+        
+        return meUpdate;
+    }
+    
+    protected static UserEntrySet updateSampleUserEntrySet(UserEntrySet ues) {
+        UserEntry ue = (UserEntry)ues.getEntries()[0];
+        UserEntry ueUpdated = updateSampleUserEntry(ue);        
+        UserEntrySet uesUpdated = new UserEntrySet(getEndpointUrl());
+        uesUpdated.setEntries(new UserEntry[] { ueUpdated });
+        
+        return uesUpdated;
+    }
+    
+    protected static WeblogEntrySet updateSampleWeblogEntrySet(WeblogEntrySet wes) {
+        WeblogEntry we = (WeblogEntry)wes.getEntries()[0];
+        WeblogEntry weUpdated = updateSampleWeblogEntry(we);        
+        WeblogEntrySet wesUpdated = new WeblogEntrySet(getEndpointUrl());
+        wesUpdated.setEntries(new WeblogEntry[] { weUpdated });
+        
+        return wesUpdated;
+    }
+
+    protected static MemberEntrySet updateSampleMemberEntrySet(MemberEntrySet mes) {
+        MemberEntry me = (MemberEntry)mes.getEntries()[0];
+        MemberEntry meUpdated = updateSampleMemberEntry(me);        
+        MemberEntrySet mesUpdated = new MemberEntrySet(getEndpointUrl());
+        mesUpdated.setEntries(new MemberEntry[] { meUpdated });
+        
+        return mesUpdated;
+    }
+
+    protected static WeblogEntry getSampleWeblogEntry() {
+        WeblogEntry we = new WeblogEntry("fooblog", getEndpointUrl());
+        we.setEmailAddress("foo@bar.org");
+        we.setCreatingUser("foo");
+        we.setDescription("Foo Weblog Description");
+        we.setLocale(Locale.getDefault());
+        we.setTimezone(TimeZone.getDefault());
+        we.setName("Foo Weblog Name");
+        
+        return we;
+    }    
+    
+    protected static UserEntrySet getSampleUserEntrySet() {
+        UserEntry ue = getSampleUserEntry();
+        UserEntrySet ues = new UserEntrySet(getEndpointUrl());
+        ues.setEntries(new UserEntry[] { ue });
+        
+        return ues;
+    }
+    
+    protected static WeblogEntrySet getSampleWeblogEntrySet() {
+        WeblogEntry we = getSampleWeblogEntry();
+        WeblogEntrySet wes = new WeblogEntrySet(getEndpointUrl());
+        wes.setEntries(new WeblogEntry[] { we });
+        
+        return wes;
+    }
+    
+    protected static MemberEntrySet getSampleMemberEntrySet() {
+        MemberEntry me = getSampleMemberEntry();
+        MemberEntrySet mes = new MemberEntrySet(getEndpointUrl());
+        mes.setEntries(new MemberEntry[] { me });
+        
+        return mes;
+    }
+
+    protected UserEntrySet createSampleUser() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        UserEntrySet ues = getSampleUserEntrySet();
+        
+        String url = ues.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = ues.toString();
+        
+        HttpResponse res = post(url, user, password, body);
+        assertEquals(201, res.getStatus());
+        
+        UserEntrySet uesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           uesResponse = new UserEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return uesResponse;
+    }
+
+    protected UserEntrySet updateSampleUser() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        UserEntrySet ues = updateSampleUserEntrySet(getSampleUserEntrySet());
+        
+        String url = ues.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = ues.toString();
+        
+        HttpResponse res = put(url, user, password, body);
+        assertEquals(200, res.getStatus());
+        
+        UserEntrySet uesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           uesResponse = new UserEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return uesResponse;
+    }
+
+    protected WeblogEntrySet updateSampleWeblog() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        WeblogEntrySet wes = updateSampleWeblogEntrySet(getSampleWeblogEntrySet());
+        
+        String url = wes.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = wes.toString();
+        
+        HttpResponse res = put(url, user, password, body);
+        assertEquals(200, res.getStatus());
+        
+        WeblogEntrySet wesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           wesResponse = new WeblogEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return wesResponse;
+    }
+
+    protected MemberEntrySet updateSampleMember() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        MemberEntrySet mes = updateSampleMemberEntrySet(getSampleMemberEntrySet());
+        
+        String url = mes.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = mes.toString();
+        
+        HttpResponse res = put(url, user, password, body);
+        assertEquals(200, res.getStatus());
+        
+        MemberEntrySet mesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           mesResponse = new MemberEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return mesResponse;
+    }
+    
+    protected WeblogEntrySet createSampleWeblog() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        WeblogEntrySet wes = getSampleWeblogEntrySet();
+        
+        String url = wes.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = wes.toString();
+        
+        HttpResponse res = post(url, user, password, body);
+        assertEquals(201, res.getStatus());
+        
+        WeblogEntrySet wesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           wesResponse = new WeblogEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return wesResponse;
+    }
+
+    protected MemberEntrySet createSampleMember() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        MemberEntrySet mes = getSampleMemberEntrySet();
+        
+        String url = mes.getHref();
+        String user = getUser();
+        String password = getPassword();
+        
+        String body = mes.toString();
+        
+        HttpResponse res = post(url, user, password, body);
+        assertEquals(201, res.getStatus());
+        
+        MemberEntrySet mesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           mesResponse = new MemberEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return mesResponse;
+    }
+    
+    protected UserEntrySet deleteSampleUser() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        UserEntry ue = getSampleUserEntry();
+        
+        HttpResponse res = delete(ue.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        UserEntrySet uesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           uesResponse = new UserEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return uesResponse;
+    }
+
+    protected UserEntrySet fetchSampleUser() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        UserEntry ue = getSampleUserEntry();
+        
+        HttpResponse res = get(ue.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        UserEntrySet uesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           uesResponse = new UserEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return uesResponse;
+    }
+
+    protected WeblogEntrySet fetchSampleWeblog() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        WeblogEntry we = getSampleWeblogEntry();
+        
+        HttpResponse res = get(we.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        WeblogEntrySet wesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           wesResponse = new WeblogEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return wesResponse;
+    }
+
+    protected MemberEntrySet fetchSampleMember() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        MemberEntry me = getSampleMemberEntry();
+        
+        HttpResponse res = get(me.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        MemberEntrySet mesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           mesResponse = new MemberEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return mesResponse;
+    }
+    
+    protected WeblogEntrySet deleteSampleWeblog() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        WeblogEntry we = getSampleWeblogEntry();
+        
+        HttpResponse res = delete(we.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        WeblogEntrySet wesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           wesResponse = new WeblogEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return wesResponse;
+    }
+
+    protected MemberEntrySet deleteSampleMember() throws IOException, JDOMException, MissingElementException,
UnexpectedRootElementException {
+        MemberEntry me = getSampleMemberEntry();
+        
+        HttpResponse res = delete(me.getHref(), getUser(), getPassword());
+        assertEquals(200, res.getStatus());
+        
+        MemberEntrySet mesResponse = null;
+        InputStream responseBody = res.getResponseBody();
+        if (responseBody != null) {
+           mesResponse = new MemberEntrySet(responseBody, getEndpointUrl());
+        }
+        
+        return mesResponse;
+    }
+    
+    protected static HttpResponse post(String url, String user, String password, String body)
throws IOException {
+        HttpClient httpClient = new HttpClient();
+        EntityEnclosingMethod method = new PostMethod(url);
+        addAuthHeader(method, user, password);
+        
+        method.setRequestBody(body);
+        
+        String contentType = "application/xml; charset=utf8";
+        method.setRequestHeader("Content-type", contentType);
+        
+        int status = httpClient.executeMethod(method);
+        InputStream responseBody = method.getResponseBodyAsStream();
+        
+        HttpResponse res = new HttpResponse(status, responseBody);
+        return res;
+    }
+
+    protected static HttpResponse put(String url, String user, String password, String body)
throws IOException {
+        HttpClient httpClient = new HttpClient();
+        EntityEnclosingMethod method = new PutMethod(url);
+        addAuthHeader(method, user, password);
+        
+        method.setRequestBody(body);
+        
+        String contentType = "application/xml; charset=utf8";
+        method.setRequestHeader("Content-type", contentType);
+        
+        int status = httpClient.executeMethod(method);
+        InputStream responseBody = method.getResponseBodyAsStream();
+        
+        HttpResponse res = new HttpResponse(status, responseBody);
+        return res;
+    }
+    
+    protected static HttpResponse get(String url, String user, String password) throws IOException
{
+        HttpClient httpClient = new HttpClient();
+        HttpMethod method = new GetMethod(url);
+        addAuthHeader(method, user, password);
+        
+        String contentType = "application/xml; charset=utf8";
+        method.setRequestHeader("Content-type", contentType);
+        
+        int status = httpClient.executeMethod(method);
+        InputStream responseBody = method.getResponseBodyAsStream();
+        
+        HttpResponse res = new HttpResponse(status, responseBody);
+        return res;
+    }
+    
+    protected static HttpResponse delete(String url, String user, String password) throws
IOException {
+        HttpClient httpClient = new HttpClient();
+        HttpMethod method = new DeleteMethod(url);
+        addAuthHeader(method, user, password);
+                
+        String contentType = "application/xml; charset=utf8";
+        method.setRequestHeader("Content-type", contentType);
+        
+        int status = httpClient.executeMethod(method);
+        InputStream responseBody = method.getResponseBodyAsStream();
+        
+        HttpResponse res = new HttpResponse(status, responseBody);
+        return res;
+    }
+    
+    private static void addAuthHeader(HttpMethod method, String user, String password) {
+        String credentials = user + ":" + password;
+        method.setRequestHeader("Authorization", "Basic "  + new String(Base64.encode(credentials.getBytes())));
+    }   
+}

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/MemberHandlerTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,66 @@
+package org.apache.roller.webservices.adminapi;
+
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.sdk.MemberEntrySet;
+import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
+import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
+import org.jdom.JDOMException;
+
+public class MemberHandlerTest extends AappTest {
+    public void testHandler() {
+        try {
+            createSampleUser();
+            createSampleWeblog();
+            
+            //create
+            MemberEntrySet mesCreate = createSampleMember();
+            assertNotNull(mesCreate);
+            assertNotNull(mesCreate.getEntries());
+            assertEquals(mesCreate.getEntries().length, 1);
+            assertEquals(mesCreate, getSampleMemberEntrySet());
+            
+            //get
+            MemberEntrySet mesFetch = fetchSampleMember();
+            assertNotNull(mesFetch);
+            assertNotNull(mesFetch.getEntries());
+            assertEquals(mesFetch.getEntries().length, 1);
+            assertEquals(mesFetch, mesCreate);
+            
+            //update
+            MemberEntrySet mesUpdate = updateSampleMember();
+            assertNotNull(mesUpdate);
+            assertNotNull(mesUpdate.getEntries());
+            assertEquals(mesUpdate.getEntries().length, 1);
+            assertEquals(mesUpdate, updateSampleMemberEntrySet(getSampleMemberEntrySet()));
+            
+            //delete
+            MemberEntrySet mesDelete = deleteSampleMember();
+            assertNotNull(mesDelete);
+            assertNotNull(mesCreate.getEntries());
+            assertEquals(mesCreate.getEntries().length, 1);
+            assertEquals(mesDelete, mesUpdate);
+            
+            deleteSampleWeblog();
+            deleteSampleUser();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();            
+            fail(ioe.getMessage());
+        } catch (JDOMException je) {
+            je.printStackTrace();
+            fail(je.getMessage());
+        } catch (MissingElementException mee) {
+            mee.printStackTrace();            
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            uree.printStackTrace();            
+            fail(uree.getMessage());
+        } finally {
+            try {
+                delete(getSampleMemberEntry().getHref(), getUser(), getPassword());
+                delete(getSampleWeblogEntry().getHref(), getUser(), getPassword());     
          
+                delete(getSampleUserEntry().getHref(), getUser(), getPassword());       
                        
+            } catch (Exception e) {
+                // nothing
+            }
+        }
+    }

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/UserHandlerTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,62 @@
+package org.apache.roller.webservices.adminapi;
+
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
+import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
+import org.apache.roller.webservices.adminapi.sdk.UserEntrySet;
+import org.jdom.JDOMException;
+
+/**
+ *
+ * @author jtb
+ */
+public class UserHandlerTest extends AappTest {
+    public void testHandler() {
+        try {
+            //create
+            UserEntrySet uesCreate = createSampleUser();
+            assertNotNull(uesCreate);
+            assertNotNull(uesCreate.getEntries());
+            assertEquals(uesCreate.getEntries().length, 1);
+            assertEquals(uesCreate, getSampleUserEntrySet());
+            
+            //get
+            UserEntrySet uesFetch = fetchSampleUser();
+            assertNotNull(uesFetch);
+            assertNotNull(uesFetch.getEntries());
+            assertEquals(uesFetch.getEntries().length, 1);
+            assertEquals(uesFetch, uesCreate);
+            
+            //update
+            UserEntrySet uesUpdate = updateSampleUser();
+            assertNotNull(uesUpdate);
+            assertNotNull(uesUpdate.getEntries());
+            assertEquals(uesUpdate.getEntries().length, 1);
+            assertEquals(uesUpdate, updateSampleUserEntrySet(getSampleUserEntrySet()));
+            
+            //delete
+            UserEntrySet uesDelete = deleteSampleUser();
+            assertNotNull(uesDelete);
+            assertNotNull(uesCreate.getEntries());
+            assertEquals(uesCreate.getEntries().length, 1);
+            assertEquals(uesDelete, uesUpdate);
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+            fail(ioe.getMessage());
+        } catch (JDOMException je) {
+            je.printStackTrace();            
+            fail(je.getMessage());
+        } catch (MissingElementException mee) {
+            mee.printStackTrace();            
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            uree.printStackTrace();            
+            fail(uree.getMessage());
+        } finally {
+            try {
+                delete(getSampleUserEntry().getHref(), getUser(), getPassword());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/WeblogHandlerTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,63 @@
+package org.apache.roller.webservices.adminapi;
+
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
+import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
+import org.apache.roller.webservices.adminapi.sdk.WeblogEntrySet;
+import org.jdom.JDOMException;
+
+public class WeblogHandlerTest extends AappTest {
+    public void testHandler() {
+        try {
+            createSampleUser();
+            
+            //create
+            WeblogEntrySet wesCreate = createSampleWeblog();
+            assertNotNull(wesCreate);
+            assertNotNull(wesCreate.getEntries());
+            assertEquals(wesCreate.getEntries().length, 1);
+            assertEquals(wesCreate, getSampleWeblogEntrySet());
+            
+            //get
+            WeblogEntrySet wesFetch = fetchSampleWeblog();
+            assertNotNull(wesFetch);
+            assertNotNull(wesFetch.getEntries());
+            assertEquals(wesFetch.getEntries().length, 1);
+            assertEquals(wesFetch, wesCreate);
+            
+            //update
+            WeblogEntrySet wesUpdate = updateSampleWeblog();
+            assertNotNull(wesUpdate);
+            assertNotNull(wesUpdate.getEntries());
+            assertEquals(wesUpdate.getEntries().length, 1);
+            assertEquals(wesUpdate, updateSampleWeblogEntrySet(getSampleWeblogEntrySet()));
+            
+            //delete
+            WeblogEntrySet wesDelete = deleteSampleWeblog();
+            assertNotNull(wesDelete);
+            assertNotNull(wesCreate.getEntries());
+            assertEquals(wesCreate.getEntries().length, 1);
+            assertEquals(wesDelete, wesUpdate);
+            
+            deleteSampleUser();
+        } catch (IOException ioe) {
+            fail(ioe.getMessage());
+            ioe.printStackTrace();            
+        } catch (JDOMException je) {
+            fail(je.getMessage());
+            je.printStackTrace();
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+            mee.printStackTrace();
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+            uree.printStackTrace();
+        } finally {
+            try {
+                delete(getSampleWeblogEntry().getHref(), getUser(), getPassword());
+                delete(getSampleUserEntry().getHref(), getUser(), getPassword());       
        
+            } catch (Exception e) {
+                // nothing
+            }
+        }
+    }

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/MemberEntryTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,51 @@
+package org.apache.roller.webservices.adminapi.sdk;
+
+import org.jdom.Document;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.AappTest;
+import org.jdom.JDOMException;
+
+public class MemberEntryTest extends AappTest {
+    public void testEquals() {
+        MemberEntrySet wes1 = getSampleMemberEntrySet();
+        MemberEntrySet wes2 = getSampleMemberEntrySet();
+        
+        assertEquals(wes1, wes2);
+    }
+    
+    public void testDocumentMarshal() {
+        try {
+            MemberEntrySet wes1 = getSampleMemberEntrySet();
+            Document d = wes1.toDocument();
+            
+            MemberEntrySet wes2 = new MemberEntrySet(d, getEndpointUrl());
+            
+            assertEquals(wes1, wes2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        }
+    }
+    
+    public void testStreamMarshal() {
+        try {
+            MemberEntrySet wes1 = getSampleMemberEntrySet();
+            String s = wes1.toString();
+            InputStream stream = new ByteArrayInputStream(s.getBytes("UTF-8")); 
+            
+            MemberEntrySet wes2 = new MemberEntrySet(stream, getEndpointUrl());
+            
+            assertEquals(wes1, wes2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        } catch (IOException ioe) {
+            fail(ioe.getMessage());
+        } catch (JDOMException je) {
+            fail(je.getMessage());
+        }
+    }    

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/UserEntryTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,51 @@
+package org.apache.roller.webservices.adminapi.sdk;
+
+import org.jdom.Document;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.AappTest;
+import org.jdom.JDOMException;
+
+public class UserEntryTest extends AappTest {
+    public void testEquals() {
+        UserEntrySet ues1 = getSampleUserEntrySet();
+        UserEntrySet ues2 = getSampleUserEntrySet();
+        
+        assertEquals(ues1, ues2);
+    }
+    
+    public void testDocumentMarshal() {
+        try {
+            UserEntrySet ues1 = getSampleUserEntrySet();
+            Document d = ues1.toDocument();
+            
+            UserEntrySet ues2 = new UserEntrySet(d, getEndpointUrl());
+            
+            assertEquals(ues1, ues2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        }
+    }
+    
+    public void testStreamMarshal() {
+        try {
+            UserEntrySet ues1 = getSampleUserEntrySet();
+            String s = ues1.toString();
+            InputStream stream = new ByteArrayInputStream(s.getBytes("UTF-8")); 
+            
+            UserEntrySet ues2 = new UserEntrySet(stream, getEndpointUrl());
+            
+            assertEquals(ues1, ues2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        } catch (IOException ioe) {
+            fail(ioe.getMessage());
+        } catch (JDOMException je) {
+            fail(je.getMessage());
+        }
+    }    

Added: incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java?rev=405263&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/webservices/adminapi/sdk/WeblogEntryTest.java
Mon May  8 18:24:18 2006
@@ -0,0 +1,51 @@
+package org.apache.roller.webservices.adminapi.sdk;
+
+import org.jdom.Document;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import org.apache.roller.webservices.adminapi.AappTest;
+import org.jdom.JDOMException;
+
+public class WeblogEntryTest extends AappTest {
+    public void testEquals() {
+        WeblogEntrySet wes1 = getSampleWeblogEntrySet();
+        WeblogEntrySet wes2 = getSampleWeblogEntrySet();
+        
+        assertEquals(wes1, wes2);
+    }
+    
+    public void testDocumentMarshal() {
+        try {
+            WeblogEntrySet wes1 = getSampleWeblogEntrySet();
+            Document d = wes1.toDocument();
+            
+            WeblogEntrySet wes2 = new WeblogEntrySet(d, getEndpointUrl());
+            
+            assertEquals(wes1, wes2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        }
+    }
+    
+    public void testStreamMarshal() {
+        try {
+            WeblogEntrySet wes1 = getSampleWeblogEntrySet();
+            String s = wes1.toString();
+            InputStream stream = new ByteArrayInputStream(s.getBytes("UTF-8")); 
+            
+            WeblogEntrySet wes2 = new WeblogEntrySet(stream, getEndpointUrl());
+            
+            assertEquals(wes1, wes2);
+        } catch (MissingElementException mee) {
+            fail(mee.getMessage());
+        } catch (UnexpectedRootElementException uree) {
+            fail(uree.getMessage());
+        } catch (IOException ioe) {
+            fail(ioe.getMessage());
+        } catch (JDOMException je) {
+            fail(je.getMessage());
+        }
+    }    



Mime
View raw message