[jslideshare commit] r21 - in trunk/JSlideShare/src: main/java/com/benfante/jslideshare main/java/com/benfante/jslides...

0 views
Skip to first unread message

codesite...@google.com

unread,
Jun 25, 2008, 1:46:28 PM6/25/08
to jslidesha...@googlegroups.com
Author: lucio.benfante
Date: Wed Jun 25 10:45:22 2008
New Revision: 21

Added:
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/SlideshowInfo.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/utils/
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/utils/Utils.java
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/utils/
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/utils/UtilsTest.java
trunk/JSlideShare/src/test/resources/xml/messages/get_slideshow_info.xml
Modified:
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/App.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParser.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParserResult.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPI.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPIImpl.java
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/Slideshow.java
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/SlideShareAPITest.java

Log:
Added getSlideshowInfo API method

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/App.java
==============================================================================
--- trunk/JSlideShare/src/main/java/com/benfante/jslideshare/App.java (original)
+++ trunk/JSlideShare/src/main/java/com/benfante/jslideshare/App.java
Wed Jun 25 10:45:22 2008
@@ -33,6 +33,8 @@
SHARED_SECRET);
System.out.println(ssapi.getSlideshow("142806"));
Thread.sleep(2000);
+ System.out.println(ssapi.getSlideshowInfo(null, "http://www.slideshare.net/benfante/using-daos-without-implementing-them"));
+ Thread.sleep(2000);
System.out.println(ssapi.getSlideshowByUser("john.leach"));
Thread.sleep(2000);
System.out.println(ssapi.getSlideshowByUser("john.leach", 1, 1));

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParser.java
==============================================================================
---
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParser.java (original)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParser.java
Wed Jun 25 10:45:22 2008
@@ -15,6 +15,7 @@

