Examples of FileSource


Examples of org.apache.excalibur.source.impl.FileSource

    public void testMove() throws Exception
    {
        final String text = "Original text";

        FileSource src = new FileSource("file", m_tempDir);

        FileSource child = (FileSource) src.getChild("child.txt");
        assertTrue("New file already exists", !child.exists());

        fillSource(child, text);
        assertTrue("New file doesn't exist", child.exists());
        long length = child.getContentLength();

        FileSource child2 = (FileSource) src.getChild("child2.txt");
        assertTrue("Second file already exist", !child2.exists());

        SourceUtil.move(child, child2);
        assertTrue("First file still exists", !child.exists());
        assertTrue("Second file doesn't exist", child2.exists());
        assertEquals("Wrong length of second file", length, child2.getContentLength());
    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    public void testCopy() throws Exception
    {
        final String text = "Original text";

        FileSource src = new FileSource("file", m_tempDir);

        FileSource child = (FileSource) src.getChild("child.txt");
        assertTrue("New file already exists", !child.exists());

        fillSource(child, text);
        assertTrue("New file doesn't exist", child.exists());
        long length = child.getContentLength();

        FileSource child2 = (FileSource) src.getChild("child2.txt");
        assertTrue("Second file already exist", !child2.exists());

        SourceUtil.copy(child, child2);

        assertTrue("First file doesn't exist", child.exists());
        assertTrue("Second file doesn't exist", child2.exists());
        assertEquals("Wrong length of second file", length, child2.getContentLength());

    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    public void testDelete() throws Exception
    {
        final String text = "Original text";

        FileSource src = new FileSource("file", m_tempDir);

        FileSource child = (FileSource) src.getChild("child.txt");
        assertTrue("New file already exists", !child.exists());
        fillSource(child, text);
        assertTrue("New file doesn't exist", child.exists());

        child.delete();
        assertTrue("File still exists", !child.exists());
    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

        assertTrue("File still exists", !child.exists());
    }

    public void testConcurrentAccess() throws Exception
    {
        FileSource src = new FileSource("file", m_tempDir);

        FileSource child = (FileSource) src.getChild("child.txt");
        assertTrue("New file already exists", !child.exists());

        child.getOutputStream();

        try
        {
            // Get it a second time
            child.getOutputStream();
        }
        catch (ConcurrentModificationException cme)
        {
            return; // This is what is expected
        }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    }

    public void testAtomicUpdate() throws Exception
    {
        final String text = "Blah, blah";
        FileSource src = new FileSource("file", m_tempDir);

        FileSource child = (FileSource) src.getChild("child.txt");
        assertTrue("New file already exists", !child.exists());
        fillSource(child, text + " and blah!");

        long length = child.getContentLength();

        SourceValidity validity = child.getValidity();
        assertEquals("Validity is not valid", 1, validity.isValid());

        // Wait 2 seconds before updating the file
        Thread.sleep(2 * 1000L);

        // Now change its content
        PrintWriter pw = new PrintWriter(child.getOutputStream());
        pw.write(text);

        assertEquals("File length modified", length, child.getContentLength());

        pw.close();

        assertTrue("File length not modified", length != child.getContentLength());

        assertEquals("Validity is valid", -1, validity.isValid());
    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    }

    protected void copyDirSource(Publication template, String publicationId,
            SourceResolver resolver, String publicationsUri, String source)
            throws MalformedURLException, IOException {
        FileSource directory = new FileSource(publicationsUri + "/" + template.getId() + "/"
                + source);
        Collection files = directory.getChildren();
        for (Iterator iter = files.iterator(); iter.hasNext();) {
            FileSource filesource = (FileSource) iter.next();
            if (filesource.isCollection()) {
                copyDirSource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            } else {
                copySource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            }
        }
    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    }

    protected void copyDirSource(Publication template, String publicationId,
            SourceResolver resolver, String publicationsUri, String source)
            throws MalformedURLException, IOException {
        FileSource directory = new FileSource(publicationsUri + "/" + template.getId() + "/"
                + source);
        Collection files = directory.getChildren();
        for (Iterator iter = files.iterator(); iter.hasNext();) {
            FileSource filesource = (FileSource) iter.next();
            if (filesource.isCollection()) {
                copyDirSource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            } else {
                copySource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            }
        }
    }
View Full Code Here

Examples of org.apache.excalibur.source.impl.FileSource

    protected void copyDirSource(Publication template,
            String publicationId,
            SourceResolver resolver,
            String publicationsUri,
            String source) throws MalformedURLException, IOException {
        FileSource directory = new FileSource(publicationsUri + "/" + template.getId() + "/"
                + source);
        Collection files = directory.getChildren();
        for (Iterator iter = files.iterator(); iter.hasNext();) {
            FileSource filesource = (FileSource) iter.next();
            if (filesource.isCollection()) {
                copyDirSource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            } else {
                copySource(template, publicationId, resolver, publicationsUri, source + "/"
                        + filesource.getName());
            }
        }
    }
View Full Code Here

Examples of org.apache.torque.generator.source.stream.FileSource

                .toString();
            File externalSchemaPath
                = new File(externalSchemaBaseDir, relativePath);
            try
            {
                FileSource fileSource = new FileSource(
                        new XmlSourceFormat(),
                        externalSchemaPath,
                        controllerState);
                SourceElement externalSchemaRootElement
                        = fileSource.getRootElement();
                externalSchemaRootElement.setAttribute(
                        DatabaseAttributeName.ROOT_DATABASE_NAME,
                        rootDatabaseName);
                DatabaseMapInitTransformer.setDatabaseMapInitClassNameAttributes(
                        externalSchemaRootElement,
View Full Code Here

Examples of org.apache.torque.generator.source.stream.FileSource

            File includeSchemaPath
                = new File(includeSchemaBaseDir, relativePath);
            log.trace("Trying to read included file " + includeSchemaPath);
            try
            {
                FileSource fileSource = new FileSource(
                        new XmlSourceFormat(),
                        includeSchemaPath,
                        controllerState);
                SourceElement includeSchemaRootElement
                        = fileSource.getRootElement();
                log.trace("successfully read included file "
                        + includeSchemaPath);

                this.transform(includeSchemaRootElement, controllerState);
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.