Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Unmarshaller


       
        addTest(setupHarness());
    }
   
    private TestHarness setupHarness() throws Exception {
        Unmarshaller unm;
        Harness harness;
        TestHarness testApp;
        Mapping mapping;

        unm = new Unmarshaller(Harness.class);
        mapping = new Mapping();
        mapping.loadMapping(Main.class.getResource("harness/mapping.xml"));
        unm.setMapping(mapping);
        if (_testRes != null) {
            harness = (Harness) unm.unmarshal(new InputStreamReader(
                    Main.class.getResourceAsStream(_testRes)));
        } else if (_testFile != null) {
            harness = (Harness) unm.unmarshal(new InputStreamReader(
                    new FileInputStream(_testFile)));
        } else if (_testUrl != null) {
            harness = (Harness) unm.unmarshal(new InputStreamReader(
                    (new URL(_testUrl)).openStream()));
        } else {
            harness = (Harness) unm.unmarshal(new InputStreamReader(
                    Main.class.getResourceAsStream(DEFAULT_FILE)));
        }
        testApp = harness.createTestHarness(_testBranchs);
        return testApp;
    }
View Full Code Here


  public static void main(String[] args) throws Exception
  {
    Mapping mapping = new Mapping(Item.class.getClassLoader());
    mapping.loadMapping("mapping.xml");

    Unmarshaller unmarshaller = new Unmarshaller(mapping);
    unmarshaller.setClassLoader(Item.class.getClassLoader());
    unmarshaller.setValidation(false);
    Item item = (Item) unmarshaller.unmarshal(new InputSource(new java.io.FileInputStream(args[0])));

    System.out.println("description     =" + item.description);
    System.out.println("mediaDescription=" + item.mediaDescription);
  }
View Full Code Here

     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testMarshallingAfterManuallyNullingID() throws Exception {
       
        Unmarshaller unmarshaller = new Unmarshaller (PartialTerminationElement.class);
       
        PartialTerminationElement entity = (PartialTerminationElement)
           unmarshaller.unmarshal(new InputSource(this.getClass().getResource("input-ok.xml").toExternalForm()));
        // assertNotNull (entity);
       
        entity.getPartyOneElement().setId("");
       
        StringWriter out = new StringWriter();
View Full Code Here

    /**
     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testMarshallingAfterManuallySettingDuplicateID() throws Exception {
        Unmarshaller unmarshaller = new Unmarshaller (PartialTerminationElement.class);
       
        PartialTerminationElement entity = (PartialTerminationElement)
           unmarshaller.unmarshal(new InputSource(getClass().getResource("input-ok.xml").toExternalForm()));
        // assertNotNull (entity);
       
        entity.getPartyOneElement().setId("ID000001");
       
        StringWriter out = new StringWriter();
View Full Code Here

     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testUnmarshalEntity() throws Exception {

        Unmarshaller unmarshaller = getXMLContext().createUnmarshaller();
        unmarshaller.setClass(Entity.class);
       
        Entity entity = (Entity) unmarshaller.unmarshal(new InputSource(getClass().getResource(SAMPLE_FILE).toExternalForm()));
        assertNotNull (entity);
        assertEquals (1, entity.getId().intValue());
        assertEquals("name", entity.getName());
    }
View Full Code Here

     */
    public void testUnmarshalEntity() throws Exception {
        Mapping mapping = new Mapping();
        mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm());
       
        Unmarshaller unmarshaller = getXMLContext().createUnmarshaller();
        unmarshaller.setClass(Entity.class);
        unmarshaller.setMapping(mapping);
       
        Entity entity = (Entity) unmarshaller.unmarshal(new InputSource(getClass().getResource(SAMPLE_FILE).toExternalForm()));
        assertNotNull (entity);
        assertEquals (1, entity.getId().intValue());
        assertEquals("name", entity.getName());
    }
View Full Code Here

     * @throws ValidationException if there is a validation error
     */
    public static Configuration read(InputStream stream)
            throws IOException, MarshalException, ValidationException {
        Configuration result = null;
        Unmarshaller unmarshaller = new Unmarshaller(Configuration.class);
        InputStreamReader reader = new InputStreamReader(stream);
        AttributeExpander handler = new AttributeExpander(reader);
        result = (Configuration) unmarshaller.unmarshal(handler);
        return setDefaults(result);
    }
View Full Code Here

        if (source == null) {
            throw new IOException(
                    "Failed to find default configuration: " + DEFAULT_CONFIG);
        }
        try {
            Unmarshaller stream = new Unmarshaller(DefaultConfiguration.class);
            AttributeExpander handler = new AttributeExpander(
                    new InputStreamReader(source));
            result = (DefaultConfiguration) stream.unmarshal(handler);
        } finally {
            try {
                source.close();
            } catch (IOException ignore) {
            }
View Full Code Here

        if (_binding == null) {
            _binding = new ExtendedBinding();
        }

        //do not use the static method to ensure validation is turned on
        Unmarshaller unmarshaller = new Unmarshaller(Binding.class);
        unmarshaller.setValidation(true);

        try {
            loaded = (Binding) unmarshaller.unmarshal(source);

            //--Copy one by one the components loaded in the root binding
            _binding.setDefaultBindingType(loaded.getDefaultBindingType());

            //--packages
View Full Code Here

    /**
     * Set the href to another existing element
     * @throws Exception
     */
    public void testMarshallChangeHref() throws Exception {
        Unmarshaller unmarshaller = new Unmarshaller (PartialTermination.class);
       
        try {
            PartialTermination entity = (PartialTerminationunmarshaller.unmarshal(new InputSource(this.getClass().getResource("input-ok.xml").toExternalForm()));
           
            AssignmentNotification[] assignmentNotification = entity.getAssignmentNotification();
            // assertEquals(assignmentNotification[0].getPartyReference().getHref(), entity.getPartyTwo());
            assignmentNotification[0].getPartyReference().setHref(entity.getPartyOne());
           
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.