You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/05/05 08:58:51 UTC
svn commit: r535465 [3/49] - in /jakarta/turbine/fulcrum/trunk: ./ bsf/
bsf/src/java/org/apache/fulcrum/bsf/ bsf/src/test/ bsf/xdocs/ cache/
cache/src/java/org/apache/fulcrum/cache/
cache/src/java/org/apache/fulcrum/cache/impl/ cache/src/test/ cache/sr...
Modified: jakarta/turbine/fulcrum/trunk/cache/src/test/org/apache/fulcrum/cache/JCSCacheTest.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/src/test/org/apache/fulcrum/cache/JCSCacheTest.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/src/test/org/apache/fulcrum/cache/JCSCacheTest.java (original)
+++ jakarta/turbine/fulcrum/trunk/cache/src/test/org/apache/fulcrum/cache/JCSCacheTest.java Fri May 4 23:58:06 2007
@@ -1,579 +1,582 @@
-package org.apache.fulcrum.cache;
-
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-// Cactus and Junit imports
-
-import java.util.ConcurrentModificationException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
-
-/**
- * JCSCacheTest
- *
- * @author <a href="tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public class JCSCacheTest extends BaseUnitTest
-{
- private GlobalCacheService globalCache = null;
- private static final String cacheKey = "CacheKey";
- private static final String cacheKey_2 = "CacheKey_2";
- public static final String SKIP_TESTS_KEY = "fulcrum.cache.skip.long.tests";
- private static final Log LOG = LogFactory.getLog(JCSCacheTest.class);
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public JCSCacheTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- try
- {
- globalCache = (GlobalCacheService) this.lookup(GlobalCacheService.ROLE + "_JCS");
- }
- catch (ComponentException e)
- {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- /**
- * Simple test that verify an object can be created and deleted.
- *
- * @throws Exception
- */
- public void testSimpleAddGetCacheObject() throws Exception
- {
- String testString = new String("This is a test");
- Object retrievedObject = null;
- CachedObject cacheObject1 = null;
- // Create object
- cacheObject1 = new CachedObject(testString);
- assertNotNull("Failed to create a cachable object 1", cacheObject1);
- // Add object to cache
- globalCache.addObject(cacheKey, cacheObject1);
- // Get object from cache
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object 1", retrievedObject);
- assertTrue("Did not retrieved a correct, expected cached object 1", retrievedObject == cacheObject1);
- // Remove object from cache
- globalCache.removeObject(cacheKey);
- // Verify object removed from cache
- retrievedObject = null;
- cacheObject1 = null;
- try
- {
- retrievedObject = globalCache.getObject(cacheKey);
- assertNull(
- "Retrieved the deleted cached object 1 and did not get expected ObjectExpiredException",
- retrievedObject);
- assertNotNull("Did not get expected ObjectExpiredException retrieving a deleted object", retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- assertNull(
- "Retrieved the deleted cached object 1, but caught expected ObjectExpiredException exception",
- retrievedObject);
- }
- catch (Exception e)
- {
- throw e;
- }
- // Remove object from cache that does NOT exist in the cache
- globalCache.removeObject(cacheKey);
- }
-
- /**
- * Simple test that adds, retrieves, and deletes 2 object.
- *
- * @throws Exception
- */
- public void test2ObjectAddGetCachedObject() throws Exception
- {
- String testString = new String("This is a test");
- Object retrievedObject = null;
- CachedObject cacheObject1 = null;
- CachedObject cacheObject2 = null;
- // Create and add Object #1
- cacheObject1 = new CachedObject(testString);
- assertNotNull("Failed to create a cachable object 1", cacheObject1);
- globalCache.addObject(cacheKey, cacheObject1);
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object 1", retrievedObject);
- assertEquals("Did not retrieved correct cached object", cacheObject1, retrievedObject);
- // Create and add Object #2
- cacheObject2 = new CachedObject(testString);
- assertNotNull("Failed to create a cachable object 2", cacheObject2);
- globalCache.addObject(cacheKey_2, cacheObject2);
- retrievedObject = globalCache.getObject(cacheKey_2);
- assertNotNull("Did not retrieved a cached object 2", retrievedObject);
- assertEquals("Did not retrieved correct cached object 2", cacheObject2, retrievedObject);
- // Get object #1
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object 1. Attempt #2", retrievedObject);
- assertEquals("Did not retrieved correct cached object 1. Attempt #2", cacheObject1, retrievedObject);
- // Get object #1
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object 1. Attempt #3", retrievedObject);
- assertEquals("Did not retrieved correct cached object 1. Attempt #3", cacheObject1, retrievedObject);
- // Get object #2
- retrievedObject = globalCache.getObject(cacheKey_2);
- assertNotNull("Did not retrieved a cached object 2. Attempt #2", retrievedObject);
- assertEquals("Did not retrieved correct cached object 2 Attempt #2", cacheObject2, retrievedObject);
- // Remove objects
- globalCache.removeObject(cacheKey);
- globalCache.removeObject(cacheKey_2);
- }
-
- /**
- * Verify that an object will throw the ObjectExpiredException
- * when it now longer exists in cache.
- *
- * @throws Exception
- */
- public void testObjectExpiration() throws Exception
- {
- String testString = new String("This is a test");
- Object retrievedObject = null;
- CachedObject cacheObject = null;
- // Create and add Object that expires in 1000 millis (1 second)
- cacheObject = new CachedObject(testString, 1000);
- assertNotNull("Failed to create a cachable object", cacheObject);
- long addTime = System.currentTimeMillis();
- globalCache.addObject(cacheKey, cacheObject);
- // Try to get un-expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object", retrievedObject);
- assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- assertTrue("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
- }
- catch (Exception e)
- {
- throw e;
- }
- // Sleep 1500 Millis (1.5 seconds)
- Thread.sleep(1500);
- // Try to get expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject(cacheKey);
- assertNull(
- "Retrieved the expired cached object and did not get expected ObjectExpiredException",
- retrievedObject);
- assertNotNull("Did not get expected ObjectExpiredException retrieving an expired object", retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- assertNull(
- "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",
- retrievedObject);
- }
- catch (Exception e)
- {
- throw e;
- }
- // Remove objects
- globalCache.removeObject(cacheKey);
- }
-
- /**
- * Verify the all object will be flushed from the cache.
- *
- * This test can take server minutes.
- *
- * @throws Exception
- */
- public void testCacheFlush() throws Exception
- {
- String testString = new String("This is a test");
- CachedObject cacheObject = null;
- // Create and add Object that expires in 1 turbine Refresh + 1 millis
- cacheObject = new CachedObject(testString, (getCacheRefresh() * 5) + 1);
- assertNotNull("Failed to create a cachable object", cacheObject);
- globalCache.addObject(cacheKey, cacheObject);
- // 1 Refresh
- Thread.sleep(getCacheRefresh() + 1);
- assertTrue("No object in cache before flush", (0 < globalCache.getNumberOfObjects()));
- // Flush Cache
- globalCache.flushCache();
- // Wait 15 seconds, 3 Refresh
- Thread.sleep((getCacheRefresh() * 2) + 1);
- assertEquals("After refresh", 0, globalCache.getNumberOfObjects());
- // Remove objects
- globalCache.removeObject(cacheKey);
- }
-
- /**
- * Verify the Cache count is correct.
- *
- * @throws Exception
- */
- public void testObjectCount() throws Exception
- {
- assertNotNull("Could not retrive cache service.", globalCache);
- // Create and add Object that expires in 1.5 turbine Refresh
- long expireTime = getCacheRefresh() + getCacheRefresh() / 2;
- CachedObject cacheObject = new CachedObject("This is a test", expireTime);
- assertNotNull("Failed to create a cachable object", cacheObject);
- globalCache.addObject("testObjectCount", cacheObject);
- assertEquals("After adding 1 Object", 1, globalCache.getNumberOfObjects());
- // Wait until we're passed 1 refresh, but not half way.
- Thread.sleep(getCacheRefresh() + getCacheRefresh() / 3);
- assertEquals("After one refresh", 1, globalCache.getNumberOfObjects());
- // Wait until we're passed 2 more refreshes
- Thread.sleep((getCacheRefresh() * 2) + getCacheRefresh() / 3);
- assertEquals("After three refreshes", 0, globalCache.getNumberOfObjects());
- }
-
- /**
- * Verfy a refreshable object will refreshed in the following cases:
- * - The object is retrieved via getObject an it is stale.
- * - The object is determied to be stale during a cache
- * refresh
- *
- * This test can take serveral minutes.
- *
- * @throws Exception
- */
- public void testRefreshableObject() throws Exception
- {
- Object retrievedObject = null;
- RefreshableCachedObject cacheObject = null;
- // Create and add Object that expires in TEST_EXPIRETIME millis.
- cacheObject = new RefreshableCachedObject(new RefreshableObject(), getTestExpireTime());
- assertNotNull("Failed to create a cachable object", cacheObject);
- long addTime = System.currentTimeMillis();
- globalCache.addObject("refreshableObject", cacheObject);
- // Try to get un-expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject("refreshableObject");
- assertNotNull("Did not retrieved a cached object", retrievedObject);
- assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- assertTrue("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
- }
- catch (Exception e)
- {
- throw e;
- }
- // Wait 1 Turbine cache refresh + 1 second.
- Thread.sleep(getTestExpireTime() + 1000);
- // Try to get expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject("refreshableObject");
- assertNotNull("Did not retrieved a cached object, after sleep", retrievedObject);
- assertNotNull(
- "Cached object has no contents, after sleep.",
- ((RefreshableCachedObject) retrievedObject).getContents());
- assertTrue(
- "Object did not refresh.",
- (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
- > 0));
- }
- catch (ObjectExpiredException e)
- {
- assertTrue(
- "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime)
- + " millis)",
- false);
- }
- catch (Exception e)
- {
- throw e;
- }
- // See if object will expires (testing every second for 100 seconds. It should not!
- for (int i = 0; i < 100; i++)
- {
- Thread.sleep(1000); // Sleep 0.5 seconds
- // Try to get expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject("refreshableObject");
- assertNotNull("Did not retrieved a cached object, after sleep", retrievedObject);
- assertNotNull(
- "Cached object has no contents, after sleep.",
- ((RefreshableCachedObject) retrievedObject).getContents());
- assertTrue(
- "Object did not refresh.",
- (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
- > 0));
- }
- catch (ObjectExpiredException e)
- {
- assertTrue(
- "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime)
- + " millis)",
- false);
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- // Remove objects
- globalCache.removeObject(cacheKey);
- }
-
- /**
- * Verify a cached object will be delete after it has been
- * untouched beyond it's TimeToLive.
- *
- * This test can take serveral minutes.
- *
- * @throws Exception
- */
- public void testRefreshableTimeToLive() throws Exception
- {
- String skipTestsProperty = System.getProperty(SKIP_TESTS_KEY,"false");
- LOG.info("What is the value of the skipTestsProperty:" + skipTestsProperty);
- if(Boolean.valueOf(skipTestsProperty).booleanValue()){
- LOG.warn("Skipping testRefreshableTimeToLive test due to property " + SKIP_TESTS_KEY + " being true.");
- return;
- }
- else {
- LOG.warn("Running testRefreshableTimeToLive test due to property " + SKIP_TESTS_KEY + " being false.");
- }
-
- Object retrievedObject = null;
- RefreshableCachedObject cacheObject = null;
- // Create and add Object that expires in TEST_EXPIRETIME millis.
- cacheObject = new RefreshableCachedObject(new RefreshableObject(), getTestExpireTime());
- assertNotNull("Failed to create a cachable object", cacheObject);
- cacheObject.setTTL(getTestExpireTime());
- // Verify TimeToLive was set
- assertEquals("Returned TimeToLive", getTestExpireTime(), cacheObject.getTTL());
- // Add object to Cache
- long addTime = System.currentTimeMillis();
- globalCache.addObject(cacheKey, cacheObject);
- // Try to get un-expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieved a cached object", retrievedObject);
- assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- fail("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)");
- }
- catch (Exception e)
- {
- throw e;
- }
- // Wait long enough to allow object to expire, but do not exceed TTL
- long timeout = getTestExpireTime() - 0000;
- Thread.sleep(timeout);
- // Try to get expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject(cacheKey);
- assertNotNull("Did not retrieve a cached object, after sleep", retrievedObject);
- assertNotNull(
- "Cached object has no contents, after sleep.",
- ((RefreshableCachedObject) retrievedObject).getContents());
- /*
- * @todo this is not working for some reason
-
- assertTrue(
- "Object did not refresh.",
- (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
- > 0));
- */
- }
- catch (ObjectExpiredException e)
- {
- assertTrue(
- "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime)
- + " millis)",
- false);
- }
- catch (Exception e)
- {
- throw e;
- }
- // Wait long enough to allow object to expire and exceed TTL
- Thread.sleep(getTestExpireTime() + 5000);
- // Try to get expired object
- try
- {
- retrievedObject = null;
- retrievedObject = globalCache.getObject(cacheKey);
- assertNull("Retrieved a cached object, after exceeding TimeToLive", retrievedObject);
- }
- catch (ObjectExpiredException e)
- {
- assertNull(
- "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",
- retrievedObject);
- }
- catch (Exception e)
- {
- throw e;
- }
- }
-
- /**
- * Test that we can get a list of the keys in the cache
- */
- public void testCacheGetKeyList() {
- globalCache.flushCache();
- globalCache.addObject("date1", new CachedObject(new Date()));
- globalCache.addObject("date2", new CachedObject(new Date()));
- globalCache.addObject("date3", new CachedObject(new Date()));
- assertTrue("Did not get key list back.", (globalCache.getKeys() != null));
- List keys = globalCache.getKeys();
- for (Iterator itr = keys.iterator(); itr.hasNext();) {
- Object key = itr.next();
- assertTrue("Key was not an instance of String.", (key instanceof String));
- }
-
- }
-
- /**
- * Test that we can get a list of the keys in the cache
- */
- public void testCacheGetCachedObjects() {
- globalCache.flushCache();
- globalCache.addObject("date1", new CachedObject(new Date()));
- globalCache.addObject("date2", new CachedObject(new Date()));
- globalCache.addObject("date3", new CachedObject(new Date()));
- assertTrue("Did not get object list back.", (globalCache.getCachedObjects() != null));
- List objects = globalCache.getCachedObjects();
- for (Iterator itr = objects.iterator(); itr.hasNext();) {
- Object obj = itr.next();
- assertNotNull("Object was null.", obj);
- assertTrue("Object was not an instance of CachedObject", (obj instanceof CachedObject));
- }
- }
-
- /**
- * Test that the retrieved list is safe from
- * ConcurrentModificationException's being thrown if the cache
- * is updated while we are iterating over the List.
- */
- public void testCacheModification() {
- globalCache.flushCache();
- globalCache.addObject("date1", new CachedObject(new Date()));
- globalCache.addObject("date2", new CachedObject(new Date()));
- globalCache.addObject("date3", new CachedObject(new Date()));
- assertTrue("Did not get key list back.", (globalCache.getKeys() != null));
- List keys = globalCache.getKeys();
- try {
- for (Iterator itr = keys.iterator(); itr.hasNext();) {
- Object key = itr.next();
- globalCache.addObject("date4", new CachedObject(new Date()));
- }
- } catch (ConcurrentModificationException cme)
- {
- fail("Caught ConcurrentModificationException adding to cache.");
- }
- List objects = globalCache.getCachedObjects();
- try {
- for (Iterator itr = objects.iterator(); itr.hasNext();) {
- Object obj = itr.next();
- globalCache.addObject("date4", new CachedObject(new Date()));
- }
- } catch (ConcurrentModificationException cme)
- {
- fail("Caught ConcurrentModificationException adding to cache.");
- }
- }
-
- /**
- * Down cast the interface to the concreate object in order to grab the
- * cache check frequency.
- *
- * @return the refresh requency in milliseconds
- */
- private long getCacheRefresh()
- {
- return 5*1000;
- }
-
- /**
- * How long until it expires
- *
- * @return the cache refresh plus 1000.
- */
- private long getTestExpireTime()
- {
- return getCacheRefresh() + 1000;
- }
-
- /**
- * Simple object that can be refreshed
- */
- class RefreshableObject implements Refreshable
- {
- private int refreshCount = 0;
-
- /**
- * Increment the refresh counter
- */
- public void refresh()
- {
- this.refreshCount++;
- }
-
- /**
- * Reutrn the number of time this object has been refreshed
- *
- * @return Number of times refresh() has been called
- */
- public int getRefreshCount()
- {
- return this.refreshCount;
- }
- }
-}
+package org.apache.fulcrum.cache;
+
+/*
+ * 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.
+ */
+
+// Cactus and Junit imports
+
+import java.util.ConcurrentModificationException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+/**
+ * JCSCacheTest
+ *
+ * @author <a href="tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class JCSCacheTest extends BaseUnitTest
+{
+ private GlobalCacheService globalCache = null;
+ private static final String cacheKey = "CacheKey";
+ private static final String cacheKey_2 = "CacheKey_2";
+ public static final String SKIP_TESTS_KEY = "fulcrum.cache.skip.long.tests";
+ private static final Log LOG = LogFactory.getLog(JCSCacheTest.class);
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public JCSCacheTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ globalCache = (GlobalCacheService) this.lookup(GlobalCacheService.ROLE + "_JCS");
+ }
+ catch (ComponentException e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Simple test that verify an object can be created and deleted.
+ *
+ * @throws Exception
+ */
+ public void testSimpleAddGetCacheObject() throws Exception
+ {
+ String testString = new String("This is a test");
+ Object retrievedObject = null;
+ CachedObject cacheObject1 = null;
+ // Create object
+ cacheObject1 = new CachedObject(testString);
+ assertNotNull("Failed to create a cachable object 1", cacheObject1);
+ // Add object to cache
+ globalCache.addObject(cacheKey, cacheObject1);
+ // Get object from cache
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object 1", retrievedObject);
+ assertTrue("Did not retrieved a correct, expected cached object 1", retrievedObject == cacheObject1);
+ // Remove object from cache
+ globalCache.removeObject(cacheKey);
+ // Verify object removed from cache
+ retrievedObject = null;
+ cacheObject1 = null;
+ try
+ {
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNull(
+ "Retrieved the deleted cached object 1 and did not get expected ObjectExpiredException",
+ retrievedObject);
+ assertNotNull("Did not get expected ObjectExpiredException retrieving a deleted object", retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertNull(
+ "Retrieved the deleted cached object 1, but caught expected ObjectExpiredException exception",
+ retrievedObject);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Remove object from cache that does NOT exist in the cache
+ globalCache.removeObject(cacheKey);
+ }
+
+ /**
+ * Simple test that adds, retrieves, and deletes 2 object.
+ *
+ * @throws Exception
+ */
+ public void test2ObjectAddGetCachedObject() throws Exception
+ {
+ String testString = new String("This is a test");
+ Object retrievedObject = null;
+ CachedObject cacheObject1 = null;
+ CachedObject cacheObject2 = null;
+ // Create and add Object #1
+ cacheObject1 = new CachedObject(testString);
+ assertNotNull("Failed to create a cachable object 1", cacheObject1);
+ globalCache.addObject(cacheKey, cacheObject1);
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object 1", retrievedObject);
+ assertEquals("Did not retrieved correct cached object", cacheObject1, retrievedObject);
+ // Create and add Object #2
+ cacheObject2 = new CachedObject(testString);
+ assertNotNull("Failed to create a cachable object 2", cacheObject2);
+ globalCache.addObject(cacheKey_2, cacheObject2);
+ retrievedObject = globalCache.getObject(cacheKey_2);
+ assertNotNull("Did not retrieved a cached object 2", retrievedObject);
+ assertEquals("Did not retrieved correct cached object 2", cacheObject2, retrievedObject);
+ // Get object #1
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object 1. Attempt #2", retrievedObject);
+ assertEquals("Did not retrieved correct cached object 1. Attempt #2", cacheObject1, retrievedObject);
+ // Get object #1
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object 1. Attempt #3", retrievedObject);
+ assertEquals("Did not retrieved correct cached object 1. Attempt #3", cacheObject1, retrievedObject);
+ // Get object #2
+ retrievedObject = globalCache.getObject(cacheKey_2);
+ assertNotNull("Did not retrieved a cached object 2. Attempt #2", retrievedObject);
+ assertEquals("Did not retrieved correct cached object 2 Attempt #2", cacheObject2, retrievedObject);
+ // Remove objects
+ globalCache.removeObject(cacheKey);
+ globalCache.removeObject(cacheKey_2);
+ }
+
+ /**
+ * Verify that an object will throw the ObjectExpiredException
+ * when it now longer exists in cache.
+ *
+ * @throws Exception
+ */
+ public void testObjectExpiration() throws Exception
+ {
+ String testString = new String("This is a test");
+ Object retrievedObject = null;
+ CachedObject cacheObject = null;
+ // Create and add Object that expires in 1000 millis (1 second)
+ cacheObject = new CachedObject(testString, 1000);
+ assertNotNull("Failed to create a cachable object", cacheObject);
+ long addTime = System.currentTimeMillis();
+ globalCache.addObject(cacheKey, cacheObject);
+ // Try to get un-expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object", retrievedObject);
+ assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertTrue("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Sleep 1500 Millis (1.5 seconds)
+ Thread.sleep(1500);
+ // Try to get expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNull(
+ "Retrieved the expired cached object and did not get expected ObjectExpiredException",
+ retrievedObject);
+ assertNotNull("Did not get expected ObjectExpiredException retrieving an expired object", retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertNull(
+ "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",
+ retrievedObject);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Remove objects
+ globalCache.removeObject(cacheKey);
+ }
+
+ /**
+ * Verify the all object will be flushed from the cache.
+ *
+ * This test can take server minutes.
+ *
+ * @throws Exception
+ */
+ public void testCacheFlush() throws Exception
+ {
+ String testString = new String("This is a test");
+ CachedObject cacheObject = null;
+ // Create and add Object that expires in 1 turbine Refresh + 1 millis
+ cacheObject = new CachedObject(testString, (getCacheRefresh() * 5) + 1);
+ assertNotNull("Failed to create a cachable object", cacheObject);
+ globalCache.addObject(cacheKey, cacheObject);
+ // 1 Refresh
+ Thread.sleep(getCacheRefresh() + 1);
+ assertTrue("No object in cache before flush", (0 < globalCache.getNumberOfObjects()));
+ // Flush Cache
+ globalCache.flushCache();
+ // Wait 15 seconds, 3 Refresh
+ Thread.sleep((getCacheRefresh() * 2) + 1);
+ assertEquals("After refresh", 0, globalCache.getNumberOfObjects());
+ // Remove objects
+ globalCache.removeObject(cacheKey);
+ }
+
+ /**
+ * Verify the Cache count is correct.
+ *
+ * @throws Exception
+ */
+ public void testObjectCount() throws Exception
+ {
+ assertNotNull("Could not retrive cache service.", globalCache);
+ // Create and add Object that expires in 1.5 turbine Refresh
+ long expireTime = getCacheRefresh() + getCacheRefresh() / 2;
+ CachedObject cacheObject = new CachedObject("This is a test", expireTime);
+ assertNotNull("Failed to create a cachable object", cacheObject);
+ globalCache.addObject("testObjectCount", cacheObject);
+ assertEquals("After adding 1 Object", 1, globalCache.getNumberOfObjects());
+ // Wait until we're passed 1 refresh, but not half way.
+ Thread.sleep(getCacheRefresh() + getCacheRefresh() / 3);
+ assertEquals("After one refresh", 1, globalCache.getNumberOfObjects());
+ // Wait until we're passed 2 more refreshes
+ Thread.sleep((getCacheRefresh() * 2) + getCacheRefresh() / 3);
+ assertEquals("After three refreshes", 0, globalCache.getNumberOfObjects());
+ }
+
+ /**
+ * Verfy a refreshable object will refreshed in the following cases:
+ * - The object is retrieved via getObject an it is stale.
+ * - The object is determied to be stale during a cache
+ * refresh
+ *
+ * This test can take serveral minutes.
+ *
+ * @throws Exception
+ */
+ public void testRefreshableObject() throws Exception
+ {
+ Object retrievedObject = null;
+ RefreshableCachedObject cacheObject = null;
+ // Create and add Object that expires in TEST_EXPIRETIME millis.
+ cacheObject = new RefreshableCachedObject(new RefreshableObject(), getTestExpireTime());
+ assertNotNull("Failed to create a cachable object", cacheObject);
+ long addTime = System.currentTimeMillis();
+ globalCache.addObject("refreshableObject", cacheObject);
+ // Try to get un-expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject("refreshableObject");
+ assertNotNull("Did not retrieved a cached object", retrievedObject);
+ assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertTrue("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Wait 1 Turbine cache refresh + 1 second.
+ Thread.sleep(getTestExpireTime() + 1000);
+ // Try to get expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject("refreshableObject");
+ assertNotNull("Did not retrieved a cached object, after sleep", retrievedObject);
+ assertNotNull(
+ "Cached object has no contents, after sleep.",
+ ((RefreshableCachedObject) retrievedObject).getContents());
+ assertTrue(
+ "Object did not refresh.",
+ (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
+ > 0));
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertTrue(
+ "Received unexpected ObjectExpiredException exception "
+ + "when retrieving refreshable object after ( "
+ + (System.currentTimeMillis() - addTime)
+ + " millis)",
+ false);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // See if object will expires (testing every second for 100 seconds. It should not!
+ for (int i = 0; i < 100; i++)
+ {
+ Thread.sleep(1000); // Sleep 0.5 seconds
+ // Try to get expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject("refreshableObject");
+ assertNotNull("Did not retrieved a cached object, after sleep", retrievedObject);
+ assertNotNull(
+ "Cached object has no contents, after sleep.",
+ ((RefreshableCachedObject) retrievedObject).getContents());
+ assertTrue(
+ "Object did not refresh.",
+ (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
+ > 0));
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertTrue(
+ "Received unexpected ObjectExpiredException exception "
+ + "when retrieving refreshable object after ( "
+ + (System.currentTimeMillis() - addTime)
+ + " millis)",
+ false);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
+ // Remove objects
+ globalCache.removeObject(cacheKey);
+ }
+
+ /**
+ * Verify a cached object will be delete after it has been
+ * untouched beyond it's TimeToLive.
+ *
+ * This test can take serveral minutes.
+ *
+ * @throws Exception
+ */
+ public void testRefreshableTimeToLive() throws Exception
+ {
+ String skipTestsProperty = System.getProperty(SKIP_TESTS_KEY,"false");
+ LOG.info("What is the value of the skipTestsProperty:" + skipTestsProperty);
+ if(Boolean.valueOf(skipTestsProperty).booleanValue()){
+ LOG.warn("Skipping testRefreshableTimeToLive test due to property " + SKIP_TESTS_KEY + " being true.");
+ return;
+ }
+ else {
+ LOG.warn("Running testRefreshableTimeToLive test due to property " + SKIP_TESTS_KEY + " being false.");
+ }
+
+ Object retrievedObject = null;
+ RefreshableCachedObject cacheObject = null;
+ // Create and add Object that expires in TEST_EXPIRETIME millis.
+ cacheObject = new RefreshableCachedObject(new RefreshableObject(), getTestExpireTime());
+ assertNotNull("Failed to create a cachable object", cacheObject);
+ cacheObject.setTTL(getTestExpireTime());
+ // Verify TimeToLive was set
+ assertEquals("Returned TimeToLive", getTestExpireTime(), cacheObject.getTTL());
+ // Add object to Cache
+ long addTime = System.currentTimeMillis();
+ globalCache.addObject(cacheKey, cacheObject);
+ // Try to get un-expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieved a cached object", retrievedObject);
+ assertEquals("Did not retrieved correct cached object", cacheObject, retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ fail("Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)");
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Wait long enough to allow object to expire, but do not exceed TTL
+ long timeout = getTestExpireTime() - 0000;
+ Thread.sleep(timeout);
+ // Try to get expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNotNull("Did not retrieve a cached object, after sleep", retrievedObject);
+ assertNotNull(
+ "Cached object has no contents, after sleep.",
+ ((RefreshableCachedObject) retrievedObject).getContents());
+ /*
+ * @todo this is not working for some reason
+ *
+ * assertTrue(
+ * "Object did not refresh.",
+ * (((RefreshableObject) ((RefreshableCachedObject) retrievedObject).getContents()).getRefreshCount()
+ * > 0));
+ */
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertTrue(
+ "Received unexpected ObjectExpiredException exception "
+ + "when retrieving refreshable object after ( "
+ + (System.currentTimeMillis() - addTime)
+ + " millis)",
+ false);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ // Wait long enough to allow object to expire and exceed TTL
+ Thread.sleep(getTestExpireTime() + 5000);
+ // Try to get expired object
+ try
+ {
+ retrievedObject = null;
+ retrievedObject = globalCache.getObject(cacheKey);
+ assertNull("Retrieved a cached object, after exceeding TimeToLive", retrievedObject);
+ }
+ catch (ObjectExpiredException e)
+ {
+ assertNull(
+ "Retrieved the expired cached object, but caught expected ObjectExpiredException exception",
+ retrievedObject);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
+
+ /**
+ * Test that we can get a list of the keys in the cache
+ */
+ public void testCacheGetKeyList() {
+ globalCache.flushCache();
+ globalCache.addObject("date1", new CachedObject(new Date()));
+ globalCache.addObject("date2", new CachedObject(new Date()));
+ globalCache.addObject("date3", new CachedObject(new Date()));
+ assertTrue("Did not get key list back.", (globalCache.getKeys() != null));
+ List keys = globalCache.getKeys();
+ for (Iterator itr = keys.iterator(); itr.hasNext();) {
+ Object key = itr.next();
+ assertTrue("Key was not an instance of String.", (key instanceof String));
+ }
+
+ }
+
+ /**
+ * Test that we can get a list of the keys in the cache
+ */
+ public void testCacheGetCachedObjects() {
+ globalCache.flushCache();
+ globalCache.addObject("date1", new CachedObject(new Date()));
+ globalCache.addObject("date2", new CachedObject(new Date()));
+ globalCache.addObject("date3", new CachedObject(new Date()));
+ assertTrue("Did not get object list back.", (globalCache.getCachedObjects() != null));
+ List objects = globalCache.getCachedObjects();
+ for (Iterator itr = objects.iterator(); itr.hasNext();) {
+ Object obj = itr.next();
+ assertNotNull("Object was null.", obj);
+ assertTrue("Object was not an instance of CachedObject", (obj instanceof CachedObject));
+ }
+ }
+
+ /**
+ * Test that the retrieved list is safe from
+ * ConcurrentModificationException's being thrown if the cache
+ * is updated while we are iterating over the List.
+ */
+ public void testCacheModification() {
+ globalCache.flushCache();
+ globalCache.addObject("date1", new CachedObject(new Date()));
+ globalCache.addObject("date2", new CachedObject(new Date()));
+ globalCache.addObject("date3", new CachedObject(new Date()));
+ assertTrue("Did not get key list back.", (globalCache.getKeys() != null));
+ List keys = globalCache.getKeys();
+ try {
+ for (Iterator itr = keys.iterator(); itr.hasNext();) {
+ Object key = itr.next();
+ globalCache.addObject("date4", new CachedObject(new Date()));
+ }
+ } catch (ConcurrentModificationException cme)
+ {
+ fail("Caught ConcurrentModificationException adding to cache.");
+ }
+ List objects = globalCache.getCachedObjects();
+ try {
+ for (Iterator itr = objects.iterator(); itr.hasNext();) {
+ Object obj = itr.next();
+ globalCache.addObject("date4", new CachedObject(new Date()));
+ }
+ } catch (ConcurrentModificationException cme)
+ {
+ fail("Caught ConcurrentModificationException adding to cache.");
+ }
+ }
+
+ /**
+ * Down cast the interface to the concreate object in order to grab the
+ * cache check frequency.
+ *
+ * @return the refresh requency in milliseconds
+ */
+ private long getCacheRefresh()
+ {
+ return 5*1000;
+ }
+
+ /**
+ * How long until it expires
+ *
+ * @return the cache refresh plus 1000.
+ */
+ private long getTestExpireTime()
+ {
+ return getCacheRefresh() + 1000;
+ }
+
+ /**
+ * Simple object that can be refreshed
+ */
+ class RefreshableObject implements Refreshable
+ {
+ private int refreshCount = 0;
+
+ /**
+ * Increment the refresh counter
+ */
+ public void refresh()
+ {
+ this.refreshCount++;
+ }
+
+ /**
+ * Reutrn the number of time this object has been refreshed
+ *
+ * @return Number of times refresh() has been called
+ */
+ public int getRefreshCount()
+ {
+ return this.refreshCount;
+ }
+ }
+}
Modified: jakarta/turbine/fulcrum/trunk/cache/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/xdocs/changes.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/xdocs/changes.xml (original)
+++ jakarta/turbine/fulcrum/trunk/cache/xdocs/changes.xml Fri May 4 23:58:06 2007
@@ -1,4 +1,22 @@
<?xml version="1.0"?>
+<!--
+ 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.
+-->
<document>
<properties>
<title>Fulcrum Cache</title>
@@ -12,23 +30,23 @@
</action>
<action dev="epugh" type="add">
Add new EHCacheService based on EHCache from http://ehcache.sourceforge.net/
- </action>
+ </action>
</release>
<release version="1.0.5" date="2004-11-24">
<action dev="epugh" type="remove">
Remove CacheServiceFacade. It was a code smell.
- </action>
+ </action>
<action dev="epugh" type="update">
Make long running tests optional. They often fail for random reasons.
- </action>
+ </action>
<action dev="epugh" type="update">
Remove extra dependencies.
- </action>
+ </action>
<action dev="epugh" type="add">
Added patch from Peter Courcoux adding new methods,
- getKeys() and getCachedObjects() together with
+ getKeys() and getCachedObjects() together with
associated unit tests.
- </action>
+ </action>
</release>
<release version="1.0-alpha-3" date="">
<action dev="epugh" type="add">
Modified: jakarta/turbine/fulcrum/trunk/cache/xdocs/index.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/xdocs/index.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/xdocs/index.xml (original)
+++ jakarta/turbine/fulcrum/trunk/cache/xdocs/index.xml Fri May 4 23:58:06 2007
@@ -1,4 +1,22 @@
<?xml version="1.0"?>
+<!--
+ 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.
+-->
<document>
@@ -33,10 +51,10 @@
information in the Global Cache and decrease the overhead of
hitting the database everytime you need State information.
</p>
-
+
<p>
- It is written
- for use in Turbine but it can be used in any container compatible
+ It is written
+ for use in Turbine but it can be used in any container compatible
with Avalon's ECM container.
</p>
@@ -63,7 +81,7 @@
]]>
</source>
</section>
-
+
<section name="EHCacheService" id="EHCacheService">
<p>
@@ -85,19 +103,19 @@
<source>
<![CDATA[
- <ehcache>
-
+ <ehcache>
+
</ehcache>
]]>
</source>
</section>
-
+
<section name="JCSCacheService" id="JCSCacheService">
<p>
The JCS cache service implements the interface <code>GlobalCacheService</code> and thus can
- serve as a drop-in replacement for <code>DefaultGlobalCacheService</code>. However it is
+ serve as a drop-in replacement for <code>DefaultGlobalCacheService</code>. However it is
possible to configure the cache behaviour in much more detail to provide disk caches or lateral TCP
caches for example.
</p>
@@ -132,7 +150,7 @@
<code>fulcrum</code>. JCS will store the objects in a group named <code>default_group</code> in that
region. The configuration file parameter gives the location of the JCS configuration file. Please
note that JCS uses a class loader to read this file, so make sure this path is part of your classpath.
- The default values of all configuration settings are shown in the example.
+ The default values of all configuration settings are shown in the example.
See <a href="http://jakarta.apache.org/jcs/">the JCS site</a> for more information about configuring
JCS.
</p>
@@ -176,11 +194,11 @@
You can also place an expiration time on your objects so the Service will
automatically remove them when they expire. If you don't specify an expiration
time, the DefaultGlobalCacheService uses 5 seconds. For JCS this value depends on values set
- in the cache configuration file. To see an example, look at the
+ in the cache configuration file. To see an example, look at the
test case <a href="xref-test/org/apache/fulcrum/cache/CacheTest.html">CacheTest</a>
</p>
- </section>
+ </section>
</body>
</document>
Modified: jakarta/turbine/fulcrum/trunk/cache/xdocs/navigation.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/xdocs/navigation.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/xdocs/navigation.xml (original)
+++ jakarta/turbine/fulcrum/trunk/cache/xdocs/navigation.xml Fri May 4 23:58:06 2007
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
<project
name="cache"
href="http://jakarta.apache.org/turbine/fulcrum/cache/">
@@ -10,11 +28,11 @@
<item name="Fulcrum"
href="http://jakarta.apache.org/turbine/fulcrum/"/>
<item name="EHCache"
- href="http://ehcache.sourceforge.net/"/>
+ href="http://ehcache.sourceforge.net/"/>
</links>
<menu name="Overview">
<item name="Main" href="/index.html"/>
</menu>
</body>
-</project>
\ No newline at end of file
+</project>
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/maven.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/maven.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/maven.xml (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/maven.xml Fri May 4 23:58:06 2007
@@ -1,3 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
<project default="local:build" xmlns:deploy="deploy" xmlns:ant="jelly:ant">
<!-- ################################################################## -->
@@ -12,7 +31,7 @@
<ant:fileset dir="${basedir}/temp">
<ant:include name="*.eml" />
</ant:fileset>
- </ant:delete>
+ </ant:delete>
</postGoal>
</project>
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/project.properties
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/project.properties?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/project.properties (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/project.properties Fri May 4 23:58:06 2007
@@ -1 +1,17 @@
+# 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.
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/project.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/project.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/project.xml (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/project.xml Fri May 4 23:58:06 2007
@@ -1,11 +1,29 @@
<?xml version="1.0"?>
+<!--
+ 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.
+-->
<project>
<extend>${basedir}/../project.xml</extend>
<id>fulcrum-commonsemail</id>
<name>Fulcrum CommonsEmail Service</name>
<currentVersion>1.0.1-dev</currentVersion>
-
+
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
@@ -34,7 +52,7 @@
<version>1.3.3</version>
<url>http://java.sun.com/products/javamail/</url>
<properties/>
- </dependency>
+ </dependency>
<!-- Needed only for testing -->
<dependency>
<groupId>fulcrum</groupId>
@@ -47,5 +65,5 @@
<version>1.0.4</version>
</dependency>
</dependencies>
-
+
</project>
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties Fri May 4 23:58:06 2007
@@ -1,3 +1,19 @@
+# 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.
#
# Root Appenders
#
@@ -16,4 +32,4 @@
# Supress messages
#
-log4j.logger.org.pdfbox=WARN
\ No newline at end of file
+log4j.logger.org.pdfbox=WARN
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java Fri May 4 23:58:06 2007
@@ -1,20 +1,22 @@
package org.apache.fulcrum.commonsemail;
/*
- * Copyright 2004 Apache Software Foundation
- * Licensed 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
+ * 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.
+ * 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.
*/
import java.util.Hashtable;
@@ -32,7 +34,7 @@
/**
* A service taking care of most of the commons-email configuration such as
- *
+ *
* <ul>
* <li>authentication</li>
* <li>mail session</li>
@@ -45,28 +47,28 @@
public interface CommonsEmailService
{
/**
- * Determines if any email for the given domain name will
+ * Determines if any email for the given domain name will
* be sent or silently consumed by the service without
* delivering it.
- *
+ *
* @param domainName the domain name
* @return true if the email will not be sent by the service
*/
boolean isMailDoNotSend(String domainName);
-
+
/**
* Factory method to create a mail session based on the domain configuration.
- *
+ *
* @param domainName the domain name
* @return a mail session
*/
Session createSmtpSession(String domainName);
/**
- * Factory method to create a mail session based on the domain configuration
+ * Factory method to create a mail session based on the domain configuration
* and a user-supplied username and password. We assume that SMTP AUTH is
* used.
- *
+ *
* @param domainName the domain name
* @param username the user name used for SMTP authentication
* @param password the password used for SMTP authentication
@@ -77,7 +79,7 @@
/**
* Factory method for creating a SimpleEmail with fully
* configured mail session based on the domain configuration.
- *
+ *
* @param domainName the sender of the email
* @return a SimpleEmail
* @throws EmailException creation failed
@@ -86,8 +88,8 @@
throws EmailException;
/**
- * Factory method for creating a SimpleEmail
- *
+ * Factory method for creating a SimpleEmail
+ *
* @param domainName the sender of the email
* @param content the content of the email
* @return a SimpleEmail
@@ -99,7 +101,7 @@
/**
* Factory method for creating a MultiPartEmail with fully
* configured mail session based on the domain configuration.
- *
+ *
* @param domainName the sender of the email
* @return a MultiPartEmail
* @throws EmailException creation failed
@@ -108,8 +110,8 @@
throws EmailException;
/**
- * Factory method for creating a MultiPartEmail
- *
+ * Factory method for creating a MultiPartEmail
+ *
* @param domainName the sender of the email
* @param content the content of the email
* @return a MultiPartEmail
@@ -121,7 +123,7 @@
/**
* Factory method for creating a HtmlEmail with fully
* configured mail session based on the domain configuration.
- *
+ *
* @param domainName the sender of the email
* @return a MultiPartEmail
* @throws EmailException creation failed
@@ -130,8 +132,8 @@
throws EmailException;
/**
- * Factory method for creating a HtmlEmail
- *
+ * Factory method for creating a HtmlEmail
+ *
* @param domainName the sender of the email
* @param content the content of the email
* @return a MultiPartEmail
@@ -144,21 +146,21 @@
* Sends an email using the service instead of calling send()
* directly on the Email. This allows to overwrite the receivers
* of the email as an additional security measure for sending
- * thousands of emails using real-world email addresses.
- *
+ * thousands of emails using real-world email addresses.
+ *
* @param domainName the sender of the email
* @param email the email to be sent
* @return the MimeMessage being sent
* @throws EmailException sending the email failed
*/
- MimeMessage send(String domainName, Email email)
+ MimeMessage send(String domainName, Email email)
throws EmailException;
-
+
/**
* Sends an email using the service instead of calling send()
* directly on the Email. The implementation uses the
* the from email address as domain name.
- *
+ *
* @param email the email to be sent
* @return the MimeMessage being sent
* @throws EmailException sending the email failed
@@ -166,26 +168,26 @@
MimeMessage send(Email email) throws EmailException;
/**
- * Sends a MimeMessage using the service instead of calling
+ * Sends a MimeMessage using the service instead of calling
* Transport.send(). This allows to overwrite the receivers
* of the email as an additional security measure for sending
- * thousands of emails using real-world email addresses.
- *
+ * thousands of emails using real-world email addresses.
+ *
* @param domainName the sender of the email
* @param session the email session
* @param mimeMessage the email to be sent
* @return the MimeMessage being sent
* @throws MessagingException sending the email failed
*/
- MimeMessage send(String domainName, Session session, MimeMessage mimeMessage)
- throws MessagingException;
+ MimeMessage send(String domainName, Session session, MimeMessage mimeMessage)
+ throws MessagingException;
/**
- * Sends a MimeMessage using the service instead of calling
+ * Sends a MimeMessage using the service instead of calling
* Transport.send(). This allows to overwrite the receivers
* of the email as an additional security measure for sending
- * thousands of emails using real-world email addresses.
- *
+ * thousands of emails using real-world email addresses.
+ *
* @param domainName the sender of the email
* @param session the email session
* @param mimeMessage the email to be sent
@@ -193,20 +195,20 @@
* @return the MimeMessage being sent
* @throws MessagingException sending the email failed
*/
- MimeMessage send(String domainName, Session session, MimeMessage mimeMessage, Address[] recipients)
- throws MessagingException;
+ MimeMessage send(String domainName, Session session, MimeMessage mimeMessage, Address[] recipients)
+ throws MessagingException;
/**
- * Sends a MimeMessage using the service instead of calling
+ * Sends a MimeMessage using the service instead of calling
* Transport.send(). This allows to overwrite the receivers
* of the email as an additional security measure for sending
- * thousands of emails using real-world email addresses.
- *
+ * thousands of emails using real-world email addresses.
+ *
* @param session the email session
* @param mimeMessage the email to be sent
* @return the MimeMessage being sent
* @throws MessagingException sending the email failed
*/
- MimeMessage send(Session session, MimeMessage mimeMessage)
- throws MessagingException;
-}
\ No newline at end of file
+ MimeMessage send(Session session, MimeMessage mimeMessage)
+ throws MessagingException;
+}
Modified: jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailConstants.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailConstants.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailConstants.java (original)
+++ jakarta/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailConstants.java Fri May 4 23:58:06 2007
@@ -1,35 +1,37 @@
-package org.apache.fulcrum.commonsemail.impl;
-
-/*
- * Copyright 2004 Apache Software Foundation
- * Licensed 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.
- */
-
-
-/**
- * Contains all transport releated session properties for javamail-1.3.3.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-
-public interface CommonsEmailConstants extends CommonsEmailSmtpConstants
-{
- /** Specifies the initial debug mode. */
- public static final String MAIL_DEBUG = "mail.debug";
-
- /** Specifies the default Transport Protocol. */
- public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
-}
-
+package org.apache.fulcrum.commonsemail.impl;
+
+/*
+ * 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.
+ */
+
+
+/**
+ * Contains all transport releated session properties for javamail-1.3.3.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+
+public interface CommonsEmailConstants extends CommonsEmailSmtpConstants
+{
+ /** Specifies the initial debug mode. */
+ public static final String MAIL_DEBUG = "mail.debug";
+
+ /** Specifies the default Transport Protocol. */
+ public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org