blob: 3e932d9c5c5e17b76004c738d891e163d4066526 [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2011, EBM WebSourcing
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* EBM WebSourcing - initial API and implementation
*******************************************************************************/
package org.eclipse.bpel.common.wsdl.parsers;
import java.net.URL;
import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.wst.wsdl.Definition;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests the WSDL parser.
* @author Vincent Zurczak - EBM WebSourcing
*/
public class WsdlParserTest {
/**
* Tests the parsing of a simple WSDL 1.1.
* @throws Exception
*/
@Test
public void testWsdlParsing1() throws Exception {
URL url = getClass().getResource( "/wsdls/test1/tuxDroid.wsdl" );
URI emfUri = URI.createURI( url.toString());
Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertNotNull( def );
Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertEquals( definitions.size(), 1 );
}
/**
* Tests the parsing of a simple WSDL 2.0 (should not work).
* @throws Exception
*/
@Test
public void testWsdlParsing2() throws Exception {
URL url = getClass().getResource( "/wsdls/test2/testwsdl20.wsdl" );
URI emfUri = URI.createURI( url.toString());
Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertFalse( WsdlParser.seemsValidDefinition( def ));
}
/**
* Tests the parsing of a WSDL 1.1 with XML schema and WSDL imports (same level).
* @throws Exception
*/
@Test
public void testWsdlParsing3() throws Exception {
URL url = getClass().getResource( "/wsdls/test7/ToConcrete.wsdl" );
URI emfUri = URI.createURI( url.toString());
Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertNotNull( def );
Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertEquals( definitions.size(), 2 );
}
/**
* Tests the parsing of a WSDL 1.1 with XML schema and WSDL imports (cyclic import).
* @throws Exception
*/
@Test
public void testWsdlParsing4() throws Exception {
URL url = getClass().getResource( "/wsdls/test8/ToConcrete.wsdl" );
URI emfUri = URI.createURI( url.toString());
Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertNotNull( def );
Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
Assert.assertEquals( definitions.size(), 2 );
}
}