/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
package org.apache.ode.bpel.compiler;

import junit.framework.TestCase;
import org.apache.ode.bpel.compiler.wsdl.WSDLFactory4BPEL;
import org.apache.ode.bpel.compiler.wsdl.WSDLFactoryBPEL11;
import org.apache.ode.utils.xsd.SchemaModel;

import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import java.net.URL;

public class WSDLRegistryTest extends TestCase {

  private WSDLRegistry _registry;

  public WSDLRegistryTest() {
    super();
  }

  protected void setUp() throws Exception
  {
    super.setUp();
    _registry = new WSDLRegistry(null);
  }

  protected void tearDown() throws Exception
  {
    _registry = null;
    super.tearDown();
  }

  public void testInitialModel() throws Exception
  {
    // access initial dummy model
    SchemaModel m = _registry.getSchemaModel();
    assertNotNull(m);

    // verify dummy model
    QName type = new QName("http://fivesight.com/bogus/namespace", "__bogusType__");
    assertTrue(m.knowsSchemaType(type));
  }

  public void testAddWSDL() throws Exception {
    URL wsd = getClass().getResource("/1.1/good/test.wsdl");

    // load & register wsdl
    WSDLFactory4BPEL factory = (WSDLFactory4BPEL)WSDLFactoryBPEL11.newInstance();
    WSDLReader reader = factory.newWSDLReader();
    ResourceFinder finder = new DefaultResourceFinder();
    //Definition4BPEL def = finder.loadDefinition(reader, null, wsd.toURI());
    //_registry.addDefinition(def);

    // access model
    SchemaModel m = _registry.getSchemaModel();
    assertNotNull(m);

    assertTrue("WSDL-Define type not visible.",m.knowsSchemaType(new QName("uri:testing", "TComplex1")));
    assertTrue("Type from import not visible.",m.knowsSchemaType(new QName("uri:test1", "TComplex2")));
    
    
  }
  
}

@@ -852,32 +852,57 @@
 ort 
-junit.framework.TestCase
+org.apache.ode.bpel.compiler.wsdl.Definition4BPEL
 ;%0Aim
@@ -1064,16 +1064,87 @@
 Model;%0A%0A
+import java.io.File;%0Aimport java.io.InputStream;%0Aimport java.net.URL;%0A%0A
 import j
@@ -1203,24 +1203,25 @@
 .QName;%0A
+%0A
 import j
 ava.net.
@@ -1212,27 +1212,39 @@
 import j
-ava.net.URL
+unit.framework.TestCase
 ;%0A%0Apubli
@@ -2221,95 +2221,188 @@
 der(
-);%0A    //Definition4BPEL def = finder.loadDefinition(reader, null, wsd.toURI()
+new File(wsd.getPath()).getParentFile());%0A    WSDLLocatorImpl loc = new WSDLLocatorImpl(finder,wsd.toURI());%0A    Definition4BPEL wsdl = (Definition4BPEL) reader.readWSDL(loc
 );%0A    
-//
 _reg
@@ -2425,11 +2425,33 @@
 ion(
-def
+wsdl, finder, wsd.toURI()
 );%0A%0A

test case fixes