[gatein-commits] gatein SVN: r961 - in portal/trunk/component/test: core/src/main/java/org/exoplatform/component/test and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Dec 7 07:11:51 EST 2009


Author: julien_viet
Date: 2009-12-07 07:11:50 -0500 (Mon, 07 Dec 2009)
New Revision: 961

Added:
   portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/
   portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java
   portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/CustomService.java
   portal/trunk/component/test/core/src/test/resources/conf/
   portal/trunk/component/test/core/src/test/resources/conf/test-configuration.xml
   portal/trunk/component/test/jcr/src/test/
   portal/trunk/component/test/jcr/src/test/java/
   portal/trunk/component/test/jcr/src/test/java/org/
   portal/trunk/component/test/jcr/src/test/java/org/exoplatform/
   portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/
   portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/
   portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/jcr/
   portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/jcr/BootstrapTestCase.java
   portal/trunk/component/test/jcr/src/test/resources/
Modified:
   portal/trunk/component/test/core/pom.xml
   portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/GateInTestClassLoader.java
   portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml
   portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml
Log:
- unit test the component test to validate they work
- added logging


Modified: portal/trunk/component/test/core/pom.xml
===================================================================
--- portal/trunk/component/test/core/pom.xml	2009-12-07 10:49:28 UTC (rev 960)
+++ portal/trunk/component/test/core/pom.xml	2009-12-07 12:11:50 UTC (rev 961)
@@ -33,6 +33,12 @@
   <dependencies>
 
     <dependency>
