Package org.apache.tuscany.sca.binding.notification.encoding

Examples of org.apache.tuscany.sca.binding.notification.encoding.DefaultEncodingRegistry


                "</wsnt:Broker>" +
            "</wsnt:Neighbors>" +
        "</wsnt:ReplaceBrokerConnection>";
   
    public void testSubscribe() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        SubscribeEnDeCoder sed = new SubscribeEnDeCoder(der);
        sed.start();
        ConsumerReferenceEnDeCoder cred = new ConsumerReferenceEnDeCoder(der);
        cred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testSubscribe));
        reader.next();
        Subscribe subscribe = (Subscribe)der.decode(reader);
        Assert.assertEquals(subscribe.getConsumerReference().getReference().getEndpointAddress().getAddress().toString(), testUrl);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(subscribe, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testSubscribe);
    }
View Full Code Here


        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testSubscribe);
    }
   
    public void testNewConsumerResponse() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewConsumerResponseEnDeCoder ncred = new NewConsumerResponseEnDeCoder(der);
        ncred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewConsumerResponse));
        reader.next();
        NewConsumerResponse newConsumerResponse = (NewConsumerResponse)der.decode(reader);
        Assert.assertEquals(newConsumerResponse.getSequenceType(), "EndProducers");
        Assert.assertEquals(newConsumerResponse.getReferenceSequence().iterator().next().getEndpointAddress().getAddress().toString(),
                            testUrl);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newConsumerResponse, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewConsumerResponse);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewConsumerResponse);
    }
   
    public void testNoProducersResponse() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewConsumerResponseEnDeCoder ncred = new NewConsumerResponseEnDeCoder(der);
        ncred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNoProducersResponse));
        reader.next();
        NewConsumerResponse newConsumerResponse = (NewConsumerResponse)der.decode(reader);
        Assert.assertEquals(newConsumerResponse.getSequenceType(), "NoProducers");
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newConsumerResponse, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNoProducersResponse);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNoProducersResponse);
    }
   
    public void testNewProducerResponse() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewProducerResponseEnDeCoder npred = new NewProducerResponseEnDeCoder(der);
        npred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewProducerResponse));
        reader.next();
        NewProducerResponse newProducerResponse = (NewProducerResponse)der.decode(reader);
        Assert.assertEquals(newProducerResponse.getSequenceType(), "EndConsumers");
        Iterator<EndpointReference> it = newProducerResponse.getReferenceSequence().iterator();
        it.next();
        Assert.assertEquals(it.next().getEndpointAddress().getAddress().toString(), testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newProducerResponse, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewProducerResponse);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewProducerResponse);
    }

    public void testNewBroker() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewBrokerEnDeCoder nbed = new NewBrokerEnDeCoder(der);
        nbed.start();
        BrokerConsumerReferenceEnDeCoder bcred = new BrokerConsumerReferenceEnDeCoder(der);
        bcred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
        ReferencePropertiesEnDeCoder rped = new ReferencePropertiesEnDeCoder(der);
        rped.start();
        BrokerIDEnDeCoder bied = new BrokerIDEnDeCoder(der);
        bied.start();
        BrokerProducerReferenceEnDeCoder bpred = new BrokerProducerReferenceEnDeCoder(der);
        bpred.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewBroker));
        reader.next();
        NewBroker newBroker = (NewBroker)der.decode(reader);
        Assert.assertEquals(newBroker.getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl1);
        Assert.assertEquals(newBroker.getBrokerProducerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newBroker, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBroker);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBroker);
    }

    public void testNewBrokerRespnse1() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewBrokerResponseEnDeCoder nbred = new NewBrokerResponseEnDeCoder(der);
        nbred.start();
        EndProducersEnDeCoder epred = new EndProducersEnDeCoder(der);
        epred.start();
        EndConsumersEnDeCoder ecred = new EndConsumersEnDeCoder(der);
        ecred.start();
        EndpointReferenceEnDeCoder ered = new EndpointReferenceEnDeCoder(der);
        ered.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewBrokerResponse1));
        reader.next();
        NewBrokerResponse newBrokerResponse = (NewBrokerResponse)der.decode(reader);
        Assert.assertFalse(!newBrokerResponse.isFirstBroker());
        Assert.assertEquals(newBrokerResponse.getEndProducers().getSequenceType(), "NoProducers");
        Assert.assertEquals(newBrokerResponse.getEndConsumers().getSequenceType(), "EndConsumers");
        Assert.assertEquals(newBrokerResponse.getEndConsumers().getReferenceSequence().get(0).getEndpointAddress().getAddress().toString(),
                            testUrl1);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newBrokerResponse, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBrokerResponse1);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBrokerResponse1);
    }

    public void testNewBrokerRespnse2() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        NewBrokerResponseEnDeCoder nbred = new NewBrokerResponseEnDeCoder(der);
        nbred.start();
        BrokersEnDeCoder bsed = new BrokersEnDeCoder(der);
        bsed.start();
        BrokerEnDeCoder bed = new BrokerEnDeCoder(der);
        bed.start();
        BrokerConsumerReferenceEnDeCoder bcred = new BrokerConsumerReferenceEnDeCoder(der);
        bcred.start();
        BrokerProducerReferenceEnDeCoder bpred = new BrokerProducerReferenceEnDeCoder(der);
        bpred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
        ReferencePropertiesEnDeCoder rped = new ReferencePropertiesEnDeCoder(der);
        rped.start();
        BrokerIDEnDeCoder bied = new BrokerIDEnDeCoder(der);
        bied.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testNewBrokerResponse2));
        reader.next();
        NewBrokerResponse newBrokerResponse = (NewBrokerResponse)der.decode(reader);
        Assert.assertFalse(newBrokerResponse.isFirstBroker());
        Assert.assertEquals(newBrokerResponse.getBrokers().getBrokerSequence().get(0)
                            .getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl1);
        Assert.assertEquals(newBrokerResponse.getBrokers().getBrokerSequence().get(0)
                            .getBrokerProducerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(newBrokerResponse, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBrokerResponse2);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testNewBrokerResponse2);
    }

    public void testRemoveBroker() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        RemoveBrokerEnDeCoder rbed = new RemoveBrokerEnDeCoder(der);
        rbed.start();
        BrokerConsumerReferenceEnDeCoder bcred = new BrokerConsumerReferenceEnDeCoder(der);
        bcred.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
        ReferencePropertiesEnDeCoder rped = new ReferencePropertiesEnDeCoder(der);
        rped.start();
        BrokerIDEnDeCoder bied = new BrokerIDEnDeCoder(der);
        bied.start();
        NeighborBrokerConsumersEnDeCoder nbced = new NeighborBrokerConsumersEnDeCoder(der);
        nbced.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testRemoveBroker));
        reader.next();
        RemoveBroker removeBroker = (RemoveBroker)der.decode(reader);
        Assert.assertEquals(removeBroker.getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl);
        NeighborBrokerConsumers neighborBrokerConsumers = removeBroker.getNeighborBrokerConsumers();
        Assert.assertEquals(neighborBrokerConsumers.getSequenceType(), "BrokerConsumers");
        Iterator<EndpointReference> it = neighborBrokerConsumers.getReferenceSequence().iterator();
        it.next();
        Assert.assertEquals(it.next().getEndpointAddress().getAddress().toString(), testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(removeBroker, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testRemoveBroker);
    }
