You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/08/04 22:52:10 UTC
svn commit: r1154008 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments:
AttachmentCacheMonitorTest.java AttachmentsTest.java
Author: veithen
Date: Thu Aug 4 20:52:10 2011
New Revision: 1154008
URL: http://svn.apache.org/viewvc?rev=1154008&view=rev
Log:
Moved testCachedFilesExpired to a separate test class. It is not testing anything in Attachments.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java?rev=1154008&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java Thu Aug 4 20:52:10 2011
@@ -0,0 +1,96 @@
+/*
+ * 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.axiom.attachments;
+
+import java.io.File;
+
+import org.apache.axiom.om.AbstractTestCase;
+
+public class AttachmentCacheMonitorTest extends AbstractTestCase {
+ public void testCachedFilesExpired() throws Exception {
+
+ // Set file expiration to 10 seconds
+ long INTERVAL = 3 * 1000; // 3 seconds for Thread to sleep
+
+
+ // Get the AttachmentCacheMonitor and force it to remove files after
+ // 10 seconds.
+ AttachmentCacheMonitor acm = AttachmentCacheMonitor.getAttachmentCacheMonitor();
+ int previousTime = acm.getTimeout();
+
+ try {
+ acm.setTimeout(10);
+
+
+ File aFile = new File("A");
+ aFile.createNewFile();
+ String aFileName = aFile.getCanonicalPath();
+ acm.register(aFileName);
+
+ Thread.sleep(INTERVAL);
+
+ File bFile = new File("B");
+ bFile.createNewFile();
+ String bFileName = bFile.getCanonicalPath();
+ acm.register(bFileName);
+
+ Thread.sleep(INTERVAL);
+
+ acm.access(aFileName);
+
+ // time since file A registration <= cached file expiration
+ assertTrue("File A should still exist", aFile.exists());
+
+ Thread.sleep(INTERVAL);
+
+ acm.access(bFileName);
+
+ // time since file B registration <= cached file expiration
+ assertTrue("File B should still exist", bFile.exists());
+
+ Thread.sleep(INTERVAL);
+
+ File cFile = new File("C");
+ cFile.createNewFile();
+ String cFileName = cFile.getCanonicalPath();
+ acm.register(cFileName);
+ acm.access(bFileName);
+
+ Thread.sleep(INTERVAL);
+
+ acm.checkForAgedFiles();
+
+ // time since file C registration <= cached file expiration
+ assertTrue("File C should still exist", cFile.exists());
+
+ Thread.sleep(10* INTERVAL); // Give task loop time to delete aged files
+
+
+ // All files should be gone by now
+ assertFalse("File A should no longer exist", aFile.exists());
+ assertFalse("File B should no longer exist", bFile.exists());
+ assertFalse("File C should no longer exist", cFile.exists());
+ } finally {
+
+ // Reset the timeout to the previous value so that no
+ // other tests are affected
+ acm.setTimeout(previousTime);
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentCacheMonitorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=1154008&r1=1154007&r2=1154008&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java Thu Aug 4 20:52:10 2011
@@ -20,7 +20,6 @@ package org.apache.axiom.attachments;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@@ -444,75 +443,4 @@ public class AttachmentsTest extends Abs
public void testReadBase64EncodedAttachmentWithPartOnFile() throws Exception {
testReadBase64EncodedAttachment(true);
}
-
- public void testCachedFilesExpired() throws Exception {
-
- // Set file expiration to 10 seconds
- long INTERVAL = 3 * 1000; // 3 seconds for Thread to sleep
-
-
- // Get the AttachmentCacheMonitor and force it to remove files after
- // 10 seconds.
- AttachmentCacheMonitor acm = AttachmentCacheMonitor.getAttachmentCacheMonitor();
- int previousTime = acm.getTimeout();
-
- try {
- acm.setTimeout(10);
-
-
- File aFile = new File("A");
- aFile.createNewFile();
- String aFileName = aFile.getCanonicalPath();
- acm.register(aFileName);
-
- Thread.sleep(INTERVAL);
-
- File bFile = new File("B");
- bFile.createNewFile();
- String bFileName = bFile.getCanonicalPath();
- acm.register(bFileName);
-
- Thread.sleep(INTERVAL);
-
- acm.access(aFileName);
-
- // time since file A registration <= cached file expiration
- assertTrue("File A should still exist", aFile.exists());
-
- Thread.sleep(INTERVAL);
-
- acm.access(bFileName);
-
- // time since file B registration <= cached file expiration
- assertTrue("File B should still exist", bFile.exists());
-
- Thread.sleep(INTERVAL);
-
- File cFile = new File("C");
- cFile.createNewFile();
- String cFileName = cFile.getCanonicalPath();
- acm.register(cFileName);
- acm.access(bFileName);
-
- Thread.sleep(INTERVAL);
-
- acm.checkForAgedFiles();
-
- // time since file C registration <= cached file expiration
- assertTrue("File C should still exist", cFile.exists());
-
- Thread.sleep(10* INTERVAL); // Give task loop time to delete aged files
-
-
- // All files should be gone by now
- assertFalse("File A should no longer exist", aFile.exists());
- assertFalse("File B should no longer exist", bFile.exists());
- assertFalse("File C should no longer exist", cFile.exists());
- } finally {
-
- // Reset the timeout to the previous value so that no
- // other tests are affected
- acm.setTimeout(previousTime);
- }
- }
}