::xox::test
Class TestXmlNodeReader

Heritage:
::xotcl::Object
  |
  +--::xox::Node
        |
        +--::xounit::Test
              |
              +--::xounit::Assert
                    |
                    +--::xounit::TestCase
Tested Class:
::xox::XmlNodeReader

Class TestXmlNodeReader
superclass ::xounit::TestCase,

Variables
NameDefault ValueClassComment
currentTestMethod    ::xounit::TestCase
 name of the currently running test method.
nodeName    ::xox::Node
 
result    ::xounit::TestCase
 the result for the current run.
 
Methods
NameComment
notestIsclassAndLoad {}  
setUp {}   setUp is called before each test method in your specific test case
testChild {}  
testChild2 {}  
testChild3 {}  
testLoadAutomatically {}  
testMixedList {}  
testNameNodeNameConfusion {}  
testNode {}  
testNodeArray {}  
testNodeLinks {}  
testNodeValue {}  
testNodes {}  
testNodesArrayObjectIndexBug {}  
testNodesArraySpaceBug {}  
testNodesLinks {}  
testNodesLinksArray {}  
   
Methods from ::xotcl::Object
#, ., ?, ?code, ?methods, ?object, abstract, copy, coverageFilter, defaultmethod, extractConfigureArg, filterappend, garbageCollect, get#, getClean#, hasclass, init, methodTag, mixinappend, move, profileFilter, self, setParameterDefaults, shell, tclcmd, traceFilter,
 
Instproc Detail

notestIsclassAndLoad

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc notestIsclassAndLoad {}  {
   

         set factory [ ::xox::XmlNodeReader new ]

         my assert [ $factory isclassAndLoad ::xotcl::Class ]
         my assertFalse [ $factory isclassAndLoad ::xox::NotAClass ]

         my assert [ $factory isclassAndLoad ::abc::ABCD ]
     
}

setUp

Description:
 setUp is called before each test method in
 your specific test case.  This provides a clean
 test fixture for each test method.  Over-ride 
 setUp in your specific TestCase to configure
 your TestCase before each test.  Example:

 SimpleTest instproc setUp {} {

     my set testValue 10
 }

 SimpleTest instproc testValue {} {

     my assertEquals [ my set testValue ] 10
 }
Overrides:
setUp in ::xounit::TestCase
Code:
  ::xox::test::TestXmlNodeReader instproc setUp {}  {
   

        my instvar writer reader

        set writer [ ::xox::XmlNodeWriter new ]
        set reader [ ::xox::XmlNodeReader new ]
     
}

testChild

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testChild {}  {
   

        set xml {
<root>
    <::xox::Node>
    </::xox::Node>
</root>}

        set factory [ ::xox::XmlNodeReader new ]
        set root [ ::xox::Node new ]

        $factory buildNodes $root $xml

        my assertEquals [ $root getNodeName ] Node
        set nodes [ $root nodes ]
        my assertEquals [ llength $nodes ] 1

        my assertEquals [ $root / Node info class ] ::xox::Node 
     
}

testChild2

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testChild2 {}  {
   

        set xml {
<root>
    <::xox::Node/>
</root>}

        set factory [ ::xox::XmlNodeReader new ]
        set root [ ::xox::Node new ]

        $factory buildNodes $root $xml

        my assertEquals [ $root getNodeName ] Node
        set nodes [ $root nodes ]
        my assertEquals [ llength $nodes ] 1

        my assertEquals [ $root / Node info class ] ::xox::Node 
     
}

testChild3

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testChild3 {}  {
   

        set xml {
<testsuite package="xounit::test">
    <::xounit::test::TestTest/>
</testsuite>}

        set factory [ ::xox::XmlNodeReader new ]
        set root [ ::xox::Node new ]

        $factory buildNodes $root $xml

        my assertEquals [ $root getNodeName ] Node
        set nodes [ $root nodes ]
        my assertEquals [ llength $nodes ] 1

        my assertEquals [ $root / TestTest info class ] ::xounit::test::TestTest
     
}

testLoadAutomatically

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testLoadAutomatically {}  {
   

         set xml {
<testsuite>
    <::abc::ABCD/>
</testsuite>}

         set factory [ ::xox::XmlNodeReader new ]
         set root [ ::xox::Node new ]

         $factory buildNodes $root $xml

         $root / ABCD

     
}

