Package org.drools.scm

Examples of org.drools.scm.ScmActionFactory


        assertEquals( "foo",
                      fact.toDirectoryName( "foo" ) );
    }

    public void testAddDirectories() throws Exception {
        ScmActionFactory svn = new JcrActionFactory( RepositorySessionUtil.getRepository() );

        CompositeScmAction actions = new CompositeScmAction();

        // Correctly add a new Directory at root
        actions = new CompositeScmAction();
        ScmAction addDirectory = new AddDirectory( "",
                                                   "folder1" );
        actions.addScmAction( addDirectory );

        svn.execute( actions,
                     "test message" );

        // Now check various flat and deep Directory creations
        actions = new CompositeScmAction();

        addDirectory = new AddDirectory( "folder1",
                                         "folder1_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "folder1/folder1_1",
                                         "folder1_1_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "folder1",
                                         "folder1_2" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "",
                                         "folder2/folder2_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "",
                                         "folder3/folder3_1/folder3_1_1/folder3_1_1_1" );
        actions.addScmAction( addDirectory );

        svn.execute( actions,
                     "test message" );
        //------
        // Now test results
        //-------               
        List list = convertToStringList( svn.listEntries( "" ) );

        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/folder1_1" ) );
        assertTrue( list.contains( "folder1/folder1_2" ) );
        assertTrue( list.contains( "folder2/folder2_1" ) );
View Full Code Here


        URL url = getClass().getResource( "/copy_svn_repo_empty" );
        delete( new File( url.getFile() ) );
    }

    public void testCannotAddDirectoryWithNoParent() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        try {
            ScmAction addDirectory = new AddDirectory( "folder1",
                                                    "folder1_1" );
            actions.addScmAction( addDirectory );
            svn.execute( actions,
                         "test message" );
            fail( "This should fail as 'folder1' has not yet been created" );
        } catch ( Exception e ) {

        }
View Full Code Here

        }
    }

    public void testCannotAddDuplicateDirectories() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        // Correctly add a new directory at root
        actions = new CompositeScmAction();
        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );

        svn.execute( actions,
                     "test message" );

        // Check we can't add duplicate Directorys
        try {
            actions = new CompositeScmAction();
            addDirectory = new AddDirectory( "",
                                          "folder1" );
            actions.addScmAction( addDirectory );
            svn.execute( actions,
                         "test message" );
            fail( "This should fail as 'folder1' already exists" );
        } catch ( Exception e ) {

        }
View Full Code Here

        }
    }

    public void testAddDirectories() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        // Correctly add a new Directory at root
        actions = new CompositeScmAction();
        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );

        svn.execute( actions,
                     "test message" );

        // Now check various flat and deep Directory creations
        actions = new CompositeScmAction();

        addDirectory = new AddDirectory( "folder1",
                                      "folder1_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "folder1/folder1_1",
                                      "folder1_1_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "folder1",
                                      "folder1_2" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "",
                                      "folder2/folder2_1" );
        actions.addScmAction( addDirectory );

        addDirectory = new AddDirectory( "",
                                      "folder3/folder3_1/folder3_1_1/folder3_1_1_1" );
        actions.addScmAction( addDirectory );

        svn.execute( actions,
                     "test message" );
        //------
        // Now test results
        //-------               
        List list = convertToStringList( svn.listEntries( "" ) );

        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/folder1_1" ) );
        assertTrue( list.contains( "folder1/folder1_2" ) );
        assertTrue( list.contains( "folder2/folder2_1" ) );
View Full Code Here

        assertTrue( list.contains( "folder2/folder2_1" ) );
        assertTrue( list.contains( "folder3/folder3_1/folder3_1_1/folder3_1_1_1" ) );
    }

    public void testAddFiles() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );

        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         new byte[]{1, 1, 1, 1} );
        actions.addScmAction( addFile );

        addDirectory = new AddDirectory( "folder1",
                                      "folder1_1" );
        actions.addScmAction( addDirectory );

        addFile = new AddFile( "folder1/folder1_1",
                               "file1_1.dat",
                               new byte[]{0, 0, 0, 0} );
        actions.addScmAction( addFile );

        svn.execute( actions,
                     "test message" );

        // Check the contents are correct
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( new byte[]{1, 1, 1, 1},
                                   baos.toByteArray() ) );

        baos = new ByteArrayOutputStream();
        svn.getContent( "folder1/folder1_1",
                        "file1_1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( new byte[]{0, 0, 0, 0},
                                   baos.toByteArray() ) );

        // Check the directories are correctly created
        List list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder1/folder1_1" ) );
        assertTrue( list.contains( "folder1/folder1_1/file1_1.dat" ) );
    }
View Full Code Here

        assertTrue( list.contains( "folder1/folder1_1" ) );
        assertTrue( list.contains( "folder1/folder1_1/file1_1.dat" ) );
    }

    public void testUpdateFile() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );

        byte[] oldContent = new byte[]{1, 1, 1, 1};
        byte[] newContent = new byte[]{1, 0, 1, 0};

        // Add the initial file
        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         oldContent );
        actions.addScmAction( addFile );
        svn.execute( actions,
                     "test message" );

        // Check the contents are correct
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( oldContent,
                                   baos.toByteArray() ) );

        // Update the existing file
        actions = new CompositeScmAction();
        ScmAction updateFile = new UpdateFile( "folder1",
                                               "file1.dat",
                                               oldContent,
                                               newContent );
        actions.addScmAction( updateFile );
        svn.execute( actions,
                     "test message" );

        // Check the contents are correct
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( newContent,
                                   baos.toByteArray() ) );

        // Check the correct directory structue was created
        List list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
    }
