Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Unmarshaller


    /**
     * Set the href to an object that HAS have an id, but an inexistent one
     * @throws Exception
     */
    public void testMarshallInexistentHref() throws Exception {
        Unmarshaller unmarshaller = new Unmarshaller (PartialTermination.class);
       
        try {
            PartialTermination entity = (PartialTerminationunmarshaller.unmarshal(new InputSource(getClass().getResource("input-ok.xml").toExternalForm()));
           
            AssignmentNotification[] assignmentNotification = entity.getAssignmentNotification();
            // assertEquals(assignmentNotification[0].getPartyReference().getHref(), entity.getPartyTwo());
           
            PartyTwo partyTwo = new PartyTwo();
View Full Code Here


   
    /**
     * Set the href manually null
     */
    public void testMarshallNullHref() throws Exception {
        Unmarshaller unmarshaller = new Unmarshaller (PartialTermination.class);
       
        try {
            PartialTermination entity = (PartialTerminationunmarshaller.unmarshal(new InputSource(getClass().getResource("input-ok.xml").toExternalForm()));
           
            AssignmentNotification[] assignmentNotification = entity.getAssignmentNotification();
            assignmentNotification[0].getPartyReference().setHref(null);
           
            StringWriter out = new StringWriter();
View Full Code Here

    /**
     * Set the href to an object that doesnt have an id
     * @throws Exception
     */
    public void testMarshallWrongHref() throws Exception {
        Unmarshaller unmarshaller = new Unmarshaller (PartialTermination.class);
       
        try {
            PartialTermination entity = (PartialTerminationunmarshaller.unmarshal(new InputSource(getClass().getResource("input-ok.xml").toExternalForm()));
           
            AssignmentNotification[] assignmentNotification = entity.getAssignmentNotification();
            assignmentNotification[0].getPartyReference().setHref("bla");
           
            StringWriter out = new StringWriter();
View Full Code Here

        InputSource source = new InputSource(url);
        _jdoConfBaseURL = source.getSystemId();
       
        CpactfConf cpactfconf = null;
        try {
            Unmarshaller unmarshaller = new Unmarshaller(CpactfConf.class);
            unmarshaller.setEntityResolver(new DTDResolver(null));
            cpactfconf = (CpactfConf) unmarshaller.unmarshal(source);
        } catch (MarshalException e) {
            throw new CPAConfigException(e);
        } catch (ValidationException e) {
            throw new CPAConfigException(e);
        }
View Full Code Here

                          || node.getLocalName().equals(JDOConstants.ANNOTATIONS_COLUMN_NAME)
                          || node.getLocalName().equals(JDOConstants.ANNOTATIONS_ONE_TO_ONE_NAME)
                          || node.getLocalName().equals(JDOConstants.ANNOTATIONS_ONE_TO_MANY))) {
              XMLContext context = new XMLContext();
              context.addPackage(JDOConstants.GENERATED_ANNOTATION_CLASSES_PACKAGE);
              Unmarshaller unmarshaller = context.createUnmarshaller();              
              unmarshaller.setClassLoader(getClass().getClassLoader());
              _appInfo.getJdoContent().add(unmarshaller.unmarshal(node));
          }           
          //-- add to appInfo
          _appInfo.add(node);
      } else {
          //-- add to parent AnyNode
View Full Code Here

            is = this.getClass().getResourceAsStream(TYPE_MAPPINGS);
        mapping.loadMapping( new InputSource(is) );

                //unmarshall the list of built in simple types
            Unmarshaller unmarshaller= new Unmarshaller(TypeList.class);
            unmarshaller.setMapping(mapping);
            //-- turn off validation
            unmarshaller.setValidation(false);

                is = this.getClass().getResourceAsStream(TYPE_DEFINITIONS);
            TypeList typeList = (TypeList)unmarshaller.unmarshal( new org.xml.sax.InputSource(is) );

                //print what we just read (only in debug mode and if we have a logWriter)
            // TODO: Joachim 2007-09-04 remove me
                // LocalConfiguration config = LocalConfiguration.getInstance();
                if (LOG.isDebugEnabled()) {
View Full Code Here

        }

        //-- Else we let the unmarshaller get us the class
        try {
            Class clazz = loader.loadClass(type);
            Unmarshaller unmarshaller = new Unmarshaller(clazz);
            return unmarshaller.unmarshal(new StringReader(value));
        } catch (ValidationException e) {
            //--this can't happen, just log it
            e.printStackTrace();
        }
View Full Code Here

     *         anything went wrong.
     * @throws Exception if anything goes wrong during the test
     */
    protected Object testUnmarshal(final InputStream stream) throws Exception {
        Object result = null;
        final Unmarshaller unmar = createUnmarshaler();
        result = unmar.unmarshal(new InputSource(stream));
        return result;
    }
View Full Code Here

        Configuration config = _unitTest.getConfiguration();
        if (config == null) {
            config = _configuration;
        }

        final Unmarshaller unmar;
        if (_mapping != null) {
//J            unmar = new Unmarshaller(_mapping);
            unmar = getXMLContext().createUnmarshaller();
            unmar.setMapping(_mapping);
        } else {
            if (_test.getClassLoader() != null) {
//J                unmar = new Unmarshaller(_rootClass, _test.getClassLoader());
                unmar = getXMLContext().createUnmarshaller();
                unmar.setClassLoader(_test.getClassLoader());
                unmar.setClass(_rootClass);
            } else {
//J                unmar = new Unmarshaller(_rootClass);
                unmar = getXMLContext().createUnmarshaller();
                unmar.setClass(_rootClass);
            }
        }

        if (_listener != null
                && _listener instanceof org.exolab.castor.xml.UnmarshalListener
                && _listenerType != TypeType.MARSHAL) {
            unmar.setUnmarshalListener((org.exolab.castor.xml.UnmarshalListener)_listener);
        }

        if (_listener != null
                && _listener instanceof org.castor.xml.UnmarshalListener
                && _listenerType != TypeType.MARSHAL) {
            unmar.setUnmarshalListener((org.castor.xml.UnmarshalListener)_listener);
        }

        unmar.setDebug(_verbose);

        if (config != null) {
            ConfigurationType unmarshal = config.getUnmarshal();
            List returnValues = invokeEnumeratedMethods(unmar, unmarshal);
            returnValues.clear(); // We don't care about the return values
View Full Code Here

        MappingRoot root = mapping.getRoot();
        _idResolver.setMapping(root);

        try {
            // Load the specificed mapping source
            Unmarshaller unm = new Unmarshaller(MappingRoot.class);
            unm.setValidation(false);
            unm.setEntityResolver(resolver);
            unm.setClassLoader(Mapping.class.getClassLoader());
            unm.setIDResolver(_idResolver);
            unm.setUnmarshalListener(
                    new MappingUnmarshallListener(this, mapping, resolver));

            MappingRoot loaded = (MappingRoot) unm.unmarshal(source);
               
            // Load all the included mapping by reference
            //-- note: this is just for processing any
            //-- includes which may have previously failed
            //-- using the IncludeListener...and to
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.Unmarshaller

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.