- ControllerContext.getInstance().setGlobalSchema( schemaContextModules );
-
- CompositeNode depth1Cont = toCompositeNode(
- toCompositeNodeData( toNestedQName( "depth1-cont" ),
- toCompositeNodeData( toNestedQName( "depth2-cont1" ),
- toCompositeNodeData( toNestedQName( "depth3-cont1" ),
- toCompositeNodeData( toNestedQName( "depth4-cont1" ),
- toSimpleNodeData( toNestedQName( "depth5-leaf1" ), "depth5-leaf1-value" )
- ),
- toSimpleNodeData( toNestedQName( "depth4-leaf1" ), "depth4-leaf1-value" )
- ),
- toSimpleNodeData( toNestedQName( "depth3-leaf1" ), "depth3-leaf1-value" )
- ),
- toCompositeNodeData( toNestedQName( "depth2-cont2" ),
- toCompositeNodeData( toNestedQName( "depth3-cont2" ),
- toCompositeNodeData( toNestedQName( "depth4-cont2" ),
- toSimpleNodeData( toNestedQName( "depth5-leaf2" ), "depth5-leaf2-value" )
- ),
- toSimpleNodeData( toNestedQName( "depth4-leaf2" ), "depth4-leaf2-value" )
- ),
- toSimpleNodeData( toNestedQName( "depth3-leaf2" ), "depth3-leaf2-value" )
- ),
- toSimpleNodeData( toNestedQName( "depth2-leaf1" ), "depth2-leaf1-value" )
- ) );
-
- when( brokerFacade.readConfigurationData( any( InstanceIdentifier.class ) ) )
- .thenReturn( depth1Cont );
+ private void getDataWithUriIncludeWhiteCharsParameter(final String target) throws UnsupportedEncodingException {
+ mockReadConfigurationDataMethod();
+ mockReadOperationalDataMethod();
+ final String uri = "/" + target + "/ietf-interfaces:interfaces/interface/eth0";
+ Response response = target(uri).queryParam("prettyPrint", "false").request("application/xml").get();
+ final String xmlData = response.readEntity(String.class);
+
+ Pattern pattern = Pattern.compile(".*(>\\s+|\\s+<).*", Pattern.DOTALL);
+ Matcher matcher = pattern.matcher(xmlData);
+ // XML element can't surrounded with white character (e.g "> " or
+ // " <")
+ assertFalse(matcher.matches());
+
+ response = target(uri).queryParam("prettyPrint", "false").request("application/json").get();
+ final String jsonData = response.readEntity(String.class);
+ pattern = Pattern.compile(".*(\\}\\s+|\\s+\\{|\\]\\s+|\\s+\\[|\\s+:|:\\s+).*", Pattern.DOTALL);
+ matcher = pattern.matcher(jsonData);
+ // JSON element can't surrounded with white character (e.g "} ", " {",
+ // "] ", " [", " :" or ": ")
+ assertFalse(matcher.matches());
+ }
+
+ @Test
+ @Ignore
+ public void getDataWithUriDepthParameterTest() throws UnsupportedEncodingException {
+ setControllerContext(schemaContextModules);
+
+ final CompositeNode depth1Cont = toCompositeNode(toCompositeNodeData(
+ toNestedQName("depth1-cont"),
+ toCompositeNodeData(
+ toNestedQName("depth2-cont1"),
+ toCompositeNodeData(
+ toNestedQName("depth3-cont1"),
+ toCompositeNodeData(toNestedQName("depth4-cont1"),
+ toSimpleNodeData(toNestedQName("depth5-leaf1"), "depth5-leaf1-value")),
+ toSimpleNodeData(toNestedQName("depth4-leaf1"), "depth4-leaf1-value")),
+ toSimpleNodeData(toNestedQName("depth3-leaf1"), "depth3-leaf1-value")),
+ toCompositeNodeData(
+ toNestedQName("depth2-cont2"),
+ toCompositeNodeData(
+ toNestedQName("depth3-cont2"),
+ toCompositeNodeData(toNestedQName("depth4-cont2"),
+ toSimpleNodeData(toNestedQName("depth5-leaf2"), "depth5-leaf2-value")),
+ toSimpleNodeData(toNestedQName("depth4-leaf2"), "depth4-leaf2-value")),
+ toSimpleNodeData(toNestedQName("depth3-leaf2"), "depth3-leaf2-value")),
+ toSimpleNodeData(toNestedQName("depth2-leaf1"), "depth2-leaf1-value")));
+
+ final Module module = TestUtils.findModule(schemaContextModules.getModules(), "nested-module");
+ assertNotNull(module);
+
+ final DataSchemaNode dataSchemaNode = TestUtils.resolveDataSchemaNode("depth1-cont", module);
+ assertNotNull(dataSchemaNode);
+
+ when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn(
+ TestUtils.compositeNodeToDatastoreNormalizedNode(depth1Cont, dataSchemaNode));