Source:
<code>public void testInvalidAttribute() throws Exception { Assert.assertNotSame(0, com.datatorrent.api.Context.DAGContext.serialVersionUID); Attribute<String> attribute = new Attribute<>("", null); Field nameField = Attribute.class.getDeclaredField("name"); nameField.setAccessible(true); nameField.set(attribute, "NOT_CONFIGURABLE"); nameField.setAccessible(false); ContextUtils.addAttribute(com.datatorrent.api.Context.DAGContext.class, attribute); AttributeParseUtils.initialize(); ConfElement.initialize(); Properties props = new Properties(); props.put(StreamingApplication.DT_PREFIX + "attr.NOT_CONFIGURABLE", "value"); LogicalPlanConfiguration dagBuilder = new LogicalPlanConfiguration(new Configuration(false)); dagBuilder.addFromProperties(props, null); try { dagBuilder.prepareDAG(new LogicalPlan(), null, ""); Assert.fail("Exception expected"); } catch (Exception e) { Assert.assertThat("Attribute not configurable", e.getMessage(), RegexMatcher.matches("Attribute does not support property configuration: NOT_CONFIGURABLE.*")); } ContextUtils.removeAttribute(com.datatorrent.api.Context.DAGContext.class, attribute); AttributeParseUtils.initialize(); ConfElement.initialize(); props = new Properties(); String invalidAttribute = StreamingApplication.DT_PREFIX + "attr.INVALID_NAME"; props.put(invalidAttribute, "value"); try { new LogicalPlanConfiguration(new Configuration(false)).addFromProperties(props, null); Assert.fail("Exception expected"); } catch (Exception e) { <START> LOG.debug("Exception message: {}", e.getMessage()); <END> Assert.assertThat("Invalid attribute name", e.getMessage(), RegexMatcher.matches("Invalid attribute reference: " + invalidAttribute)); } }</code><technical_language>LOG.debug("Exception message: {}", e);</technical_language>

Target:
public void testInvalidAttribute() throws Exception { Assert.assertNotSame(0, com.datatorrent.api.Context.DAGContext.serialVersionUID); Attribute<String> attribute = new Attribute<>("", null); Field nameField = Attribute.class.getDeclaredField("name"); nameField.setAccessible(true); nameField.set(attribute, "NOT_CONFIGURABLE"); nameField.setAccessible(false); ContextUtils.addAttribute(com.datatorrent.api.Context.DAGContext.class, attribute); AttributeParseUtils.initialize(); ConfElement.initialize(); Properties props = new Properties(); props.put(StreamingApplication.DT_PREFIX + "attr.NOT_CONFIGURABLE", "value"); LogicalPlanConfiguration dagBuilder = new LogicalPlanConfiguration(new Configuration(false)); dagBuilder.addFromProperties(props, null); try { dagBuilder.prepareDAG(new LogicalPlan(), null, ""); Assert.fail("Exception expected"); } catch (Exception e) { Assert.assertThat("Attribute not configurable", e.getMessage(), RegexMatcher.matches("Attribute does not support property configuration: NOT_CONFIGURABLE.*")); } ContextUtils.removeAttribute(com.datatorrent.api.Context.DAGContext.class, attribute); AttributeParseUtils.initialize(); ConfElement.initialize(); props = new Properties(); String invalidAttribute = StreamingApplication.DT_PREFIX + "attr.INVALID_NAME"; props.put(invalidAttribute, "value"); try { new LogicalPlanConfiguration(new Configuration(false)).addFromProperties(props, null); Assert.fail("Exception expected"); } catch (Exception e) { LOG.debug("Exception message: {}", e); Assert.assertThat("Invalid attribute name", e.getMessage(), RegexMatcher.matches("Invalid attribute reference: " + invalidAttribute)); } }