View Full Code Here

        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
    }

    public void testCopyFile() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );
        byte[] content = new byte[]{1, 1, 1, 1};
        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         content );
        actions.addScmAction( addFile );
        svn.execute( actions,
                     "test message" );

        // Check the contents are correct
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        List list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
        assertFalse( list.contains( "folder2/file2.dat" ) );

        // Now copy the file
        actions = new CompositeScmAction();
        addDirectory = new AddDirectory( "",
                                      "folder2" );
        actions.addScmAction( addDirectory );
        ScmAction copyFile = new CopyFile( "folder1",
                                           "file1.dat",
                                           "folder2",
                                           "file2.dat",
                                           svn.getLatestRevision() );
        actions.addScmAction( copyFile );
        svn.execute( actions,
                     "test message" );

        baos = new ByteArrayOutputStream();
        svn.getContent( "folder2",
                        "file2.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder2/file2.dat" ) );
    }
View Full Code Here

        assertTrue( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder2/file2.dat" ) );
    }

    public void testCopyDirectory() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );
        byte[] content1 = new byte[]{1, 1, 1, 1};
        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         content1 );
        actions.addScmAction( addFile );

        addDirectory = new AddDirectory( "folder1",
                                      "folder1_1" );
        actions.addScmAction( addDirectory );
        byte[] content2 = new byte[]{1, 0, 0, 1};
        addFile = new AddFile( "folder1/folder1_1",
                               "file1.dat",
                               content2 );
        actions.addScmAction( addFile );
        svn.execute( actions,
                     "test message" );

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content1,
                                   baos.toByteArray() ) );
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder1/folder1_1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content2,
                                   baos.toByteArray() ) );

        List list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/folder1_1/file1.dat" ) );
        assertFalse( list.contains( "folder2/folder1/file1.dat" ) );

        // Now copy the directory
        actions = new CompositeScmAction();
        addDirectory = new AddDirectory( "",
                                      "folder2" );
        actions.addScmAction( addDirectory );
        ScmAction copyDirectory = new CopyDirectory( "folder1",
                                                     "folder2/folder1",
                                                     svn.getLatestRevision() );
        actions.addScmAction( copyDirectory );
        svn.execute( actions,
                     "test message" );

        baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content1,
                                   baos.toByteArray() ) );
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder1/folder1_1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content2,
                                   baos.toByteArray() ) );
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder2/folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content1,
                                   baos.toByteArray() ) );
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder2/folder1/folder1_1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content2,
                                   baos.toByteArray() ) );

        list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/folder1_1/file1.dat" ) );
        assertTrue( list.contains( "folder2/folder1/file1.dat" ) );
    }
View Full Code Here

        assertTrue( list.contains( "folder1/folder1_1/file1.dat" ) );
        assertTrue( list.contains( "folder2/folder1/file1.dat" ) );
    }

    public void testMoveFile() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );
        byte[] content = new byte[]{1, 1, 1, 1};
        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         content );
        actions.addScmAction( addFile );
        svn.execute( actions,
                     "test message" );

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        List list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertTrue( list.contains( "folder1/file1.dat" ) );
        assertFalse( list.contains( "folder2/file2.dat" ) );

        // No do the file move
        actions = new CompositeScmAction();
        addDirectory = new AddDirectory( "",
                                      "folder2" );
        actions.addScmAction( addDirectory );
        MoveFile moveFile = new MoveFile( "folder1",
                                          "file1.dat",
                                          "folder2",
                                          "file2.dat",
                                          svn.getLatestRevision() );
        actions.addScmAction( moveFile );
        svn.execute( actions,
                     "test message" );

        baos = new ByteArrayOutputStream();
        svn.getContent( "folder2",
                        "file2.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        list = convertToStringList( svn.listEntries( "" ) );
        assertTrue( list.contains( "folder1" ) );
        assertFalse( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder2/file2.dat" ) );
    }
View Full Code Here

        assertFalse( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder2/file2.dat" ) );
    }

    public void testMoveDirectory() throws Exception {
        ScmActionFactory svn = new SvnActionFactory( svnUrl,
                                                     "mrtrout",
                                                     "drools" );

        CompositeScmAction actions = new CompositeScmAction();

        ScmAction addDirectory = new AddDirectory( "",
                                                "folder1" );
        actions.addScmAction( addDirectory );
        byte[] content = new byte[]{1, 1, 1, 1};
        ScmAction addFile = new AddFile( "folder1",
                                         "file1.dat",
                                         content );
        actions.addScmAction( addFile );
        svn.execute( actions,
                     "test message" );

        // check the intial content and dir structure
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        svn.getContent( "folder1",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        actions = new CompositeScmAction();
        MoveDirectory moveDirectory = new MoveDirectory( "folder1",
                                                         "folder2",
                                                         svn.getLatestRevision() );
        actions.addScmAction( moveDirectory );
        svn.execute( actions,
                     "test message" );

        // Check the moved content and dir structure
        baos = new ByteArrayOutputStream();
        svn.getContent( "folder2",
                        "file1.dat",
                        -1,
                        baos );
        assertTrue( Arrays.equals( content,
                                   baos.toByteArray() ) );

        List list = convertToStringList( svn.listEntries( "" ) );

        assertFalse( list.contains( "folder1" ) );
        assertFalse( list.contains( "folder1/file1.dat" ) );
        assertTrue( list.contains( "folder2/file1.dat" ) );
    }
View Full Code Here

TOP

Related Classes of org.drools.scm.ScmActionFactory

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.