portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r1678357 - in /portals/jetspeed-2/portal/trunk: ./ components/jetspeed-cm/ components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/ components/jetspeed-page-manager/ components/jetspeed-portal/ components/jetspeed-security/...
Date Fri, 08 May 2015 14:15:24 GMT
Author: rwatler
Date: Fri May  8 14:15:23 2015
New Revision: 1678357

URL: http://svn.apache.org/r1678357
Log:
JS2-1324: Implement distributed JetspeedSecurityPersistenceManager, (JSPM), cache tests; upgrade
Jexl to 2.1.1.

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/DistributedJSPMCacheServer.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestDistributedJSPMCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestJSPMCache.java
      - copied, changed from r1678139, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestJSPMCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/resources/log4j-stdout.properties
Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestJSPMCache.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestCase.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestServer.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCacheImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMQueryEhCacheImpl.java
    portals/jetspeed-2/portal/trunk/pom.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml Fri May  8 14:15:23 2015
@@ -138,7 +138,7 @@
             junit dependency above.
         -->
         <dependency>
-            <groupId>commons-jexl</groupId>
+            <groupId>org.apache.commons</groupId>
             <artifactId>commons-jexl</artifactId>
             <scope>provided</scope>
         </dependency>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestCase.java?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestCase.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestCase.java
Fri May  8 14:15:23 2015
@@ -202,6 +202,23 @@ public abstract class AbstractJexlSpring
     }
 
     /**
+     * Parse result for result value after separator.
+     *
+     * @param result result string
+     * @return result value string or null
+     */
+    protected String getResultValue(String result) {
+        if (result == null) {
+            return null;
+        }
+        int resultValueIndex = result.indexOf(SCRIPT_RESULT_RETURN_VALUE_SEPARATOR);
+        if (resultValueIndex < 0) {
+            return null;
+        }
+        return result.substring(resultValueIndex+SCRIPT_RESULT_RETURN_VALUE_SEPARATOR.length());
+    }
+
+    /**
      * Test program process implementation.
      */
     protected class TestProgram {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestServer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestServer.java?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestServer.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/test/AbstractJexlSpringTestServer.java
Fri May  8 14:15:23 2015
@@ -17,10 +17,11 @@
 
 package org.apache.jetspeed.components.test;
 
-import org.apache.commons.jexl.JexlContext;
-import org.apache.commons.jexl.JexlHelper;
-import org.apache.commons.jexl.Script;
-import org.apache.commons.jexl.ScriptFactory;
+import org.apache.commons.jexl2.JexlContext;
+import org.apache.commons.jexl2.JexlEngine;
+import org.apache.commons.jexl2.JexlException;
+import org.apache.commons.jexl2.MapContext;
+import org.apache.commons.jexl2.Script;
 import org.apache.jetspeed.components.JetspeedBeanDefinitionFilter;
 import org.apache.jetspeed.components.SpringComponentManager;
 import org.apache.jetspeed.security.JSSubject;
@@ -67,8 +68,7 @@ public abstract class AbstractJexlSpring
         scm.start();
 
         // create jexl context
-        jexlContext = JexlHelper.createContext();
-        jexlContext.getVars().putAll(getContextVars());
+        jexlContext = new MapContext(getContextVars());
     }
 
     /**
@@ -121,11 +121,20 @@ public abstract class AbstractJexlSpring
         // execute script line and return result line
         String resultLine = scriptLine;
         try {
-            Script jexlScript = ScriptFactory.createScript(scriptLine);
+            JexlEngine jexl = new JexlEngine();
+            jexl.setSilent(false);
+            jexl.setLenient(false);
+            Script jexlScript = jexl.createScript(scriptLine);
             Object result = jexlScript.execute(jexlContext);
             if (result != null) {
                 resultLine += SCRIPT_RESULT_RETURN_VALUE_SEPARATOR+result;
             }
+        } catch (JexlException je) {
+            if (je.getCause() != null) {
+                resultLine += SCRIPT_RESULT_RETURN_VALUE_SEPARATOR+je.getCause();
+            } else {
+                resultLine += SCRIPT_RESULT_RETURN_VALUE_SEPARATOR+je;
+            }
         } catch (Exception e) {
             resultLine += SCRIPT_RESULT_RETURN_VALUE_SEPARATOR+e;
         }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/pom.xml?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/pom.xml Fri May  8 14:15:23
2015
@@ -128,7 +128,7 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>commons-jexl</groupId>
+      <groupId>org.apache.commons</groupId>
       <artifactId>commons-jexl</artifactId>
       <scope>test</scope>
     </dependency>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml Fri May  8 14:15:23
2015
@@ -290,7 +290,7 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>commons-jexl</groupId>
+      <groupId>org.apache.commons</groupId>
       <artifactId>commons-jexl</artifactId>
       <scope>test</scope>
     </dependency>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml Fri May  8 14:15:23
2015
@@ -98,6 +98,11 @@
       <version>${org.apache.jetspeed.test.jdbc.driver.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-jexl</artifactId>
+      <scope>test</scope>
+    </dependency>
     <!--
       Note: tyrex and junit is normally required only for test, but in this case, abstract
test cases are included in
       the component build... this should probably be fixed... for now, assume that junit
will be provided if these test

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCache.java?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCache.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCache.java
Fri May  8 14:15:23 2015
@@ -242,4 +242,11 @@ public interface JSPMCache {
      * Clear all instance and query caches.
      */
     void clear();
