1 4 package com.openedit.modules.translations; 5 6 import java.util.Date ; 7 import java.util.HashMap ; 8 import java.util.List ; 9 import java.util.Map ; 10 11 import org.openedit.repository.filesystem.StringItem; 12 13 import com.openedit.BaseTestCase; 14 import com.openedit.WebPageRequest; 15 import com.openedit.page.Page; 16 import com.openedit.page.PageProperty; 17 18 public class TranslationModuleTest extends BaseTestCase 19 { 20 21 public TranslationModuleTest(String inName) 22 { 23 super( inName); 24 } 25 26 public void testListing() throws Exception 27 { 28 TranslationModule trm = (TranslationModule)getModule("TranslationModule"); 29 30 WebPageRequest req = getFixture().createPageRequest(); 31 Translation trans = trm.getTranslations(req); 32 33 assertNotNull(trans); 34 35 List languages = trans.getLanguages(); 36 assertEquals( 5,languages.size() ); 37 38 Language spanish = (Language)languages.get(3); 39 40 Page root = getFixture().getPageManager().getPage("/index.html"); 42 root.setContentItem(new StringItem("/index.html","Some text " + new Date (), null)); 43 getFixture().getPageManager().putPage(root); 44 assertFalse( spanish.isCurrent("/index.html") ); 45 46 Page sroot = getFixture().getPageManager().getPage("/translations/es/index.html"); 49 sroot.setContentItem(new StringItem("/translations/es/index.html","Some text " + new Date (), null)); 50 getFixture().getPageManager().putPage(sroot); 51 assertTrue( spanish.isCurrent("/index.html") ); 52 53 } 54 55 public void testxconf() 56 { 57 Translation trans = new Translation(); 58 59 Map props = new HashMap (); 60 61 PageProperty prop = new PageProperty("title"); 62 prop.setValue("Hello"); 63 props.put("title", prop); 64 65 PageProperty prop2 = new PageProperty("text.1"); 66 prop2.setValue("Accounts"); 67 props.put("text.1", prop2); 68 69 PageProperty prop3 = new PageProperty("text.2"); 70 prop3.setValue("Fish"); 71 props.put("text.2", prop3); 72 73 PageProperty prop4 = new PageProperty("text.3"); 74 prop4.setValue("Dog"); 75 props.put("text.3", prop4); 76 77 trans.webTranslateProperties(props, "es"); 78 79 assertEquals("Hello", prop.getValue() ); 80 assertEquals("Hola", prop.getValue("es")); 81 assertEquals("Cuentas", prop2.getValue("es")); 82 assertEquals("Pescados", prop3.getValue("es")); 83 assertEquals("Perro", prop4.getValue("es")); 84 85 } 86 118 public void testPageTrans() throws Exception 119 { 120 TranslationModule mod = (TranslationModule)getModule("TranslationModule"); 121 122 WebPageRequest req = getFixture().createPageRequest(); 123 req.setRequestParameter("targetpage", "/normal.html"); 124 req.setRequestParameter("targetlanguage", "es"); 125 req.setRequestParameter("pagetype", "content"); 126 127 mod.getTranslations(req); 128 mod.autoTranslate(req); 129 Page transPage = getPage("/translations/es/normal.draft.html"); 130 assertTrue(transPage.exists()); 131 String content = transPage.getContent(); 132 assertEquals("<p> Probar la materia </p>", content); 133 134 } 135 } 136 | Popular Tags |