testMixedList

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testMixedList {}  {
   

         set xml { <testbed>
    <nodeName>ESTBBA</nodeName>
    <EnablePassword>lab</EnablePassword>
    <TacacsPassword>lab</TacacsPassword>
    <TacacsUsername>lab</TacacsUsername>
    <topomapFile>estbba-topo.xml</topomapFile>
    <webPath>http://estmpls1.cisco.com/estbba/</webPath>
    <location>/var/www/html/estbba/</location>
    <title>EST BBA Network Verification</title>
    <url>http://www.cisco.com</url>
    <includes>::xox::Interface testPingAllPeerInterfaces</includes>     
    <excludes>::xox::Interface testDescriptionExists</excludes>
    <excludes>::xox::Interface testLayer3Connected</excludes>
</testbed>}

        set factory [ ::xox::XmlNodeReader new ]
        set root [ ::xox::Node new ]

        $factory buildNodes $root $xml

        my assertEquals [ $root set nodeName ] ESTBBA
        my assertEquals [ $root set EnablePassword ] lab
        my assertEquals [ $root set TacacsPassword ] lab
        my assertEquals [ $root set TacacsUsername ] lab
        my assertEquals [ $root set topomapFile ] estbba-topo.xml
        my assertEquals [ $root set webPath ] http://estmpls1.cisco.com/estbba/
        my assertEquals [ $root set location ] /var/www/html/estbba/
        my assertEquals [ $root set title ] "EST BBA Network Verification"
        my assertEquals [ $root set url ] http://www.cisco.com
        my assertEquals [ $root set includes ] "::xox::Interface testPingAllPeerInterfaces"

        
        #Is this the expected behavior?
        #my assertEquals [ $root set excludes ] "::xox::Interface testDescriptionExists"
        my assertEquals [ $root set excludes ] "::xox::Interface testLayer3Connected"
     
}

testNameNodeNameConfusion

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNameNodeNameConfusion {}  {
   

        my instvar writer reader

         set parent [ ::xox::Node new ]

         set nodeA [ ::xox::Node new -set name A -set nodeName A ]
         set nodeB [ ::xox::Node new -set name A -set nodeName B ]

         set nodeA [ $parent addNode $nodeA ]
         set nodeB [ $parent addNode $nodeB ]

         my assertEquals [ $nodeA set name ] A 
         my assertEquals [ $nodeB set name ] A 

         my assertEquals [ $nodeA getNodeName ] A 
         my assertEquals [ $nodeB getNodeName ] B

         $parent / A
         $parent / B

         set xml [ $writer generateXml $parent ] 

         set otherParent [ ::xox::Node new ]

         $reader buildNodes $otherParent $xml

         set xml [ $writer generateXml $otherParent ] 

         $otherParent / A
         $otherParent / B
     
}

testNode

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNode {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        set xml [ $writer generateXml $element ] 

        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        my assertNotEquals $element $otherNode

        my assertEquals [ $element getNodeName ] [ $otherNode getNodeName ]

        my assertEquals [ $element info class ] ::xox::Node
        my assertEquals [ $otherNode info class ] ::xox::Node
     
}

testNodeArray

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodeArray {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        $element set someVariable(1) someValue

        set xml [ $writer generateXml $element ] 

        #my debug $xml
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        my assertEquals [ $element set someVariable(1) ] someValue
        my assertEquals [ $otherNode set someVariable(1) ] someValue
     
}

testNodeLinks

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodeLinks {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        set subNode0 [ $element addAutoNameNode [ ::xox::Node new ] ]
        set subNode1 [ $element addAutoNameNode [ ::xox::Node new ] ]

        $subNode0 set neighbor $subNode1
        $subNode1 set neighbor $subNode0

        set xml [ $writer generateXml $element ] 
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        $element / Node
        $element / Node_0

        my assertEquals [ $subNode0 set neighbor ] $subNode1
        my assertEquals [ $subNode1 set neighbor ] $subNode0

        set otherSubNode0 [ $otherNode / Node ]
        set otherSubNode1 [ $otherNode / Node_0 ]

        my assertEquals [ $otherSubNode0 set neighbor ] $otherSubNode1
        my assertEquals [ $otherSubNode1 set neighbor ] $otherSubNode0
     
}

testNodeValue

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodeValue {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        $element set someVariable someValue

        set xml [ $writer generateXml $element ] 
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        my assertEquals [ $element set someVariable ] someValue
        my assertEquals [ $otherNode set someVariable ] someValue
     
}

testNodes

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodes {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        set subNode [ $element addNode [ ::xox::Node new ] ]

        set xml [ $writer generateXml $element ] 

        my debug $xml
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        $element / Node

        $otherNode / Node
     
}

