Package org.codehaus.enunciate.apt

Examples of org.codehaus.enunciate.apt.EnunciateFreemarkerModel


  /**
   * tests a basic collection element ref.
   */
  public void testBasicCollectionRef() throws Exception {
    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());

    ClassDeclaration decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotOne");
    ComplexTypeDefinition type = new ComplexTypeDefinition(decl);
    RootElementDeclaration rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotTwo");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanThree");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanFour");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.ElementRefsBean"));
    PropertyDeclaration property = findProperty(typeDef, "beanThrees");
    ElementRef element = new ElementRef(property, typeDef);
    assertEquals(1, element.getChoices().size());
View Full Code Here


    }
  }

  @Override
  public void doFreemarkerGenerate() throws IOException, TemplateException {
    EnunciateFreemarkerModel model = getModel();

    Map<String, SchemaInfo> ns2schema = model.getNamespacesToSchemas();
    Map<String, WsdlInfo> ns2wsdl = model.getNamespacesToWSDLs();

    model.put("prefix", new PrefixMethod());
    model.put("isDefinedGlobally", new IsDefinedGloballyMethod());
    model.setVariable("uniqueContentTypes", new UniqueContentTypesMethod());
    model.put("wadlStylesheetUri", this.wadlStylesheetUri);
    model.put("accessorOverridesAnother", new AccessorOverridesAnotherMethod());
    model.put("qnameForType", new QNameForTypeMethod());
    File artifactDir = getGenerateDir();
    model.setFileOutputDirectory(artifactDir);
    boolean upToDate = isUpToDate(artifactDir);
    if (!upToDate) {
      processTemplate(getTemplateURL(), model);
    }
    else {
      info("Skipping generation of XML files since everything appears up-to-date...");
    }

    for (WsdlInfo wsdl : ns2wsdl.values()) {
      File wsdlFile = (File) wsdl.getProperty("file");
      if (wsdlFile == null) {
        String file = (String) wsdl.getProperty("filename");
        wsdlFile = new File(artifactDir, file);
        wsdl.setProperty("file", wsdlFile);

        if (!upToDate && prettyPrint) {
          prettyPrint(wsdlFile);
        }
      }

      FileArtifact wsdlArtifact = new FileArtifact(getName(), wsdl.getId() + ".wsdl", wsdlFile);
      wsdlArtifact.setDescription("WSDL file for namespace " + wsdl.getTargetNamespace());
      getEnunciate().addArtifact(wsdlArtifact);
    }

    for (SchemaInfo schemaInfo : ns2schema.values()) {
      File schemaFile = (File) schemaInfo.getProperty("file");
      if (schemaFile == null) {
        String file = (String) schemaInfo.getProperty("filename");
        schemaFile = new File(artifactDir, file);
        schemaInfo.setProperty("file", schemaFile);

        if (!upToDate && prettyPrint) {
          prettyPrint(schemaFile);
        }

        if (!upToDate && validateSchemas) {
          //todo: write some logic to validate the schemas.
        }
      }

      FileArtifact schemaArtifact = new FileArtifact(getName(), schemaInfo.getId() + ".xsd", schemaFile);
      schemaArtifact.setDescription("Schema file for namespace " + schemaInfo.getNamespace());
      getEnunciate().addArtifact(schemaArtifact);
    }

    if (!isDisableWadl()) {
      File wadl = new File(artifactDir, "application.wadl");
      if (wadl.exists()) {
        FileArtifact wadlArtifact = new FileArtifact(getName(), "application.wadl", wadl);
        wadlArtifact.setDescription("WADL document");
        getEnunciate().addArtifact(wadlArtifact);
        prettyPrint(wadl);
        model.setWadlFile(wadl);
      }
    }
  }