import com.benfante.jslideshare.messages.Group;
import com.benfante.jslideshare.messages.Slideshow;
+import com.benfante.jslideshare.messages.SlideshowInfo;
import com.benfante.jslideshare.messages.Tag;
import com.benfante.jslideshare.messages.User;
import java.io.IOException;
@@ -34,14 +35,19 @@
* @author Lucio Benfante (<a href="mailto:lu...@benfante.com">lu...@benfante.com</a>)
*/
public class DocumentParser extends DefaultHandler {
+
public static final String COUNT_TAG = "count";
public static final String DESCRIPTION_TAG = "Description";
public static final String EMBED_CODE_TAG = "EmbedCode";
public static final String GROUP_TAG = "Group";
public static final String ID_ATTRIBUTE = "id";
+ public static final String ID_TAG = "ID";
+ public static final String LANGUAGE_TAG = "Language";
public static final String MESSAGE_TAG = "Message";
public static final String NAME_TAG = "name";
public static final String PERMALINK_TAG = "Permalink";
+ public static final String PLAYER_DOC_TAG = "PlayerDoc";
+ public static final String RELATED_SLIDESHOWS_TAG = "RelatedSlideshows";
public static final String SLIDESHOWS_TAG = "Slideshows";
public static final String SLIDESHOW_ID_TAG = "SlideShowID";
public static final String SLIDESHOW_TAG = "Slideshow";
@@ -49,13 +55,19 @@
public static final String SLIDESHOW_DELETED_TAG = "SlideShowDeleted";
public static final String STATUS_DESCRIPTION_TAG = "StatusDescription";
public static final String STATUS_TAG = "Status";
- public static final String TAGS_TAG = "Tags";
public static final String TAG_TAG = "Tag";
+ public static final String TAGS_TAG = "Tags";
public static final String THUMBNAIL_TAG = "Thumbnail";
+ public static final String THUMBNAIL_URL_TAG = "ThumbnailURL";
+ public static final String THUMBNAIL_SMALL_URL_TAG = "ThumbnailSmallURL";
public static final String TITLE_TAG = "Title";
+ public static final String TOTAL_SLIDES_TAG = "TotalSlides";
public static final String USER_TAG = "User";
+ public static final String USER_ID_TAG = "UserID";
+ public static final String USER_LOGIN_TAG = "UserLogin";
+ public static final String URL_TAG = "URL";
+ public static final String URL_DOC_TAG = "URLDoc";
public static final String VIEWS_TAG = "Views";
-
private StringBuilder tempVal = new StringBuilder();
private Slideshow tempSlideshow;
private List<Slideshow> tempSlideshows;
@@ -67,6 +79,7 @@
private int tempCount;
private String tempSlideShowId;
private DocumentParserResult parserResult;
+ private SlideshowInfo tempSlideshowInfo;

private DocumentParser() {
}
@@ -98,6 +111,7 @@
tempVal.setLength(0);
if (qName.equalsIgnoreCase(SLIDESHOW_TAG)) {
tempSlideshow = new Slideshow();
+ tempSlideshowInfo = new SlideshowInfo();
} else if (qName.equalsIgnoreCase(SLIDESHOWS_TAG)) {
tempSlideshows = new LinkedList<Slideshow>();
} else if (qName.equalsIgnoreCase(USER_TAG)) {
@@ -123,10 +137,17 @@
public void endElement(String uri, String localName,
String qName) throws SAXException {
if (qName.equalsIgnoreCase(SLIDESHOW_TAG)) {
- tempSlideshows.add(tempSlideshow);
+ if (tempSlideshowInfo.getUrl() != null) { // I parsed a SlideshowInfo
+ createResult();
+ this.parserResult.setSlideShowInfo(tempSlideshowInfo);
+ } else {
+ tempSlideshows.add(tempSlideshow);
+ }
} else if (qName.equalsIgnoreCase(SLIDESHOWS_TAG)) {
createResult();
- this.parserResult.setSlideShows(tempSlideshows);
+ if (!tempSlideshows.isEmpty()) {
+ this.parserResult.setSlideShows(tempSlideshows);
+ }
} else if (qName.equalsIgnoreCase(USER_TAG)) {
tempUser.setName(tempName);
tempUser.setCount(tempCount);
@@ -156,16 +177,21 @@
tempVal.toString());
} else if (qName.equalsIgnoreCase(STATUS_TAG)) {
tempSlideshow.setStatus(secureParseInt(tempVal.toString(), -1));
+
tempSlideshowInfo.setStatus(secureParseInt(tempVal.toString(), -1));
} else if (qName.equalsIgnoreCase(STATUS_DESCRIPTION_TAG)) {
tempSlideshow.setStatusDescription(tempVal.toString());
} else if (qName.equalsIgnoreCase(TITLE_TAG)) {
tempSlideshow.setTitle(tempVal.toString());
+ tempSlideshowInfo.setTitle(tempVal.toString());
} else if (qName.equalsIgnoreCase(DESCRIPTION_TAG)) {
tempSlideshow.setDescription(tempVal.toString());
+ tempSlideshowInfo.setDescription(tempVal.toString());
} else if (qName.equalsIgnoreCase(TAGS_TAG)) {
tempSlideshow.setTags(tempVal.toString());
+ tempSlideshowInfo.setTags(tempVal.toString());
} else if (qName.equalsIgnoreCase(EMBED_CODE_TAG)) {
tempSlideshow.setEmbedCode(tempVal.toString());
+ tempSlideshowInfo.setEmbedCode(tempVal.toString());
} else if (qName.equalsIgnoreCase(THUMBNAIL_TAG)) {
tempSlideshow.setThumbnail(tempVal.toString());
} else if (qName.equalsIgnoreCase(PERMALINK_TAG)) {
@@ -178,6 +204,29 @@
tempCount = secureParseInt(tempVal.toString(), -1);
} else if (qName.equalsIgnoreCase(SLIDESHOW_ID_TAG)) {
tempSlideShowId = tempVal.toString();
+ } else if (qName.equals(ID_TAG)) {
+ tempSlideshowInfo.setId(tempVal.toString());
+ } else if (qName.equals(PLAYER_DOC_TAG)) {
+ tempSlideshowInfo.setPlayerDoc(tempVal.toString());
+ } else if (qName.equalsIgnoreCase(TOTAL_SLIDES_TAG)) {
+ tempSlideshowInfo.setTotalSlides(secureParseInt(tempVal.toString(),
+ 0));
+ } else if (qName.equals(URL_DOC_TAG)) {
+ tempSlideshowInfo.setUrlDoc(tempVal.toString());
+ } else if (qName.equals(LANGUAGE_TAG)) {
+ tempSlideshowInfo.setLanguage(tempVal.toString());
+ } else if (qName.equals(URL_TAG)) {
+ tempSlideshowInfo.setUrl(tempVal.toString());
+ } else if (qName.equals(USER_ID_TAG)) {
+ tempSlideshowInfo.setUserId(tempVal.toString());
+ } else if (qName.equals(USER_LOGIN_TAG)) {
+ tempSlideshowInfo.setUserLogin(tempVal.toString());
+ } else if (qName.equals(RELATED_SLIDESHOWS_TAG)) {
+ tempSlideshowInfo.setRelatedSlideshows(tempVal.toString());
+ } else if (qName.equals(THUMBNAIL_URL_TAG)) {
+ tempSlideshowInfo.setThumbnailUrl(tempVal.toString());
+ } else if (qName.equals(THUMBNAIL_SMALL_URL_TAG)) {
+ tempSlideshowInfo.setThumbnailSmallUrl(tempVal.toString());
}
}

@@ -190,7 +239,7 @@
}
return result;
}
-
+
private void createResult() {
if (this.parserResult == null) {
this.parserResult = new DocumentParserResult();

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParserResult.java
==============================================================================
---
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParserResult.java (original)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/DocumentParserResult.java
Wed Jun 25 10:45:22 2008
@@ -15,6 +15,7 @@

import com.benfante.jslideshare.messages.Group;
import com.benfante.jslideshare.messages.Slideshow;
+import com.benfante.jslideshare.messages.SlideshowInfo;
import com.benfante.jslideshare.messages.Tag;
import com.benfante.jslideshare.messages.User;
import java.util.LinkedList;
@@ -27,7 +28,8 @@
*/
public class DocumentParserResult {

- private List<Slideshow> slideShows = new LinkedList();
+ private List<Slideshow> slideShows = new LinkedList<Slideshow>();
+ private SlideshowInfo slideShowInfo = new SlideshowInfo();
private User user;
private Tag tag;
private Group group;
@@ -41,6 +43,14 @@
this.slideShows = slideShows;
}

+ public SlideshowInfo getSlideShowInfo() {
+ return slideShowInfo;
+ }
+
+ public void setSlideShowInfo(SlideshowInfo slideShowInfo) {
+ this.slideShowInfo = slideShowInfo;
+ }
+
public User getUser() {
return user;
}
@@ -72,7 +82,7 @@
public void setSlideShowId(String slideShowId) {
this.slideShowId = slideShowId;
}
-
+
public Slideshow getSlideShow() {
Slideshow result = null;
if (slideShows != null && !slideShows.isEmpty()) {
@@ -80,4 +90,5 @@
}
return result;
}
+
}

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPI.java
==============================================================================
---
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPI.java (original)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPI.java
Wed Jun 25 10:45:22 2008
@@ -15,6 +15,7 @@

import com.benfante.jslideshare.messages.Group;
import com.benfante.jslideshare.messages.Slideshow;
+import com.benfante.jslideshare.messages.SlideshowInfo;
import com.benfante.jslideshare.messages.Tag;
import com.benfante.jslideshare.messages.User;
import java.io.File;
@@ -37,6 +38,18 @@
Slideshow getSlideshow(String id) throws SlideShareException,
SlideShareErrorException;

+ /**
+ * Retrieve a slideshow using its id or its URL. If both are
specified (not null or empty), the id has the precedence.
+ *
+ * @param id The slideshow id
+ * @param url The slideshow URL
+ * @return The slideshow
+ * @throws com.benfante.jslideshare.SlideShareException In case of
a SlideShareServiceError
+ * @throws com.benfante.jslideshare.SlideShareErrorException In
case of an error using the service (IO error, timeouts, http status
other than OK, etc.)
+ */
+ SlideshowInfo getSlideshowInfo(String id, String url) throws SlideShareException,
+ SlideShareErrorException;
+
/**
* Retrieve slideshows for a given user.
*

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPIImpl.java
==============================================================================
---
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPIImpl.java (original)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/SlideShareAPIImpl.java
Wed Jun 25 10:45:22 2008
@@ -15,6 +15,7 @@

import com.benfante.jslideshare.messages.Group;
import com.benfante.jslideshare.messages.Slideshow;
+import com.benfante.jslideshare.messages.SlideshowInfo;
import com.benfante.jslideshare.messages.Tag;
import com.benfante.jslideshare.messages.User;
import java.io.File;
@@ -35,6 +36,8 @@
SlideShareAPIImpl.class);
public static final String URL_GET_SLIDESHOW =
"http://www.slideshare.net/api/1/get_slideshow";
+ public static final String URL_GET_SLIDESHOW_INFO =
+ "http://www.slideshare.net/api/1/get_slideshow_info";
public static final String URL_GET_SLIDESHOW_BY_USER =
"http://www.slideshare.net/api/1/get_slideshow_by_user";
public static final String URL_GET_SLIDESHOW_BY_TAG =
@@ -70,6 +73,16 @@
return sendMessage(URL_GET_SLIDESHOW, parameters).getSlideShow();
}

+ public SlideshowInfo getSlideshowInfo(String id, String url) throws
+ SlideShareException,
+ SlideShareErrorException {
+ logger.info("Called getSlideshowInfo with id=" + id + ", url="
+ url);
+ Map<String, String> parameters = new HashMap<String, String>();
+ addParameter(parameters, "slideshow_id", id);
+ addParameter(parameters, "slideshow_url", url);
+ return sendGetMessage(URL_GET_SLIDESHOW_INFO, parameters).getSlideShowInfo();
+ }
+
public User getSlideshowByUser(String username) throws SlideShareException,
SlideShareErrorException {
logger.info("Called getSlideshowByUser with username=" + username);
@@ -158,7 +171,6 @@
// addParameter(parameters, "slideshow_id", id);
// return sendGetMessage(URL_DELETE_SLIDESHOW, parameters).getSlideShowId();
// }
-
private Map<String, String> addParameter(Map<String, String> parameters,
String name, String value) {
if (value != null) {
@@ -209,7 +221,7 @@
}
return result;
}
-
+
private DocumentParserResult sendMessage(String url,
Map<String, String> parameters, Map<String, File> files) throws
SlideShareErrorException {

Modified: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/Slideshow.java
==============================================================================
---
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/Slideshow.java (original)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/Slideshow.java
Wed Jun 25 10:45:22 2008
@@ -13,6 +13,8 @@
// limitations under the License.
package com.benfante.jslideshare.messages;

+import com.benfante.jslideshare.utils.Utils;
+
/**
* The slideshow document.
*
@@ -100,6 +102,10 @@

public void setViews(int views) {
this.views = views;
+ }
+
+ public String[] getTagArray() {
+ return Utils.splitCsvLine(this.tags);
}

@Override

Added: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/SlideshowInfo.java
==============================================================================
--- (empty file)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/messages/SlideshowInfo.java
Wed Jun 25 10:45:22 2008
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2008 The JSlideShare Team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+package com.benfante.jslideshare.messages;
+
+import com.benfante.jslideshare.utils.Utils;
+
+/**
+ * The slideshow document with more infos.
+ *
+ * @author Lucio Benfante (<a href="mailto:lu...@benfante.com">lu...@benfante.com</a>)
+ */
+public class SlideshowInfo {
+
+ private String id;
+ private String title;
+ private String description;
+ private int status;
+ private String embedCode;
+ private String playerDoc;
+ private int totalSlides;
+ private String urlDoc;
+ private String language;
+ private String url;
+ private String userId;
+ private String userLogin;
+ private String relatedSlideshows;
+ private String thumbnailUrl;
+ private String thumbnailSmallUrl;
+ private String tags;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getEmbedCode() {
+ return embedCode;
+ }
+
+ public void setEmbedCode(String embedCode) {
+ this.embedCode = embedCode;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getPlayerDoc() {
+ return playerDoc;
+ }
+
+ public void setPlayerDoc(String playerDoc) {
+ this.playerDoc = playerDoc;
+ }
+
+ public String getRelatedSlideshows() {
+ return relatedSlideshows;
+ }
+
+ public void setRelatedSlideshows(String relatedSlideshows) {
+ this.relatedSlideshows = relatedSlideshows;
+ }
+
+ public String[] getRelatedSlideshowsArray() {
+ return Utils.splitCsvLine(this.relatedSlideshows);
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public String[] getTagArray() {
+ return Utils.splitCsvLine(this.tags);
+ }
+
+ public String getThumbnailSmallUrl() {
+ return thumbnailSmallUrl;
+ }
+
+ public void setThumbnailSmallUrl(String thumbnailSmallUrl) {
+ this.thumbnailSmallUrl = thumbnailSmallUrl;
+ }
+
+ public String getThumbnailUrl() {
+ return thumbnailUrl;
+ }
+
+ public void setThumbnailUrl(String thumbnailUrl) {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getTotalSlides() {
+ return totalSlides;
+ }
+
+ public void setTotalSlides(int totalSlides) {
+ this.totalSlides = totalSlides;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUrlDoc() {
+ return urlDoc;
+ }
+
+ public void setUrlDoc(String urlDoc) {
+ this.urlDoc = urlDoc;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUserLogin() {
+ return userLogin;
+ }
+
+ public void setUserLogin(String userLogin) {
+ this.userLogin = userLogin;
+ }
+
+ @Override
+ public String toString() {
+ return "id=" + this.id + ";status=" + this.status + ";title=" +
+ this.title + ";description=" + this.description
+ ";tags=" +
+ this.tags + ";embedCode=" + this.embedCode
+ ";playerDoc=" +
+ this.playerDoc + ";totalSlides=" + this.totalSlides
+ ";urlDoc=" +
+ this.urlDoc + ";language=" + this.language + ";url=" +
this.url +
+ ";userId=" + this.userId + ";userLogin=" +
this.userLogin +
+ ";relatedSlideshows=" + this.relatedSlideshows +
+ ";thumbnailUrl=" + this.thumbnailUrl
+ ";thumbnailSmallUrl=" +
+ this.thumbnailSmallUrl;
+ }
+}
\ No newline at end of file

Added: trunk/JSlideShare/src/main/java/com/benfante/jslideshare/utils/Utils.java
==============================================================================
--- (empty file)
+++
trunk/JSlideShare/src/main/java/com/benfante/jslideshare/utils/Utils.java
Wed Jun 25 10:45:22 2008
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 lucio.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+
+package com.benfante.jslideshare.utils;
+
+/**
+ *
+ * @author lucio
+ */
+public class Utils {
+
+ private Utils() {
+ }
+
+ public static String[] splitCsvLine(String csvLine) {
+// return csvLine.split(",(?!(?:[^\",]|[^\"],[^\"])+\")");
+// return csvLine.split(",(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))");
+ return csvLine.split(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
+ }
+}

Modified: trunk/JSlideShare/src/test/java/com/benfante/jslideshare/SlideShareAPITest.java
==============================================================================
---
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/SlideShareAPITest.java (original)
+++
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/SlideShareAPITest.java
Wed Jun 25 10:45:22 2008
@@ -15,6 +15,7 @@

import com.benfante.jslideshare.messages.Group;
import com.benfante.jslideshare.messages.Slideshow;
+import com.benfante.jslideshare.messages.SlideshowInfo;
import com.benfante.jslideshare.messages.Tag;
import com.benfante.jslideshare.messages.User;
import java.io.File;
@@ -55,6 +56,7 @@
"Presentation of Groovy and Grails made at the JUG
Padova on 17 May 2008",
result.getDescription());
assertEquals("grails,groovy", result.getTags());
+ assertEquals(2, result.getTagArray().length);
assertEquals(
"<object type=\"application/x-shockwave-flash\"
data=\"http://s3.amazonaws.com/slideshare/ssplayer.swf?id=414888&doc=groovyandgrails-1211192948866493-8&branding=no\"
width=\"425\" height=\"348\"><param name=\"movie\"
value=\"http://s3.amazonaws.com/slideshare/ssplayer.swf?id=414888&doc=groovyandgrails-1211192948866493-8&branding=no\" /></object>",
result.getEmbedCode());
@@ -65,6 +67,43 @@
"http://www.slideshare.net/john.leach/groovy-and-grails-jug-padova",
result.getPermalink());
assertEquals(25, result.getViews());
+ }
+
+ public void testGetSlideshowInfo() throws Exception {
+ SlideShareAPI instance = new SlideShareAPIImpl(
+ new MockSlideShareConnector(
+ "xml/messages/get_slideshow_info.xml"));
+ SlideshowInfo result = instance.getSlideshowInfo(null, "what
you want");
+ assertEquals("142806", result.getId());
+ assertEquals(2, result.getStatus());
+ assertEquals("Using DAOs without implementing them", result.getTitle());
+ assertEquals(
+ "With Parancoe (www.parancoe.org) You can define and
use your DAOs without implementing them. This speeds up the development
of your application and the satisfaction of the developers. This
presentation was held at the JavaDay in Torino, the October 20, 2007.",
+ result.getDescription());
+ assertEquals("dao,parancoe,dao,hibernate,jpa", result.getTags());
+ assertEquals(5, result.getTagArray().length);
+ assertEquals(
+ "<div style=\"width:425px;text-align:left\"
id=\"__ss_142806\"><object style=\"margin:0px\" width=\"425\"
height=\"355\"><param name=\"movie\"
value=\"http://static.slideshare.net/swf/ssplayer2.swf?doc=using-daos-without-implementing-them-1193116570658927-4\"/><param
name=\"allowFullScreen\" value=\"true\"/><param
name=\"allowScriptAccess\" value=\"always\"/><embed
src=\"http://static.slideshare.net/swf/ssplayer2.swf?doc=using-daos-without-implementing-them-1193116570658927-4\"
type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\"
allowfullscreen=\"true\" width=\"425\"
height=\"355\"></embed></object><div
style=\"font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;\"><a
href=\"http://www.slideshare.net/?src=apiembed\"><img
src=\"http://static.slideshare.net/swf/logo_embd.png\"
style=\"border:0px none;margin-bottom:-5px\" alt=\"SlideShare\"/></a> |
<a
href=\"http://www.slideshare.net/benfante/using-daos-without-implementing-them?src=apiembed\"
title=\"View Using DAOs without implementing them on
SlideShare\">View</a> | <a
href=\"http://www.slideshare.net/upload?src=apiembed\">Upload your own</a></div></div>",
+ result.getEmbedCode());
+ assertEquals("using-daos-without-implementing-them-1193116570658927-4",
+ result.getPlayerDoc());
+ assertEquals(29, result.getTotalSlides());
+ assertEquals("using-daos-without-implementing-them", result.getUrlDoc());
+ assertEquals("en", result.getLanguage());
+ assertEquals(
+ "http://www.slideshare.net/benfante/using-daos-without-implementing-them",
+ result.getUrl());
+ assertEquals("198837", result.getUserId());
+ assertEquals("benfante", result.getUserLogin());
+ assertEquals("96741,38699,193375,134318,44689,69765,31664,68855,69943,",
+ result.getRelatedSlideshows());
+ assertEquals(9, result.getRelatedSlideshowsArray().length);
+ assertEquals(
+ "http://cdn.slideshare.net/using-daos-without-implementing-them-1193116570658927-4-thumbnail?1193116571",
+ result.getThumbnailUrl());
+ assertEquals(
+ "http://cdn.slideshare.net/using-daos-without-implementing-them-1193116570658927-4-thumbnail-2",
+ result.getThumbnailSmallUrl());
}

/**

Added: trunk/JSlideShare/src/test/java/com/benfante/jslideshare/utils/UtilsTest.java
==============================================================================
--- (empty file)
+++
trunk/JSlideShare/src/test/java/com/benfante/jslideshare/utils/UtilsTest.java
Wed Jun 25 10:45:22 2008
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2008 JSlideShare Team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+
+package com.benfante.jslideshare.utils;
+
+import java.util.Arrays;
+import junit.framework.TestCase;
+
+/**
+ * Tests of the Util methods.
+ *
+ * @author Lucio Benfante (<a href="mailto:lu...@benfante.com">lu...@benfante.com</a>)
+ */
+public class UtilsTest extends TestCase {
+
+ public UtilsTest(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test of splitCsvLine method, of class Utils.
+ */
+ public void testSplitCsvLineSimple() {
+ String csvLine = "a,b,c,d,e";
+ String[] expResult = new String[] {"a","b","c","d","e"};
+ String[] result = Utils.splitCsvLine(csvLine);
+ assertTrue("Expected <"+Arrays.toString(expResult)+"> but was
<"+Arrays.toString(result)+">", Arrays.equals(expResult, result));
+ }
+
+ /**
+ * Test of splitCsvLine method, of class Utils.
+ */
+ public void testSplitCsvLineEndingWithComma() {
+ String csvLine = "a,b,c,d,e,";
+ String[] expResult = new String[] {"a","b","c","d","e"};
+ String[] result = Utils.splitCsvLine(csvLine);
+ assertTrue("Expected <"+Arrays.toString(expResult)+"> but was
<"+Arrays.toString(result)+">", Arrays.equals(expResult, result));
+ }
+
+ /**
+ * Test of splitCsvLine method, of class Utils.
+ */
+ public void testSplitCsvLineWithComposedWords() {
+ String csvLine = "a,b,\"c c\",d,e";
+ String[] expResult = new String[] {"a","b","\"c c\"","d","e"};
+ String[] result = Utils.splitCsvLine(csvLine);
+ assertTrue("Expected <"+Arrays.toString(expResult)+"> but was
<"+Arrays.toString(result)+">", Arrays.equals(expResult, result));
+ }
+
+ /**
+ * Test of splitCsvLine method, of class Utils.
+ */
+ public void testSplitCsvLineWithCommasInside() {
+ String csvLine = "a,b,\"c,c\",d,e";
+ String[] expResult = new String[] {"a","b","\"c,c\"","d","e"};
+ String[] result = Utils.splitCsvLine(csvLine);
+ assertTrue("Expected <"+Arrays.toString(expResult)+"> but was
<"+Arrays.toString(result)+">", Arrays.equals(expResult, result));
+ }
+
+}

Added: trunk/JSlideShare/src/test/resources/xml/messages/get_slideshow_info.xml
==============================================================================
--- (empty file)
+++
trunk/JSlideShare/src/test/resources/xml/messages/get_slideshow_info.xml
Wed Jun 25 10:45:22 2008
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Slideshow>
+ <ID>142806</ID>
+ <Title>Using DAOs without implementing them</Title>
+ <Description>With Parancoe (www.parancoe.org) You can define and use
your DAOs without implementing them. This speeds up the development of
your application and the satisfaction of the developers. This
presentation was held at the JavaDay in Torino, the October 20, 2007.</Description>
+ <Status>2</Status>
+ <EmbedCode>&lt;div style="width:425px;text-align:left"
id="__ss_142806"&gt;&lt;object style="margin:0px" width="425"
height="355"&gt;&lt;param name="movie"
value="http://static.slideshare.net/swf/ssplayer2.swf?doc=using-daos-without-implementing-them-1193116570658927-4"/&gt;&lt;param
name="allowFullScreen" value="true"/&gt;&lt;param
name="allowScriptAccess" value="always"/&gt;&lt;embed
src="http://static.slideshare.net/swf/ssplayer2.swf?doc=using-daos-without-implementing-them-1193116570658927-4"
type="application/x-shockwave-flash" allowscriptaccess="always"
allowfullscreen="true" width="425"
height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div
style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;&lt;a
href="http://www.slideshare.net/?src=apiembed"&gt;&lt;img
src="http://static.slideshare.net/swf/logo_embd.png" style="border:0px
none;margin-bottom:-5px" alt="SlideShare"/&gt;&lt;/a&gt; | &lt;a
href="http://www.slideshare.net/benfante/using-daos-without-implementing-them?src=apiembed"
title="View Using DAOs without implementing them on
SlideShare"&gt;View&lt;/a&gt; | &lt;a
href="http://www.slideshare.net/upload?src=apiembed"&gt;Upload your own&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</EmbedCode>
+ <PlayerDoc>using-daos-without-implementing-them-1193116570658927-4</PlayerDoc>
+ <TotalSlides>29</TotalSlides>
+ <URLDoc>using-daos-without-implementing-them</URLDoc>
+ <Language>en</Language>
+ <URL>http://www.slideshare.net/benfante/using-daos-without-implementing-them</URL>
+ <UserID>198837</UserID>
+ <UserLogin>benfante</UserLogin>
+ <RelatedSlideshows>96741,38699,193375,134318,44689,69765,31664,68855,69943,</RelatedSlideshows>
+ <ThumbnailURL>http://cdn.slideshare.net/using-daos-without-implementing-them-1193116570658927-4-thumbnail?1193116571</ThumbnailURL>
+ <ThumbnailSmallURL>http://cdn.slideshare.net/using-daos-without-implementing-them-1193116570658927-4-thumbnail-2</ThumbnailSmallURL>
+ <Tags>dao,parancoe,dao,hibernate,jpa</Tags>
+</Slideshow>

Reply all
Reply to author
Forward
0 new messages