+
+    /**
+     * Return distributed cache configuration.
+     *
+     * @return distributed
+     */
+    boolean isDistributed();
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCacheImpl.java?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCacheImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMCacheImpl.java
Fri May  8 14:15:23 2015
@@ -290,7 +290,7 @@ public class JSPMCacheImpl implements JS
     @Override
     public void putDomainQuery(String key, Long domainId, Object query)
     {
-        permissionQueryCache.put(newJSPMQueryEhCacheElementImpl(key, null, null, null, domainId,
null, query));
+        domainQueryCache.put(newJSPMQueryEhCacheElementImpl(key, null, null, null, domainId,
null, query));
     }
 
     @Override
@@ -323,6 +323,12 @@ public class JSPMCacheImpl implements JS
         domainQueryCache.clear();
     }
 
+    @Override
+    public boolean isDistributed() {
+        // return distributed status for instance caches
+        return (principalCache.isDistributed() && permissionCache.isDistributed()
&& domainCache.isDistributed());
+    }
+
     /**
      * Construct new query cache element with dependent instance
      * cache ids.

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMQueryEhCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMQueryEhCacheImpl.java?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMQueryEhCacheImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/cache/JSPMQueryEhCacheImpl.java
Fri May  8 14:15:23 2015
@@ -72,7 +72,7 @@ public class JSPMQueryEhCacheImpl extend
             return;
         }
         // iterate over cache elements
-        for (Object key : getKeys())
+        for (Object key : ehcache.getKeys())
         {
             JSPMQueryCacheElement element = (JSPMQueryCacheElement)ehcache.get(key);
             if (element != null)
@@ -102,7 +102,7 @@ public class JSPMQueryEhCacheImpl extend
             return;
         }
         // iterate over cache elements
-        for (Object key : getKeys())
+        for (Object key : ehcache.getKeys())
         {
             JSPMQueryCacheElement element = (JSPMQueryCacheElement)ehcache.get(key);
             if (element != null)
@@ -132,7 +132,7 @@ public class JSPMQueryEhCacheImpl extend
             return;
         }
         // iterate over cache elements
-        for (Object key : getKeys())
+        for (Object key : ehcache.getKeys())
         {
             JSPMQueryCacheElement element = (JSPMQueryCacheElement)ehcache.get(key);
             if (element != null)

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/DistributedJSPMCacheServer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/DistributedJSPMCacheServer.java?rev=1678357&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/DistributedJSPMCacheServer.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/DistributedJSPMCacheServer.java
Fri May  8 14:15:23 2015
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.spi.cache;
+
+import org.apache.jetspeed.components.jndi.JetspeedTestJNDIComponent;
+import org.apache.jetspeed.components.test.AbstractJexlSpringTestServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.orm.ojb.PersistenceBrokerTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * DistributedJSPMCacheServer - test JetspeedSecurityPersistenceManager cache
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class DistributedJSPMCacheServer extends AbstractJexlSpringTestServer
+{
+    protected static Logger log = LoggerFactory.getLogger(DistributedJSPMCacheServer.class);
+
+    private JetspeedTestJNDIComponent jndiDS;
+    private PersistenceBrokerTransactionManager txnManager;
+    private TransactionStatus txn;
+
+    @Override
+    public void initialize() throws Exception
+    {
+        // setup jetspeed test datasource
+        jndiDS = new JetspeedTestJNDIComponent();
+        jndiDS.setup();
+
+        // initialize component manager and server
+        super.initialize();
+
+        // lookup components
+        txnManager = scm.lookupComponent("transactionManager");
+
+        log.info("DistributedJSPMCache server initialized");
+    }
+
+    @Override
+    protected String getBeanDefinitionFilterCategories()
+    {
+        return "security,dbSecurity,transaction,cache,jdbcDS";
+    }
+
+    @Override
+    protected String[] getBootConfigurations()
+    {
+        return new String[]{"boot/datasource.xml"};
+    }
+
+    @Override
+    protected String[] getConfigurations()
+    {
+        // note: override the JetspeedPrincipalManagerProvider bean to get rid of
+        // dependency on SSO
+        return new String[]{"security-atn.xml", "security-atz.xml", "security-managers.xml",
"security-providers.xml",
+                "security-spi.xml", "security-spi-atn.xml", "transaction.xml", "cache-test.xml",
+                "static-bean-references.xml", "JETSPEED-INF/spring/JetspeedPrincipalManagerProviderOverride.xml",
+                "JETSPEED-INF/spring/TestRegistryStubs.xml"};
+    }
+
+    @Override
+    protected Map<String,Object> getContextVars()
+    {
+        Map<String,Object> contextVars = new HashMap<String,Object>();
+        contextVars.put("jspm", scm.lookupComponent("org.apache.jetspeed.security.spi.impl.JetspeedSecurityPersistenceManager"));
+        contextVars.put("userType", scm.lookupComponent("org.apache.jetspeed.security.JetspeedPrincipalType.user"));
+        contextVars.put("roleType", scm.lookupComponent("org.apache.jetspeed.security.JetspeedPrincipalType.role"));
+        contextVars.put("groupType", scm.lookupComponent("org.apache.jetspeed.security.JetspeedPrincipalType.group"));
+        contextVars.put("jspmCache", scm.lookupComponent("org.apache.jetspeed.security.spi.impl.cache.JSPMCache"));
+        contextVars.put("jspmCacheServer", this);
+        return contextVars;
+    }
+
+    @Override
+    public void terminate() throws Exception
+    {
+        // terminate component manager and server
+        super.terminate();
+
+        // tear down test datasource
+        jndiDS.tearDown();
+
+        log.info("DistributedJSPMCache server terminated");
+    }
+
+    /**
+     * Begin transaction on current thread.
+     */
+    public void beginTransaction()
+    {
+        txn = txnManager.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
+    }
+
+    /**
+     * Commit transaction on current thread.
+     */
+    public void commitTransaction()
+    {
+        if (txn != null)
+        {
+            txnManager.commit(txn);
+            txn = null;
+        }
+    }
+
+    /**
+     * Rollback transaction on current thread.
+     */
+    public void rollbackTransaction()
+    {
+        try
+        {
+            if (txn != null)
+            {
+                txnManager.rollback(txn);
+                txn = null;
+            }
+        }
+        catch (Exception e)
+        {
+            txn = null;
+        }
+    }
+
+    /**
+     * Server main entry point.
+     *
+     * @param args not used
+     */
+    public static void main(String [] args)
+    {
+        Throwable error = (new DistributedJSPMCacheServer()).run();
+        if (error != null)
+        {
+            log.error( "Unexpected exception: "+error, error);
+        }
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestDistributedJSPMCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestDistributedJSPMCache.java?rev=1678357&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestDistributedJSPMCache.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestDistributedJSPMCache.java
Fri May  8 14:15:23 2015
@@ -0,0 +1,373 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.spi.cache;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.jetspeed.cache.impl.EhCacheConfigResource;
+import org.apache.jetspeed.components.test.AbstractJexlSpringTestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * TestDistributedJSPMCache - test JetspeedSecurityPersistenceManager cache
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class TestDistributedJSPMCache extends AbstractJexlSpringTestCase
+{
+    protected static Logger log = LoggerFactory.getLogger(TestDistributedJSPMCache.class);
+
+    private static final long CACHE_NOTIFICATION_STARTUP_WAIT = 10000;
+    private static final long CACHE_NOTIFICATION_WAIT = 2000;
+    private static final long CACHE_NOTIFICATION_POLL = 250;
+
+    /**
+     * Creates the test suite.
+     *
+     * @return a test suite that includes all methods starting with "test"
+     */
+    public static Test suite()
+    {
+        return new TestSuite(TestDistributedJSPMCache.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        // setup cache properties
+        EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DISTRIBUTED_CACHE,
true);
+
+        // continue setup
+        super.setUp();
+    }
+
+    @Override
+    protected String testProgramSystemPropertyValueFilter(String propertyName, int index,
String propertyValue)
+    {
+        if (propertyName.equals(EhCacheConfigResource.EHCACHE_PORT_PROP_NAME))
+        {
+            return Integer.toString(Integer.parseInt(propertyValue)+index);
+        }
+        return propertyValue;
+    }
+
+    @Override
+    protected Map<String,String> testProgramSystemProperties()
+    {
+        Map<String,String> systemProperties = super.testProgramSystemProperties();
+        systemProperties.put("log4j.configuration", "log4j-stdout.properties");
+        return systemProperties;
+    }
+
+    /**
+     * Tests distributed cache operation for JSPM
+     */
+    public void testDistributedJSPMCache()
+    {
+        String result;
+
+        // check for distributed database support
+        String databaseName = System.getProperty("org.apache.jetspeed.database.default.name");
+        if ((databaseName != null) && databaseName.equals("derby"))
+        {
+            System.out.println("Database support not distributed: system limitation... test
skipped");
+            log.warn("Database support not distributed: system limitation... test skipped");
+            return;
+        }
+
+        // create and start servers
+        final TestProgram server0 = new TestProgram("server-0", DistributedJSPMCacheServer.class,
0);
+        final TestProgram server1 = new TestProgram("server-1", DistributedJSPMCacheServer.class,
1);
+        try
+        {
+            // start servers
+            server0.start();
+            server1.start();
+
+            // wait until servers have started
+            server0.execute("");
+            server1.execute("");
+
+            // check to ensure servers have distributed page manager caches
+            boolean server0Distributed = false;
+            boolean server1Distributed = false;
+            final long distributedCheckStarted = System.currentTimeMillis();
+            do
+            {
+                // check servers
+                if (!server0Distributed)
+                {
+                    result = server0.execute("jspmCache.isDistributed();");
+                    assertTrue(!result.contains("Exception"));
+                    server0Distributed = result.endsWith("true");
+                }
+                if (!server1Distributed)
+                {
+                    result = server1.execute("jspmCache.isDistributed();");
+                    assertTrue(!result.contains("Exception"));
+                    server1Distributed = result.endsWith("true");
+                }
+
+                // wait if servers not distributed
+                if (!server0Distributed || !server1Distributed)
+                {
+                    sleep(server0, server1, CACHE_NOTIFICATION_POLL);
+                }
+            }
+            while ((!server0Distributed || !server1Distributed) && (System.currentTimeMillis()-distributedCheckStarted
< CACHE_NOTIFICATION_STARTUP_WAIT));
+            if (!server0Distributed && !server1Distributed)
+            {
+                System.out.println("Server JSPM cache not distributed: possible system limitation...
test skipped");
+                log.warn("Server JSPM cache not distributed: possible system limitation...
test skipped");
+                return;
+            }
+            assertTrue(server0Distributed);
+            assertTrue(server1Distributed);
+
+            // start transaction
+            result = server0.execute("jspmCacheServer.beginTransaction();");
+            assertTrue(!result.contains("Exception"));
+            result = server1.execute("jspmCacheServer.beginTransaction();");
+            assertTrue(!result.contains("Exception"));
+            try
+            {
+                // create default domain if necessary
+                boolean createdDefaultDomain = false;
+                result = server0.execute("(jspm.getDomainByName(\"[default]\") != null);");
+                assertTrue(!result.contains("Exception"));
+                if (!Boolean.parseBoolean(getResultValue(result)))
+                {
+                    result = server0.execute("defaultDomain = new(\"org.apache.jetspeed.security.impl.SecurityDomainImpl\");");
+                    assertTrue(!result.contains("Exception"));
+                    result = server0.execute("defaultDomain.setName(\"[default]\")");
+                    assertTrue(!result.contains("Exception"));
+                    result = server0.execute("jspm.addDomain(defaultDomain);");
+                    assertTrue(!result.contains("Exception"));
+                    result = server0.execute("jspmCacheServer.commitTransaction();");
+                    assertTrue(!result.contains("Exception"));
+                    result = server1.execute("jspmCacheServer.commitTransaction();");
+                    assertTrue(!result.contains("Exception"));
+                    createdDefaultDomain = true;
+                    sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                    result = server0.execute("jspmCacheServer.beginTransaction();");
+                    assertTrue(!result.contains("Exception"));
+                    result = server1.execute("jspmCacheServer.beginTransaction();");
+                    assertTrue(!result.contains("Exception"));
+                }
+
+                // clear caches
+                result = server0.execute("jspmCache.clear();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCache.clear();");
+                assertTrue(!result.contains("Exception"));
+
+                // perform some queries to load the caches
+                result = server0.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                int server0Principals = Integer.parseInt(getResultValue(result));
+                result = server1.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                int server1Principals = Integer.parseInt(getResultValue(result));
+                assertEquals(server0Principals, server1Principals);
+                result = server0.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                int server0Permissions = Integer.parseInt(getResultValue(result));
+                result = server1.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                int server1Permissions = Integer.parseInt(getResultValue(result));
+                assertEquals(server1Permissions, server1Permissions);
+                result = server0.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                int server0Domains = Integer.parseInt(getResultValue(result));
+                result = server1.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                int server1Domains = Integer.parseInt(getResultValue(result));
+                assertEquals(server0Domains, server1Domains);
+
+                // test principal instance and query cache operation
+                result = server0.execute("testUser = new(\"org.apache.jetspeed.security.impl.UserImpl\",
\"TEST-USER\");");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.addPrincipal(testUser, null);");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Principals+1, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Principals+1, Integer.parseInt(getResultValue(result)));
+                result = server1.execute("testUser = jspm.getPrincipal(\"TEST-USER\", userType);");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.removePrincipal(testUser);");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Principals, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getPrincipals(\"\", userType).size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Principals, Integer.parseInt(getResultValue(result)));
+
+                // test permission instance and query cache operation
+                result = server0.execute("testPermission = new(\"org.apache.jetspeed.security.spi.impl.PersistentJetspeedPermissionImpl\",
\"TEST-PERMISSION-TYPE\", \"TEST-PERMISSION\");");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("testPermission.setActions(\"TEST-PERMISSION-ACTION\");");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.addPermission(testPermission);");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Permissions+1, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Permissions+1, Integer.parseInt(getResultValue(result)));
+                result = server1.execute("testPermission = jspm.getPermissions(\"TEST-PERMISSION-TYPE\",
\"TEST-PERMISSION\").get(0);");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.removePermission(testPermission);");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Permissions, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getPermissions().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Permissions, Integer.parseInt(getResultValue(result)));
+
+                // test domain instance and query cache operation
+                result = server0.execute("testDomain = new(\"org.apache.jetspeed.security.impl.SecurityDomainImpl\");");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("testDomain.setName(\"TEST-DOMAIN\");");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.addDomain(testDomain);");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Domains+1, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Domains+1, Integer.parseInt(getResultValue(result)));
+                result = server1.execute("testDomain = jspm.getDomainByName(\"TEST-DOMAIN\");");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.removeDomain(testDomain);");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server1Domains, Integer.parseInt(getResultValue(result)));
+                result = server0.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.commitTransaction();");
+                assertTrue(!result.contains("Exception"));
+                sleep(server0, server1, CACHE_NOTIFICATION_WAIT);
+                result = server0.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server1.execute("jspmCacheServer.beginTransaction();");
+                assertTrue(!result.contains("Exception"));
+                result = server0.execute("jspm.getAllDomains().size();");
+                assertTrue(!result.contains("Exception"));
+                assertEquals(server0Domains, Integer.parseInt(getResultValue(result)));
+
+                // remove default domain if created
+                if (createdDefaultDomain)
+                {
+                    result = server0.execute("defaultDomain = jspm.getDomainByName(\"[default]\");");
+                    assertTrue(!result.contains("Exception"));
+                    result = server0.execute("jspm.removeDomain(defaultDomain);");
+                    assertTrue(!result.contains("Exception"));
+                    result = server0.execute("jspmCacheServer.commitTransaction();");
+                    assertTrue(!result.contains("Exception"));
+                }
+            }
+            finally
+            {
+                // rollback transaction
+                server0.execute("jspmCacheServer.rollbackTransaction();");
+                server1.execute("jspmCacheServer.rollbackTransaction();");
+            }
+        }
+        catch (final Exception e)
+        {
+            log.error("Server test exception: "+e, e);
+            fail( "Server test exception: "+e);
+        }
+        finally
+        {
+            // silently shutdown servers
+            try
+            {
+                server0.shutdown(CACHE_NOTIFICATION_STARTUP_WAIT);
+            }
+            catch (final Exception e)
+            {
+                log.error( "Server shutdown exception: "+e, e);
+            }
+            try
+            {
+                server1.shutdown(CACHE_NOTIFICATION_STARTUP_WAIT);
+            }
+            catch (final Exception e)
+            {
+                log.error( "Server shutdown exception: "+e, e);
+            }
+        }
+    }
+}

Copied: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestJSPMCache.java
(from r1678139, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestJSPMCache.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestJSPMCache.java?p2=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestJSPMCache.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestJSPMCache.java&r1=1678139&r2=1678357&rev=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestJSPMCache.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/cache/TestJSPMCache.java
Fri May  8 14:15:23 2015
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.security.spi;
+package org.apache.jetspeed.security.spi.cache;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -32,6 +32,7 @@ import org.apache.jetspeed.security.impl
 import org.apache.jetspeed.security.impl.RoleImpl;
 import org.apache.jetspeed.security.impl.SecurityDomainImpl;
 import org.apache.jetspeed.security.impl.UserImpl;
+import org.apache.jetspeed.security.spi.PersistentJetspeedPermission;
 import org.apache.jetspeed.security.spi.impl.JetspeedSecurityPersistenceManager;
 import org.apache.jetspeed.security.spi.impl.PasswordCredentialImpl;
 import org.apache.jetspeed.security.spi.impl.PersistentJetspeedPermissionImpl;

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/resources/log4j-stdout.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/resources/log4j-stdout.properties?rev=1678357&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/resources/log4j-stdout.properties
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/resources/log4j-stdout.properties
Fri May  8 14:15:23 2015
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# ------------------------------------------------------------------------
+#
+# Stdout Logging Configuration
+#
+# $Id: log4j.properties 722139 2008-12-01 17:22:03Z rwatler $
+#
+# ------------------------------------------------------------------------
+
+log4j.rootLogger = ERROR, stdout
+
+#log4j.category.net.sf.ehcache.distribution = DEBUG, stdout
+#log4j.additivity.net.sf.ehcache.distribution = false
+
+log4j.category.org.apache.jetspeed = INFO, stdout
+log4j.additivity.org.apache.jetspeed = false
+
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.conversionPattern = %d [%t] %-5p %c - %m%n

Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=1678357&r1=1678356&r2=1678357&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Fri May  8 14:15:23 2015
@@ -238,7 +238,7 @@
     <commons-fileupload.version>1.3.1</commons-fileupload.version>
     <commons-httpclient.version>3.1</commons-httpclient.version>
     <commons-io.version>2.4</commons-io.version>
-    <commons-jexl.version>1.1</commons-jexl.version>
+    <commons-jexl.version>2.1.1</commons-jexl.version>
     <commons-lang.version>2.6</commons-lang.version>
     <commons-logging.version>1.1.3</commons-logging.version>
     <commons-pool.version>1.6</commons-pool.version>
@@ -869,7 +869,7 @@
         <version>${log4j.version}</version>
       </dependency>
       <dependency>
-        <groupId>commons-jexl</groupId>
+        <groupId>org.apache.commons</groupId>
         <artifactId>commons-jexl</artifactId>
         <version>${commons-jexl.version}</version>
         <exclusions>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message