Author: mickw
Date: 2006-05-05 08:53:28 +0200 (Fri, 05 May 2006)
New Revision: 2858

Modified:
   
trunk/src/test/java/no/schibstedsok/front/searchportal/configuration/SearchModeFactoryTest.java
   
trunk/src/test/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactoryTest.java
Log:
testing against all available locales


Modified: 
trunk/src/test/java/no/schibstedsok/front/searchportal/configuration/SearchModeFactoryTest.java
===================================================================
--- 
trunk/src/test/java/no/schibstedsok/front/searchportal/configuration/SearchModeFactoryTest.java
     2006-05-04 14:28:51 UTC (rev 2857)
+++ 
trunk/src/test/java/no/schibstedsok/front/searchportal/configuration/SearchModeFactoryTest.java
     2006-05-05 06:53:28 UTC (rev 2858)
@@ -8,6 +8,7 @@
 
 package no.schibstedsok.front.searchportal.configuration;
 
+import java.util.Locale;
 import javax.xml.parsers.DocumentBuilder;
 import junit.framework.TestCase;
 import no.schibstedsok.front.searchportal.configuration.loader.DocumentLoader;
@@ -38,10 +39,10 @@
      */
     public void testGetModeFactory(){
 
-        assertNotNull(getModeFactory());
+        assertNotNull(getModeFactory(null));
     }
 
-    private SearchModeFactory getModeFactory() {
+    private SearchModeFactory getModeFactory(final Locale locale) {
         LOG.trace("getModeFactory");
 
         final SearchModeFactory.Context cxt = new SearchModeFactory.Context(){
@@ -49,16 +50,13 @@
                 return FileResourceLoader.newDocumentLoader(this, resource, 
builder);
             }
             public Site getSite()  {
-                return Site.DEFAULT;
+                return locale == null ? Site.DEFAULT : 
Site.valueOf(Site.DEFAULT.getName(), locale);
             }
         };
 
         final SearchModeFactory result = SearchModeFactory.getModeFactory(cxt);
         assertNotNull(result);
 
-        // TODO review the generated test code and remove the default call to 
fail.
-        //fail("The test case is a prototype.");
-
         return result;
     }
 
@@ -69,10 +67,33 @@
         LOG.trace("testGetMode");
 
         final String id = "norsk-magic";
-        final SearchModeFactory instance = getModeFactory();
+        final SearchModeFactory instance = getModeFactory(null);
 
         final SearchMode result = instance.getMode(id);
         assertNotNull(result);
     }
+    
+    /**
+     * Test of memory against getMode method, 
+     * of class 
no.schibstedsok.front.searchportal.configuration.SearchModeFactory.
+     */
+    public void testGetModeOnAllAvailableLocales() {
+        LOG.trace("testGetModeOnAllAvailableLocales");
 
+        final String id = "norsk-magic";
+        System.gc();
+        final long initialTotal = Runtime.getRuntime().totalMemory();
+        final long initialFree = Runtime.getRuntime().freeMemory();
+        LOG.info("Number of Available locales " + 
Locale.getAvailableLocales().length);
+        for( Locale l : Locale.getAvailableLocales() ){
+            final SearchModeFactory instance = getModeFactory(l);
+
+            final SearchMode result = instance.getMode(id);
+            assertNotNull(result);
+        }
+        LOG.info("Total memory increased 
"+(Runtime.getRuntime().totalMemory()-initialTotal) + " bytes");
+        LOG.info("Free memory decreased 
"+(initialFree-Runtime.getRuntime().freeMemory()) + " bytes");
+        System.gc();
+    }
+
 }
\ No newline at end of file

Modified: 
trunk/src/test/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactoryTest.java
===================================================================
--- 
trunk/src/test/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactoryTest.java
        2006-05-04 14:28:51 UTC (rev 2857)
+++ 
trunk/src/test/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactoryTest.java
        2006-05-05 06:53:28 UTC (rev 2858)
@@ -8,6 +8,7 @@
 
 package no.schibstedsok.front.searchportal.view.config;
 
+import java.util.Locale;
 import javax.xml.parsers.DocumentBuilder;
 import junit.framework.TestCase;
 import no.schibstedsok.front.searchportal.configuration.loader.DocumentLoader;
@@ -39,7 +40,7 @@
      */
     public void testGetViewFactory() {
 
-        assertNotNull(getViewFactory());
+        assertNotNull(getViewFactory(null));
     }
 
     /**
@@ -50,7 +51,7 @@
         LOG.trace("testGetTab");
 
         final String id = "norwegian-internet";
-        final SearchTabFactory instance = getViewFactory();
+        final SearchTabFactory instance = getViewFactory(null);
 
         final SearchTab result = instance.getTabByName(id);
         assertNotNull(result);
@@ -64,15 +65,38 @@
         LOG.trace("testGetTab");
 
         final String key = "d";
-        final SearchTabFactory instance = getViewFactory();
+        final SearchTabFactory instance = getViewFactory(null);
 
         final SearchTab result = instance.getTabByKey(key);
         assertNotNull(result);
     }
 
+    /**
+     * Test of memory against getTabByKey method, 
+     * of class 
no.schibstedsok.front.searchportal.configuration.SearchModeFactory.
+     */
+    public void testGetTabByKeyModeOnAllAvailableLocales() {
+        LOG.trace("testGetModeOnAllAvailableLocales");
 
-    private SearchTabFactory getViewFactory() {
+        final String key = "d";
+        System.gc();
+        final long initialTotal = Runtime.getRuntime().totalMemory();
+        final long initialFree = Runtime.getRuntime().freeMemory();
+        LOG.info("Number of Available locales " + 
Locale.getAvailableLocales().length);
+        for( Locale l : Locale.getAvailableLocales() ){
+            final SearchTabFactory instance = getViewFactory(l);
 
+            final SearchTab result = instance.getTabByKey(key);
+            assertNotNull(result);
+        }
+        LOG.info("Total memory increased 
"+(Runtime.getRuntime().totalMemory()-initialTotal) + " bytes");
+        LOG.info("Free memory decreased 
"+(initialFree-Runtime.getRuntime().freeMemory()) + " bytes");
+        System.gc();
+    }
+    
+
+    private SearchTabFactory getViewFactory(final Locale locale) {
+
         LOG.trace("getModeFactory");
 
         final SearchTabFactory.Context cxt = new SearchTabFactory.Context(){
@@ -80,7 +104,7 @@
                 return FileResourceLoader.newDocumentLoader(this, resource, 
builder);
             }
             public Site getSite()  {
-                return Site.DEFAULT;
+                return locale == null ? Site.DEFAULT 
:Site.valueOf(Site.DEFAULT.getName(), locale);
             }
         };
 

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to