use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class GitDiffConsumerTest method testLog2Consumer.
public void testLog2Consumer() throws Exception {
GitDiffConsumer consumer = new GitDiffConsumer(new DefaultLog(), null);
File f = getTestFile("src/test/resources/git/diff/git-diff2.log");
BufferedReader r = new BufferedReader(new FileReader(f));
String line;
while ((line = r.readLine()) != null) {
consumer.consumeLine(line);
}
List<ScmFile> changedFiles = consumer.getChangedFiles();
assertEquals(2, changedFiles.size());
testScmFile(changedFiles.get(0), "pom.xml", ScmFileStatus.MODIFIED);
testScmFile(changedFiles.get(1), "test.txt", ScmFileStatus.MODIFIED);
Map<String, CharSequence> differences = consumer.getDifferences();
assertNotNull(differences);
StringBuilder addDiffs = new StringBuilder(differences.get("pom.xml"));
assertNotNull(addDiffs);
assertTrue(addDiffs.indexOf("+ <!-- test -->") >= 0);
addDiffs = new StringBuilder(differences.get("test.txt"));
assertNotNull(addDiffs);
assertTrue(addDiffs.indexOf("+maven-scm git provider works fine :-)") >= 0);
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class GitDiffConsumerTest method testLog1Consumer.
public void testLog1Consumer() throws Exception {
GitDiffConsumer consumer = new GitDiffConsumer(new DefaultLog(), null);
File f = getTestFile("src/test/resources/git/diff/git-diff1.log");
BufferedReader r = new BufferedReader(new FileReader(f));
String line;
while ((line = r.readLine()) != null) {
consumer.consumeLine(line);
}
List<ScmFile> changedFiles = consumer.getChangedFiles();
assertEquals(1, changedFiles.size());
testScmFile((ScmFile) changedFiles.get(0), "olamy.test", ScmFileStatus.MODIFIED);
Map<String, CharSequence> differences = consumer.getDifferences();
assertNotNull(differences);
StringBuilder readmeDiffs = new StringBuilder(differences.get("olamy.test"));
assertNotNull(readmeDiffs);
assertTrue(readmeDiffs.indexOf("+new line") >= 0);
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class PerforceTagConsumerTest method testGoodParse.
public void testGoodParse() throws Exception {
File testFile = getTestFile("src/test/resources/perforce/tag_good.txt");
PerforceTagConsumer consumer = new PerforceTagConsumer();
FileInputStream fis = new FileInputStream(testFile);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String s = in.readLine();
while (s != null) {
consumer.consumeLine(s);
s = in.readLine();
}
assertEquals("", consumer.getOutput());
assertTrue(consumer.isSuccess());
List<ScmFile> results = consumer.getTagged();
assertEquals("Wrong number of entries returned", 2, results.size());
String entry = results.get(0).getPath();
assertTrue(entry.endsWith("pom.xml"));
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class PerforceUnEditConsumerTest method testGoodParse.
public void testGoodParse() throws Exception {
File testFile = getTestFile("src/test/resources/perforce/unedit_good.txt");
PerforceUnEditConsumer consumer = new PerforceUnEditConsumer();
FileInputStream fis = new FileInputStream(testFile);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String s = in.readLine();
while (s != null) {
consumer.consumeLine(s);
s = in.readLine();
}
assertTrue(consumer.isSuccess());
List<ScmFile> edits = consumer.getEdits();
assertEquals("Wrong number of entries returned", 2, edits.size());
String entry = edits.get(0).getPath();
assertTrue(entry.startsWith("//"));
assertTrue(entry.endsWith(".classpath"));
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class SynergyCheckOutCommand method executeCheckOutCommand.
/**
* {@inheritDoc}
*/
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
if (fileSet.getFileList().size() != 0) {
throw new ScmException("This provider doesn't support checking out subsets of a project");
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing checkout command...");
}
SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
if (getLogger().isDebugEnabled()) {
getLogger().debug(fileSet.toString());
}
String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
File waPath;
try {
String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
if (projectSpec != null) {
if (getLogger().isInfoEnabled()) {
getLogger().info("A working project already exists [" + projectSpec + "].");
}
SynergyUtil.synchronize(getLogger(), projectSpec, ccmAddr);
} else {
SynergyUtil.checkoutProject(getLogger(), null, repo.getProjectSpec(), version, repo.getProjectPurpose(), repo.getProjectRelease(), ccmAddr);
projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
if (getLogger().isInfoEnabled()) {
getLogger().info("A new working project [" + projectSpec + "] was created.");
}
}
SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
} finally {
SynergyUtil.stop(getLogger(), ccmAddr);
}
File source = new File(waPath, repo.getProjectName());
if (getLogger().isInfoEnabled()) {
getLogger().info("We will now copy files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
}
// Move files to the expected folder
try {
FileUtils.copyDirectoryStructure(source, fileSet.getBasedir());
} catch (IOException e1) {
throw new ScmException("Unable to copy directory structure", e1);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("We will list content of checkout directory.");
}
// We need to list files in the directory
List<ScmFile> files = new ArrayList<ScmFile>();
try {
@SuppressWarnings("unchecked") List<File> realFiles = FileUtils.getFiles(fileSet.getBasedir(), null, "_ccmwaid.inf");
for (File f : realFiles) {
files.add(new ScmFile(f.getPath(), ScmFileStatus.CHECKED_OUT));
}
} catch (IOException e) {
throw new ScmException("Unable to list files in checkout directory", e);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("checkout command end successfully ...");
}
return new CheckOutScmResult(files, new ScmResult("multiple commandline", "OK", "OK", true));
}
Aggregations