[jboss-cvs] JBossAS SVN: r60219 - in branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field: deprec and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 2 16:50:23 EST 2007


Author: bstansberry at jboss.com
Date: 2007-02-02 16:50:22 -0500 (Fri, 02 Feb 2007)
New Revision: 60219

Added:
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/bindSession.jsp
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/getAttribute.jsp
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifyAttribute.jsp
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifySubject.jsp
   branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/setSession.jsp
Log:
Test both marker interface-based and annotation-based FIELD instrumentation

Added: branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/bindSession.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/bindSession.jsp	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/bindSession.jsp	2007-02-02 21:50:22 UTC (rev 60219)
@@ -0,0 +1,62 @@
+<%@page contentType="text/html"
+   import="java.util.*, 
+   org.jboss.test.cluster.web.aop.deprec.AopBindingListener"
+%>
+
+<html>
+<%
+   String resp = "FAILED";
+   AopBindingListener listener = new AopBindingListener();
+%>
+
+<% 
+   String bind = (String)request.getParameter("Binding");
+   if( "new".equals(bind) ) {
+      session.setAttribute("binding", listener);
+      try {
+         Thread.sleep(1000);
+      } catch (Exception ex) {}
+
+      if( listener.getValueBound() ) {
+         resp = "OK";
+      }
+   } 
+   else if ( "replace".equals(bind) ) {
+      listener = (AopBindingListener)session.getAttribute("binding");
+      session.setAttribute("binding", new AopBindingListener());
+      try {
+         Thread.sleep(1000);
+      } catch (Exception ex) {}
+
+      if( listener.getValueUnBound() ) {
+         resp = "OK";
+      }
+   } 
+   else if ( "rebind".equals(bind) ){
+      // JBAS-2381 -- if we rebind the same object 
+      // we should not get a valueUnbound()
+      listener = (AopBindingListener)session.getAttribute("binding");
+      session.setAttribute("binding", listener);
+      try {
+         Thread.sleep(1000);
+      } catch (Exception ex) {}
+
+      if( listener.getValueUnBound() == false ) {
+         resp = "OK";
+      }
+   } 
+   else if ( "remove".equals(bind) ) {
+      listener = (AopBindingListener)session.getAttribute("binding");
+      session.removeAttribute("binding");
+      try {
+         Thread.sleep(1000);
+      } catch (Exception ex) {}
+
+      if( listener.getValueUnBound() ) {
+         resp = "OK";
+      }
+   }
+%>
+
+<%=resp%>
+</html>

Added: branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/getAttribute.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/getAttribute.jsp	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/getAttribute.jsp	2007-02-02 21:50:22 UTC (rev 60219)
@@ -0,0 +1,39 @@
+<%@page contentType="text/html"
+   import="java.util.*, 
+   javax.servlet.ServletContext, 
+   org.jboss.test.cluster.web.CacheHelper, 
+   org.jboss.test.cluster.web.aop.deprec.*"
+%>
+
+<%
+   String isNew = session.isNew() ? "true" : "false";
+   response.setHeader("X-SessionIsNew", isNew);
+   
+   Student ben = (Student)session.getAttribute("TEST_PERSON");
+   String flag = ben != null ? "true" : "false";
+   response.setHeader("X-SawTestHttpAttribute", flag);
+   Address addr = (Address)ben.getAddress();
+      flag = addr != null ? "true" : "false";
+      response.setHeader("X-SawTestHttpAttribute", flag);
+
+   Student jane = (Student)session.getAttribute("WIFE");
+   Collection col = jane.getCourses();
+   Course first = null;
+   if(!(col == null || col.size() == 0))
+   {
+      first = (Course)col.iterator().next();
+   } else
+   {
+      throw new RuntimeException("getAttribute(): Empty course from student jane.");
+   }
+
+   // Bind ben to the servlet context as well so it can be
+   // accessed later without involving the session
+   ServletContext ctx = getServletConfig().getServletContext();
+   ctx.setAttribute("TEST_PERSON", ben);
+%>
+
+<%=ben.getName() %>
+<%=addr.getZip() %>
+<%=ben.getLanguages() %>
+<%=first.getInstructor() %>

