### Question:
PlatformPluginDeploymentListener implements ArtifactUrlTransformer { @Override public boolean canHandle( File artifact ) { if ( artifact == null || artifact.getName() == null || !artifact.getName().endsWith( ".zip" ) ) { return false; } ZipFile zipFile = null; try { zipFile = new ZipFile( artifact ); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while ( entries.hasMoreElements() ) { String[] splitName = entries.nextElement().getName().split( "/" ); if ( splitName.length == 2 && PLUGIN_XML_FILENAME.equals( splitName[ 1 ] ) ) { return true; } } } catch ( IOException e ) { logger.error( e.getMessage(), e ); } finally { if ( zipFile != null ) { try { zipFile.close(); } catch ( IOException e ) { } } } return false; }  @Override URL transform( URL artifact ); @Override boolean canHandle( File artifact ); static final String PROTOCOL; static final String PLUGIN_XML_FILENAME; }### Answer:
@Test public void testCantHandleNullFile() { assertFalse( platformPluginDeploymentListener.canHandle( null ) ); }
@Test public void testCantHandleNullFileName() { File file = mock( File.class ); assertFalse( platformPluginDeploymentListener.canHandle( file ) ); }
@Test public void testCantHandleNonZip() { File file = mock( File.class ); when( file.getName() ).thenReturn( "Test.notzip" ); assertFalse( platformPluginDeploymentListener.canHandle( file ) ); }
@Test public void testEatsExceptionForNonexistentFile() { platformPluginDeploymentListener.canHandle( new File( "THIS_FILE_SHOULD_NOT_EXIST_ON_YOUR_MACHINE_IT_IS_FOR_TESTING_A_NEGATIVE_CASE.dontcreatethisfile.zip" ) ); }
@Test public void testCanHandleWithPluginXmlOneDirDown() { File file = new File( this.getClass().getClassLoader() .getResource( "org/pentaho/osgi/platform/plugin/deployer/testCanHandleWithPluginXmlOneDirDown.zip" ).getFile() ); assertTrue( platformPluginDeploymentListener.canHandle( file ) ); }
@Test public void testCantHandleNoPluginXml() { File file = new File( this.getClass().getClassLoader() .getResource( "org/pentaho/osgi/platform/plugin/deployer/testCantHandleNoPlugin.xml.zip" ).getFile() ); assertFalse( platformPluginDeploymentListener.canHandle( file ) ); }