View Full Code Here

  /**
   * tests a collection element ref.
   */
  public void testSuperTypeCollectionRef() throws Exception {
    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());

    ClassDeclaration decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotOne");
    ComplexTypeDefinition type = new ComplexTypeDefinition(decl);
    RootElementDeclaration rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotTwo");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanThree");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOne");
    type = new ComplexTypeDefinition(decl);
    model.add(type);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanFour");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.ElementRefsBean"));
    PropertyDeclaration property = findProperty(typeDef, "beanOnes");
    ElementRef element = new ElementRef(property, typeDef);
    Collection<ElementRef> choices = element.getChoices();
View Full Code Here

  /**
   * tests a collection of specified element refs.
   */
  public void testSpecifiedElementsCollectionRef() throws Exception {
    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());

    ClassDeclaration decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotOne");
    ComplexTypeDefinition type = new ComplexTypeDefinition(decl);
    RootElementDeclaration rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOneDotTwo");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanThree");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOne");
    type = new ComplexTypeDefinition(decl);
    model.add(type);

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanFour");
    type = new ComplexTypeDefinition(decl);
    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.ElementRefsBean"));
    PropertyDeclaration property = findProperty(typeDef, "foursAndThrees");
    ElementRef element = new ElementRef(property, typeDef);
    Collection<ElementRef> choices = element.getChoices();
View Full Code Here

  /**
   * the names and properties of a web result.
   */
  public void testNamesAndProperties() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne")));
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanTwo")));
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree")));
    FreemarkerModel.set(model);
    EndpointInterface ei = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.WebMethodExamples"));

    WebMethod docLitBareMethod = null;
    WebMethod docLitWrappedMethod = null;
View Full Code Here

  /**
   * tests the list of endpoint implementations for this ei.
   */
  public void testEndpointImplementations() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);

    EndpointInterface ei = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.NoNamespaceWebService"));
    Collection<EndpointImplementation> impls = ei.getEndpointImplementations();
    assertEquals(3, impls.size());
View Full Code Here

* @author Ryan Heaton
*/
public class TestWebMethod extends InAPTTestCase {

  public void testName() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne")));
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanTwo")));
    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree")));
    FreemarkerModel.set(model);
    EndpointInterface ei = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.WebMethodExamples"));

    WebMethod specialNameMethod = null;
    WebMethod docBareVoidMethod = null;
View Full Code Here

  /**
   * Tests the default implicit web fault.
   */
  public void testDefaultImplicitWebFault() throws Exception {
    FreemarkerModel.set(new EnunciateFreemarkerModel());
    WebFault webFault = new WebFault((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.services.ImplicitWebFault"));
    assertEquals("ImplicitWebFault", webFault.getMessageName());
    assertEquals("ImplicitWebFault", webFault.getElementName());
    assertEquals("org.codehaus.enunciate.samples.services.jaxws.ImplicitWebFaultBean", webFault.getImplicitFaultBeanQualifiedName());
    assertEquals("http://services.samples.enunciate.codehaus.org/", webFault.getTargetNamespace());
View Full Code Here

  /**
   * Tests the implicit web fault.
   */
  public void testImplicitWebFault() throws Exception {
    FreemarkerModel.set(new EnunciateFreemarkerModel());
    WebFault webFault = new WebFault((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.services.ImplicitWebFaultTwo"));
    assertEquals("ImplicitWebFaultTwo", webFault.getMessageName());
    assertEquals("implicit-fault", webFault.getElementName());
    assertEquals("urn:implicit-fault", webFault.getTargetNamespace());
    assertEquals("ImplicitWebFaultTwo", webFault.getPartName());
View Full Code Here

  /**
   * tests the explicit web fault.
   */
  public void testExplicitWebFault() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    model.add(new RootElementDeclaration((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree"), null));
    FreemarkerModel.set(model);
    WebFault webFault = new WebFault((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.services.ExplicitFaultBean"));
    assertNotNull(webFault.getExplicitFaultBeanType());
    assertEquals("ExplicitFaultBean", webFault.getMessageName());
    assertNull(webFault.getElementName());
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.apt.EnunciateFreemarkerModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.