@Test public void testManifest() throws IOException { final ServletContext contextMock = mock(ServletContext.class); when(contextMock.getResourceAsStream(anyString())).thenReturn(new FileInputStream(new File("./src/test/resources/META-INF/MANIFEST.MF"))); Response response = cut.manifest(contextMock); assertNotNull(response.getEntity()); InputStream mockInputStream = mock(InputStream.class); when(mockInputStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(new IOException("Test bad manifest file")); when(contextMock.getResourceAsStream(anyString())).thenReturn(mockInputStream); boolean exceptionThrown = false; try { cut.manifest(contextMock); } catch (Exception e) { exceptionThrown = true; } assertTrue(exceptionThrown); }
@Override public Response manifest(ServletContext context) { Attributes attributes = null; if (context != null) { try { InputStream manifestStream = context.getResourceAsStream("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(manifestStream); attributes = manifest.getMainAttributes(); } catch (IOException e) { LOGGER.debug("Error getting manifest for " + context.getServletContextName(), e); throw new InternalErrorException(FaultType.INVALID_PATH, "Failed to read MANIFEST.MF for " + context.getServletContextName()); } } return ResponseBuilder.ok(attributes); }
AdminServiceRestImpl implements AdminServiceRest { @Override public Response manifest(ServletContext context) { Attributes attributes = null; if (context != null) { try { InputStream manifestStream = context.getResourceAsStream("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(manifestStream); attributes = manifest.getMainAttributes(); } catch (IOException e) { LOGGER.debug("Error getting manifest for " + context.getServletContextName(), e); throw new InternalErrorException(FaultType.INVALID_PATH, "Failed to read MANIFEST.MF for " + context.getServletContextName()); } } return ResponseBuilder.ok(attributes); } }
AdminServiceRestImpl implements AdminServiceRest { @Override public Response manifest(ServletContext context) { Attributes attributes = null; if (context != null) { try { InputStream manifestStream = context.getResourceAsStream("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(manifestStream); attributes = manifest.getMainAttributes(); } catch (IOException e) { LOGGER.debug("Error getting manifest for " + context.getServletContextName(), e); throw new InternalErrorException(FaultType.INVALID_PATH, "Failed to read MANIFEST.MF for " + context.getServletContextName()); } } return ResponseBuilder.ok(attributes); } AdminServiceRestImpl(FilesConfiguration theFilesConfiguration, ResourceService resourceService); }
AdminServiceRestImpl implements AdminServiceRest { @Override public Response manifest(ServletContext context) { Attributes attributes = null; if (context != null) { try { InputStream manifestStream = context.getResourceAsStream("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(manifestStream); attributes = manifest.getMainAttributes(); } catch (IOException e) { LOGGER.debug("Error getting manifest for " + context.getServletContextName(), e); throw new InternalErrorException(FaultType.INVALID_PATH, "Failed to read MANIFEST.MF for " + context.getServletContextName()); } } return ResponseBuilder.ok(attributes); } AdminServiceRestImpl(FilesConfiguration theFilesConfiguration, ResourceService resourceService); @Override Response reload(); @Override Response view(); @Override Response encrypt(String cleartext); @Override Response manifest(ServletContext context); @Override Response isJwalaAuthorizationEnabled(); @Override Response getAuthorizationDetails(); }
AdminServiceRestImpl implements AdminServiceRest { @Override public Response manifest(ServletContext context) { Attributes attributes = null; if (context != null) { try { InputStream manifestStream = context.getResourceAsStream("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(manifestStream); attributes = manifest.getMainAttributes(); } catch (IOException e) { LOGGER.debug("Error getting manifest for " + context.getServletContextName(), e); throw new InternalErrorException(FaultType.INVALID_PATH, "Failed to read MANIFEST.MF for " + context.getServletContextName()); } } return ResponseBuilder.ok(attributes); } AdminServiceRestImpl(FilesConfiguration theFilesConfiguration, ResourceService resourceService); @Override Response reload(); @Override Response view(); @Override Response encrypt(String cleartext); @Override Response manifest(ServletContext context); @Override Response isJwalaAuthorizationEnabled(); @Override Response getAuthorizationDetails(); static final String JSON_RESPONSE_TRUE; static final String JSON_RESPONSE_FALSE; }