### Question:
MicroIntegratorRegistry extends AbstractRegistry { @Override public OMNode lookup(String key) { if (log.isDebugEnabled()) { log.debug("==> Repository fetch of resource with key : " + key); } String resolvedRegKeyPath = resolveRegistryURI(key); URLConnection urlConnection; URL url = null; try { url = new URL(resolvedRegKeyPath); } catch (MalformedURLException e) { handleException("Invalid path '" + resolvedRegKeyPath + "' for URL", e); } if (lookupUtil(key, url)) { return null; } try { urlConnection = url.openConnection(); urlConnection.connect(); } catch (IOException e) { return null; } InputStream input = null; try { input = urlConnection.getInputStream(); } catch (IOException e) { handleException("Error when getting a stream from the URL", e); } if (input == null) { return null; } BufferedInputStream inputStream = new BufferedInputStream(input); OMNode result = null; try { XMLStreamReader parser = XMLInputFactory.newInstance(). createXMLStreamReader(inputStream); StAXOMBuilder builder = new StAXOMBuilder(parser); result = builder.getDocumentElement(); } catch (OMException | XMLStreamException ignored) { if (log.isDebugEnabled()) { log.debug("The resource at the provided URL isn't well-formed XML,So,takes it as a text"); } try { inputStream.close(); } catch (IOException e) { log.error("Error in closing the input stream. ", e); } try { result = readNonXML(url); } catch (IOException e) { log.error("Error occurred while retrieving text content from registry artifact", e); result = null; } } finally { try { if (result != null && result.getParent() != null) { result.detach(); OMDocumentImpl parent = new OMDocumentImpl(OMAbstractFactory.getOMFactory()); parent.addChild(result); } inputStream.close(); } catch (IOException e) { log.error("Error in closing the input stream.", e); } } return result; } MicroIntegratorRegistry(); static Long getResourceLastModifiedEntry(String path); static void addResourceLastModifiedEntry(String path, Long version); static void deleteResourceLastModifiedEntry(String path); @Override void init(Properties properties); @Override OMNode lookup(String key); @Override boolean isResourceExists(String key); @Override RegistryEntry getRegistryEntry(String key); @Override OMNode lookupFormat(String key); @Override RegistryEntry[] getChildren(RegistryEntry entry); @Override RegistryEntry[] getDescendants(RegistryEntry entry); @Override void delete(String path); @Override void newResource(String path, boolean isDirectory); @Override void newNonEmptyResource(String path, boolean isDirectory, String mediaType, String content,
                                    String propertyName); @Override void updateResource(String path, Object value); @Override void updateRegistryEntry(RegistryEntry entry); @Override Properties getResourceProperties(String entryKey); Resource getResource(String key);  }### Answer:
@Test public void testRegistryResourceRead() throws IOException { OMNode omNode = microIntegratorRegistry.lookup("gov:/custom/checkJsScript.js"); String mediaType = ((DataHandler) ((OMTextImpl) omNode).getDataHandler()).getContentType(); Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType); }
@Test public void testRegistryResourceReadWithEmptyMediaType() { OMNode omNode = microIntegratorRegistry.lookup("conf:/custom/QueueName"); Assert.assertEquals("File content should be as expected","ordersQueue", ((OMTextImpl) omNode).getText().trim()); }