0
我有這樣的代碼:提交測試與cvsClient API返回false
package fr.cnamts.navigo.cvs;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
import org.netbeans.lib.cvsclient.command.CommandException;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
import org.netbeans.lib.cvsclient.command.commit.CommitCommand;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
import org.netbeans.lib.cvsclient.connection.PServerConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CvsCommandTest {
private static final Logger LOG = LoggerFactory
.getLogger(CvsCommandTest.class);
private final String cvsroot = ":pserver:name:[email protected]:2401/cvsdata/BUS-2010";
private final String localPath = "/cvsdata/BUS-2010";
private final File f = new File(
"d:/projets/bus/workspaceJhipster/navigo/src/main/resources/logback.xml");
private final File[] files = new File[1];
@Test
public void test() {
CVSRoot root = CVSRoot.parse(cvsroot);
PServerConnection con = new PServerConnection(root);
// con.setUserName(user);
// con.setEncodedPassword(StandardScrambler.getInstance().scramble(
// password));
GlobalOptions globalOptions = new GlobalOptions();
globalOptions.setCVSRoot(root.toString());
Client client = new Client(con, new StandardAdminHandler());
// this line is important, because otherwise you'll get a
// NullpointerException!
client.setLocalPath(localPath);
files[0] = f;
LOG.info("COMMITING");
CommitCommand commitCmd = new CommitCommand();
commitCmd.setBuilder(null);
commitCmd.setRecursive(true);
for (int i = 0; i < files.length; i++) {
LOG.info("- " + files[i].getAbsolutePath());
}
commitCmd.setFiles(files);
commitCmd.setToRevisionOrBranch("testTag");
try {
client.getConnection().open();
LOG.info("CVS COMMAND: " + commitCmd.getCVSCommand());
boolean success = client.executeCommand(commitCmd, globalOptions);
LOG.info("COMMIT COMPLETED : " + success);
client.getConnection().close();
} catch (CommandAbortedException cae) {
LOG.error("Probleme CommandAbortedException : " + cae.getMessage());
} catch (AuthenticationException ae) {
LOG.error("Probleme AuthenticationException : " + ae.getMessage());
} catch (CommandException ce) {
LOG.error("Probleme CommandException : " + ce.getMessage());
} catch (IOException ioe) {
LOG.error("Probleme IOException : " + ioe.getMessage());
}
}
}
成功是假的:
[INFO] fr.cnamts.navigo.cvs.CvsCommandTest - COMMITING [INFO] fr.cnamts.navigo.cvs.CvsCommandTest - - d:\ projets \ bus \ workspaceJhipster \ navigo \ src \ main \ resources \ logback.xml [INFO] fr.cnamts.navigo.cvs.CvsCommandTest - CVS COMMAND: commit -r testTag logback.xml [INFO] fr.cnamts.navigo.cvs.CvsCommandTest - COMMIT COMPLETED:false
但我不知道爲什麼會失敗。有沒有辦法找到它失敗的原因?