incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r506298 [2/2] - in /incubator/xap/trunk: buildsystem/JSDoc-1.9.9.2/ codebase/src/xap/ codebase/src/xap/application/ codebase/src/xap/bridges/basic/ codebase/src/xap/bridges/dojo/ codebase/src/xap/bridges/google/ codebase/src/xap/bridges/mic...
Date Mon, 12 Feb 2007 05:53:13 GMT
Modified: incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/xmodify/CommandDirective.js Sun Feb 11 21:53:11
2007
@@ -21,7 +21,7 @@
 Xap.require("xap.xml.xmodify.XmodifyException");
 Xap.require("xap.xml.xmodify.UpdateDirective");
 Xap.require("xap.xml.dom.Document");
-Xap.require("xap.util.LogFactory");
+Xap.require("xap.log.Logger");
 Xap.require("google.xpath");
 Xap.require("xap.util.XapException");
  
@@ -64,6 +64,9 @@
 
 xap.xml.xmodify.CommandDirective = function(elemDirectiveElement, session)
 {
+	//enough logging in here to be worth it to save a reference
+	this._log = xap.xml.xmodify.CommandDirective.s_log;
+	
 	/* Call our superclass' xap.xml.xmodify.UpdateDirective */
 	xap.xml.xmodify.UpdateDirective.call( this, elemDirectiveElement );  
 	
@@ -82,7 +85,7 @@
 	this._session = session;  
 }
 
-xap.xml.xmodify.CommandDirective.s_log = xap.util.LogFactory.getLog( "xap.xml.xmodify.Xmodify"
);
+xap.xml.xmodify.CommandDirective.s_log = xap.log.Logger.getLogger( "xap.xml.xmodify.Xmodify"
);
 
 /**
  * Executes this command directive against the passed-in context node---
@@ -107,8 +110,8 @@
     
     //if we need a target and don't have one log a message and continue
     if ( needsTarget && ( this._commandTargets.length == 0 ) ){
-    	if (xap.xml.xmodify.CommandDirective.s_log.isDebug() && xap.util.LogFactory.s_loggingEnabled){
-			xap.xml.xmodify.CommandDirective.s_log.debug(xap.util.XapException.exceptionToString(
+    	if (this._log.isDebug()){
+			this._log.debug(xap.util.XapException.exceptionToString(
 				new xap.xml.xmodify.XmodifyException(
 					xap.xml.xmodify.XmodifyException.ZERO_RESULTS, 
 					this._selectAttr)
@@ -156,7 +159,7 @@
           this._handleSetInnerHtml(uiDocumentNode);
           break;                            	                               
         default: 
-	       if (xap.util.LogFactory.s_loggingEnabled) xap.xml.xmodify.UpdateDirective.s_log.debug("Unhandled
command : "+this._strType);
+	       if (this._log.isDebug()) this._log.debug("Unhandled command : "+this._strType);
     } /* end switch */
 } /* end execute */
 
@@ -218,8 +221,8 @@
 {
     var targetNodes = this._commandTargets ;
     var elemsToAppend = this._commandArguments;      
-    if (xap.util.LogFactory.s_loggingEnabled)
-	    xap.xml.xmodify.CommandDirective.s_log.debug (
+    if (this._log.isDebug())
+	    this._log.debug (
 				 "We have " 
 				 + elemsToAppend.length 
 				 + " children  to append to " 
@@ -242,8 +245,8 @@
 			throw new xap.xml.xmodify.XmodifyException(xap.xml.xmodify.XmodifyException.SET_ROOT_ELEMENT_EXPECTS_ONE_ARG);
 		    }
 		
-		if (xap.util.LogFactory.s_loggingEnabled)
-			xap.xml.xmodify.CommandDirective.s_log.debug (
+		if (this._log.isDebug())
+			this._log.debug (
 			"We have 1 elem to append as new root : " 
 			+ elemsToAppend[0]
 			);
@@ -276,8 +279,8 @@
         }
     } /* end for i < targetNodes.length...*/
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-	    xap.xml.xmodify.CommandDirective.s_log.debug("Post Append uIDoc: \n " 
+	if (this._log.isDebug())
+	    this._log.debug("Post Append uIDoc: \n " 
 				+ this.formatDocument(uiDocumentNode) 
 				);
 
@@ -335,8 +338,8 @@
 	}
     }; /* End for */
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Post Set-Attr: \n " + this.formatDocument(uiDocumentNode)
);
+	if (this._log.isDebug())
+		this._log.debug("Post Set-Attr: \n " + this.formatDocument(uiDocumentNode) );
  
 } /* end handleSetAttribute */
 
