1 package org.exoplatform.container.test; 2 3 import java.util.List ; 4 import org.exoplatform.container.PortalContainer; 5 import org.exoplatform.container.RootContainer; 6 import org.exoplatform.test.BasicTestCase; 7 12 public class TestContainer extends BasicTestCase { 13 14 public void testPortalContainer() throws Exception { 15 RootContainer rootContainer = RootContainer.getInstance() ; 16 PortalContainer pcontainer = rootContainer.getPortalContainer("portal") ; 17 Object parent = pcontainer.getParent() ; 18 assertTrue("Root container should not be null", parent != null) ; 19 pcontainer.createSessionContainer("sessioncontainer1", "anon") ; 20 pcontainer.createSessionContainer("sessioncontainer2", "anon") ; 21 List sessions = pcontainer.getLiveSessions() ; 22 assertEquals("expect 2 session container", 2 , sessions.size()) ; 23 25 int INSERTLOOP = 0 ; 26 long start = System.currentTimeMillis() ; 27 for(int i = 0 ; i < INSERTLOOP; i++) { 28 rootContainer.getPortalContainer("name-" + Integer.toString(i)) ; 29 } 30 System.out.println("Insert 1000 components " + (System.currentTimeMillis() - start ) +"ms") ; 31 32 int LOOP = 10000000 ; 33 start = System.currentTimeMillis() ; 34 for(int i = 0 ; i < LOOP; i++) { 35 pcontainer = (PortalContainer)rootContainer.getComponentInstance("portal") ; 36 assertTrue("not null", pcontainer != null) ; 37 } 38 System.out.println("Retrieve compoponent 10M times " + (System.currentTimeMillis() - start ) +"ms") ; 39 System.out.println("AVG = " + (System.currentTimeMillis() - start )/LOOP +"ms") ; 40 System.out.println("-------------------------------------------------------------------------") ; 41 Object oo = pcontainer.getComponentInstance("org/exoplatform/container/groovy/test/TestGroovyObject.groovy") ; 42 System.out.println("++++++++" +oo) ; 43 pcontainer.getGroovyManager().reloadGroovyObjects() ; 44 pcontainer.getComponentInstance("org/exoplatform/container/groovy/test/TestGroovyObject.groovy") ; 45 } 46 } | Popular Tags |