View Full Code Here

        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testRemoveBroker);
    }

    public void testReplaceBrokerConnection() throws Exception {
        DefaultEncodingRegistry der = new DefaultEncodingRegistry();
        ReplaceBrokerConnectionEnDeCoder rbced = new ReplaceBrokerConnectionEnDeCoder(der);
        rbced.start();
        RemovedBrokerEnDeCoder rbed = new RemovedBrokerEnDeCoder(der);
        rbed.start();
        EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
        epred.start();
        EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
        eaed.start();
        ReferencePropertiesEnDeCoder rped = new ReferencePropertiesEnDeCoder(der);
        rped.start();
        BrokerIDEnDeCoder bied = new BrokerIDEnDeCoder(der);
        bied.start();
        BrokerEnDeCoder bed = new BrokerEnDeCoder(der);
        bed.start();
        BrokerConsumerReferenceEnDeCoder bcred = new BrokerConsumerReferenceEnDeCoder(der);
        bcred.start();
        BrokerProducerReferenceEnDeCoder bpred = new BrokerProducerReferenceEnDeCoder(der);
        bpred.start();
        NeighborsEnDeCoder nced = new NeighborsEnDeCoder(der);
        nced.start();
       
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testReplaceBrokerConnection));
        reader.next();
        ReplaceBrokerConnection replaceBrokerConnection = (ReplaceBrokerConnection)der.decode(reader);
        Assert.assertEquals(replaceBrokerConnection.getRemovedBroker().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl);
        Neighbors neighbors = replaceBrokerConnection.getNeighbors();
        Assert.assertEquals(neighbors.getBrokerSequence().get(0)
                            .getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl1);
        Assert.assertEquals(neighbors.getBrokerSequence().get(0)
                            .getBrokerProducerReference().getReference().getEndpointAddress().getAddress().toString(),
                            testUrl2);
       
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        StringWriter testWriter = new StringWriter();
        XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
        der.encode(replaceBrokerConnection, writer);
        writer.flush();
        String encoded = testWriter.toString();
        Assert.assertEquals(encoded, testReplaceBrokerConnection);
    }
View Full Code Here

   
    private static final String DEFAULT_PORT = "8086";

    public void start(ExtensionPointRegistry registry) {
       
        EncodingRegistry encodingRegistry = new DefaultEncodingRegistry();
        subscribeEnDeCoder = new SubscribeEnDeCoder(encodingRegistry);
        subscribeEnDeCoder.start();
        consumerReferenceEnDeCoder = new ConsumerReferenceEnDeCoder(encodingRegistry);
        consumerReferenceEnDeCoder.start();
        endpointAddressEnDeCoder = new EndpointAddressEnDeCoder(encodingRegistry);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.notification.encoding.DefaultEncodingRegistry

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.