@@ -383,8 +386,8 @@
     var xpathRemoved = this._selectAttr;
     var targetNodes = this._commandTargets ;  
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-	xap.xml.xmodify.CommandDirective.s_log.debug('removing the element at XPath : ' 
+	if (this._log.isDebug())
+		this._log.debug('removing the element at XPath : ' 
             + xpathRemoved + " Results: " 
             + targetNodes.length
             );
@@ -439,8 +442,8 @@
         }; /* end for */
 
     } catch (e) {alert(e.message);}
-    if (xap.util.LogFactory.s_loggingEnabled)
-        xap.xml.xmodify.CommandDirective.s_log.debug("Post Remove: " + this.formatDocument(uiDocumentNode));
+    if (this._log.isDebug())
+        this._log.debug("Post Remove: " + this.formatDocument(uiDocumentNode));
 
 } /* end handleRemove */
 
@@ -460,8 +463,8 @@
     var parentSelector = this._selectAttr;
     var targetNodes = this._commandTargets ;  
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-	    xap.xml.xmodify.CommandDirective.s_log.debug('Removing the children of nodes for XPath
: ' 
+	if (this._log.isDebug())
+	    this._log.debug('Removing the children of nodes for XPath : ' 
 		    + parentSelector + " Results: " 
 		    + targetNodes.length
 		    );
@@ -495,9 +498,8 @@
     } catch (e) {
         alert(e.message);
     } 
-    if (xap.util.LogFactory.s_loggingEnabled)
-	xap.xml.xmodify.CommandDirective.s_log.debug("Post Remove: " + this.formatDocument(uiDocumentNode));
-//xap.xml.xmodify.Xmodify.DEBUG=false ;        
+    if (this._log.isDebug())
+		this._log.debug("Post Remove: " + this.formatDocument(uiDocumentNode));       
 
 } /* end _handleRemoveChildren */
 
@@ -516,8 +518,8 @@
     var attrsToRemove = this._commandArguments ;
     var targetNodes = this._commandTargets ;  
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Pre Remove-Attr: "+this._selectAttr+"\n "
+ this.formatDocument(uiDocumentNode) );
+	if (this._log.isDebug())
+		this._log.debug("Pre Remove-Attr: "+this._selectAttr+"\n " + this.formatDocument(uiDocumentNode)
);
 
     for (var i = 0; i < targetNodes.length ; i ++){
         var currentNode = targetNodes[i];
@@ -549,8 +551,8 @@
      }
     }; // (End iterating over attribute[s] to remove.)
 
-    if (xap.util.LogFactory.s_loggingEnabled)
-	xap.xml.xmodify.CommandDirective.s_log.debug("Post Remove-Attr: \n " + this.formatDocument(uiDocumentNode)
);
+    if (this._log.isDebug())
+		this._log.debug("Post Remove-Attr: \n " + this.formatDocument(uiDocumentNode) );
  
 } /* end handleRemoveAttribute */
 
@@ -672,13 +674,13 @@
         }
 
         // Do the simple thing, at this point:
-        if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Pre insert-before: <" + currentNode.nodeName+"/>:\n"
+ this.formatDocument(parent));
+        if (this._log.isDebug())
+			this._log.debug("Pre insert-before: <" + currentNode.nodeName+"/>:\n" + this.formatDocument(parent));
         
         this._insertCommandArgumentsBefore(parent,currentNode) ;
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Post insert-before:  <" + currentNode.nodeName+"/>:\n"
+ this.formatDocument(parent) );
+	if (this._log.isDebug())
+		this._log.debug("Post insert-before:  <" + currentNode.nodeName+"/>:\n" + this.formatDocument(parent)
);
 
 
         //this.insertCommandArgumentsAt(index, parent, contextNode, i);
