### Question:
LayerActivationHandler implements LayerActivationListener { @Override public void layerActivated(GeoPackageDataTypeInfo layer) { String packageFile = layer.getLayer().getPackageFile(); GeoPackage geoPackage = GeoPackageManager.open(new File(packageFile)); GeoPackageImageEnvoy envoy = new GeoPackageImageEnvoy(myToolbox, geoPackage); myEnvoyRegistry.addObjectsForSource(packageFile, New.list(envoy)); myTileActivationListener.layerActivated(layer); } LayerActivationHandler(Toolbox toolbox, LayerActivationListener tileActivationListener); @Override void layerActivated(GeoPackageDataTypeInfo layer); @Override void layerDeactivated(GeoPackageDataTypeInfo layer);  }### Answer:
@Test public void testLayerActivated() throws IOException { EasyMockSupport support = new EasyMockSupport(); File testFile = File.createTempFile("test", ".gpkg"); testFile.deleteOnExit(); testFile = new File(testFile.getParentFile(), "a" + testFile.getName()); testFile.deleteOnExit(); GeoPackageManager.create(testFile); GeoPackageLayer geoLayer = new GeoPackageLayer("package", testFile.toString(), "tile", LayerType.TILE, 100); GenericRegistry<Envoy> envoyRegistry = new GenericRegistry<>(); Toolbox toolbox = createToolbox(support, envoyRegistry); LayerActivationListener tileListener = support.createMock(LayerActivationListener.class); GeoPackageDataTypeInfo layer = createFeatureLayer(geoLayer); tileListener.layerActivated(EasyMock.eq(layer)); tileListener.layerDeactivated(EasyMock.eq(layer)); support.replayAll(); LayerActivationHandler handler = new LayerActivationHandler(toolbox, tileListener); handler.layerActivated(layer); Collection<Envoy> envoys = envoyRegistry.getObjectsForSource(geoLayer.getPackageFile()); GeoPackageImageEnvoy envoy = (GeoPackageImageEnvoy)envoys.iterator().next(); DataModelCategory category = new DataModelCategory(geoLayer.getPackageFile(), "tile", Image.class.getName()); assertTrue(envoy.providesDataFor(category)); handler.layerDeactivated(layer); assertTrue(envoyRegistry.getObjectsForSource(geoLayer.getPackageFile()).isEmpty()); support.verifyAll(); }