[richfaces-svn-commits] JBoss Rich Faces SVN: r2086 - in trunk: framework/test/src/test/java/org/ajax4jsf/resource and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 6 15:06:24 EDT 2007


Author: alexsmirnov
Date: 2007-08-06 15:06:24 -0400 (Mon, 06 Aug 2007)
New Revision: 2086

Modified:
   trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
   trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
   trunk/samples/scrollable-grid-demo/pom.xml
Log:
Fix thread problem in resource test. Add version number to a scrollable-grid-demo, remove unused package declaration

Modified: trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java	2007-08-06 18:55:20 UTC (rev 2085)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java	2007-08-06 19:06:24 UTC (rev 2086)
@@ -22,7 +22,6 @@
 import org.ajax4jsf.application.AjaxStateManager.TreeStrutureNode;
 import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
 
-import com.sun.media.sound.AlawCodec;
 
 /**
  * @author asmirnov

Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java	2007-08-06 18:55:20 UTC (rev 2085)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java	2007-08-06 19:06:24 UTC (rev 2086)
@@ -21,6 +21,10 @@
 
 package org.ajax4jsf.resource;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
 import javax.faces.context.FacesContext;
 
 import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
@@ -30,9 +34,10 @@
 
 /**
  * @author shura
- *
+ * 
  */
-public class ResourceServiceThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
+public class ResourceServiceThreadsTestCase extends
+		AbstractThreadedAjax4JsfTestCase {
 
 	/**
 	 * @param s
@@ -50,10 +55,12 @@
 		super.setUp();
 		service = new InternetResourceService();
 		MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
-		mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+		mockFilterConfig.setInitParameter(
+				InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
 		service.init(mockFilterConfig);
 		InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
-		resource = builder.createResource(this, MockCacheableResource.class.getName());
+		resource = builder.createResource(this, MockCacheableResource.class
+				.getName());
 		key = resource.getKey();
 	}
 
@@ -62,13 +69,12 @@
 		InternetResourceBuilder.setInstance(null);
 		resource = null;
 		service = null;
-		key=null;
+		key = null;
 	}
-	
+
 	public class ResourceRunner extends TestCaseRunnable {
-		
+
 		private String data;
-		
 
 		/**
 		 * @param data
@@ -78,31 +84,45 @@
 			this.data = data;
 		}
 
+		public void runTestCase(FacesContext context) throws Throwable {
+			MockHttpServletResponse response = new MockHttpServletResponse() {
+				/* (non-Javadoc)
+				 * @see org.apache.shale.test.mock.MockHttpServletResponse#addDateHeader(java.lang.String, long)
+				 * Default shale implementation is not thread-safe.
+				 */
+				public void addDateHeader(String name, long value) {
+					SimpleDateFormat format = new SimpleDateFormat(
+							"EEE, dd MMM yyyy HH:mm:ss zzz");
+					format.setTimeZone(TimeZone.getTimeZone("GMT"));
+					addHeader(name, format.format(new Date(value)));
+				}
 
-		public void runTestCase(FacesContext context) throws Throwable {
-			MockHttpServletResponse response = new MockHttpServletResponse();
+			};
 			MockHttpServletRequest req = new MockHttpServletRequest(session);
 			req.setServletContext(servletContext);
-			req.setPathElements(request.getContextPath(), request.getServletPath(), request.getPathInfo(), data);
+			req.setPathElements(request.getContextPath(), request
+					.getServletPath(), request.getPathInfo(), data);
 			MockResourceRequest resourceRequest = new MockResourceRequest(req);
-			service.serviceResource(key,resourceRequest,response);
-			byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
+			service.serviceResource(key, resourceRequest, response);
+			byte[] content = ((MockServletOutputStream) response
+					.getOutputStream()).content();
 			String strContent = new String(content);
 			assertEquals(strContent, "test");
-			
+
 		}
-		
+
 	}
-	
+
 	public void testTreadServiceResource() {
 		TestCaseRunnable[] runnables = new TestCaseRunnable[1000];
 		for (int i = 0; i < runnables.length; i++) {
-			runnables[i] = new ResourceRunner(String.valueOf(i%10));
-			
+			runnables[i] = new ResourceRunner(String.valueOf(i % 10));
+
 		}
 		this.runTestCaseRunnables(runnables);
 		int counter = ((MockCacheableResource) resource).getCounter();
-		assertTrue("Resource was generated "+counter+" times", counter<= 10);
+		assertTrue("Resource was generated " + counter + " times",
+				counter <= 10);
 
 	}
 }

Modified: trunk/samples/scrollable-grid-demo/pom.xml
===================================================================
--- trunk/samples/scrollable-grid-demo/pom.xml	2007-08-06 18:55:20 UTC (rev 2085)
+++ trunk/samples/scrollable-grid-demo/pom.xml	2007-08-06 19:06:24 UTC (rev 2086)
@@ -1,44 +1,47 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <parent>
-    <artifactId>samples</artifactId>
-    <groupId>org.richfaces</groupId>
-    <version>3.1.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>scrollable-grid-demo</artifactId>
-  <groupId>org.richfaces.samples</groupId>
-  <packaging>war</packaging>
-  <name>scrollable-grid-demo Maven Webapp</name>
-  <dependencies>
-    <dependency>
-      <groupId>org.richfaces.ui</groupId>
-      <artifactId>scrollable-grid</artifactId>
-      <version>3.1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.richfaces.samples</groupId>
-      <artifactId>skins</artifactId>
-      <version>3.1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-	<groupId>org.richfaces.ui</groupId>
-	<artifactId>core</artifactId>
-      <version>3.1.0-SNAPSHOT</version>
-    </dependency>
-  </dependencies>
-  
-  <build>
-    <finalName>scrollable-grid-demo</finalName>
-    <plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<configuration>
-					<source>1.5</source>
-					<target>1.5</target>
-				</configuration>
-			</plugin>
-		</plugins>
-    
-  </build>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>samples</artifactId>
+		<groupId>org.richfaces</groupId>
+		<version>3.1.0-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>scrollable-grid-demo</artifactId>
+	<groupId>org.richfaces.samples</groupId>
+	<version>3.1.0-SNAPSHOT</version>
+	<packaging>war</packaging>
+	<name>scrollable-grid-demo Maven Webapp</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.richfaces.ui</groupId>
+			<artifactId>scrollable-grid</artifactId>
+			<version>3.1.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.richfaces.samples</groupId>
+			<artifactId>skins</artifactId>
+			<version>3.1.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.richfaces.ui</groupId>
+			<artifactId>core</artifactId>
+			<version>3.1.0-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<finalName>scrollable-grid-demo</finalName>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+		</plugins>
+
+	</build>
 </project>
\ No newline at end of file




More information about the richfaces-svn-commits mailing list