Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-4730

CamelBlueprintTestSupport doesnt support multiple blueprint descriptors

XMLWordPrintable

    • % %
    • 6.3 Sprint 1 (4-Jan->29-Jan)

      A new method has been added into CamelBlueprintTestSupport called - expectBlueprintContainerReloadOnConfigAdminUpdate.
      It expects that the getBlueprintDescriptor is a single string, where as it supports multiples via commas.

      Fixed upstream in
      https://github.com/apache/camel/blob/master/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java#L249

      To fix this issue, override the code with the below:

      @Override
      protected boolean expectBlueprintContainerReloadOnConfigAdminUpdate() {
          boolean expectedReload = false;
      	Iterator<Object> it = ObjectHelper.createIterator(getBlueprintDescriptor());
          while (it.hasNext()) {
              String s = (String) it.next();
      	    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      	    dbf.setNamespaceAware(true);
      	    try {
      	        // cm-1.0 doesn't define update-strategy attribute
      	        Set<String> cmNamesaces = new HashSet<>(Arrays.asList(
      	                CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_1,
      	                CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_2,
      	                CmNamespaceHandler.BLUEPRINT_CM_NAMESPACE_1_3
      	        ));
      	        
      	        DocumentBuilder db = dbf.newDocumentBuilder();
      	        Document doc = db.parse(ResourceHelper.resolveResourceAsInputStream(RESOLVER, s));
      	        NodeList nl = doc.getDocumentElement().getChildNodes();
      	        for (int i = 0; i < nl.getLength(); i++) {
      	            Node node = nl.item(i);
      	            if (node instanceof Element) {
      	                Element pp = (Element) node;
      	                if (cmNamesaces.contains(pp.getNamespaceURI())) {
      	                    String us = pp.getAttribute("update-strategy");
      	                    if (us != null && us.equals("reload")) {
      	                        expectedReload = true;
      	                        break;
      	                    }
      	                }
      	            }
      	        }
      	        
      	        if (expectedReload) {
      	        	break;
      	        }
      	    } catch (Exception e) {
      	        throw new RuntimeException(e.getMessage(), e);
      	    }
      	}
              
          return expectedReload;
      }
      

      Notice that in the above, i am using 'Iterator<Object> it = ObjectHelper.createIterator(getBlueprintDescriptor());' to loop over the list of descriptors and also 'ResourceHelper.resolveResourceAsInputStream(RESOLVER, s)' to resolve the file to a stream.

            ggrzybek Grzegorz Grzybek
            rhn-support-lakagwu Lami Akagwu
            Tomas Turek Tomas Turek
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: