Package org.codehaus.enunciate.contract.jaxb

Examples of org.codehaus.enunciate.contract.jaxb.ComplexTypeDefinition


  /**
   * 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


*/
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

   */
  public void testAddTypeDefinition() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    int nsCount = model.getNamespacesToPrefixes().size();
    ComplexTypeDefinition typeDef1 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne"));
    String targetNamespace = typeDef1.getNamespace();
    assertNull(model.findTypeDefinition(typeDef1));
    model.add(typeDef1);
    SchemaInfo schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNull("The element form default should not have been set.", schemaInfo.getElementFormDefault());
    assertNull("The attribute form default should not have been set.", schemaInfo.getAttributeFormDefault());
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef1));
    assertNotNull(model.findTypeDefinition(typeDef1));
    assertEquals(targetNamespace, schemaInfo.getNamespace());

    nsCount += 1;
    assertEquals("There should have been one and only one new namespace added", nsCount, model.getNamespacesToPrefixes().size());

    ComplexTypeDefinition typeDef2 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOne"));
    targetNamespace = typeDef2.getNamespace();
    assertNull(model.findTypeDefinition(typeDef2));
    model.add(typeDef2);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef2));
    assertNotNull(model.findTypeDefinition(typeDef2));
    assertEquals(targetNamespace, schemaInfo.getNamespace());
    assertEquals("qualified", schemaInfo.getElementFormDefault());
    assertEquals("qualified", schemaInfo.getAttributeFormDefault());
    nsCount += 3;
    assertEquals("There should have been three new namespaces added, as specified in the package info for the schema.", nsCount, model.getNamespacesToPrefixes().size());

    ComplexTypeDefinition typeDef3 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanTwo"));
    targetNamespace = typeDef3.getNamespace();
    assertNull(model.findTypeDefinition(typeDef3));
    model.add(typeDef3);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef3));
View Full Code Here

      }
    };
    FreemarkerModel.set(model);
    int nsCount = model.getNamespacesToPrefixes().size();
    ClassDeclaration declaration = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree");
    TypeDefinition typeDef1 = new ComplexTypeDefinition(declaration);
    RootElementDeclaration element1 = new RootElementDeclaration(declaration, typeDef1);
    String targetNamespace = element1.getNamespace();
    assertNull(model.findRootElementDeclaration(element1));
    model.add(element1);
    SchemaInfo schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNull("The element form default should not have been set.", schemaInfo.getElementFormDefault());
    assertNull("The attribute form default should not have been set.", schemaInfo.getAttributeFormDefault());
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.rootElements.contains(element1));
    assertNotNull(model.findRootElementDeclaration(element1));
    assertEquals(targetNamespace, schemaInfo.getNamespace());

    nsCount += 1;
    assertEquals("There should have been one and only one new namespace added", nsCount, model.getNamespacesToPrefixes().size());

    declaration = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanThree");
    ComplexTypeDefinition typeDef2 = new ComplexTypeDefinition(declaration);
    RootElementDeclaration element2 = new RootElementDeclaration(declaration, typeDef2);
    targetNamespace = element2.getNamespace();
    assertNull(model.findRootElementDeclaration(element2));
    model.add(element2);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.rootElements.contains(element2));
    assertNotNull(model.findRootElementDeclaration(element2));
    assertEquals(targetNamespace, schemaInfo.getNamespace());
    assertEquals("qualified", schemaInfo.getElementFormDefault());
    assertEquals("qualified", schemaInfo.getAttributeFormDefault());
    nsCount += 3;
    assertEquals("There should have been three new namespaces added, as specified in the package info for the schema.", nsCount, model.getNamespacesToPrefixes().size());

    declaration = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanFour");
    ComplexTypeDefinition typeDef3 = new ComplexTypeDefinition(declaration);
    RootElementDeclaration element3 = new RootElementDeclaration(declaration, typeDef3);
    targetNamespace = element3.getNamespace();
    assertNull(model.findRootElementDeclaration(element3));
    model.add(element3);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
View Full Code Here

  /**
   * Tests the names and properties of a web param.
   */
  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

  /**
   * see https://jira.codehaus.org/browse/ENUNCIATE-626
   */
  public void testAdaptingSubclassedAdapter() throws Exception {
    TypeDeclaration decl = getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanWithPropertyAdaptedBySubclass");
    ComplexTypeDefinition ct = new ComplexTypeDefinition((ClassDeclaration) decl);
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    model.add(ct);
    Element el = ct.getElements().first();
    assertEquals(KnownXmlType.LONG.getQname(), el.getBaseType().getQname());
//    assertEquals("org.codehaus.enunciate.samples.anotherschema.BeanTwo", ((DeclaredType) el.getAdapterType().getAdaptedType()).getDeclaration().getQualifiedName());
  }
View Full Code Here

  /**
   * see https://jira.codehaus.org/browse/ENUNCIATE-514
   */
  public void testAdaptingIfaceToImpl() throws Exception {
    TypeDeclaration decl = getDeclaration("org.codehaus.enunciate.samples.schema.BeanWithAdaptedIfaceAccessor");
    ComplexTypeDefinition ct = new ComplexTypeDefinition((ClassDeclaration) decl);
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    model.add(ct);
    Element el = ct.getElements().first();
    assertEquals(new QName("urn:adaptediface", "adaptediface"), el.getBaseType().getQname());
//    assertEquals("org.codehaus.enunciate.samples.anotherschema.BeanTwo", ((DeclaredType) el.getAdapterType().getAdaptedType()).getDeclaration().getQualifiedName());
  }
View Full Code Here

   */
  public void testFindSpecifiedType() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);

    model.add(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.AdaptedBeanTwo")));

    ClassDeclaration adaptedBeanExamplesDeclaration = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.AdaptedBeanExamples");
    ComplexTypeDefinition examples = new ComplexTypeDefinition(adaptedBeanExamplesDeclaration);
    Accessor beanOneField = null;
    Accessor beanThreeField = null;
    Accessor beanFourField = null;
    Accessor stringBufferField = null;
    for (Accessor fieldDeclaration : examples.getElements()) {
      if ("adaptedBeanOne".equals(fieldDeclaration.getSimpleName())) {
        beanOneField = fieldDeclaration;
      }
      else if ("adaptedBeanThree".equals(fieldDeclaration.getSimpleName())) {
        beanThreeField = fieldDeclaration;
      }
      else if ("stringBuffer".equals(fieldDeclaration.getSimpleName())) {
        stringBufferField = fieldDeclaration;
      }
      else if ("beanFour".equals(fieldDeclaration.getSimpleName())) {
        beanFourField = fieldDeclaration;
      }
    }

    assertNotNull(beanFourField);
    XmlType beanFourXmlType = XmlTypeFactory.findExplicitSchemaType(beanFourField);
    assertEquals("The xml type for bean four should have been specified at the package-level.", "specified-bean-four", beanFourXmlType.getName());
    assertEquals("The xml type for bean four should have been specified at the package-level.", "http://org.codehaus.enunciate/core/samples/beanfour", beanFourXmlType.getNamespace());
    assertNull(XmlTypeFactory.findSpecifiedType(new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.DifferentPackageReferencingBeanFour")).getElements().first()));

    assertNotNull(beanOneField);
    assertEquals(new QName("http://org.codehaus.enunciate/core/samples/another", "adaptedBeanTwo"), XmlTypeFactory.findSpecifiedType(beanOneField).getQname());
    assertNotNull(beanThreeField);
    assertEquals(KnownXmlType.STRING.getQname(), XmlTypeFactory.findSpecifiedType(beanThreeField).getQname());
    assertNotNull(stringBufferField);
    assertEquals(KnownXmlType.STRING.getQname(), XmlTypeFactory.findSpecifiedType(stringBufferField).getQname());

    EndpointInterface ei = new EndpointInterface(adaptedBeanExamplesDeclaration);
    WebParam beanFourParam = ei.getWebMethods().iterator().next().getWebParameters().iterator().next();
    assertNotNull(beanFourParam);
    assertEquals(new QName("http://org.codehaus.enunciate/core/samples/another", "adaptedBeanTwo"), XmlTypeFactory.findSpecifiedType(beanFourParam).getQname());

    try {
      new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.AdaptedBeanBadExamples"));
      fail("Shouldn't be a valid xml type adapter.");
    }
    catch (ValidationException e) {
      //fall through...
    }

    try {
      new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.AdaptedBeanBadExamples2"));
      fail("Shouldn't be a valid xml type adapter.");
    }
    catch (ValidationException e) {
      //fall through...
    }
View Full Code Here

    XmlType stringXmlType = XmlTypeFactory.getXmlType(stringType);
    assertSame(KnownXmlType.STRING, stringXmlType);
    assertSame(stringXmlType, XmlTypeFactory.getXmlType(String.class));

    ClassDeclaration decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanThree");
    ComplexTypeDefinition definition = new ComplexTypeDefinition(decl);
    model.add(definition);
    DeclaredType beanThreeType = Context.getCurrentEnvironment().getTypeUtils().getDeclaredType(decl);
    assertNotNull("The xml type for bean three should have been created.", XmlTypeFactory.getXmlType(beanThreeType));
  }
View Full Code Here

      }
    };
    meth.setJdk15(true);

    ClassDeclaration decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.SelfReferencingClass");
    ComplexTypeDefinition ct = new ComplexTypeDefinition(decl);
    assertTrue(String.valueOf(meth.exec(Arrays.asList(ct))).startsWith("org.codehaus.enunciate.samples.client.schema.SelfReferencingClass"));

    decl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.SelfReferencingPropertyBean");
    ct = new ComplexTypeDefinition(decl);
    assertTrue(String.valueOf(meth.exec(Arrays.asList(ct.getElements().first()))).startsWith("org.codehaus.enunciate.samples.client.schema.SelfReferencingClass"));
  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.jaxb.ComplexTypeDefinition

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.