Added: branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifyAttribute.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifyAttribute.jsp	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifyAttribute.jsp	2007-02-02 21:50:22 UTC (rev 60219)
@@ -0,0 +1,29 @@
+<%@page contentType="text/html"
+   import="java.util.*, 
+   javax.servlet.ServletContext, 
+   org.jboss.test.cluster.web.aop.deprec.*"
+%>
+
+<% 
+   // Note: The name are hard-coded in the test case as well!!!
+   // POJO modify no need to do setAttribute again!
+   Student ben = (Student)session.getAttribute("TEST_PERSON");
+   ben.setName("Joe");
+   ben.setAge(60);
+   ben.getAddress().setZip(94086);
+
+   Student jane = (Student)session.getAttribute("WIFE");
+   if( jane.getAddress().getZip() != 94086 )
+   {
+      throw new RuntimeException("modifyAttribute(): address zip is not modified properly.");
+   }
+
+   List lang = new ArrayList();
+   lang.add("English");
+   lang.add("Holo");
+   ben.setLanguages(lang);
+
+   Collection col = ben.getCourses();
+   Course first = (Course)col.iterator().next();
+   first.setInstructor("White");
+%>

Added: branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifySubject.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifySubject.jsp	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/modifySubject.jsp	2007-02-02 21:50:22 UTC (rev 60219)
@@ -0,0 +1,16 @@
+<%@page contentType="text/html"
+   import="java.util.*, 
+   javax.servlet.ServletContext, 
+   org.jboss.test.cluster.web.aop.deprec.*, 
+   java.security.SecureRandom"
+%>
+
+<% 
+   // Modify the POJO that was bound to the servlet context and
+   // to the session as well.  Only access it via the servlet context
+   // so we can check whether modifying it causes the session
+   // to be replicated.
+   ServletContext ctx = getServletConfig().getServletContext();
+   Person ben = (Person)ctx.getAttribute("TEST_PERSON");
+   ben.setAge(ben.getAge() + new SecureRandom().nextInt(10));
+%>

Added: branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/setSession.jsp
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/setSession.jsp	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/http/http-field/deprec/setSession.jsp	2007-02-02 21:50:22 UTC (rev 60219)
@@ -0,0 +1,47 @@
+<%@page contentType="text/html"
+   import="java.util.*, 
+   javax.servlet.ServletContext, 
+   org.jboss.test.cluster.web.aop.deprec.*"
+%>
+
+<html>
+<center>
+<% 
+   String id=request.getSession().getId();
+   session.setAttribute("TEST_ID",id); 
+   Student ben=new Student();
+   Student jane=new Student();
+   Address addr = new Address();
+   addr.setZip(95123);
+   addr.setCity("San Jose");
+   ben.setAge(100);
+   ben.setName("Ben");
+   ben.setAddress(addr);
+   jane.setAge(50);
+   jane.setName("Jane");
+   jane.setAddress(addr);
+
+   Course foo = new Course();
+   foo.setTitle("Intro to Foo");
+   foo.setInstructor("Jones");
+
+   ben.addCourse(foo);
+   jane.addCourse(foo);
+
+   session.setAttribute("TEST_PERSON", ben);
+   session.setAttribute("WIFE", jane);
+
+   Collection col = ben.getCourses();
+   Course first = (Course)col.iterator().next();
+   first.setInstructor("Black");
+
+   // Bind ben to the servlet context as well so it can be
+   // accessed without involving the session
+   ServletContext ctx = getServletConfig().getServletContext();
+   ctx.setAttribute("TEST_PERSON", ben);
+   ctx.setAttribute("WIFE", jane);
+%>
+<%=id%>
+
+<h1><%=application.getServerInfo()%>:<%=request.getServerPort()%></h1>
+</html>




More information about the jboss-cvs-commits mailing list