Package org.talend.esb.servicelocator.client

Examples of org.talend.esb.servicelocator.client.SLPropertiesImpl


    @Test
    public void lookUpEndpointWithReturnProps() throws ServiceLocatorException, InterruptedException {
        names.clear();
        names.add(ENDPOINTURL);

        SLPropertiesImpl slPropertiesImpl = new SLPropertiesImpl();
        List<String> list = new ArrayList<String>();
        slPropertiesImpl.addProperty("test", list);

        expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
        expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(
                endpoint);
        expect(endpoint.getProperties()).andStubReturn(slPropertiesImpl);


        return bus.getExtension(ServiceLocatorManager.class);
    }

    @Override
    public void setAvailableEndpointProperties(Map<String, String> properties) {
        slProps = new SLPropertiesImpl();

        for (Map.Entry<String, String> entry : properties.entrySet()) {
            slProps.addProperty(entry.getKey(), tokenize(entry.getValue()));
        }
    }

    public void lookUpEndpointWithReturnProps() throws InterruptedExceptionFault,
            ServiceLocatorFault, ServiceLocatorException, InterruptedException {
        names.clear();
        names.add(ENDPOINTURL);

        SLPropertiesImpl slPropertiesImpl = new SLPropertiesImpl();
        List<String> list = new ArrayList<String>();
        slPropertiesImpl.addProperty("test", list);

        expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
        expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(
                endpoint);
        expect(endpoint.getProperties()).andStubReturn(slPropertiesImpl);

            initLocator();
            BindingType bindingType = arg0.getBinding() == null ? BindingType.OTHER : BindingType
                    .valueOf(arg0.getBinding().value());
            TransportType transportType = arg0.getTransport() == null ? TransportType.OTHER
                    : TransportType.valueOf(arg0.getTransport().value());
            SLPropertiesImpl slProps = null;
            if (!arg0.getEntryType().isEmpty()) {
                slProps = new SLPropertiesImpl();
                List<EntryType> entries = arg0.getEntryType();
                for (EntryType entry : entries) {
                    slProps.addProperty(entry.getKey(), entry.getValue());
                }
            }
            Endpoint simpleEndpoint =
                new SimpleEndpoint(serviceName, endpointURL, bindingType, transportType, slProps);
            locatorClient.register(simpleEndpoint, true);

            initLocator();
            BindingType bindingType = binding == null ? BindingType.SOAP11
                    : BindingType.valueOf(binding.value());
            TransportType transportType = transport == null ? TransportType.HTTP
                    : TransportType.valueOf(transport.value());
            SLPropertiesImpl slProps = null;
            if (properties != null) {
                slProps = new SLPropertiesImpl();
                List<EntryType> entries = properties.getEntry();
                for (EntryType entry : entries) {
                    slProps.addProperty(entry.getKey(), entry.getValue());
                }
            }
            SimpleEndpoint eprProvider = new SimpleEndpoint(serviceName,
                    endpointURL, bindingType, transportType, slProps);

        }
        return slPropertiesType;
    }

    public static SLProperties toSLProperties(ServiceLocatorPropertiesType props) {
        SLPropertiesImpl slProperties = new SLPropertiesImpl();
       
        for (EntryType entry : props.getEntry()) {
            String key = entry.getKey();
            List<String> values = entry.getValue();
            slProperties.addProperty(key, values);
        }
       
        return slProperties;
    }

                        return SLPropertiesConverter.toSLProperties(slp);
                    }
                }
            }
        }
        return new SLPropertiesImpl();
    }

    public static final String VALUE_3 = "value3";

    @Test
    public void slProperties2JAXBSlPropertiesType() throws Exception {
        SLPropertiesImpl props = new SLPropertiesImpl();
        props.addProperty(KEY_1, VALUE_1, VALUE_2);
        props.addProperty(KEY_2, VALUE_2, VALUE_3);
       
        ServiceLocatorPropertiesType jaxbProperties = SLPropertiesConverter.toServiceLocatorPropertiesType(props);
        List<EntryType> entries = jaxbProperties.getEntry();
        List<String> values =  entries.get(0).getValue();
        assertEquals(VALUE_1, values.get(0));

TOP

Related Classes of org.talend.esb.servicelocator.client.SLPropertiesImpl

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.