001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.tools.common.toolspec;
019:
020: import org.apache.cxf.tools.common.ToolException;
021: import org.junit.Assert;
022: import org.junit.Test;
023:
024: public class ToolSpecTest extends Assert {
025: ToolSpec toolSpec;
026:
027: @Test
028: public void testConstruct() {
029: toolSpec = null;
030: toolSpec = new ToolSpec();
031: assertTrue(toolSpec != null);
032: }
033:
034: @Test
035: public void testConstructFromInputStream() {
036: String tsSource = "parser/resources/testtool.xml";
037: try {
038: toolSpec = new ToolSpec(getClass().getResourceAsStream(
039: tsSource), false);
040: } catch (ToolException e) {
041: throw new RuntimeException(e);
042: }
043: assertTrue(toolSpec.getAnnotation() == null);
044: }
045:
046: @Test
047: public void testGetParameterDefault() throws Exception {
048: String tsSource = "parser/resources/testtool.xml";
049:
050: toolSpec = new ToolSpec(getClass()
051: .getResourceAsStream(tsSource), false);
052:
053: assertTrue(toolSpec.getAnnotation() == null);
054: assertTrue(toolSpec.getParameterDefault("namespace") == null);
055: assertTrue(toolSpec.getParameterDefault("wsdlurl") == null);
056: }
057:
058: @Test
059: public void testGetStreamRefName1() throws Exception {
060: String tsSource = "parser/resources/testtool1.xml";
061: toolSpec = new ToolSpec(getClass()
062: .getResourceAsStream(tsSource), false);
063: assertEquals("test getStreamRefName failed", toolSpec
064: .getStreamRefName("streamref"), "namespace");
065: }
066:
067: @Test
068: public void testGetStreamRefName2() throws Exception {
069: String tsSource = "parser/resources/testtool2.xml";
070: toolSpec = new ToolSpec(getClass()
071: .getResourceAsStream(tsSource), false);
072: assertEquals("test getStreamRefName2 failed", toolSpec
073: .getStreamRefName("streamref"), "wsdlurl");
074: }
075:
076: @Test
077: public void testIsValidInputStream() throws Exception {
078: String tsSource = "parser/resources/testtool1.xml";
079: toolSpec = new ToolSpec(getClass()
080: .getResourceAsStream(tsSource), false);
081: assertTrue(toolSpec.isValidInputStream("testID"));
082: assertTrue(!toolSpec.isValidInputStream("dummyID"));
083: assertTrue(toolSpec.getInstreamIds().size() == 1);
084: }
085:
086: @Test
087: public void testGetHandler() throws Exception {
088: String tsSource = "parser/resources/testtool1.xml";
089: toolSpec = new ToolSpec(getClass()
090: .getResourceAsStream(tsSource), false);
091: assertNotNull(toolSpec.getHandler());
092: assertNotNull(toolSpec.getHandler(this .getClass()
093: .getClassLoader()));
094: }
095:
096: @Test
097: public void testGetOutstreamIds() throws Exception {
098: String tsSource = "parser/resources/testtool2.xml";
099: toolSpec = new ToolSpec(getClass()
100: .getResourceAsStream(tsSource), false);
101: assertTrue(toolSpec.getOutstreamIds().size() == 1);
102: }
103: }
|