Skip to content

Commit

Permalink
Add a fix for recognizing eBay's new item URL, and _gasp_ a test for …
Browse files Browse the repository at this point in the history
…the fix!
  • Loading branch information
cyberfox committed Apr 26, 2010
1 parent 94ec9a6 commit 16d8942
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/com/jbidwatcher/auction/server/ebay/ebayServer.java
Expand Up @@ -417,6 +417,15 @@ public String extractIdentifierFromURLString(String urlStyle) {
}
}

try {
URL pieces = new URL(urlStyle);
String path = pieces.getPath();
String digits = path.substring(path.lastIndexOf('/')+1);
if(StringTools.isNumberOnly(digits)) return(digits);
} catch (Exception e) {
JConfig.log().logDebug("Failed to parse " + urlStyle + " as a URL");
}

JConfig.log().logDebug("extractIdentifierFromURLString failed.");
return null;
}
Expand Down
35 changes: 35 additions & 0 deletions test/com/jbidwatcher/auction/server/ebay/ebayServerTest.java
@@ -0,0 +1,35 @@
package com.jbidwatcher.auction.server.ebay;

import com.jbidwatcher.auction.server.AuctionServer;
import junit.framework.TestCase;

/**
* Created by IntelliJ IDEA.
* User: mrs
* Date: Apr 26, 2010
* Time: 12:54:48 AM
* To change this template use File | Settings | File Templates.
*/
public class ebayServerTest extends TestCase {
public void testExtractIdentifierFromURLString() throws Exception {
AuctionServer ebay = new ebayServer();
String id = ebay.extractIdentifierFromURLString("http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=220594110651");
assertEquals("220594110651", id);
id = ebay.extractIdentifierFromURLString("http://cgi.ebay.com/Panasonic-Lumix-20mm-/220594110651?cmd=ViewItem&pt=Camera_Lenses&hash=item335c6f00bb");
assertEquals("220594110651", id);
id = ebay.extractIdentifierFromURLString("http://cgi.ebay.com/220594110651");
assertEquals("220594110651", id);
}

public void testGetStringURLFromItem() throws Exception {
}

public void testGetBrowsableURLFromItem() throws Exception {
}

public void testIsDefaultUser() throws Exception {
}

public void testGetUserId() throws Exception {
}
}

0 comments on commit 16d8942

Please sign in to comment.