### Question:
KMLPeeker implements StartElementInspector { public boolean isKml(URL url) { boolean isKml = false; try { InputStream stream = openStream(url); if (stream != null) { try { isKml = XMLUtilities.canUnmarshal(stream, this); if (!isKml) { stream.close(); stream = openStream(url); if (stream != null) { isKml = StreamUtilities.isZipInputStreamNoReset(stream); } } } finally { if (stream != null) { stream.close(); } } } } catch (IOException | GeneralSecurityException | URISyntaxException e) { LOGGER.error(e.getMessage(), e); } return isKml; } KMLPeeker(Toolbox toolbox); boolean isKml(URL url); @Override boolean isValidStartElement(StartElement element);  }### Answer:
@Test public void testIsKmlDocument() throws GeneralSecurityException, IOException, URISyntaxException { EasyMockSupport support = new EasyMockSupport(); String xml = "<Document xmlns=\"http: Toolbox toolbox = createToolbox(support, xml); support.replayAll(); KMLPeeker peeker = new KMLPeeker(toolbox); assertTrue(peeker.isKml(new URL(ourUrl))); support.verifyAll(); }
@Test public void testIsKmlFalse() throws MalformedURLException, GeneralSecurityException, IOException, URISyntaxException { EasyMockSupport support = new EasyMockSupport(); String xml = "someplaintext"; Toolbox toolbox = createToolbox(support, xml); support.replayAll(); KMLPeeker peeker = new KMLPeeker(toolbox); assertFalse(peeker.isKml(new URL(ourUrl))); support.verifyAll(); }
@Test public void testIsKmlTrue() throws GeneralSecurityException, IOException, URISyntaxException { EasyMockSupport support = new EasyMockSupport(); String xml = "<kml></kml>"; Toolbox toolbox = createToolbox(support, xml); support.replayAll(); KMLPeeker peeker = new KMLPeeker(toolbox); assertTrue(peeker.isKml(new URL(ourUrl))); support.verifyAll(); }