- public static Node<?> readInputToCnSn(String path, boolean dummyNamespaces,
- MessageBodyReader<Node<?>> reader) throws WebApplicationException {
-
- InputStream inputStream = TestUtils.class.getResourceAsStream(path);
- try {
- final Node<?> node = reader.readFrom(null, null, null, null, null, inputStream);
- assertTrue(node instanceof CompositeNodeWrapper);
- if (dummyNamespaces) {
- try {
- TestUtils.addDummyNamespaceToAllNodes((CompositeNodeWrapper) node);
- return ((CompositeNodeWrapper) node).unwrap();
- } catch (URISyntaxException e) {
- LOG.error(e.getMessage());
- assertTrue(e.getMessage(), false);
- }
- }
- return node;
- } catch (IOException e) {
- LOG.error(e.getMessage());
- assertTrue(e.getMessage(), false);
- }
- return null;
- }
-
-// public static Node<?> readInputToCnSnNew(String path, MessageBodyReader<Node<?>> reader) throws WebApplicationException {
-// InputStream inputStream = TestUtils.class.getResourceAsStream(path);
-// try {
-// return reader.readFrom(null, null, null, null, null, inputStream);
-// } catch (IOException e) {
-// LOG.error(e.getMessage());
-// assertTrue(e.getMessage(), false);
-// }
-// return null;
-// }
-
- public static Node<?> readInputToCnSn(String path, MessageBodyReader<Node<?>> reader) {
- return readInputToCnSn(path, false, reader);
- }
-
- public static String writeCompNodeWithSchemaContextToOutput(Node<?> node, Set<Module> modules,
- DataSchemaNode dataSchemaNode, MessageBodyWriter<StructuredData> messageBodyWriter) throws IOException,
- WebApplicationException {
-
- assertNotNull(dataSchemaNode);
- assertNotNull("Composite node can't be null", node);
- ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
-
- ControllerContext.getInstance().setSchemas(loadSchemaContext(modules));
-
- assertTrue(node instanceof CompositeNode);
- messageBodyWriter.writeTo(new StructuredData((CompositeNode)node, dataSchemaNode, null), null, null, null, null,
- null, byteArrayOS);
-
- return byteArrayOS.toString();
- }
-
- public static String loadTextFile(String filePath) throws IOException {
- FileReader fileReader = new FileReader(filePath);
- BufferedReader bufReader = new BufferedReader(fileReader);