@@ -728,13 +730,13 @@
         }
 
         // Do the simple thing, at this point:
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Pre insert-after: <" + currentNode.nodeName+"/>:\n"
+ this.formatDocument(parent));
+	if (this._log.isDebug())
+		this._log.debug("Pre insert-after: <" + currentNode.nodeName+"/>:\n" + this.formatDocument(parent));
         
         this._insertCommandArgumentsAfter(parent,currentNode) ;
 
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug("Post insert-after:  <" + currentNode.nodeName+"/>:\n"
+ this.formatDocument(parent) );
+	if (this._log.isDebug())
+		this._log.debug("Post insert-after:  <" + currentNode.nodeName+"/>:\n" + this.formatDocument(parent)
);
 
 
         //this.insertCommandArgumentsAt(index, parent, contextNode, i);
@@ -853,13 +855,9 @@
 			throw new xap.xml.xmodify.XmodifyException(xap.xml.xmodify.XmodifyException.CANNOT_REPLACE__ORIGINAL_INVALID,""+oldChild)
;
 		}	
     }
-    if (xap.util.LogFactory.s_loggingEnabled)
-	xap.xml.xmodify.CommandDirective.s_log.debug("Post replacement:\n" + this.formatDocument(contextNode));
-    
-
-
-	//xap.xml.xmodify.CommandDirective.s_log.debug("Post replacement:  <" + contextNode.nodeName+"/>:\n"
+ this.formatDocument(contextNode) );
-	
+    if (this._log.isDebug())
+		this._log.debug("Post replacement:\n" + this.formatDocument(contextNode));
+    	
 }
 
 
