package org.codehaus.xfire.aegis.inheritance.xfire704;

import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.xfire.aegis.AbstractXFireAegisTest;
import org.codehaus.xfire.aegis.inheritance.xfire704.response.TestBaseResponse;
import org.codehaus.xfire.aegis.inheritance.xfire704.response.TestSubResponse;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.wsdl.WSDLWriter;

public class WSDLNamespaceTest extends AbstractXFireAegisTest
{
    public void testWsdl() throws Exception 
    {
        Map props = new HashMap();
        props.put("writeXsiType", Boolean.TRUE);
        
        List types = new ArrayList();
        types.add(TestValue.class.getName());
        types.add(TestBaseResponse.class.getName());
        types.add(TestSubResponse.class.getName());

        props.put("overrideTypesList", types);
        Service service = getServiceFactory().create(TestService.class, props);
        getServiceRegistry().register(service);
        
        WSDLWriter wsdl = getWSDL(service.getSimpleName());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        wsdl.write(out);
        out.close();
        
        String wstr = out.toString();
        int start = wstr.indexOf("xmlns:ns1");
        int count = 0;
        while (start != -1) {
            count++;
            start = wstr.indexOf("xmlns:ns1", start+1);
        }
        assertEquals(1, count);
    }
}

@@ -53,46 +53,8 @@
 4;%0A%0A
-import java.io.ByteArrayOutputStream;%0A
 impo
@@ -73,24 +73,24 @@
 .ArrayList;%0A
+
 import java.
@@ -422,38 +422,21 @@
 org.
-codehaus.xfire.wsdl.WSDLWriter
+jdom.Document
 ;%0A%0Ap
@@ -1007,24 +1007,16 @@
 rvice);%0A
-        
 %0A       
@@ -1020,18 +1020,16 @@
     
-WSDLWriter
+Document
  wsd
@@ -1039,16 +1039,24 @@
  getWSDL
+Document
 (service
@@ -1086,374 +1086,83 @@
     
-ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        wsdl.write(out);%0A        out.close();%0A        %0A        String wstr = out.toString();%0A        int start = wstr.indexOf(%22xmlns:ns1%22);%0A        int count = 0;%0A        while (start != -1) %7B%0A            count++;%0A            start = wstr.indexOf(%22xmlns:ns1%22, start+1);%0A        %7D%0A        assertEquals(1, count
+assertValid(%22//xsd:element%5B@name='testValue'%5D%5B@type='tns:TestValue'%5D%22, wsdl
 );%0A 

Fix XFIRE-704 unit test