public void testUserDataHandlerNotifiedOfOnlyShallowAdoptions() throws Exception {
  domToString(document);
  RecordingHandler handler=new RecordingHandler();
  name.setUserData("a","apple",handler);
  name.setUserData("b","banana",handler);
  standard.setUserData("c","cat",handler);
  waffles.setUserData("d","dog",handler);
  Document newDocument=builder.newDocument();
  assertSame(name,newDocument.adoptNode(name));
  assertSame(newDocument,name.getOwnerDocument());
  assertSame(newDocument,standard.getOwnerDocument());
  assertSame(newDocument,waffles.getOwnerDocument());
  Set<String> expected=new HashSet<String>();
  expected.add(notification(NODE_ADOPTED,"a","apple",name,null));
  expected.add(notification(NODE_ADOPTED,"b","banana",name,null));
  assertEquals(expected,handler.calls);
}

public void testUserDataHandlerNotifiedOfOnlyShallowAdoptions ( ) throws Exception { domToString ( document ) ; RecordingHandler handler = new RecordingHandler ( ) ; name . setUserData ( "a" , "apple" , handler ) ; name . setUserData ( "b" , "banana" , handler ) ; standard . setUserData ( "c" , "cat" , handler ) ; waffles . setUserData ( "d" , "dog" , handler ) ; Document newDocument = builder . newDocument ( ) ; assertSame ( name , newDocument . adoptNode ( name ) ) ; assertSame ( newDocument , name . getOwnerDocument ( ) ) ; assertSame ( newDocument , standard . getOwnerDocument ( ) ) ; assertSame ( newDocument , waffles . getOwnerDocument ( ) ) ; Set < String > expected = new HashSet < String > ( ) ; expected . add ( notification ( NODE_ADOPTED , "a" , "apple" , name , null ) ) ; expected . add ( notification ( NODE_ADOPTED , "b" , "banana" , name , null ) ) ; assertEquals ( expected , handler . calls ) ; }
there should be notifications for adopted node itself but none of its children . the dom spec is vague on this , so we ' re consistent with the ri .
