@Test public void testLogin() throws Exception { AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester(); accuRevCL.setResponse( "Password: a124235bacc3ff" ); accuRevCL.setExecutable( "accurev.exe" ); accuRevCL.login( "aUser", "topSecret" ); Commandline lastCL = accuRevCL.getCommandline(); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { assertThat( lastCL.getArguments(), is( new String[] { "login", "-A", "aUser", "topSecret" } ) ); assertThat( accuRevCL.getStdinReader(), is( nullValue() ) ); } else { assertThat( lastCL.getArguments(), is( new String[] { "login", "-A", "aUser" } ) ); assertThat( accuRevCL.getStdinReader().readLine(), is( "topSecret" ) ); } accuRevCL.info( null ); assertThat( lastCL.getArguments(), is( new String[] { "info", "-A", "a124235bacc3ff" } ) ); assumeTrue( !Os.isFamily( Os.FAMILY_WINDOWS ) ); accuRevCL.login( "anOther", "opensaysme" ); assertThat( lastCL.getArguments(), is( new String[] { "login", "-A", "anOther" } ) ); assertThat( accuRevCL.getStdinReader().readLine(), is( "opensaysme" ) ); accuRevCL.login( "AUser", null ); assertThat( lastCL.getArguments(), is( new String[] { "login", "-A", "AUser" } ) ); assertThat( accuRevCL.getStdinReader().readLine(), is( "" ) ); }
public boolean login( String user, String password ) throws AccuRevException { cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; }
AccuRevCommandLine implements AccuRev { public boolean login( String user, String password ) throws AccuRevException { cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; } }
AccuRevCommandLine implements AccuRev { public boolean login( String user, String password ) throws AccuRevException { cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; } AccuRevCommandLine();  AccuRevCommandLine( String host, int port ); }
AccuRevCommandLine implements AccuRev { public boolean login( String user, String password ) throws AccuRevException { cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; } AccuRevCommandLine();  AccuRevCommandLine( String host, int port ); void setServer( String host, int port ); void setExecutable( String accuRevExe ); void reset(); boolean mkws( String basisStream, String workspaceName, File basedir ); List<File> update( File baseDir, String transactionId ); List<File> add( File basedir, List<File> elements, String message ); List<File> defunct( File basedir, List<File> files, String message ); List<File> promote( File basedir, List<File> files, String message ); String getCommandLines(); String getErrorOutput(); void setLogger( ScmLogger logger ); ScmLogger getLogger(); boolean mkdepot( String depotName ); boolean mkstream( String backingStream, String newStreamName ); boolean promoteStream( String subStream, String commitMessage, List<File> promotedFiles ); List<File> promoteAll( File baseDir, String commitMessage ); AccuRevInfo info( File basedir ); boolean reactivate( String workSpaceName ); boolean rmws( String workSpaceName ); String stat( File element ); boolean chws( File basedir, String workSpaceName, String newBasisStream ); boolean mksnap( String snapShotName, String basisStream ); List<File> statTag( String streamName ); List<File> stat( File basedir, Collection<File> elements, AccuRevStat statType ); List<File> pop( File basedir, Collection<File> elements ); List<File> popExternal( File basedir, String versionSpec, String tranSpec, Collection<File> elements ); CategorisedElements statBackingStream( File basedir, Collection<File> elements ); List<Transaction> history( String baseStream, String fromTimeSpec, String toTimeSpec, int count,
                                      boolean depotHistory, boolean transactionsOnly ); List<FileDifference> diff( String baseStream, String fromTimeSpec, String toTimeSpec ); boolean login( String user, String password ); boolean logout(); List<BlameLine> annotate( File basedir, File file ); Map<String, WorkSpace> showRefTrees(); Map<String, WorkSpace> showWorkSpaces(); Stream showStream( String stream ); String getExecutable(); String getClientVersion(); boolean syncReplica(); }
AccuRevCommandLine implements AccuRev { public boolean login( String user, String password ) throws AccuRevException { cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; } AccuRevCommandLine();  AccuRevCommandLine( String host, int port ); void setServer( String host, int port ); void setExecutable( String accuRevExe ); void reset(); boolean mkws( String basisStream, String workspaceName, File basedir ); List<File> update( File baseDir, String transactionId ); List<File> add( File basedir, List<File> elements, String message ); List<File> defunct( File basedir, List<File> files, String message ); List<File> promote( File basedir, List<File> files, String message ); String getCommandLines(); String getErrorOutput(); void setLogger( ScmLogger logger ); ScmLogger getLogger(); boolean mkdepot( String depotName ); boolean mkstream( String backingStream, String newStreamName ); boolean promoteStream( String subStream, String commitMessage, List<File> promotedFiles ); List<File> promoteAll( File baseDir, String commitMessage ); AccuRevInfo info( File basedir ); boolean reactivate( String workSpaceName ); boolean rmws( String workSpaceName ); String stat( File element ); boolean chws( File basedir, String workSpaceName, String newBasisStream ); boolean mksnap( String snapShotName, String basisStream ); List<File> statTag( String streamName ); List<File> stat( File basedir, Collection<File> elements, AccuRevStat statType ); List<File> pop( File basedir, Collection<File> elements ); List<File> popExternal( File basedir, String versionSpec, String tranSpec, Collection<File> elements ); CategorisedElements statBackingStream( File basedir, Collection<File> elements ); List<Transaction> history( String baseStream, String fromTimeSpec, String toTimeSpec, int count,
                                      boolean depotHistory, boolean transactionsOnly ); List<FileDifference> diff( String baseStream, String fromTimeSpec, String toTimeSpec ); boolean login( String user, String password ); boolean logout(); List<BlameLine> annotate( File basedir, File file ); Map<String, WorkSpace> showRefTrees(); Map<String, WorkSpace> showWorkSpaces(); Stream showStream( String stream ); String getExecutable(); String getClientVersion(); boolean syncReplica();  }