[jboss-cvs] jboss-portal/core/src/main/org/jboss/portal/test/core/deployment ...

Chris Laprun chris.laprun at jboss.com
Thu Aug 17 01:56:48 EDT 2006


  User: claprun 
  Date: 06/08/17 01:56:48

  Added:       core/src/main/org/jboss/portal/test/core/deployment 
                        JBossApplicationMetaDataFactoryTestCase.java
  Log:
  - Added JBossApplicationMetaDataFactoryTestCase.
  - Minor code improvements.
  - Fixed build files.
  
  Revision  Changes    Path
  1.1      date: 2006/08/17 05:56:48;  author: claprun;  state: Exp;jboss-portal/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
  
  Index: JBossApplicationMetaDataFactoryTestCase.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  
  package org.jboss.portal.test.core.deployment;
  
  import junit.framework.TestCase;
  import org.jboss.portal.common.util.URLTools;
  import org.jboss.portal.core.deployment.JBossApplicationMetaDataFactory;
  import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
  import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
  import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
  import org.jboss.xb.binding.Unmarshaller;
  import org.jboss.xb.binding.UnmarshallerFactory;
  
  import java.net.URL;
  import java.util.List;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  public class JBossApplicationMetaDataFactoryTestCase extends TestCase
  {
     public void testHeaderContentMetaData() throws Exception
     {
        URL jbossPortletXML = Thread.currentThread().getContextClassLoader().getResource("test/deployment/jboss-portlet.xml");
        assertTrue(URLTools.exists(jbossPortletXML));
  
        //
        JBossApplicationMetaDataFactory factory = new JBossApplicationMetaDataFactory();
  
        //
        Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
  
        //
        Object o = unmarshaller.unmarshal(jbossPortletXML.openStream(), factory, null);
        assertNotNull(o);
        assertTrue(o instanceof JBossApplicationMetaData);
        JBossApplicationMetaData app = (JBossApplicationMetaData)o;
  
        //
        assertNotNull(app.getPortlets());
        assertEquals(1, app.getPortlets().size());
  
        //
        JBossPortletMetaData portlet1 = (JBossPortletMetaData)app.getPortlets().get("Portlet1");
        assertNotNull(portlet1);
        assertEquals("Portlet1", portlet1.getName());
        HeaderContentMetaData headerContent = portlet1.getHeaderContent();
        assertNotNull(headerContent);
  
        List elements = headerContent.getElements();
        assertEquals(3, elements.size());
  
        HeaderContentMetaData.LinkElement link = (HeaderContentMetaData.LinkElement)elements.get(0);
        assertEquals(HeaderContentMetaData.Element.LINK, link.getElementType());
        assertEquals("text/css", link.getType());
        assertEquals("stylesheet", link.getRel());
        assertEquals("stylesheet title", link.getTitle());
        assertEquals("screen", link.getMedia());
        assertEquals("test.css", link.getHref());
  
        HeaderContentMetaData.ScriptElement script = (HeaderContentMetaData.ScriptElement)elements.get(1);
        assertEquals(HeaderContentMetaData.Element.SCRIPT, script.getElementType());
        assertEquals("text/javascript", script.getType());
        assertEquals("test.js", script.getSrc());
  
        HeaderContentMetaData.NamedMetaElement meta = (HeaderContentMetaData.NamedMetaElement)elements.get(2);
        assertEquals(HeaderContentMetaData.Element.META, meta.getElementType());
        assertNull(meta.getType());
        assertEquals("description", meta.getName());
        assertEquals("test content", meta.getContent());
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list