[jdom-interest] Anything else for beta 9?

Bradley S. Huffman hip at a.cs.okstate.edu
Tue Apr 8 21:01:36 PDT 2003


Jason Hunter writes:

> That's definitely a bug, although I don't think it's worth holding up b9
> over.  Do you have a fix?  If so, I'll include it.  It's pretty low
> risk.

And to jdom-test.
 
*** TestElement.java	Tue Apr  8 22:55:30 2003
--- TestElement.new	Tue Apr  8 22:47:11 2003
***************
*** 752,757 ****
--- 752,760 ----
  		element.addContent(child1);
  		element.addContent(child3);
  
+                 element.addNamespaceDeclaration(Namespace.getNamespace("foo", "http://test1"));
+                 element.addNamespaceDeclaration(Namespace.getNamespace("bar", "http://test2"));
+ 
  		//add mixed content to the nested child2 element
  		Comment comment = new Comment("hi");
  		child2.addContent(comment);
***************
*** 772,777 ****
--- 775,789 ----
  		child2 = null;
  		child1 = null;
  		
+                 // additional namespaces
+                 List additional = clone.getAdditionalNamespaces();
+ 		assertEquals("incorrect deep clone additional namespace", 
+ 		             (Namespace) additional.get(0),
+                              Namespace.getNamespace("foo", "http://test1"));
+ 		assertEquals("incorrect deep clone additional namespace", 
+ 		             (Namespace) additional.get(1),
+                              Namespace.getNamespace("bar", "http://test2"));
+ 			
  		List list = clone.getContent();
  
  		//finally the test
***************
*** 800,806 ****
  		//text
  		assertEquals("incorrect deep clone test", "finally a new wand!", ((Text)deepClone.getContent().get(4)).getText());
  		
- 			
  		
  		
  		
--- 812,817 ----
***************
*** 1675,1679 ****
--- 1686,1726 ----
  	op.output(elIn, sw);
  	assertTrue("Incorrect data after serialization", sw.toString().equals(bufWithEmptyNS));
  
+ 	//set up an element to test with
+ 	Element element2= new Element("element", Namespace.getNamespace("http://foo"));
+ 	element2.addNamespaceDeclaration(Namespace.getNamespace("foo", "http://test1"));
+ 	element2.addNamespaceDeclaration(Namespace.getNamespace("bar", "http://test2"));
+ 	Element child21 = new Element("child1");
+ 	child21.setAttribute(new Attribute("anAttribute", "no namespace"));
+ 	Element child22 = new Element("child2");
+ 	Attribute att21 = new Attribute("anAttribute", "with namespace", Namespace.getNamespace("x", "http://foo"));
+ 	child22.setAttribute(att21);
+ 	//add another child level deep
+ 	Element descendent2 = new Element("descendent");
+ 	child22.addContent(descendent2);
+ 	element2.addContent(child21);
+ 	element2.addContent(child22);
+ 
+ 	
+ 	
+ 	//here is what we expect back after serialization
+ 	String bufWithEmptyNS2 = 
+ 	"<element xmlns=\"http://foo\" xmlns:foo=\"http://test1\" xmlns:bar=\"http://test2\"><child1 xmlns=\"\" anAttribute=\"no namespace\" /><child2 xmlns=\"\" xmlns:x=\"http://foo\" x:anAttribute=\"with namespace\"><descendent /></child2></element>";
+ 
+ 	File dir2 = new File(scratchDir);
+ 	dir2.mkdirs();
+ 
+ 	ObjectOutputStream out2 = new ObjectOutputStream(new FileOutputStream(scratchDir + "/object.ser"));
+ 	out2.writeObject(element2);
+ 
+ 	ObjectInputStream in2 = new ObjectInputStream(new FileInputStream(scratchDir + "/object.ser"));
+ 
+ 	Element elIn2 = (Element) in2.readObject();
+ 	
+ 	StringWriter sw2 = new StringWriter();
+ 	XMLOutputter op2= new XMLOutputter("", false);
+ 	op.output(elIn2, sw2);
+ 	assertTrue("Incorrect data after serialization", sw2.toString().equals(bufWithEmptyNS2));
+ 
  }
  }



More information about the jdom-interest mailing list