+      <groupId>org.gatein.common</groupId>
+      <artifactId>common-logging</artifactId>
+      <version>${org.gatein.common.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
@@ -46,10 +52,34 @@
 
     <dependency>
       <groupId>org.exoplatform.kernel</groupId>
+      <artifactId>exo.kernel.component.common</artifactId>
+      <version>${org.exoplatform.kernel.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.exoplatform.kernel</groupId>
       <artifactId>exo.kernel.container</artifactId>
       <version>${org.exoplatform.kernel.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.5.6</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <version>1.2.2</version>
+      <exclusions>
+        <exclusion>
+          <groupId>xerces</groupId>
+          <artifactId>xercesImpl</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
   </dependencies>
 
   <build>

Modified: portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/GateInTestClassLoader.java
===================================================================
--- portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/GateInTestClassLoader.java	2009-12-07 10:49:28 UTC (rev 960)
+++ portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/GateInTestClassLoader.java	2009-12-07 12:11:50 UTC (rev 961)
@@ -18,9 +18,10 @@
  */
 package org.exoplatform.component.test;
 
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
 import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -50,6 +51,9 @@
    /** . */
    private final Set<String> portalConfigPaths;
 
+   /** . */
+   private Logger log = LoggerFactory.getLogger(AbstractGateInTest.class);
+
    public GateInTestClassLoader(ClassLoader parent, Set<String> rootConfigPaths, Set<String> portalConfigPaths)
    {
       super(parent);
@@ -62,14 +66,15 @@
    @Override
    public Enumeration<URL> getResources(String name) throws IOException
    {
-      System.out.println("name = " + name);
       if ("conf/configuration.xml".equals(name))
       {
-         return getURLs(rootConfigPaths);
+         log.info("About to load root configuration");
+         return getResourceURLs(rootConfigPaths);
       }
       else if ("conf/portal/configuration.xml".equals(name))
       {
-         return getURLs(portalConfigPaths);
+         log.info("About to load portal configuration");
+         return getResourceURLs(portalConfigPaths);
       }
       else if ("conf/portal/test-configuration.xml".equals(name))
       {
@@ -81,12 +86,14 @@
       }
    }
 
-   private Enumeration<URL> getURLs(Set<String> paths) throws IOException
+   private Enumeration<URL> getResourceURLs(Set<String> paths) throws IOException
    {
       ArrayList<URL> urls = new ArrayList<URL>();
       for (String path : paths)
       {
-         urls.addAll(Collections.list(super.getResources(path)));
+         ArrayList<URL> resourceURLs = Collections.list(super.getResources(path));
+         log.info("Want to load for resource named " + path + " the urls " + resourceURLs);
+         urls.addAll(resourceURLs);
       }
       return Collections.enumeration(urls);
    }

Modified: portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml
===================================================================
--- portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml	2009-12-07 10:49:28 UTC (rev 960)
+++ portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml	2009-12-07 12:11:50 UTC (rev 961)
@@ -24,4 +24,46 @@
   xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
   xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
+  <component>
+    <key>org.exoplatform.services.naming.InitialContextInitializer</key>
+    <type>org.exoplatform.services.naming.InitialContextInitializer</type>
+    <init-params>
+      <properties-param>
+        <name>default-properties</name>
+        <description>Default initial context properties</description>
+      </properties-param>
+    </init-params>
+  </component>
+
+  <external-component-plugins>
+    <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+    <component-plugin>
+      <name>bind.datasource</name>
+      <set-method>addPlugin</set-method>
+      <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+      <init-params>
+        <value-param>
+          <name>bind-name</name>
+          <value>jdbcexo</value>
+        </value-param>
+        <value-param>
+          <name>class-name</name>
+          <value>javax.sql.DataSource</value>
+        </value-param>
+        <value-param>
+          <name>factory</name>
+          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+        </value-param>
+        <properties-param>
+          <name>ref-addresses</name>
+          <description>ref-addresses</description>
+          <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+          <property name="url" value="jdbc:hsqldb:file:../temp/data/exodb"/>
+          <property name="username" value="sa"/>
+          <property name="password" value=""/>
+        </properties-param>
+      </init-params>
+    </component-plugin>
+  </external-component-plugins>
+
 </configuration>

Modified: portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml
===================================================================
--- portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml	2009-12-07 10:49:28 UTC (rev 960)
+++ portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml	2009-12-07 12:11:50 UTC (rev 961)
@@ -28,46 +28,4 @@
     <type>org.exoplatform.container.definition.PortalContainerConfig</type>
   </component>
 
-  <component>
-    <key>org.exoplatform.services.naming.InitialContextInitializer</key>
-    <type>org.exoplatform.services.naming.InitialContextInitializer</type>
-    <init-params>
-      <properties-param>
-        <name>default-properties</name>
-        <description>Default initial context properties</description>
-      </properties-param>
-    </init-params>
-  </component>
-
-  <external-component-plugins>
-    <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
-    <component-plugin>
-      <name>bind.datasource</name>
-      <set-method>addPlugin</set-method>
-      <type>org.exoplatform.services.naming.BindReferencePlugin</type>
-      <init-params>
-        <value-param>
-          <name>bind-name</name>
-          <value>jdbcexo</value>
-        </value-param>
-        <value-param>
-          <name>class-name</name>
-          <value>javax.sql.DataSource</value>
-        </value-param>
-        <value-param>
-          <name>factory</name>
-          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
-        </value-param>
-        <properties-param>
-          <name>ref-addresses</name>
-          <description>ref-addresses</description>
-          <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
-          <property name="url" value="jdbc:hsqldb:file:../temp/data/exodb"/>
-          <property name="username" value="sa"/>
-          <property name="password" value=""/>
-        </properties-param>
-      </init-params>
-    </component-plugin>
-  </external-component-plugins>
-
 </configuration>

Added: portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java
===================================================================
--- portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java	                        (rev 0)
+++ portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java	2009-12-07 12:11:50 UTC (rev 961)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 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.exoplatform.component.test;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.naming.InitialContextInitializer;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at ConfiguredBy({
+   @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/jcr/jcr-configuration.xml"),
+   @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/test-configuration.xml")
+})
+public class BootstrapTestCase extends AbstractGateInTest
+{
+
+   public void testBoot()
+   {
+      PortalContainer container = PortalContainer.getInstance();
+      CustomService testService = (CustomService)container.getComponentInstanceOfType(CustomService.class);
+      assertNotNull(testService);
+   }
+
+   public void testDataSource() throws Exception
+   {
+      PortalContainer container = PortalContainer.getInstance();
+      container.getComponentInstanceOfType(InitialContextInitializer.class);
+      DataSource ds = (DataSource)new InitialContext().lookup("jdbcexo");
+      assertNotNull(ds);
+   }
+}

Added: portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/CustomService.java
===================================================================
--- portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/CustomService.java	                        (rev 0)
+++ portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/CustomService.java	2009-12-07 12:11:50 UTC (rev 961)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2009 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.exoplatform.component.test;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class CustomService
+{
+}

Added: portal/trunk/component/test/core/src/test/resources/conf/test-configuration.xml
===================================================================
--- portal/trunk/component/test/core/src/test/resources/conf/test-configuration.xml	                        (rev 0)
+++ portal/trunk/component/test/core/src/test/resources/conf/test-configuration.xml	2009-12-07 12:11:50 UTC (rev 961)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Copyright (C) 2009 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.
+  -->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+  xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+  <component>
+    <type>org.exoplatform.component.test.CustomService</type>
+  </component>
+
+</configuration>

Added: portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/jcr/BootstrapTestCase.java
===================================================================
--- portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/jcr/BootstrapTestCase.java	                        (rev 0)
+++ portal/trunk/component/test/jcr/src/test/java/org/exoplatform/component/test/jcr/BootstrapTestCase.java	2009-12-07 12:11:50 UTC (rev 961)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 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.exoplatform.component.test.jcr;
+
+import org.exoplatform.component.test.AbstractGateInTest;
+import org.exoplatform.component.test.ConfigurationUnit;
+import org.exoplatform.component.test.ConfiguredBy;
+import org.exoplatform.component.test.ContainerScope;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+
+import javax.jcr.Session;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at ConfiguredBy({@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/jcr/jcr-configuration.xml")})
+public class BootstrapTestCase extends AbstractGateInTest
+{
+
+   public void testWorkspace() throws Exception
+   {
+      PortalContainer container = PortalContainer.getInstance();
+      RepositoryService repos = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+      assertNotNull(repos);
+      ManageableRepository repo = repos.getDefaultRepository();
+      assertNotNull(repo);
+      Session session = repo.getSystemSession("portal-test");
+      assertNotNull(session);
+      session.logout();
+   }
+}



More information about the gatein-commits mailing list