jakarta-watchdog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sant...@locus.apache.org
Subject cvs commit: jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples ExampleTagBase.java FooTagExtraInfo.java LifeCycleTag.java PageTag.java TestTag.java TestTagExtraInfo.java
Date Tue, 03 Oct 2000 23:36:13 GMT
santosh     00/10/03 16:36:13

  Added:       src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples
                        ExampleTagBase.java FooTagExtraInfo.java
                        LifeCycleTag.java PageTag.java TestTag.java
                        TestTagExtraInfo.java
  Log:
  watchdog 4.0
  
  Revision  Changes    Path
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/ExampleTagBase.java
  
  Index: ExampleTagBase.java
  ===================================================================
  package examples;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  public abstract class ExampleTagBase 
  
  implements Tag {
  
      public void setParent(Tag parent) {
          this.parent = parent;
      }
  
      public void setBodyContent(BodyContent bodyOut) {
          this.bodyOut = bodyOut;
      }
  
      public void setPageContext(PageContext pageContext) {
          this.pageContext = pageContext;
      }
  
      public Tag getParent() {
          return this.parent;
      }
      
      public int doStartTag() throws JspException {
          return SKIP_BODY;
      }
  
      public int doEndTag() throws JspException {
          return EVAL_PAGE;
      }
      
  
      // Default implementations for BodyTag methods as well
      // just in case a tag decides to implement BodyTag.
  
      public void doInitBody() throws JspException {
      }
  
  
  
      public int doAfterBody() throws JspException {
          return SKIP_BODY;
      }
  
      public void release() {
          bodyOut = null;
          pageContext = null;
          parent = null;
      }
      
      protected BodyContent bodyOut;
      protected PageContext pageContext;
      protected Tag parent;
  }
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/FooTagExtraInfo.java
  
  Index: FooTagExtraInfo.java
  ===================================================================
  package examples;
  
  import javax.servlet.jsp.tagext.*;
  
  public class FooTagExtraInfo extends TagExtraInfo {
      public VariableInfo[] getVariableInfo(TagData data) {
          return new VariableInfo[] 
              {
                  new VariableInfo("member",
                                   "String",
                                   true,
                                   VariableInfo.NESTED)
              };
      }
  }
  
          
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/LifeCycleTag.java
  
  Index: LifeCycleTag.java
  ===================================================================
  package examples;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import java.io.IOException;
  
  /**
   * LifeCycleTag class is used to tests tagext API's 
   */
  public class LifeCycleTag  extends ExampleTagBase 
      implements BodyTag {
  
  
      boolean toBrowser = false;
      String TestString="";
      String endString=" method <br>";
      private String atts1,atts2,atts3,atts4,atts5,atts6;
      int count=0;
     
   
      
      // setting the value from jsp att1,att1 from JSP test case 
      public void setAtt1(String value) {
          atts1 = value;
      }
    
      public String getAtt1() {
      	return atts1;
       }
      
  
      public void setAtt2(String value) {
          atts2 = value;
      }
    
      public String getAtt2() {
      	return atts2;
       }
       
  
      public void setAtt3(String value) {
          atts3 = value;
      }
    
      public String getAtt3() {
      	return atts3;
       }
      
  
      public void setAtt4(String value) {
          atts4 = value;
      }
    
      public String getAtt4() {
      	return atts4;
       }
  
      public void setAtt5(String value) {
          atts5 = value;
      }
    
      public String getAtt5() {
      	return atts5;
       }
      
  
      public void setAtt6(String value) {
          atts6 = value;
      }
    
      public String getAtt6() {
      	return atts6;
       }
       
       
       
       
       
       
  
    
      public void setToBrowser(String value) {
          if (value == null)
              toBrowser = false;
          else if (value.equalsIgnoreCase("true"))
              toBrowser = true;
          else
              toBrowser = false;
      }
  
  // Test for setPageContext in TagSupport class.
  		public void setPageContext(PageContext pc) {
  if ("pageContext".equalsIgnoreCase (this.getAtt1())) {
  	 
  	TestString = TestString + this.getAtt1() + endString;
  	}
  }
  
  	
  // Test for doStartTag method in TagSupport class.
  
      public int doStartTag() {
         if ("doStartTag".equalsIgnoreCase (this.getAtt2())) { 
  	TestString = TestString + this.getAtt2() + endString;
   
   
  } // if condition
  return EVAL_BODY_TAG;
  }
      
  // Test for doInitBody method in BodyTagsupport class     
      public void doInitBody() throws JspException {
         if ("doInitBody".equalsIgnoreCase (this.getAtt3())) { 
  		TestString = TestString + this.getAtt3() + endString;
  		}
  	}
  
  //Test for doAfterBody method in BodyTagSupport class
      
      public int doAfterBody() throws JspException {
          try {
  
         if ("doAfterBody".equalsIgnoreCase (this.getAtt4())) { 
  		TestString = TestString + this.getAtt4() + endString;
          }
              String s = bodyOut.getString();
              System.err.println(s);
              if (false)
              	bodyOut.println(TestString);
              return SKIP_BODY;
          } catch (IOException ex) {
              throw new JspException(ex.toString());
          }
      }
      
  // Test for doEndTag method in BodyTagSupport class
      
      public int doEndTag() throws JspException{
      	
         if ("doEndTag".equalsIgnoreCase (this.getAtt5())) { 
  	TestString = TestString + this.getAtt5() + endString;
  		} 
         return EVAL_PAGE;	
      }	
  
  
  // Test for release method in BodyTagSupport class
  
      public void release() {
         if ("release".equalsIgnoreCase (this.getAtt6())) { 
   	TestString = TestString + this.getAtt6() + endString;
  
         	} 
  
      try {
      
          if (toBrowser)
              bodyOut.println(TestString);
       		bodyOut.writeOut(bodyOut.getEnclosingWriter());
       } catch (IOException ioe) {}
  
      }	
  
  
  
  }
  
      
          
      
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/PageTag.java
  
  Index: PageTag.java
  ===================================================================
  package examples;
  
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import java.io.IOException;
  
  /**
   * PageTag class is used to tests tagext API's
   */
  public class PageTag extends ExampleTagBase  implements BodyTag {
  
      boolean toBrowser = false;
      String TestString="";
      private String atts1,atts2;
  
  	String PageString="";
  
      // setting the value from jsp att1
  
  
      public void setAtt1(String value) {
          atts1 = value;
      }
  
      public String getAtt1() {
      	return atts1;
       }
  
  
      public void setAtt2(String value) {
          atts2 = value;
      }
  
      public String getAtt2() {
      	return atts2;
       }
  
  
      public void setToBrowser(String value) {
          if (value == null)
              toBrowser = false;
          else if (value.equalsIgnoreCase("true"))
              toBrowser = true;
          else
              toBrowser = false;
      }
  
  // Test for setPageContext in TagSupport class.
  		public void setPageContext(PageContext pc) {
  		pc.setAttribute("name","pageContext");
  		PageString = (String)pc.getAttribute("name");
  
  
  		}
  
      public int doStartTag() {
      	       if ("doStartTag".equalsIgnoreCase (this.getAtt1())) {
         		   		 TestString += this.getAtt1();
  				}
  
  				if("pageContext".equalsIgnoreCase(this.getAtt1())){
  					TestString=TestString+PageString;
  				}
  
          return EVAL_BODY_TAG;
      }
  
  
      public void doInitBody() throws JspException {
      }
  
  
  
      public int doAfterBody() throws JspException {
          try {
  
  
              String s = bodyOut.getString();
              System.err.println(s);
  
              if (toBrowser)
              	bodyOut.println(TestString);
       			bodyOut.writeOut(bodyOut.getEnclosingWriter());
              return SKIP_BODY;
          } catch (IOException ex) {
              throw new JspException(ex.toString());
          }
      }
  
  }
  
  
  
  
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/TestTag.java
  
  Index: TestTag.java
  ===================================================================
  package examples;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import java.io.IOException;
  
  /**
   * TestTag class is used to tests tagext API's
   */
  public class TestTag  extends ExampleTagBase
      implements BodyTag {
  
  
      boolean toBrowser = false;
      String TestString="";
      private String atts1,atts2;
      int count=0;
      TestTagExtraInfo ftet;
  
  
      // setting the value from jsp att1,att1 from JSP test case
      public void setAtt1(String value) {
          atts1 = value;
      }
  
      public String getAtt1() {
      	return atts1;
       }
  
  
      public void setAtt2(String value) {
          atts2 = value;
      }
  
      public String getAtt2() {
      	return atts2;
       }
  
  
      public void setToBrowser(String value) {
          if (value == null)
              toBrowser = false;
          else if (value.equalsIgnoreCase("true"))
              toBrowser = true;
          else
              toBrowser = false;
      }
  
  // Test for setPageContext in TagSupport class.
  		public void setPageContext(PageContext pc) {
  
  			pc.setAttribute("name","pageContext");
  		}
  
  // Test for doStartTag method in TagSupport class.
      public int doStartTag() {
         if ("doStartTag".equalsIgnoreCase (this.getAtt1())) {
  
  // Test for methods in variableInfo class.
  
  // Creating a hashttable to be passed TagData constructor,
     java.util.Hashtable ht = new java.util.Hashtable();
  	ht.put("a1","98.5");
  	ht.put("a2","107.1");
  	ht.put("a3","105.1");
  
  	TagData td = new TagData(ht);
  
  
      ftet = new TestTagExtraInfo();
      VariableInfo[] vi = ftet.getVariableInfo(td);
      BodyTagSupport bts = new BodyTagSupport();
  
  	if(this.getAtt2().equals("getClassName")) {
  	TestString = TestString + vi[0].getClassName();
  	} else if (this.getAtt2().equals("getDeclare")) {
  	TestString = TestString + vi[0].getDeclare();
  	} else if (this.getAtt2().equals("getScope")) {
  	TestString = TestString + vi[0].getScope();
  	} else if (this.getAtt2().equals("getVarName")) {
  	TestString = TestString + vi[0].getVarName();
  	}
  
  
  
  } // if condition
  return EVAL_BODY_TAG;
  }
  
  // Test for doInitBody method in BodyTagsupport class
  
      public void doInitBody() throws JspException {
  
  		TestTagExtraInfo texInfo=new TestTagExtraInfo();
  		TagInfo tagInfo=texInfo.getInfoObj();
  		TagLibraryInfo tlibInfo=tagInfo.getTagLibrary();
  		TagAttributeInfo[] tagAttrInfo=tagInfo.getAttributes();
  
  
  		//Checking for TagAttributeInfo methods
  
  		if("getName".equalsIgnoreCase(this.getAtt1()))
  			if(tagAttrInfo[0].getName().equalsIgnoreCase("toBrowser"))
  				TestString=TestString+"getName";
  
  		if("getTypeName".equalsIgnoreCase(this.getAtt1()))
  			if(tagAttrInfo[0].getTypeName().equalsIgnoreCase("java.lang.String"))
  				TestString=TestString+"getTypeName";
  
  
  		if("isRequired".equalsIgnoreCase(this.getAtt1()))
  			if(tagAttrInfo[0].isRequired() == false)
  				TestString=TestString+"isRequired";
  
  
  		if("getIdAttribute".trim().equalsIgnoreCase(this.getAtt1()))
  			if(tagAttrInfo[0].getIdAttribute(tagAttrInfo).getName().equalsIgnoreCase("id") )
  				TestString=TestString+"getIdAttribute";
  
  		if("canBeRequestTime".trim().equalsIgnoreCase(this.getAtt1()))
  			if(tagAttrInfo[0].canBeRequestTime() == false)
  				TestString=TestString+"canBeRequestTime";
  
  
  		//Checking for TagLibraryInfo methods
  
  		String info="A simple tag library for the examples";
  		String uri="/WEB-INF/classes/jsp/example-taglib.tld";
  
  		if("getInfoString".equalsIgnoreCase(this.getAtt1())){
  
  			if(tlibInfo.getInfoString().trim().equalsIgnoreCase(info))
  				TestString=TestString+this.getAtt1();
  		}
  
  		if("getPrefixString".equalsIgnoreCase(this.getAtt1()))
  			if(tlibInfo.getPrefixString().equalsIgnoreCase("eg"))
  				TestString=TestString+this.getAtt1();
  
  		if("getReliableURN".equalsIgnoreCase(this.getAtt1()))
  			if(tlibInfo.getReliableURN().equalsIgnoreCase("1.0"))
  				TestString=TestString+this.getAtt1();
  
  
  		if("getRequiredVersion".equalsIgnoreCase(this.getAtt1()))
  			if(tlibInfo.getRequiredVersion().equalsIgnoreCase("1.1"))
  				TestString=TestString+this.getAtt1();
  
  		if("getShortName".equalsIgnoreCase(this.getAtt1()))
  			if(tlibInfo.getShortName().equalsIgnoreCase("simple"))
  				TestString=TestString+this.getAtt1();
  
  		if("getURI".equalsIgnoreCase(this.getAtt1())){
  
  			if(tlibInfo.getURI().equalsIgnoreCase(uri))
  				TestString=TestString+this.getAtt1();
  
  		}
  
  		//Checking for tagInfo object by calling one of its methods.
  
  		if("getTag".equalsIgnoreCase(this.getAtt1())){
  
  			if(tlibInfo.getTag("test").getTagName().equalsIgnoreCase("test"))
  				TestString=TestString+this.getAtt1();
  
  		}
  
  		//Checking for the no of tags defined in the tld using
  		// the array returned.
  
  		if("getTags".equalsIgnoreCase(this.getAtt1())){
  				if(tlibInfo.getTags().length == 5)
  					TestString=TestString+this.getAtt1();
  		}
  
  		//Checking for TagExtraInfo methods
  
  		if("getTagInfo".equalsIgnoreCase(this.getAtt1()))
  			TestString =TestString+texInfo.getRes();
  
  		if("isValid".equalsIgnoreCase(this.getAtt1())){
  			TestString =TestString+texInfo.getRes1();
  		}
  		if("setTagInfo".equalsIgnoreCase(this.getAtt1()))
  			TestString =TestString+texInfo.getRes2();
  
  		if("getVariableInfo".equalsIgnoreCase(this.getAtt1()))
  			TestString =TestString+texInfo.getRes3();
  
        //Test for doInitBody method.
  
          if ("doInitBody".equalsIgnoreCase (this.getAtt1())) {
         		TestString +=this.getAtt1(); }
  
  // Test for getParent method in TagSupport
  
       	if ("getParent".equalsIgnoreCase (this.getAtt2())) {
         		TagSupport ts = new TagSupport();
         		setParent(this);
         		Tag tt = getParent();
  			if(tt.toString().regionMatches(true,9,"examples.TestTag",9,7)) {
         			TestString = TestString + "Pass";
         		}
         		else {
         			TestString = TestString + "Fails";
         		}
  		}
  	}
  
  //Test for doAfterBody method in BodyTagSupport class
  
      public int doAfterBody() throws JspException {
  
  
          try {
  
         if ("doAfterBody".equalsIgnoreCase (this.getAtt1())) {
              TestString += this.getAtt1();
          }
              String s = bodyOut.getString();
              System.err.println(s);
              if (false)
              	bodyOut.println(TestString);
              return SKIP_BODY;
          } catch (IOException ex) {
              throw new JspException(ex.toString());
          }
      }
  
  // Test for doEndTag method in BodyTagSupport class
  
      public int doEndTag() throws JspException{
  
  
         if ("doEndTag".equalsIgnoreCase (this.getAtt1())) {
         	TestString +=this.getAtt1();
  		}
         return EVAL_PAGE;
      }
  
  
  // Test for release method in BodyTagSupport class
  
      public void release() {
         if ("release".equalsIgnoreCase (this.getAtt1())) {
         		TestString +=this.getAtt1();
         	}
          try {
              if (toBrowser)
              bodyOut.println(TestString);
       	    bodyOut.writeOut(bodyOut.getEnclosingWriter());
  	    toBrowser = false;
  	    //TestString="";
              atts1="";
              atts2="";
              count=0;
       	} catch (IOException ioe) {}
      }
  }
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/jsp/tags/examples/TestTagExtraInfo.java
  
  Index: TestTagExtraInfo.java
  ===================================================================
   /*
   * This is a hack on a hack.  We are trying to create a new TestTagExtraInfo that
   * will pass the tests  - epll.  May 21st, 2000
   */
  
  package examples;
  
  import javax.servlet.jsp.tagext.*;
  
  public class TestTagExtraInfo extends TagExtraInfo {
  
  	static String res1="";
  	static String res2="";
  	static String res3="";
  	static String res="";
  	static TagInfo tgInfo;
  
  
  	public TestTagExtraInfo(){}
  
  	public boolean isValid(TagData tagData){
  		res1="isValid";
  		String att=tagData.getAttributeString("att1");
  		String id=tagData.getId();
  
  		// Add the following patch - epll.
  
  		res = "getTagInfo";
  		res2 = "setTagInfo";
  		this.tgInfo = this.getTagInfo();
  
  		// up to here is the new patch
  		return true;
  	}
  
  
  	public VariableInfo[] getVariableInfo(TagData data) {
  		res3="getVariableInfo";
           return new VariableInfo[] {
                  new VariableInfo("member",
                                   "String",
                                   true,
                                   VariableInfo.NESTED)
              };
      }
  
  
      public String getRes(){
  		return res;
  	}
  
  	public String getRes1(){
  			return res1;
  	}
  
  	public String getRes2(){
  			return res2;
  	}
  
  	public String getRes3(){
  			return res3;
  	}
  
  	public TagInfo getInfoObj(){
  		return this.tgInfo;
  	}
  }
  
  
  

Mime
View raw message