|
| 1 | +/* |
| 2 | + * To change this template, choose Tools | Templates |
| 3 | + * and open the template in the editor. |
| 4 | + */ |
| 5 | +package com.silverpeas.openoffice.util; |
| 6 | + |
| 7 | +import junit.framework.TestCase; |
| 8 | + |
| 9 | +/** |
| 10 | + * |
| 11 | + * @author ehugonnet |
| 12 | + */ |
| 13 | +public class UrlExtractorTest extends TestCase { |
| 14 | + |
| 15 | + public UrlExtractorTest(String testName) { |
| 16 | + super(testName); |
| 17 | + } |
| 18 | + |
| 19 | + @Override |
| 20 | + protected void setUp() throws Exception { |
| 21 | + super.setUp(); |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + protected void tearDown() throws Exception { |
| 26 | + super.tearDown(); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Test of decodeUrl method, of class UrlExtractor. |
| 31 | + */ |
| 32 | + public void testDecodeUrl() { |
| 33 | + String encodedUrl = "http%3A%2F%2Fdsr-preprod-3%2Fsilverpeas%2Frepository%2Fjackrabbit%2Fattachments%2Fkmelia34%2FAttachment%2FImages%2F44733%2FAtelier+en+classe.doc"; |
| 34 | + String expResult = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc"; |
| 35 | + String result = UrlExtractor.decodeUrl(encodedUrl); |
| 36 | + assertEquals(expResult, result); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Test of escapeUrl method, of class UrlExtractor. |
| 41 | + */ |
| 42 | + public void testEscapeUrl() { |
| 43 | + String url = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc"; |
| 44 | + String expResult = "\"http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc\""; |
| 45 | + String expResultUnix = "http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier%20en%20classe.doc"; |
| 46 | + System.setProperty("os.name", "Windows XP"); |
| 47 | + String result = UrlExtractor.escapeUrl(url); |
| 48 | + assertEquals(expResult, result); |
| 49 | + System.setProperty("os.name", "Linux"); |
| 50 | + result = UrlExtractor.escapeUrl(url); |
| 51 | + assertEquals(expResultUnix, result); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Test of extractUrl method, of class UrlExtractor. |
| 56 | + */ |
| 57 | + public void testExtractUrl() { |
| 58 | + System.setProperty("os.name", "Windows XP"); |
| 59 | + String encodedUrl = "http%3A%2F%2Fdsr-preprod-3%2Fsilverpeas%2Frepository%2Fjackrabbit%2Fattachments%2Fkmelia34%2FAttachment%2FImages%2F44733%2FAtelier+en+classe.doc"; |
| 60 | + String expResult = "\"http://dsr-preprod-3/silverpeas/repository/jackrabbit/attachments/kmelia34/Attachment/Images/44733/Atelier en classe.doc\""; |
| 61 | + String result = UrlExtractor.extractUrl(encodedUrl); |
| 62 | + assertEquals(expResult, result); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Test of decodePath method, of class UrlExtractor. |
| 67 | + */ |
| 68 | + public void testDecodePath() { |
| 69 | + String encodedPath = "C%3A%5C%5CProgram+Files%5C%5CMicrosoft+Office%5C%5COFFICE10"; |
| 70 | + String expResult = "C:\\\\Program Files\\\\Microsoft Office\\\\OFFICE10"; |
| 71 | + String result = UrlExtractor.decodePath(encodedPath); |
| 72 | + assertEquals(expResult, result); |
| 73 | + } |
| 74 | +} |
0 commit comments