Examples of ShpFiles


Examples of org.geotools.data.shapefile.files.ShpFiles

        shpFiles.dispose();
    }

    @Test
    public void testUnlockWriteAssertion() throws Throwable {
        ShpFiles shpFiles = new ShpFiles("http://somefile.com/shp.shp");

        URL url = shpFiles.acquireWrite(DBF, this);
        assertEquals("http://somefile.com/shp.dbf", url.toExternalForm());
        assertEquals(1, shpFiles.numberOfLocks());
        FileWriter testWriter = new FileWriter() {

            public String id() {
                return "Other";
            }

        };

        // same thread should work
        Result<URL, State> result1 = shpFiles.tryAcquireWrite(SHX, testWriter);
        assertEquals("http://somefile.com/shp.shx", result1.value
                .toExternalForm());
        assertEquals(2, shpFiles.numberOfLocks());

        try {
            shpFiles.unlockRead(result1.value, this);
            throw new RuntimeException(
                    "Unlock should fail because it is in the wrong reader");
        } catch (IllegalArgumentException e) {
            // good
        } catch (RuntimeException e) {
            fail(e.getMessage());
        }

        shpFiles.unlockWrite(url, this);
        shpFiles.unlockWrite(result1.value, testWriter);
        shpFiles.dispose();
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

            shp = shp.toUpperCase();
            dbf = dbf.toUpperCase();
            shx = shx.toUpperCase();
        }
       
        ShpFiles files = new ShpFiles(base+shp);
       
        BasicShpFileWriter requestor = new BasicShpFileWriter("testCaseURL");
        URL shpURL = files.acquireRead(SHP, requestor);
        URL dbfURL = files.acquireRead(DBF, requestor);
        URL shxURL = files.acquireRead(SHX, requestor);
        try{
            assertEquals(base+shp, shpURL.toExternalForm());
            assertEquals(base+dbf, dbfURL.toExternalForm());
            assertEquals(base+shx, shxURL.toExternalForm());
        }finally{
            files.unlockRead(shpURL, requestor);
            files.unlockRead(dbfURL, requestor);
            files.unlockRead(shxURL, requestor);
        }
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    public void testCaseFile() throws Exception {
        Map<ShpFileType, File> files = createFiles("testCaseFile", ShpFileType.values(), true);
       
        String fileName = files.get(SHP).getPath();
        fileName = fileName.substring(0, fileName.length()-4)+".shp";
        ShpFiles shpFiles = new ShpFiles(fileName);

        BasicShpFileWriter requestor = new BasicShpFileWriter("testCaseFile");
        URL shpURL = shpFiles.acquireRead(SHP, requestor);
        URL dbfURL = shpFiles.acquireRead(DBF, requestor);
        URL shxURL = shpFiles.acquireRead(SHX, requestor);
        try{
            assertEquals(files.get(SHP).toURI().toURL().toExternalForm(), shpURL.toExternalForm());
            assertEquals(files.get(DBF).toURI().toURL().toExternalForm(), dbfURL.toExternalForm());
            assertEquals(files.get(SHX).toURI().toURL().toExternalForm(), shxURL.toExternalForm());
        }finally{
            shpFiles.unlockRead(shpURL, requestor);
            shpFiles.unlockRead(dbfURL, requestor);
            shpFiles.unlockRead(shxURL, requestor);
        }
       
       
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

       
    }

    @Test
    public void testGetTypeName() throws Exception {
        assertEquals("shape", new ShpFiles("dir/shape.shp").getTypeName());
        assertEquals(".shape", new ShpFiles("dir/.shape.shp").getTypeName());
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    public void testShapefileFilesAll() throws Exception {
        Map<ShpFileType, File> expected = createFiles("testShapefileFilesAll",
                ShpFileType.values(), false);

        File file = expected.values().iterator().next();
        ShpFiles shapefiles = new ShpFiles(file);

        assertEqualMaps(expected, shapefiles.getFileNames());
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    public void testURLStringConstructor() throws Exception {
        Map<ShpFileType, File> expected = createFiles(
                "testURLStringConstructor", ShpFileType.values(), false);

        File file = expected.values().iterator().next();
        ShpFiles shapefiles = new ShpFiles(file.toURI().toURL()
                .toExternalForm());

        assertEqualMaps(expected, shapefiles.getFileNames());
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    public void testFileStringConstructor() throws Exception {
        Map<ShpFileType, File> expected = createFiles(
                "testFileStringConstructor", ShpFileType.values(), false);

        File file = expected.values().iterator().next();
        ShpFiles shapefiles = new ShpFiles(file.getPath());

        assertEqualMaps(expected, shapefiles.getFileNames());
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

        Map<ShpFileType, File> expected = createFiles("testShapefileFilesSome",
                new ShpFileType[] { SHP, DBF, SHX, PRJ }, false);

        File prj = expected.remove(PRJ);

        ShpFiles shapefiles = new ShpFiles(prj);

        assertEqualMaps(expected, shapefiles.getFileNames());
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }

    @Test
    public void testBadFormat() throws Exception {
        try {
            new ShpFiles("SomeName.woo");
            fail("The file is not one of the files types associated with a shapefile therefore the ShapefileFiles class should not be constructable");
        } catch (IllegalArgumentException e) {
            // good
        }
    }
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }

    @Test
    public void testFileInNonExistingDirectory() throws Exception {
        try {
            new ShpFiles(new File("nowhere/test.shp"));
            // ok
        } catch (Exception e) {
            fail(e.getClass().getSimpleName() + " should not be thrown");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.