Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Added blank unit test for register portlet
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jun 21, 2013
1 parent 35ee48d commit 21c7e6c
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public void execute(ServletContext context, PortalContainer portalContainer) {

// Init portal container
RootContainer root = RootContainer.getInstance();
root.addInitTask(filterConfig.getServletContext(), task);
root.registerPortalContainer(filterConfig.getServletContext());
ServletContext context = filterConfig.getServletContext();
root.addInitTask(context, task);
root.registerPortalContainer(context);

//
PortalContainer container = this.container.get();
Expand Down
42 changes: 41 additions & 1 deletion portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<name>GateIn Portal Module</name>

<properties>
<juzu.version>0.7.0-beta11</juzu.version>
<juzu.version>0.7.0-beta12</juzu.version>
</properties>

<modules>
Expand All @@ -42,4 +42,44 @@
<module>web</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-core</artifactId>
<version>${juzu.version}</version>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-plugins-portlet</artifactId>
<version>${juzu.version}</version>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian</artifactId>
<version>${juzu.version}</version>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian-tomcat7</artifactId>
<version>${juzu.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
<version>2.0.0-alpha-4</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>
22 changes: 22 additions & 0 deletions portal/ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@
<scope>provided</scope>
</dependency>

<!-- -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian-tomcat7</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2012 eXo Platform SAS.
*
* 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.gatein.portal.ui.register;

import java.io.File;
import java.net.URL;

import juzu.arquillian.Helper;
import org.gatein.portal.common.kernel.KernelLifeCycle;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor;
import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import static org.junit.Assert.*;

/**
* @author Julien Viet
*/
@RunWith(Arquillian.class)
public class RegisterTestCase {

@Deployment
public static WebArchive getDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "portal.war");
Helper.createBasePortletDeployment(war, "guice", Controller.class);
PortletDescriptor descriptor = Descriptors.
create(PortletDescriptor.class).
createPortlet().
portletName("RegisterPortlet").
portletClass(RegisterPortlet.class.getName()).
up();
war.addAsWebInfResource(new StringAsset(descriptor.exportAsString()), "portlet.xml");
Node node = war.get("WEB-INF/web.xml");
WebAppDescriptor webApp = Descriptors.importAs(WebAppDescriptor.class).fromStream(node.getAsset().openStream());
webApp.displayName("portal").createFilter().filterName("KernelLifeCycle").filterClass(KernelLifeCycle.class.getName()).up().
createFilterMapping().filterName("KernelLifeCycle").servletName("EmbedServlet").up();
war.delete(node.getPath());
war.setWebXML(new StringAsset(webApp.exportAsString()));
return war;
}

@Drone
WebDriver driver;

@Test
@RunAsClient
public void testFoo(@ArquillianResource URL deploymentURL) throws Exception {
URL url = deploymentURL.toURI().resolve("./embed/RegisterPortlet").toURL();
driver.get(url.toString());

// Really dumb test for now
WebElement register = driver.findElement(By.cssSelector("div.register-unit"));
assertNotNull(register);
}
}
8 changes: 0 additions & 8 deletions portal/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-core</artifactId>
<version>${juzu.version}</version>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-plugins-portlet</artifactId>
<version>${juzu.version}</version>
</dependency>

<!-- -->
Expand Down Expand Up @@ -183,19 +181,16 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian</artifactId>
<version>0.6.0-beta8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-bom-arquillian-tomcat7</artifactId>
<version>0.6.0-beta8</version>
<scope>test</scope>
</dependency>

Expand All @@ -209,19 +204,16 @@
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
<version>2.0.0-alpha-4</version>
<scope>test</scope>
</dependency>

Expand Down

0 comments on commit 21c7e6c

Please sign in to comment.