testNodesArrayObjectIndexBug

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodesArrayObjectIndexBug {}  {
   

        my instvar writer reader

        set node [ ::xox::Node new ]

        $node set "array($node)" 1

        set xml [ $writer generateXml $node ] 

        #my debug $xml

        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        set xml [ $writer generateXml $otherNode ] 

        #my debug $xml

        my assertNotEquals $node $otherNode 1

        my assertEquals [ $node getNodeName ] [ $otherNode getNodeName ] 2

        my assertEquals [ $node info class ] ::xox::Node 3
        my assertEquals [ $otherNode info class ] ::xox::Node 4
        my assert [ $node exists array($node) ] 4.5
        my assertEquals [ $node set "array($node)" ] 1 5
        my assertFalse [ $otherNode exists "array($node)" ] 5.4
        my assertFalse [ $otherNode exists "array(Node)" ] 5.45
        my assert [ $otherNode exists "array($otherNode)" ] 5.5
        my assertEquals [ $otherNode set "array($otherNode)" ] 1 6
     
}

testNodesArraySpaceBug

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodesArraySpaceBug {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        $element set "array(name with spaces)" 1

        set xml [ $writer generateXml $element ] 

        my debug $xml

        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        set xml [ $writer generateXml $otherNode ] 

        #my debug $xml

        my assertNotEquals $element $otherNode

        my assertEquals [ $element getNodeName ] [ $otherNode getNodeName ]

        my assertEquals [ $element info class ] ::xox::Node
        my assertEquals [ $otherNode info class ] ::xox::Node
        my assertEquals [ $element set "array(name with spaces)" ] 1
        my assertEquals [ $otherNode set "array(name with spaces)" ] 1
     
}

testNodesLinks

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodesLinks {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        set subNode0 [ $element addAutoNameNode [ ::xox::Node new ] ]
        set subNode1 [ $element addAutoNameNode [ ::xox::Node new ] ]
        set subNode2 [ $element addAutoNameNode [ ::xox::Node new ] ]

        $subNode0 lappend neighbor $subNode1
        $subNode0 lappend neighbor $subNode2
        $subNode1 lappend neighbor $subNode0
        $subNode1 lappend neighbor $subNode2
        $subNode2 lappend neighbor $subNode0
        $subNode2 lappend neighbor $subNode1

        set xml [ $writer generateXml $element ] 
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        $element / Node
        $element / Node_0
        $element / Node_1

        my assertEquals [ $subNode0 set neighbor ]  [ list $subNode1 $subNode2 ]
        my assertEquals [ $subNode1 set neighbor ]  [ list $subNode0 $subNode2 ]
        my assertEquals [ $subNode2 set neighbor ]  [ list $subNode0 $subNode1 ]

        set otherSubNode0 [ $otherNode / Node ]
        set otherSubNode1 [ $otherNode / Node_0 ]
        set otherSubNode2 [ $otherNode / Node_1 ]

        my assertEquals [ $otherSubNode0 set neighbor ]  [ list $otherSubNode1 $otherSubNode2 ]
        my assertEquals [ $otherSubNode1 set neighbor ]  [ list $otherSubNode0 $otherSubNode2 ]
        my assertEquals [ $otherSubNode2 set neighbor ]  [ list $otherSubNode0 $otherSubNode1 ]

     
}

testNodesLinksArray

Description:
 
Code:
  ::xox::test::TestXmlNodeReader instproc testNodesLinksArray {}  {
   

        my instvar writer reader

        set element [ ::xox::Node new ]

        set subNode0 [ $element addAutoNameNode [ ::xox::Node new ] ]
        set subNode1 [ $element addAutoNameNode [ ::xox::Node new ] ]
        set subNode2 [ $element addAutoNameNode [ ::xox::Node new ] ]

        $subNode0 lappend neighbor(1) $subNode1
        $subNode0 lappend neighbor(1) $subNode2
        $subNode1 lappend neighbor(1) $subNode0
        $subNode1 lappend neighbor(1) $subNode2
        $subNode2 lappend neighbor(1) $subNode0
        $subNode2 lappend neighbor(1) $subNode1

        set xml [ $writer generateXml $element ] 

        #my debug $xml
        
        set otherNode [ ::xox::Node new ]

        $reader buildNodes $otherNode $xml

        $element / Node
        $element / Node_0
        $element / Node_1

        my assertEquals [ $subNode0 set neighbor(1) ]  [ list $subNode1 $subNode2 ]
        my assertEquals [ $subNode1 set neighbor(1) ]  [ list $subNode0 $subNode2 ]
        my assertEquals [ $subNode2 set neighbor(1) ]  [ list $subNode0 $subNode1 ]

        set otherSubNode0 [ $otherNode / Node ]
        set otherSubNode1 [ $otherNode / Node_0 ]
        set otherSubNode2 [ $otherNode / Node_1 ]

        my assertEquals [ $otherSubNode0 set neighbor(1) ]  [ list $otherSubNode1 $otherSubNode2 ]
        my assertEquals [ $otherSubNode1 set neighbor(1) ]  [ list $otherSubNode0 $otherSubNode2 ]
        my assertEquals [ $otherSubNode2 set neighbor(1) ]  [ list $otherSubNode0 $otherSubNode1 ]

     
}