Package net.sourceforge.purrpackage.recording

Examples of net.sourceforge.purrpackage.recording.PropDb


    }

    @Test
    public void testWriteAndRead() throws IOException {
        File dir = new File(System.getProperty("java.io.tmpdir"));
        PropDb db = new PropDb();
        db.setCount(12);
        db.setPackageName("foo");
        db.write(dir);
        PropDb back = new PropDb();
        back.read(dir);
        assertEquals(back.getCount(), db.getCount());
        assertEquals(back.getPackageName(), db.getPackageName());
    }
View Full Code Here


     */
    @Test
    public void testSampleDirectory() throws IOException {
        sabotageIo = false;
        System.out.println(testdataDir.getCanonicalPath());
        PropDb q = new PropDb();
        q.read(testdataDir);
        System.out.println(q);
        PropDb x = new PropDb();
        x.setCount(new Integer(12));
        x.setPackageName("something");
        x.write(testdataDir);
        accum.loadDirectory(testdataDir);
        assertEquals(2, accum.getUnloadableFiles().size(),
                accum.getUnloadableFiles() + "");
        for (String s : accum.getUnloadableFiles().keySet()) {
            Exception e = accum.getUnloadableFiles().get(s);
View Full Code Here

                f.delete();
            }
            subdir.delete();
        }
        subdir.mkdirs();
        PropDb db = new PropDb();
        db.read(subdir);
        assertNull(db.getCount());
        assertNull(db.getPackageName());

        db = new PropDb();
        Properties p = new Properties();
        FileOutputStream fos = new FileOutputStream(new File(dir,
                PropDb.FILE_NAME));
        p.store(fos, "broken");
        fos.close();
        try {
            db.read(dir);
            fail();
        } catch (Exception e) {
            assertTrue(e.getMessage().indexOf(PropDb.FILE_NAME) > -1);
        }

        db = new PropDb() {
            @Override
            Properties makeProperties() {
                return new Properties() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void load(InputStream is) throws IOException {
                        throw new IOException("Sabotage");
                    }

                    @Override
                    public void store(OutputStream is, String comment)
                            throws IOException {
                        throw new IOException("Sabotage");
                    }
                };
            }
        };
        try {
            db.read(dir);
            fail();
        } catch (IOException e) {
            assertEquals(e.getMessage(), "Sabotage");
        }
        try {
            db.setPackageName("foo");
            db.setCount(12);
            db.write(dir);
            fail();
        } catch (IOException e) {
            assertEquals(e.getMessage(), "Sabotage");

        }
View Full Code Here

TOP

Related Classes of net.sourceforge.purrpackage.recording.PropDb

Copyright © 2018 www.massapicom. 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.