@@ -882,8 +880,8 @@
          newChild = arrArguments[ii] ;
          // Just try it for XNode and descendants so far:
          if (oldChild instanceof google.XNode){
-		if (xap.util.LogFactory.s_loggingEnabled)
-		  xap.xml.xmodify.CommandDirective.s_log.debug(
+		if (this._log.isDebug())
+		  this._log.debug(
 		    "Pre insertion of " + this.formatDocument(newChild)+"\nbefore\n" 
 		    + this.formatDocument(oldChild)
 		    + this.formatDocument(parent) 
@@ -896,15 +894,15 @@
           } catch (insertionException){
               throw new xap.xml.xmodify.XmodifyException(xap.xml.xmodify.XmodifyException.CANNOT_REPLACE__INSERTION,newChild.nodeName,""+insertionException);
           }
-		if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug(
+		if (this._log.isDebug())
+			this._log.debug(
 		    "Post insertion of " + this.formatDocument(newChild) +"\nbefore\n" 
 		    + this.formatDocument(oldChild)
 		    + this.formatDocument(parent) 
                                 ) ;                             
          } else if (this._bHtmlDocument){
-		if (xap.util.LogFactory.s_loggingEnabled)
-		      xap.xml.xmodify.CommandDirective.s_log.debug(
+		if (this._log.isDebug())
+		      this._log.debug(
 			"Pre insertion of " + this.formatDocument(newChild)+"\nbefore\n" 
 			+ this.formatDocument(oldChild)
 			+ this.formatDocument(parent) 
@@ -944,8 +942,8 @@
                        ""+replacementException
                        );     
     } finally {
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.CommandDirective.s_log.debug(
+	if (this._log.isDebug())
+		this._log.debug(
 			"Post all insertions and removals composited into replacement:"
 			+ '\n'+ this.formatDocument(parent)) ;
     	//xap.xml.xmodify.Xmodify.DEBUG=false;

Modified: incubator/xap/trunk/codebase/src/xap/xml/xmodify/Xmodify.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/xmodify/Xmodify.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/xmodify/Xmodify.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/xmodify/Xmodify.js Sun Feb 11 21:53:11 2007
@@ -21,7 +21,6 @@
 
 
 Xap.require( "xap.xml.xmodify.DirectiveSet" ) ;
-Xap.require( "xap.util.LogFactory" ) ;
  
 /**
  * @author xap@hisown.com
@@ -34,20 +33,6 @@
    var checkThisOutOnDebugging = true ; 
 }
 
-
-//-----------------------------------------------------------------------
-// Class Methods
-//-----------------------------------------------------------------------
-
-
-xap.xml.xmodify.Xmodify.s_log = xap.util.LogFactory.getLog( "xap.xml.xmodify.Xmodify" );
-
-//-----------------------------------------------------------------------
-// Constructors.
-//-----------------------------------------------------------------------
-
-
-
 //-----------------------------------------------------------------------
 // Public Methods. (publc instance methods)
 //-----------------------------------------------------------------------
@@ -69,9 +54,6 @@
 	 * Start the machinery put into place on creation:
 	 */
     this._directiveSet.execute(uiDoc, this._modificationsElement.baseUrl);
-
-	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.xml.xmodify.Xmodify.s_log.debug(uiDoc);
 }  /* end execute */
 
 //-----------------------------------------------------------------------

Modified: incubator/xap/trunk/samples/WebContent/XapConfig.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/XapConfig.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/samples/WebContent/XapConfig.js (original)
+++ incubator/xap/trunk/samples/WebContent/XapConfig.js Sun Feb 11 21:53:11 2007
@@ -102,12 +102,18 @@
      *                  root of the application.
 	 */
     element: null,
-	/**
-	 * The loggingEnabled value determines whether or not logging is turned on in the Xap client.
-	 * if logging is enabled then a new window will open that has the log produced by the Xap
client
-	 * during runtime.  It is not recommended to close the logging window during execution.
-     *
-     * Accepted Values: can be null, undefined, or true / false.
+    
+  
+  	
+ 	/**
+	 * The logLevel controls the logging level.
+     * Accepted Values: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, NONE
 	 */
-	logging: false
+    logLevel: 'TRACE',
+    
+    /**
+	 * Array of appender names, eitehr built in or custom.
+	 * TODO make configuration more like log4j
+	 */
+    logAppenders: ['xap.log.ConsoleAppender', 'xap.log.AlertAppender']
 }

Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js Sun
Feb 11 21:53:11 2007
@@ -17,7 +17,14 @@
  *
  */
 
+Xap.require("xap.log.LogFactory");
+
+
+
 AttributeTester = function(){
+	this._log = xap.log.Logger.getLogger("AttributeTester");
+	this._log.setLevel(xap.log.Logger.TRACE);
+	
 	AttributeTesterObj = this;
 	this._registeredElements = [];
 }
@@ -143,60 +150,10 @@
 
 //pp is PrettyPrint. True will format the text as indented, fixed-width XML. False just outputs
the text
 AttributeTester.prototype.log = function(text, pp){
-	if (!this._logDiv){
-		var l = document.createElement('div');
-		l.style.position = 'absolute';
-	    l.style.right = '5px';
-	    l.style.top = '5px';
-	    l.style.width = '200px';
-	    l.style.height = '350px';
-	    l.style.overflow = 'auto';
-	    l.style.backgroundColor = '#f0f0f0';
-	    l.style.border = '1px solid gray';
-	    l.style.fontSize = '10px';
-	    l.style.padding = '5px';
-	    document.body.appendChild(l);   
-	    this._logDiv = l;
-		dojo.event.connect(this._logDiv, "ondblclick",this,"clearLog");		  	    
-	}
-	if(this._logDiv.innerHTML == "") this._logDiv.innerHTML="[Double-click to clear.]<br/><br/><A
HREF=\"javascript:AttributeTesterObj.resizeOutput(true)\">Bigger</A> | <A HREF=\"javascript:AttributeTesterObj.resizeOutput(false)\">Smaller</A>";
       
-	
-	//dojo.event.connect(this.body, "ondblclick",this,"transportWidget");	
-
-	text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g,
'&gt;');
-	text = text.replace(/\n/g,'<br>');
-	if(pp == null || !pp){
-		this._logDiv.innerHTML = this._logDiv.innerHTML.replace(/<[\/]*b>/g,"") +
-			 "<br/><br/><b>" + text+"</b>";
-	}
-	else{
-	 	this._logDiv.innerHTML = this._logDiv.innerHTML.replace(/<[\/]*b>/g,"") + "<br/><br/><b><pre>"
+ this.prettyPrint(text)+"</pre></b>";
-	}
-	this._logDiv.scrollTop = this._logDiv.scrollHeight;
-	this._logDiv.style.display = "block";
-	
-}
-
-AttributeTester.prototype.resizeOutput = function(bigger){
-	if(bigger){
-		this._logDiv.style.width = (parseInt(this._logDiv.style.width) + 100) + "px";
-		this._logDiv.style.height = (parseInt(this._logDiv.style.height) + 100) + "px";
-	}
-	else{
-		this._logDiv.style.width = Math.max(parseInt(this._logDiv.style.width) - 100, 150) + "px";
-		this._logDiv.style.height = Math.max(parseInt(this._logDiv.style.height) - 100, 100) +
"px";
-	}
+	this._log.trace(text);
 }
 
 
-AttributeTester.prototype.clearLog = function(){
-
-	if (this._logDiv){
-		this._logDiv.style.display = "none";
-		this._logDiv.innerHTML = "" ;	
-	}
-}
-
 
 //IMPORTANT this works if you remove the same thing twice,
 //no error. Because we still found element in hashtable?
@@ -228,39 +185,6 @@
 }
 
 
-// I was having some weird issues before that meant indexOf wasn't working, so sorry for
the bastardized code.
-AttributeTester.prototype.prettyPrint = function(str){
-	var indentCount = 0;
-	for(var i = 0; i < str.length; i++){
-		//unindent on </
-		if(str.substring(i, i+5) == "&lt;/"){
-			indentCount--;
-			str = str.substring(0, i) + "\n" + this.spaceString(indentCount*2) + str.substring(i);
-			i += 3 + (indentCount*2);
-		}
-		//indent on <
-		else if(str.substring(i, i+4) == "&lt;"){
-			str = str.substring(0, i) + "\n" + this.spaceString(indentCount*2) + str.substring(i);
-			i += 3 + (indentCount*2);
-			indentCount++;
-		}
-		//unindent on />
-		else if(str.substring(i, i+5) == "/&gt;"){
-			i += 1;
-			indentCount--;
-		}
-	
-	}
-	return str;
-}
-
-AttributeTester.prototype.spaceString = function(size){
-	var str = "";
-	for(i = 0; i < size; i++){
-		str += " ";
-	}
-	return str;
-}
 		
 
 AttributeTester.prototype.addBorderComponent = function( parent, borderPosition ){

Modified: incubator/xap/trunk/unittests/jsunit-server-properties.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/jsunit-server-properties.xml?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/unittests/jsunit-server-properties.xml (original)
+++ incubator/xap/trunk/unittests/jsunit-server-properties.xml Sun Feb 11 21:53:11 2007
@@ -9,7 +9,7 @@
 
 	<property
 	            name="browserFileNames"
-		value="C:\Program Files\Internet Explorer\iexplore.exe"
+		value="C:\Program Files\mozilla.org\Mozilla\mozilla.exe"
 				description="the list of browsers in which to run tests when StandaloneTest is invoked
on this machine."
 	            />
 

Modified: incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html (original)
+++ incubator/xap/trunk/unittests/testsrc/XapUnitTestSuite.html Sun Feb 11 21:53:11 2007
@@ -27,12 +27,18 @@
 	<script language="JavaScript" type="text/javascript" src="/jsunit/jsunit/app/jsUnitCore.js"></script>
 	<script language="JavaScript" type="text/javascript">
 
+
+		function logSuite( webappContext ) {
+            var result = new top.jsUnitTestSuite();
+            result.addTestPage( webappContext + "/testsrc/xap/log/_TestLogger.html" );
+            return result;
+        }
+        
 	    function utilSuite( webappContext ) {
             var result = new top.jsUnitTestSuite();
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestEscapeSyntaxParser.html"
);
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestMessageFormat.html"
);
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestHashtable.html" );
-            result.addTestPage( webappContext + "/testsrc/xap/util/_TestLogFactory.html"
);
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestCharacter.html" );
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestXmlUtils.html" );
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestHttpUtils.html" );
@@ -94,6 +100,7 @@
             var suite = new top.jsUnitTestSuite();
             var	webappContext = "/jsunit";
 
+			suite.addTestSuite (logSuite( webappContext ) );
 			suite.addTestSuite (requestServiceSuite( webappContext ) );
             suite.addTestSuite( taghandlingSuite( webappContext ) );
             suite.addTestSuite( utilSuite( webappContext ) );

Added: incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.html?view=auto&rev=506298
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.html (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.html Sun Feb 11 21:53:11 2007
@@ -0,0 +1,37 @@
+<!--
+ - Copyright  2006,2007 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.
+ -
+-->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+	"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<title>Element Unit Tests</title>
+	<link rel="stylesheet" type="text/css" href="/jsunit/jsunit/css/jsUnitStyle.css">
+	<script language="JavaScript" type="text/javascript" src="/jsunit/jsunit/app/jsUnitCore.js"></script>
+	<script language="JavaScript" type="text/javascript" src="/jsunit/src/dojo/dojo.js"></script>
+	<script language="JavaScript" type="text/javascript" src="/jsunit/src/xap/util/Utils.js"></script>
+	<script language="JavaScript" type="text/javascript" src="/jsunit/src/xap/Xap.js"></script>
+	
+	<script language="JavaScript" type="text/javascript" src="_TestLogger.js"></script>
+</head>
+
+<body>
+  		
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.js?view=auto&rev=506298
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.js (added)
+++ incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.js Sun Feb 11 21:53:11 2007
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ */
+ 
+dojo.hostenv.setModulePrefix("dojo", "../dojo/src");
+dojo.hostenv.setModulePrefix("xap", "../xap");
+dojo.hostenv.setModulePrefix("google", "../google");
+ 
+Xap.require("xap.log.Logger");
+
+
+function exposeTestFunctionNames(){
+	 return ["testApacheExample"];
+}
+	
+
+
+StringAppender = function(){
+	this._string = "";
+	this._lastMessage = "";
+}
+
+StringAppender.prototype.doAppend = function( logEvent ){
+	//just save the message body
+	this._string += logEvent.message;
+	this._lastMessage = logEvent.message;
+}
+
+
+function testApacheExample() {
+	
+	//this code is taken directly from the getting started
+	//log4j guide
+	//http://logging.apache.org/log4j/docs/manual.html
+	
+	var rootLog = xap.log.Logger.getRootLogger();
+	var stringAppender = new StringAppender();
+	rootLog.addAppender(new xap.log.ConsoleAppender());
+	rootLog.addAppender(stringAppender);
+	
+	// get a logger instance named "com.foo"
+	var  logger = xap.log.Logger.getLogger("com.foo");
+
+	// Now set its level. Normally you do not need to set the
+	// level of a logger programmatically. This is usually done
+	// in configuration files.
+	logger.setLevel( xap.log.Logger.INFO);
+
+	barlogger = xap.log.Logger.getLogger("com.foo.Bar");
+
+	// This request is enabled, because WARN >= INFO.
+	logger.warn("Low fuel level.");
+	assertTrue( stringAppender._lastMessage =="Low fuel level.");
+
+	// This request is disabled, because DEBUG < INFO.
+	logger.debug("Starting search for nearest gas station.");
+	assertTrue( stringAppender._lastMessage =="Low fuel level.");
+
+	// The logger instance barlogger, named "com.foo.Bar",
+	// will inherit its level from the logger named
+	// "com.foo" Thus, the following request is enabled
+	// because INFO >= INFO.
+	barlogger.info("Located nearest gas station.");
+	assertTrue( stringAppender._lastMessage =="Located nearest gas station.");
+
+	// This request is disabled, because DEBUG < INFO.
+	barlogger.debug("Exiting gas station search");
+	assertTrue( stringAppender._lastMessage =="Located nearest gas station.");
+}
\ No newline at end of file

Propchange: incubator/xap/trunk/unittests/testsrc/xap/log/_TestLogger.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/unittests/testsrc/xap/performance/_TestParserPerformance.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/performance/_TestParserPerformance.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/performance/_TestParserPerformance.js (original)
+++ incubator/xap/trunk/unittests/testsrc/xap/performance/_TestParserPerformance.js Sun Feb
11 21:53:11 2007
@@ -38,38 +38,38 @@
 		xap.util.Profiler.start("Load file:" + fileName);
 		var pluginString = xap.util.HttpUtils.get( fileDirectory+ fileName).responseText;	
 		var endTime = xap.util.Profiler.end("Load file:" + fileName);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Loaded file: " + fileName + " in
" + endTime + "ms");
-		xap.util.LogFactory.getLog("ParserPerformance").info("Length = " + pluginString.length);
+		xap.log.Logger.getLogger("ParserPerformance").info("Loaded file: " + fileName + " in "
+ endTime + "ms");
+		xap.log.Logger.getLogger("ParserPerformance").info("Length = " + pluginString.length);
 	
 		//parse the file with the sax parser
 		xap.util.Profiler.start("Parse file with SaxParser:" + fileName);
 		var parsedDocument = parseWithSaxParser(pluginString);
 		saxParserEndTime = xap.util.Profiler.end("Parse file with SaxParser:" + fileName);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Parsed file with SaxParser: " + 
+		xap.log.Logger.getLogger("ParserPerformance").info("Parsed file with SaxParser: " + 
 							fileName + " in " + saxParserEndTime + "ms");
 		var elementCount = countElements(parsedDocument.childNodes[0]);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Element count: " + elementCount);
+		xap.log.Logger.getLogger("ParserPerformance").info("Element count: " + elementCount);
 				
 				
 		//parse the file with the native parser. This also has copying over the dom
 		xap.util.Profiler.start("Parse file with NativeParser:" + fileName);
 		var parsedDocument = parseWithNativeParser(pluginString);
 		nativeParserEndTime = xap.util.Profiler.end("Parse file with NativeParser:" + fileName);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Parse file with NativeParser:" +

+		xap.log.Logger.getLogger("ParserPerformance").info("Parse file with NativeParser:" + 
 							fileName + " in " + nativeParserEndTime + "ms");
 		var elementCount = countElements(parsedDocument.childNodes[0]);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Element count: " + elementCount);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Times Faster: " + (saxParserEndTime
/ nativeParserEndTime));
+		xap.log.Logger.getLogger("ParserPerformance").info("Element count: " + elementCount);
+		xap.log.Logger.getLogger("ParserPerformance").info("Times Faster: " + (saxParserEndTime
/ nativeParserEndTime));
 
 		//parse the file with the native parser. Don't convert to our DOM
 		xap.util.Profiler.start("Parse file with NativeDocument:" + fileName);
 		var parsedDocument = createNativeDoc(pluginString);
 		nativeDocumentEndTime = xap.util.Profiler.end("Parse file with NativeDocument:" + fileName);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Parse file with NativeDocument:"
+ 
+		xap.log.Logger.getLogger("ParserPerformance").info("Parse file with NativeDocument:" +

 							fileName + " in " + nativeDocumentEndTime + "ms");
 		var elementCount = countElements(parsedDocument.childNodes[0]);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Element count: " + elementCount);
-		xap.util.LogFactory.getLog("ParserPerformance").info("Times Faster: " + (nativeParserEndTime
/ nativeDocumentEndTime));
+		xap.log.Logger.getLogger("ParserPerformance").info("Element count: " + elementCount);
+		xap.log.Logger.getLogger("ParserPerformance").info("Times Faster: " + (nativeParserEndTime
/ nativeDocumentEndTime));
 				
 		xap.util.Profiler.start("Array push");
 		var newString = [];
@@ -79,7 +79,7 @@
 		}
 
 		var stringTime = xap.util.Profiler.end("Array push");
