@Test
 public void testReadConfigBinding() throws Exception {
   ModelPuller<RESTEasyBindingModel> puller = new ModelPuller<RESTEasyBindingModel>();
   RESTEasyBindingModel model = puller.pull(REST_BINDING, getClass());
   Assert.assertTrue(model.isModelValid());
   model = puller.pull(REST_BINDING_INVALID, getClass());
   Assert.assertFalse(model.isModelValid());
 }
 @Test
 public void testWriteComplete() throws Exception {
   String old_xml = new StringPuller().pull(COMPLETE_XML, getClass());
   SwitchYardModel switchyard = _puller.pull(new StringReader(old_xml));
   String new_xml = switchyard.toString();
   XMLUnit.setIgnoreWhitespace(true);
   Diff diff = XMLUnit.compareXML(old_xml, new_xml);
   Assert.assertTrue(diff.toString(), diff.identical());
 }
 @Test
 public void testReadComplete() throws Exception {
   SwitchYardModel switchyard = _puller.pull(COMPLETE_XML, getClass());
   CompositeModel composite = switchyard.getComposite();
   ComponentModel component = composite.getComponents().get(0);
   ComponentImplementationModel implementation = component.getImplementation();
   Assert.assertTrue(implementation instanceof BeanComponentImplementationModel);
   BeanComponentImplementationModel bci = (BeanComponentImplementationModel) implementation;
   Assert.assertEquals("bean", bci.getType());
   Assert.assertEquals("org.switchyard.example.m1app.SimpleBean", bci.getClazz());
   Configuration config = bci.getModelConfiguration();
   Assert.assertEquals("implementation.bean", config.getName());
   QName qname = config.getQName();
   Assert.assertEquals("urn:switchyard-component-bean:config:1.0", qname.getNamespaceURI());
   Assert.assertEquals("implementation.bean", qname.getLocalPart());
 }
示例#4
0
  @Before
  public void setUp() throws Exception {
    _puller = new ModelPuller<CompositeModel>();
    CompositeModel composite = _puller.pull("/HelloSwitchYard.xml", getClass());
    composite.assertModelValid();

    CompositeServiceModel compositeService = composite.getServices().get(0);
    _config = (HttpBindingModel) compositeService.getBindings().get(0);

    // Massive hack for Test Runner. Register both a service and a reference binding.
    _domain.registerService(_config.getServiceName(), new InOutService(), mockService);
    _domain.registerServiceReference(_config.getServiceName(), new InOutService());
    _httpInbound = new InboundHandler(_config, _domain);
    _httpInbound.start();

    CompositeReferenceModel compositeReference = composite.getReferences().get(0);
    _configRef = (HttpBindingModel) compositeReference.getBindings().get(0);

    _httpOutbound = new OutboundHandler(_configRef);
    // Massive hack for Test Runner. Register both a service and a reference binding.
    _domain.registerService(_configRef.getServiceName(), new HelloInterface(), _httpOutbound);
    _domain.registerServiceReference(_configRef.getServiceName(), new HelloInterface());
    _httpOutbound.start();
  }
 @Test
 public void testValidation() throws Exception {
   SwitchYardModel switchyard = _puller.pull(COMPLETE_XML, getClass());
   switchyard.assertModelValid();
 }