Package org.apache.jetspeed.deployment.impl

Examples of org.apache.jetspeed.deployment.impl.StandardDeploymentManager


                webAppsDir, portletRegistry, entityAccess, windowAccess, portletCache, manager), portletRegistry, portletFactory );
        ArrayList eventListeners = new ArrayList(2);
        eventListeners.add(ddel);
        eventListeners.add(dpal);
        // Use a -1 delay to disable auto scan
        StandardDeploymentManager autoDeployment = new StandardDeploymentManager(deploySrc.getAbsolutePath(), -1, eventListeners );
       
        autoDeployment.start();
        autoDeployment.fireDeploymentEvent();

        File decoratorVm = new File(deployRootFile.getAbsolutePath() + File.separator + "generic" + File.separator + "html" + File.separator
                + "portletstd" + File.separator + "decorator.vm");
       
        File demoAppDeployed = new File(webAppsDirFile, TEST_PORTLET_APP_NAME);
        File demoApp = demoAppDeployed;
        File securityApp = new File(webAppsDirFile, "TestSecurityRoles");

        assertTrue(decoratorVm.getCanonicalPath() + " was not created!", decoratorVm.exists());

        verifyDemoAppCreated(TEST_PORTLET_APP_NAME, demoApp);
        verifyDemoAppCreated("TestSecurityRoles", securityApp);
      
        MutablePortletApplication jetspeedApp = portletRegistry.getPortletApplicationByIdentifier("jetspeed");
        assertNotNull("jetspeed was not registered into the portlet registery.", jetspeedApp);
        assertFalse("local app, jetspeed, got deployed when it should have only been registered.", new File(webAppsDir
                + "/jetspeed").exists());

        //make sure we can load registered app's classes
        Iterator portletDefItr = jetspeedApp.getPortletDefinitions().iterator();
        while (portletDefItr.hasNext())
        {
            PortletDefinition def = (PortletDefinition) portletDefItr.next();
            try
            {
                Portlet portlet = JetspeedPortletFactoryProxy.loadPortletClass(def.getClassName());
                assertNotNull("Could not load portlet class: "+def.getClassName(), portlet);
            }
            catch (Exception e)
            {
                assertNull("Unable to load registered portlet class, " + def.getClassName(), e);
            }

        }
       
        // test undeploy
        File demoWar = new File(deploySrc, "demo.war");
        demoWar.delete();
        autoDeployment.fireUndeploymentEvent();       
        verifyDemoAppDeleted(TEST_PORTLET_APP_NAME, demoApp);   
       
        // test deploy again       
        copyDeployables();
        autoDeployment.fireDeploymentEvent();
        verifyDemoAppCreated(TEST_PORTLET_APP_NAME, demoApp);
        demoWar.delete();
        autoDeployment.fireUndeploymentEvent();
        verifyDemoAppDeleted(TEST_PORTLET_APP_NAME, demoApp);
       
        // test redeploy
       
        // So, first deploy the typical demo.war we have been using before.
        copyDeployables();
        autoDeployment.fireDeploymentEvent();
        verifyDemoAppCreated(TEST_PORTLET_APP_NAME, demoApp);
        DirectoryHelper demoAppDeployedDir = new DirectoryHelper(demoAppDeployed);
        long beforeSize = new File(demoAppDeployedDir.getRootDirectory(), "WEB-INF/portlet.xml").length();
       
        // Trigger re-deployment using a demo.war that has a slightly larger portlet.xml
        // then the one we just deployed.  We will use size comparisons as or litmus test.
        File redeployDemoWar = new File("./test/deployment/redeploy/demo.war");
        FileChannel srcDemoWarChannel = new FileInputStream(redeployDemoWar).getChannel();
        FileChannel dstDemoWarChannel = new FileOutputStream(demoWar).getChannel();
        dstDemoWarChannel.transferFrom(srcDemoWarChannel, 0, srcDemoWarChannel.size());
        srcDemoWarChannel.close();
        dstDemoWarChannel.close();
       
        // Make sure the demo.war that will trigger redeploy has a larger portlet.xml then the current one
        JarHelper rdDemoWar = new JarHelper(demoWar, true);
        assertTrue(new File(rdDemoWar.getRootDirectory(), "WEB-INF/portlet.xml").length() > beforeSize);
       
        // Need to slow it down so the timestamp check works
        Thread.sleep(500);
        demoWar.setLastModified(System.currentTimeMillis());
        autoDeployment.fireRedeploymentEvent();
     
        long afterSize = new File(demoAppDeployedDir.getRootDirectory(), "WEB-INF/portlet.xml").length();
        // The portlet.xml in re-deploy has an additional portlet entry in portlet.xml, so it should be bigger
        assertTrue(afterSize > beforeSize);
        autoDeployment.stop();
       
    }
View Full Code Here


        ArrayList eventListeners = new ArrayList(1);
       
        eventListeners.add(dpal);
       
        // Use a -1 delay to disable auto scan
        StandardDeploymentManager autoDeployment = new StandardDeploymentManager(deploySrc.getAbsolutePath(), -1, eventListeners );       
        autoDeployment.start();

        buildEntityTestData(autoDeployment);      
       
       
        MutablePortletEntity entity = entityAccess.getPortletEntity("testEnity");
       
        PreferenceSetCtrl prefs = (PreferenceSetCtrl) entity.getPreferenceSet();
        List values = new ArrayList(1);
        values.add("some value");
        prefs.add("pref1", values);
       
        entity.store();
       
        assertNotNull(entity);
       
        Preference pref = entity.getPreferenceSet().get("pref1");
       
        assertNotNull(pref);
       
        //test entity removal via undeploy
        File demoWar = new File(deploySrc, "demo.war");
        demoWar.delete();
       
        autoDeployment.fireUndeploymentEvent();
       
               
        entity = entityAccess.getPortletEntity("testEnity");
       
        assertNull(entity);
       
        // Now test that redploy DOES NOT kill the entity
        buildEntityTestData(autoDeployment);
       
        entity = entityAccess.getPortletEntity("testEnity");
       
        assertNotNull(entity);
       
        pref = entity.getPreferenceSet().get("pref1");
       
        assertNull("Preference was not deleted with last undeploy",pref);
       
        demoWar.setLastModified(System.currentTimeMillis());
       
        autoDeployment.fireRedeploymentEvent();       
       
        entity = entityAccess.getPortletEntity("testEnity");
       
        assertNotNull(entity);
       
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.deployment.impl.StandardDeploymentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.