-		xap.util.LogFactory.getLog("ParserPerformance").info("Array push time:" + stringTime);
+		xap.log.Logger.getLogger("ParserPerformance").info("Array push time:" + stringTime);
 	}
 	
 	alert("Check the jsLex Stats before clicking OK");

Modified: incubator/xap/trunk/unittests/testsrc/xap/session/_TestContainer.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/session/_TestContainer.js?view=diff&rev=506298&r1=506297&r2=506298
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/session/_TestContainer.js (original)
+++ incubator/xap/trunk/unittests/testsrc/xap/session/_TestContainer.js Sun Feb 11 21:53:11
2007
@@ -52,12 +52,14 @@
 	var containerObject2 = new ContainerListener();
 	var containerObject3 = new ContainerListener();
 
-	var container = new xap.session.Container();
+	var fakeSession = "a fake session";
+	var container = new xap.session.Container(fakeSession);
 	
 	container.put(null, containerObject1);
 	assertTrue("Called addedToContainer when adding un-named object",
 		containerObject1._lastListenerMethod==containerObject1.addedToContainer);
 	
+	assertTrue("Injected a proper getSession()" ,containerObject1.getSession()===fakeSession);
 	assertTrue("Called with name null", containerObject1._lastName==null);	
 	
 	assertTrue("Container getName() null",



Mime
View raw message