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.wsdlto.frontend.jaxws;
019:
020: import java.util.Map;
021:
022: import org.apache.cxf.tools.common.Processor;
023: import org.apache.cxf.tools.plugin.FrontEnd;
024: import org.apache.cxf.tools.plugin.Generator;
025: import org.apache.cxf.tools.plugin.Plugin;
026: import org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder;
027: import org.apache.cxf.tools.wsdlto.core.FrontEndProfile;
028: import org.apache.cxf.tools.wsdlto.core.PluginLoader;
029: import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor;
030: import org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder;
031: import org.junit.Assert;
032: import org.junit.Test;
033:
034: public class JAXWSProfileTest extends Assert {
035:
036: @Test
037: public void testLoadPlugins() {
038: PluginLoader loader = PluginLoader.getInstance();
039: assertNotNull(loader);
040:
041: loader
042: .loadPlugin("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-plugin.xml");
043:
044: assertEquals(2, loader.getPlugins().size());
045: Plugin plugin = getPlugin(loader, 1);
046: assertEquals("tools-jaxws-frontend", plugin.getName());
047: assertEquals("2.0", plugin.getVersion());
048: assertEquals("apache cxf", plugin.getProvider());
049:
050: Map<String, FrontEnd> frontends = loader.getFrontEnds();
051: assertNotNull(frontends);
052: assertEquals(1, frontends.size());
053:
054: FrontEnd frontend = getFrontEnd(frontends, 0);
055: assertEquals("jaxws", frontend.getName());
056: assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws",
057: frontend.getPackage());
058: assertEquals("JAXWSProfile", frontend.getProfile());
059: assertNotNull(frontend.getGenerators());
060: assertNotNull(frontend.getGenerators().getGenerator());
061: assertEquals(2, frontend.getGenerators().getGenerator().size());
062: assertEquals("AntGenerator", getGenerator(frontend, 0)
063: .getName());
064: assertEquals("ImplGenerator", getGenerator(frontend, 1)
065: .getName());
066:
067: FrontEndProfile profile = loader.getFrontEndProfile("jaxws");
068: assertNotNull(profile);
069: //TODO: After generator completed ,umcomment these linses
070: /*List<FrontEndGenerator> generators = profile.getGenerators();
071: assertNotNull(generators);
072: assertEquals(2, generators.size());
073: assertTrue(generators.get(0) instanceof AntGenerator);
074: assertTrue(generators.get(1) instanceof ImplGenerator);
075: */
076: Processor processor = profile.getProcessor();
077: assertNotNull(processor);
078: assertTrue(processor instanceof WSDLToJavaProcessor);
079:
080: AbstractWSDLBuilder builder = profile.getWSDLBuilder();
081: assertNotNull(builder);
082: assertTrue(builder instanceof JAXWSDefinitionBuilder);
083:
084: Class container = profile.getContainerClass();
085: assertEquals(container, JAXWSContainer.class);
086: assertEquals(
087: "/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml",
088: profile.getToolspec());
089: }
090:
091: protected Generator getGenerator(FrontEnd frontend, int index) {
092: return frontend.getGenerators().getGenerator().get(index);
093: }
094:
095: protected FrontEnd getFrontEnd(Map<String, FrontEnd> frontends,
096: int index) {
097: int size = frontends.size();
098: return frontends.values().toArray(new FrontEnd[size])[index];
099: }
100:
101: protected Plugin getPlugin(PluginLoader loader, int index) {
102: int size = loader.getPlugins().size();
103: return loader.getPlugins().values().toArray(new Plugin[size])[index];
104: }
105: }
|