use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.
the class SynergyGetCompletedTasksConsumerTest method testSynergyGetCompletedTasksConsumer.
public void testSynergyGetCompletedTasksConsumer() throws IOException {
InputStream inputStream = getResourceAsStream("/synergy/consumer/getCompletedTasks.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String s = in.readLine();
SynergyGetCompletedTasksConsumer consumer = new SynergyGetCompletedTasksConsumer(new DefaultLog());
while (s != null) {
consumer.consumeLine(s);
s = in.readLine();
}
Collection<SynergyTask> entries = consumer.getTasks();
assertEquals("Wrong number of tasks returned", 1, entries.size());
SynergyTask task = (SynergyTask) entries.iterator().next();
assertEquals(35, task.getNumber());
assertEquals("AHD456", task.getUsername());
assertEquals("gefdeag", task.getComment());
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2006, Calendar.OCTOBER, 4, 15, 42, 47);
assertEquals(cal.getTime(), task.getModifiedTime());
}
use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.
the class SynergyChangeLogCommand method executeChangeLogCommand.
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing changelog command...");
}
SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
if (getLogger().isDebugEnabled()) {
getLogger().debug("basedir: " + fileSet.getBasedir());
}
String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
List<ChangeSet> csList = new ArrayList<ChangeSet>();
try {
String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
if (projectSpec == null) {
throw new ScmException("You should checkout a working project first");
}
List<SynergyTask> tasks = SynergyUtil.getCompletedTasks(getLogger(), projectSpec, startDate, endDate, ccmAddr);
for (SynergyTask t : tasks) {
ChangeSet cs = new ChangeSet();
cs.setAuthor(t.getUsername());
cs.setComment("Task " + t.getNumber() + ": " + t.getComment());
cs.setDate(t.getModifiedTime());
cs.setFiles(SynergyUtil.getModifiedObjects(getLogger(), t.getNumber(), ccmAddr));
csList.add(cs);
}
} finally {
SynergyUtil.stop(getLogger(), ccmAddr);
}
return new ChangeLogScmResult("ccm query ...", new ChangeLogSet(csList, startDate, endDate));
}
use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.
the class SynergyGetCompletedTasksConsumer method consumeLine.
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Consume: " + line);
}
StringTokenizer tokenizer = new StringTokenizer(line.trim(), SynergyUtil.SEPARATOR);
if (tokenizer.countTokens() == 4) {
SynergyTask task = new SynergyTask();
task.setNumber(Integer.parseInt(tokenizer.nextToken()));
task.setUsername(tokenizer.nextToken());
try {
task.setModifiedTime(new SimpleDateFormat(ccmDateFormat, new Locale(language, country)).parse(tokenizer.nextToken()));
} catch (ParseException e) {
if (getLogger().isErrorEnabled()) {
getLogger().error("Wrong date format", e);
}
}
task.setComment(tokenizer.nextToken());
// Add the task to the list
entries.add(task);
} else {
if (getLogger().isErrorEnabled()) {
getLogger().error("Invalid token count in SynergyGetCompletedTasksConsumer [" + tokenizer.countTokens() + "]");
}
if (getLogger().isDebugEnabled()) {
while (tokenizer.hasMoreElements()) {
getLogger().debug(tokenizer.nextToken());
}
}
}
}
use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.
the class SynergyGetCompletedTasksConsumerTest method testSynergyGetCompletedTasksConsumerWithFrenchDate.
public void testSynergyGetCompletedTasksConsumerWithFrenchDate() throws IOException {
InputStream inputStream = getResourceAsStream("/synergy/consumer/getCompletedTasksFrenchDate.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String s = in.readLine();
System.setProperty(SynergyGetCompletedTasksConsumer.CCMDATEFORMAT_PROPERTY, "EEEE dd MMMM yyyy HH:mm:ss");
System.setProperty(SynergyGetCompletedTasksConsumer.LANGUAGE_PROPERTY, "fr");
System.setProperty(SynergyGetCompletedTasksConsumer.COUNTRY_PROPERTY, "FR");
SynergyGetCompletedTasksConsumer consumer = new SynergyGetCompletedTasksConsumer(new DefaultLog());
while (s != null) {
consumer.consumeLine(s);
s = in.readLine();
}
Collection<SynergyTask> entries = consumer.getTasks();
assertEquals("Wrong number of tasks returned", 2, entries.size());
Iterator<SynergyTask> i = entries.iterator();
SynergyTask task = (SynergyTask) i.next();
assertEquals(52, task.getNumber());
assertEquals("ccm_root", task.getUsername());
assertEquals("Modification du pom (url scm)", task.getComment());
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2006, Calendar.OCTOBER, 6, 10, 3, 59);
assertEquals(cal.getTime(), task.getModifiedTime());
task = (SynergyTask) i.next();
assertEquals(53, task.getNumber());
assertEquals("ccm_root", task.getUsername());
assertEquals("Inverser l'odre purpose/release", task.getComment());
cal.clear();
cal.set(2006, Calendar.OCTOBER, 6, 10, 47, 13);
assertEquals(cal.getTime(), task.getModifiedTime());
}
Aggregations