~piastucki/bzr-eclipse/execute-bit

« back to all changes in this revision

Viewing changes to org.vcs.bazaar.eclipse.core.tests/src/org/vcs/bazaar/eclipse/core/commands/CommitCommandTest.java

  • Committer: Guillermo Gonzalez
  • Date: 2010-02-02 06:40:31 UTC
  • mfrom: (219 trunk)
  • mto: This revision was merged to the branch mainline in revision 223.
  • Revision ID: guillo.gonzo@gmail.com-20100202064031-r0hch2h8bq67y1sx
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import java.util.List;
10
10
 
11
11
import org.eclipse.core.resources.IFile;
12
 
import org.eclipse.core.resources.IProject;
13
12
import org.eclipse.core.resources.IResource;
14
13
import org.eclipse.core.runtime.NullProgressMonitor;
15
14
import org.eclipse.core.runtime.Path;
16
 
import org.junit.After;
17
 
import org.junit.Before;
18
15
import org.junit.Test;
19
16
import org.vcs.bazaar.client.BazaarStatusKind;
20
17
import org.vcs.bazaar.client.BazaarTreeStatus;
21
 
import org.vcs.bazaar.client.IBazaarClient;
22
18
import org.vcs.bazaar.client.commandline.commands.options.Option;
23
 
import org.vcs.bazaar.client.testUtils.ExpectedWorkingTree;
24
 
import org.vcs.bazaar.eclipse.AbstractCoreTestCase;
25
19
import org.vcs.bazaar.eclipse.BzrWorkspaceRoot;
26
 
import org.vcs.bazaar.eclipse.EclipseBazaarCore;
27
 
import org.vcs.bazaar.eclipse.WorkspaceUtil;
28
 
import org.vcs.bazaar.eclipse.core.commands.CommitCommand;
 
20
import org.vcs.bazaar.eclipse.TestCaseWithProject;
29
21
import org.vcs.bazaar.eclipse.core.model.local.IBzrLocalResource;
30
 
import org.vcs.bazaar.eclipse.core.repository.BazaarTeamProvider;
31
22
 
32
23
/**
33
24
 * 
34
25
 * @author Guillermo Gonzalez <guillo.gonzo@gmail.com>
35
26
 *
36
27
 */
37
 
public class CommitCommandTest extends AbstractCoreTestCase {
38
 
 
39
 
        private IProject project;
40
 
        private ExpectedWorkingTree wt;
41
 
        private IBazaarClient client;
42
 
 
43
 
        @Before
44
 
        public void setUp() throws Exception {
45
 
                client = EclipseBazaarCore.getDefault().createClient();
46
 
                project = WorkspaceUtil.createProject("commit");
47
 
                wt = createWorkingTree(project.getLocation());
48
 
                project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
49
 
                BazaarTeamProvider.map(project, BazaarTeamProvider.ID);
50
 
        }
51
 
 
52
 
        @After
53
 
        public void tearDown() throws Exception {
54
 
                if(project != null)
55
 
                        project.delete(true, true, new NullProgressMonitor());
56
 
        }
 
28
public class CommitCommandTest extends TestCaseWithProject {
57
29
 
58
30
        @Test
59
31
        public final void testExecute() throws Exception {
60
32
                final List<IBzrLocalResource> resources = new ArrayList<IBzrLocalResource>();
61
 
                final IFile res = project.getFile(new Path("file_in_root.txt"));
 
33
                final IFile res = getProject().getFile(new Path("file_in_root.txt"));
62
34
                assertNotNull(res);
63
35
                IBzrLocalResource bzrRes = BzrWorkspaceRoot.getBzrFileFor(res);
64
36
                assertNotNull(bzrRes);
69
41
                addContentToFile(aFile, textToAdd);
70
42
 
71
43
                // change the expectedWorkingTree to the expected status
72
 
                wt.setItemStatus(aFile.getName(), BazaarStatusKind.MODIFIED);
73
 
                String currentContent = wt.getItemContent(aFile.getName());
74
 
                wt.setItemContent(aFile.getName(), currentContent + textToAdd);
 
44
                getWt().setItemStatus(aFile.getName(), BazaarStatusKind.MODIFIED);
 
45
                String currentContent = getWt().getItemContent(aFile.getName());
 
46
                getWt().setItemContent(aFile.getName(), currentContent + textToAdd);
75
47
 
76
48
                // Check if status is ok
77
 
                client.setWorkDir(project.getLocation().toFile());
78
 
                BazaarTreeStatus treeStatus = client.status(new File[] { project.getLocation().toFile() });
79
 
                wt.check(treeStatus.getStatusAsArray(), project.getLocation().toFile().getCanonicalPath());
 
49
                getClient().setWorkDir(getProject().getLocation().toFile());
 
50
                BazaarTreeStatus treeStatus = getClient().status(new File[] { getProject().getLocation().toFile() });
 
51
                getWt().check(treeStatus.getStatusAsArray(), getProject().getLocation().toFile().getCanonicalPath());
80
52
                
81
53
                CommitCommand cmd = new CommitCommand(resources, "test commit", new ArrayList<Option>(0));
82
54
                IResource[] commitedResources = cmd.execute(new NullProgressMonitor());
88
60
        @Test
89
61
        public void testExecuteEncoding() throws Exception {
90
62
                final List<IBzrLocalResource> resources = new ArrayList<IBzrLocalResource>();
91
 
                final IFile res = project.getFile(new Path("file_in_root.txt"));
 
63
                final IFile res = getProject().getFile(new Path("file_in_root.txt"));
92
64
                assertNotNull(res);
93
65
                IBzrLocalResource bzrRes = BzrWorkspaceRoot.getBzrFileFor(res);
94
66
                assertNotNull(bzrRes);