@Test
    public void testCreateDeleteImageMosaicDatastore() throws MalformedURLException, UnsupportedEncodingException {
        if (!enabled()) {
            return;
        }
        deleteAll();
        
        final String wsName = "geosolutions";
        final String coverageStoreName = "resttestImageMosaic";

        final GSImageMosaicEncoder coverageEncoder = new GSImageMosaicEncoder();
        /*
         * unused in mosaic creation
         * this is only useful if you want to modify an existing coverage:
         * publisher.configureCoverage(ce, wsname, csname);
         * or create a new one from an existing store:
         * publisher.createCoverage(ce, wsname, csname);
         */
//        coverageEncoder.setName("time_geotiff");
        
        coverageEncoder.setAllowMultithreading(true);
        coverageEncoder.setBackgroundValues("");
        coverageEncoder.setFilter("");
        coverageEncoder.setInputTransparentColor("");
        coverageEncoder.setLatLonBoundingBox(-180, -90, 180, 90, "EPSG:4326");
        coverageEncoder.setMaxAllowedTiles(6000);
        coverageEncoder.setNativeBoundingBox(-180, -90, 180, 90, "EPSG:4326");
        coverageEncoder.setOutputTransparentColor("");
        coverageEncoder.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
        coverageEncoder.setSRS("EPSG:4326");
        coverageEncoder.setSUGGESTED_TILE_SIZE("256,256");
        coverageEncoder.setUSE_JAI_IMAGEREAD(true);

        GSVersionDecoder v=reader.getGeoserverVersion();
        if (v.compareTo(GSVersionDecoder.VERSION.v24)>=0){
            GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
                    "GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
                    "dobson units", "REAL_32BITS");
            coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);            
        }

            // activate time
            final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
            time.setPresentation(Presentation.LIST);
            // set time metadata
            coverageEncoder.setMetadata("time", time);
            // not active elevation
            coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());

        
        
        assertTrue(publisher.createWorkspace(wsName));
        
        LOGGER.info(coverageEncoder.toString());
        
        final String styleName = "raster";
        File sldFile;
		try {
			sldFile = new ClassPathResource("testdata/raster.sld").getFile();
	        // insert style
	        assertTrue(publisher.publishStyle(sldFile));
		} catch (IOException e1) {
			assertFalse(e1.getLocalizedMessage(),Boolean.FALSE);
			e1.printStackTrace();
		}

        
        GSLayerEncoder layerEncoder=new GSLayerEncoder();
        
        layerEncoder.setDefaultStyle(styleName);
        LOGGER.info(layerEncoder.toString());
        // creation test
        RESTCoverageStore coverageStore =null;
        try {
        	final File mosaicFile = new ClassPathResource("testdata/time_geotiff/").getFile();
        	
        	if (!publisher.publishExternalMosaic(wsName,coverageStoreName,mosaicFile,coverageEncoder,layerEncoder)){
        		fail();
        	}
    		coverageStore = reader.getCoverageStore(wsName,coverageStoreName);
    		
    		if (coverageStore==null){
                LOGGER.error("*** coveragestore " + coverageStoreName + " has not been created.");
                fail("*** coveragestore " + coverageStoreName + " has not been created.");
    		}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
			fail(e.getLocalizedMessage());
		} catch (IOException e) {
			e.printStackTrace();
			fail(e.getLocalizedMessage());
		}
        // Get a Granule
        String coverageName = "time_geotiff";
        RESTStructuredCoverageGranulesList granules = reader.getGranules(wsName, coverageStoreName, coverageName, null, null, null);
        String granuleId = granules.get(0).getFid();
        // Test Granule Exists
        assertTrue(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId));
        // test a Granule does not exists
        assertFalse(reader.existsGranule(wsName, coverageStoreName, coverageName, granuleId.substring(0, granuleId.indexOf(".")) + "." + granules.size() + 1));
		
        // removing recursively coveragestore
        boolean removed = publisher.removeCoverageStore(coverageStore.getWorkspaceName(), coverageStore.getName(), true);
        if( ! removed ){
            LOGGER.error("*** CoverageStore " + coverageStoreName + " has not been removed.");
            fail("*** CoverageStore " + coverageStoreName + " has not been removed.");
        }
        
        assertTrue(publisher.removeStyle(styleName));
        assertTrue(publisher.removeWorkspace(wsName));
    }