continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r430041 - in /maven/continuum/trunk/continuum-sandbox: ./ continuum-python/
Date Wed, 09 Aug 2006 12:19:00 GMT
Author: jvanzyl
Date: Wed Aug  9 05:18:59 2006
New Revision: 430041

URL: http://svn.apache.org/viewvc?rev=430041&view=rev
Log:
o adding python code used for old integration tests, andy i know you're using this for trac so you can work with it here and make
  whatever you like of it.

Added:
    maven/continuum/trunk/continuum-sandbox/
    maven/continuum/trunk/continuum-sandbox/continuum-python/
    maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/it.py   (with props)
    maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py   (with props)

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt Wed Aug  9 05:18:59 2006
@@ -0,0 +1,29 @@
+* Files
+
+ [[add-*]]: These scripts will add the respective projects to Continuum.
+
+ [[cli.py]] is a small library for making interactive command line
+            programs. It's used by continuum_cli.py
+
+ [[continuum.py]] is a reusable library for interfacing with Continuum over
+                  the XML-RPC interface. It's used by the integration tests.
+
+ [[continuum_cli.py]] is a interactive command line interface to Continuum.
+                      Start it with this command:
+ ------------------------------------------------------------------------------
+ $ python continuum_cli.py
+ ------------------------------------------------------------------------------
+                      and write "help" at the command prompt to list all
+                      available commands.
+
+ [[it.py]] is the integration tests. Se the next section for more information.
+
+* Integration tests
+
+These integration tests are executed by the it.py program. It assumes that you
+have Continuum running on localhost, with the XML-RPC interface running on port
+8000.
+
+To run the tests execute the script like this:
+
+$ python it.py

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/README.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import continuum
+import sys
+
+baseurl = "http://svn.apache.org/viewcvs.cgi/*checkout*/maven/continuum/trunk/"
+pomAsText = "/pom.xml?content-type=text%2Fplain"
+
+projects = [ 
+"continuum-model", 
+"continuum-core", 
+"continuum-web", 
+"continuum-xmlrpc" 
+]
+
+continuum = continuum.Continuum( "http://localhost:8000" )
+
+for project in projects:
+    url = baseurl + project + pomAsText
+    print url
+    mavenProject = continuum.addMavenTwoProject( url )

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-continuum-projects.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import continuum
+import sys
+
+baseurl = "http://svn.apache.org/viewcvs.cgi/*checkout*/maven/components/trunk/"
+pomAsText = "/pom.xml?content-type=text%2Fplain"
+
+projects = [ 
+"maven-model", 
+"maven-project", 
+"maven-artifact", 
+"maven-core" 
+]
+
+continuum = continuum.Continuum( "http://localhost:8000" )
+
+for project in projects:
+    url = baseurl + project + pomAsText
+    print url
+    mavenProject = continuum.addMavenTwoProject( url )

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-maven-projects.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+import continuum
+import sys
+
+baseurl = "http://cvs.plexus.codehaus.org/*checkout*/plexus/"
+pomAsText = "/pom.xml?content-type=text%2Fplain"
+
+projects = [ 
+"plexus-components/plexus-action/pom.xml",
+"plexus-components/plexus-archiver/pom.xml",
+"plexus-components/plexus-bayesian/pom.xml",
+"plexus-components/plexus-command/pom.xml",
+"plexus-components/plexus-compiler/pom.xml",
+"plexus-components/plexus-compiler/plexus-compiler-api/pom.xml",
+"plexus-components/plexus-compiler/plexus-compilers/pom.xml",
+"plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml",
+"plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml",
+"plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml",
+"plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml",
+"plexus-components/plexus-drools/pom.xml",
+"plexus-components/plexus-formica-web/pom.xml",
+"plexus-components/plexus-formica/pom.xml",
+"plexus-components/plexus-hibernate/pom.xml",
+"plexus-components/plexus-i18n/pom.xml",
+"plexus-components/plexus-jetty-httpd/pom.xml",
+"plexus-components/plexus-jetty/pom.xml",
+"plexus-components/plexus-mimetyper/pom.xml",
+"plexus-components/plexus-summit/pom.xml",
+"plexus-components/plexus-velocity/pom.xml",
+"plexus-components/plexus-werkflow/pom.xml",
+"plexus-components/plexus-xmlrpc/pom.xml",
+"plexus-containers/pom.xml",
+"plexus-containers/plexus-container-artifact/pom.xml",
+"plexus-containers/plexus-container-default/pom.xml",
+"plexus-utils/pom.xml",
+"plexus-servlet/pom.xml",
+"plexus-tools/pom.xml",
+"plexus-tools/plexus-cdc/pom.xml",
+"plexus-tools/plexus-runtime-builder/pom.xml" 
+]
+
+continuum = continuum.Continuum( "http://localhost:8000" )
+
+for project in projects:
+    url = baseurl + project + pomAsText
+    print url
+    mavenProject = continuum.addMavenTwoProject( url )

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/add-plexus-projects.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,112 @@
+import os
+import sys
+import string
+
+class cli:
+    prompt = '# '
+
+    def __init__(self):
+        try:
+            import readline
+            readline.set_completer(self.complete)
+            readline.parse_and_bind("tab: complete")
+        except:
+            pass
+
+    def cmdloop(self):
+        stop = None
+        while not stop:
+            try:
+                line = raw_input(self.prompt)
+            except EOFError:
+                print
+                break
+
+            line = self.precmd(line)
+            stop = self.onecmd(line)
+            stop = self.postcmd(stop, line)
+
+        self.postloop()
+
+    def postloop(self):
+        pass
+
+    def precmd(self, line):
+        return line
+
+    def postcmd(self, stop, line):
+        return stop
+
+    def onecmd(self, line):
+        line = string.strip(line)
+        if not line:
+            return None
+        tokens = string.split(line)
+
+        help = 0
+        if tokens[0] == 'help' or tokens[0] == 'man':
+            help = 1
+            del(tokens[0])
+
+        func = None
+        for i in range(len(tokens), 0, -1):
+            try:
+                func = getattr(self, 'do_' + string.join(tokens[:i], '_'))
+                args = tokens[i:]
+            except AttributeError:
+                func = None
+            else:
+                break
+
+        if help:
+            self.do_help(func)
+        elif func:
+            return func(args)
+        else:
+            print "%s: no such command" % (tokens[0])
+            return None
+
+    def do_help(self, func):
+        """Welcome to the help system"""
+        if func:
+            if func.__doc__:
+                print func.__doc__
+            else:
+                print "No help available"
+        else:
+            sortedkeys = self.__class__.__dict__.keys()
+            sortedkeys.sort()
+            for i in sortedkeys:
+                if i[0:3] == 'do_':
+                    print "  %-20s  %s" % \
+                      ( string.replace(i[3:], '_', ' '),
+                        string.split(self.__class__.__dict__[i].__doc__, "\n")[0])
+
+        return None
+        
+    def complete(self, text, state):
+        #import readline
+        #print
+        #print "DEBUG bidx =", readline.get_begidx()
+        #print "DEBUG eidx =", readline.get_endidx()
+        #print "DEBUG line =", readline.get_line_buffer()
+        #print "DEBUG text =", text
+        if state == 0:
+            self.matches = self.global_matches(text)
+        try:
+            return self.matches[state]
+        except IndexError:
+            return None
+
+    def global_matches(self, text):
+        matches = []
+        n = len(text)
+
+        for word in self.__class__.__dict__.keys():
+            if word[0:3] == 'do_':
+                word = string.join(string.split(word, '_')[1:], ' ')
+                if word[:n] == text:
+                    matches.append(word)
+
+        return matches
+

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/cli.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,477 @@
+import os
+from time import strftime, gmtime
+import xmlrpclib
+
+class XmlRpcException:
+    def __init__( self, method, message, stackTrace ):
+        self.method = method
+        self.message = message
+        self.stackTrace = stackTrace
+
+    def __str__( self ):
+        return "Error while executing method." + os.linesep + \
+               "Method: " + self.method + os.linesep + \
+               "Message: " + self.message + os.linesep + \
+               "Stack trace: " + self.stackTrace + os.linesep
+
+def checkResult( map ):
+    if ( map[ "result" ] == "ok" ):
+        return map
+
+    ex = XmlRpcException( map[ "method" ], 
+                          map[ "message" ], 
+                          map[ "stackTrace" ] )
+
+    if 1:
+        print str( ex )
+
+    raise ex
+
+def decodeState( state ):
+    if ( state == Continuum.STATE_NEW ):
+        return "new"
+    elif ( state == Continuum.STATE_OK ):
+        return "ok"
+    elif ( state == Continuum.STATE_FAILED ):
+        return "failed"
+    elif ( state == Continuum.STATE_ERROR ):
+        return "error"
+#    elif ( state == 5 ):
+#        return Continuum.STATE_BUILD_SIGNALED
+    elif ( state == Continuum.STATE_BUILDING ):
+        return "building"
+    elif ( state == Continuum.STATE_CHECKING_OUT ):
+        return "checking out"
+    elif ( state == Continuum.STATE_UPDATING ):
+        return "updating"
+    elif ( state == Continuum.STATE_WARNED ):
+        return "warned"
+    else:
+        return "UNKNOWN STATE (" + str( state ) + ")."
+
+def decodeTrigger( trigger ):
+    if (trigger == Continuum.TRIGGER_FORCED):
+        return "forced"
+    elif (trigger == Continuum.TRIGGER_SCHEDULED):
+        return "scheduled"
+    else:
+        return "UNKNOWN TRIGGER (" + str( trigger ) + ")."
+def makeMailNotifier( address ):
+    notifier = ContinuumNotifier()
+
+    notifier.type = "mail"
+    notifier.configuration = { "address" : address }
+
+class Continuum:
+    STATE_NEW = 1
+    STATE_OK = 2
+    STATE_FAILED = 3
+    STATE_ERROR = 4
+    #STATE_BUILD_SIGNALED = "build signaled"
+    STATE_BUILDING = 6
+    STATE_CHECKING_OUT = 7
+    STATE_UPDATING = 8
+    STATE_WARNED = 9
+
+    TRIGGER_SCHEDULED = 0
+    TRIGGER_FORCED = 1
+
+    def __init__( self, url ):
+        self.server = xmlrpclib.Server(url, allow_none=True)
+
+        # This will make sure the server is working
+        self.server.continuum.getProjects()
+
+    ####################################################################
+    # These methods correspods 1<=>1 with the ContinuumXmlRpc interface
+    ####################################################################
+
+    ####################################################################
+    # Projects
+    ####################################################################
+
+    def removeProject( self, projectId ):
+        checkResult( self.server.continuum.removeProject( projectId ) )
+
+    #def updateProject( projectId, name, scmUrl, nagEmailAddress, version, arguments ):
+    #    checkResult( server.continuum.updateProject( projectId, name, scmUrl, nagEmailAddress, version, arguments ) )
+
+    #def updateProjectFromScm( projectId ):
+    #    checkResult( server.continuum.updateProjectFromScm( projectId ) )
+
+    #def updateProjectConfiguration( self, projectId, configuration ):
+    #    checkResult( self.server.continuum.updateProjectConfiguration( projectId, configuration ) )
+
+    def getProject( self, projectId ):
+        result = checkResult( self.server.continuum.getProject( projectId ) )
+
+        return self.makeProject( result[ "project" ] )
+
+    def getProjects( self ):
+        result = checkResult( self.server.continuum.getProjects() )
+
+        projects = []
+        for project in result[ "projects" ]:
+            projects.append( self.makeProject( project ) )
+
+        return projects
+
+    ####################################################################
+    # Builds
+    ####################################################################
+
+    def buildProject( self, projectId, force ):
+        checkResult( self.server.continuum.buildProject( projectId, force ) )
+
+    def getBuild( self, buildId ):
+        result = checkResult( self.server.continuum.getBuildResult( buildId ) )
+
+        return Build( result[ "build" ] )
+
+    def getBuildsForProject( self, projectId ):
+        result = checkResult( self.server.continuum.getBuildResultsForProject( projectId ) )
+
+        builds = []
+        for build in result[ "builds" ]:
+            builds.append( Build( build ) )
+
+        return builds
+
+    def getBuildOutput( self, projectId, buildId ):
+        return checkResult( self.server.continuum.getBuildOutput( projectId, buildId ) )[ "buildOutput" ]
+
+    def getChangedFilesForBuild( self, buildId ):
+        result = checkResult( self.server.continuum.getBuild( buildId ) )
+        scmResult = ScmResult( result[ "scmResult" ] )
+
+        return scmResult.changes
+
+    ####################################################################
+    # Maven 2.x projects
+    ####################################################################
+
+    def addMavenTwoProject( self, argument ):
+        result = checkResult( self.server.continuum.addMavenTwoProject( argument ) )
+
+        return result[ "projectIds" ]
+
+    def updateMavenTwoProject( self, mavenTwoProject ):
+        checkResult( self.server.continuum.updateaddMavenTwoProject( mavenTwoProject ) )
+
+    ####################################################################
+    # Maven 1.x projects
+    ####################################################################
+
+    def addMavenOneProject( self, argument ):
+        result = checkResult( self.server.continuum.addMavenOneProject( argument ) )
+
+        return result[ "projectIds" ]
+
+    def updateMavenOneProject( self, mavenOneProject ):
+        checkResult( self.server.continuum.updateMavenOneProject( mavenOneProject ) )
+
+    ####################################################################
+    # Ant projects
+    ####################################################################
+
+    def addAntProject( self, antProject ):
+        result = checkResult( self.server.continuum.addAntProject( antProject ) )
+
+        return result[ "projectIds" ]
+
+    def updateAntProject( self, antProject ):
+        checkResult( self.server.continuum.updateAntProject( antProject ) )
+
+    ####################################################################
+    # Shell projects
+    ####################################################################
+
+    def addShellProject( self, shellProject ):
+        result = checkResult( self.server.continuum.addShellProject( shellProject ) )
+
+        return result[ "projectIds" ]
+
+    def updateShellProject( self, shellProject ):
+        checkResult( self.server.continuum.updateShellProject( shellProject ) )
+
+    ####################################################################
+    #
+    ####################################################################
+
+    def makeProject( self, map ):
+        executorId = map[ "executorId" ]
+        if ( executorId == "maven2" ):
+            return MavenTwoProject( map )
+        elif ( executorId == "maven-1" ):
+            return MavenOneProject( map )
+        elif ( executorId == "ant" ):
+            return AntProject( map )
+        elif ( executorId == "shell" ):
+            return ShellProject( map )
+        else:
+            raise Exception( "Unknown executor id '" + executorId + "'." );
+
+
+####################################################################
+# Domain classes
+####################################################################
+
+class Project:
+    def __init__( self, map ):
+        self.map = map;
+        self.dependencies = []
+        self.developers = []
+        self.notifiers = []
+
+        if ( map == None ):
+            return
+
+        self.id = map[ "id" ]
+        self.name = map[ "name" ]
+        self.scmUrl = map[ "scmUrl" ]
+        self.version = map[ "version" ]
+        self.build = map[ "buildNumber" ]
+        if ( map.has_key( "workingDirectory" ) ):
+            self.workingDirectory = map[ "workingDirectory" ]
+        else:
+            self.workingDirectory = ""
+        self.state = int( map[ "state" ] )
+        self.executorId = map[ "executorId" ]
+
+        if ( map.has_key( "commandLineArguments" ) ):
+            self.commandLineArguments = map[ "commandLineArguments" ]
+        else:
+            self.commandLineArguments = ""
+
+        self.dependencies = list()
+        if ( map.has_key( "dependencies" ) ):
+            for f in map[ "dependencies" ]:
+                self.dependencies.append( ContinuumDependency( f ) )
+
+        self.developers = list()
+        if ( map.has_key( "developers" ) ):
+            for f in map[ "developers" ]:
+                self.developers.append( ContinuumDeveloper( f ) )
+
+        self.notifiers = list()
+        if ( map.has_key( "notifiers" ) ):
+            for f in map[ "notifiers" ]:
+                self.notifiers.append( ContinuumNotifier( f ) )
+
+    def __str__( self ):
+        s = "id: " + self.id + os.linesep +\
+            "name: " + self.name + os.linesep +\
+            "version: " + self.version + os.linesep +\
+            "executor id: " + self.executorId + os.linesep +\
+            "state: " + decodeState( self.state ) + os.linesep
+
+        return s
+
+class MavenTwoProject( Project ):
+    def __init__( self, map=None ):
+        Project.__init__( self, map )
+
+        if ( map == None ):
+            return
+    
+        self.goals = '' #map[ "goals" ]
+        self.group = map[ "groupId" ]
+
+    def __str__( self ):
+        return Project.__str__( self ) + os.linesep +\
+               "goals: " + self.goals + os.linesep
+
+class MavenOneProject( Project ):
+    def __init__( self, map=None ):
+        Project.__init__( self, map )
+
+        if ( map == None ):
+            return
+    
+        self.goals = '' #map[ "goals" ]
+        self.group = map[ "groupId" ]
+
+    def __str__( self ):
+        return Project.__str__( self ) + os.linesep +\
+               "goals: " + self.goals + os.linesep
+
+class AntProject( Project ):
+    def __init__( self, map=None ):
+        Project.__init__( self, map )
+
+        if ( map == None ):
+            return
+#        self.executable = map[ "executable" ]
+#        self.targets = map[ "goals" ]
+
+    def __str__( self ):
+        return Project.__str__( self ) + os.linesep +\
+               "executable: " + self.executable + os.linesep +\
+               "targets: " + self.targets + os.linesep
+
+class ShellProject( Project ):
+    def __init__( self, map=None ):
+        Project.__init__( self, map )
+
+        if ( map == None ):
+            return
+    
+        self.executable = map[ "executable" ]
+
+    def __str__( self ):
+        return Project.__str__( self ) + os.linesep +\
+               "executable: " + self.executable + os.linesep
+
+class Build:
+    def __init__( self, map ):
+        map[ "totalTime" ] = int( map[ "endTime" ] )/ 1000 - int( map[ "startTime" ] ) / 1000
+
+        self.id = map[ "id" ]
+        self.buildNumber = map[ "buildNumber" ]
+        if self.buildNumber == '0':
+            self.buildNumber = ''
+        self.state = int( map[ "state" ] )
+        if ( map.has_key( "trigger" ) ):
+            self.forced = map[ "trigger" ] == Continuum.TRIGGER_FORCED
+            self.trigger = int( map[ "trigger" ] )
+        else:
+            self.forced = False
+            self.trigger = 0
+
+        self.startTime = gmtime( int( map[ "startTime" ] ) / 1000 )
+        self.endTime = gmtime( int( map[ "endTime" ] ) / 1000 )
+        self.totalTime = map[ "totalTime" ]
+        self.error = map.get( "error" )
+        self.map = map
+        if ( map.has_key( "scmResult" ) ):
+            self.scmResult = ScmResult( map[ "scmResult" ] )
+        else:
+            self.scmResult = None
+
+        if ( self.error == None ):
+            self.error = ""
+            map[ "error" ] = ""
+
+        self.success = map[ "success" ] == "true"
+        self.exitCode = int( map[ "exitCode" ] )
+        if ( map.has_key( "standardOutput" ) ):
+            self.standardOutput = map[ "standardOutput" ]
+        else:
+            self.standardOutput = None
+        if ( map.has_key( "standardError" ) ):
+            self.standardError = map[ "standardError" ]
+        else:
+            self.standardError = None
+
+    def __str__( self ):
+        s = "Id: " + self.id + os.linesep +\
+            "State: " + decodeState( self.state ) + os.linesep +\
+            "End time: " + strftime( "%a, %d %b %Y %H:%M:%S +0000", self.endTime ) + os.linesep +\
+            "Build time: " + self.totalTime + os.linesep
+
+        if ( self.error != "" ):
+            s += "Error: %(error)s" % self.map
+        value = "Success: " + str( self.success )
+        value += os.linesep + "Exit code: " + str( self.exitCode )
+        if ( len( self.standardOutput ) > 0 ):
+              value += os.linesep + "Standard output: " + self.standardOutput
+        if ( len( self.standardError ) > 0 ):
+               value += os.linesep + "Standard error: " + self.standardError
+
+        return s
+
+class ScmResult:
+    def __init__( self, map ):
+        self.map = map
+        self.success = map[ "success" ] == "true"
+
+        if ( map.has_key( "providerMessage" ) ):
+            self.providerMessage = map[ "providerMessage" ]
+        else:
+            self.providerMessage = ""
+
+        if ( map.has_key( "commandOutput" ) ):
+            self.commandOutput = map[ "commandOutput" ]
+        else:
+            self.commandOutput = ""
+
+        self.changes = list()
+        if ( map.has_key( "changes" ) ):
+            for f in map[ "changes" ]:
+                self.changes.append( ChangeSet( f ) )
+
+    def __str__( self ):
+        value = "Success: " + str( self.success ) + os.linesep +\
+                "Provider Message: " + self.providerMessage + os.linesep +\
+                "Command output: " + self.commandOutput
+
+        return value
+
+class ChangeSet:
+    def __init__( self, map ):
+        self.map = map
+        self.author = map[ "author" ]
+        self.comment = map[ "comment" ]
+        self.date = gmtime( int( map[ "date" ] ) / 1000 )
+
+        self.files = list()
+        for f in map[ "files" ]:
+            self.files.append( ChangeFile( f ) )
+
+    def __str__( self ):
+        value = "Author: " + self.author + os.linesep +\
+                "Comment: " + self.comment
+
+        return value
+
+class ChangeFile:
+    def __init__( self, map ):
+        self.map = map
+        self.name = map[ "name" ]
+        self.revision = map[ "revision" ]
+
+    def __str__( self ):
+        value = "File: " + self.name + " (" + self.revision + ")"
+
+        return value
+
+class ContinuumDependency:
+    def __init__( self, map ):
+        self.group = map[ "groupId" ]
+        self.artifact = map[ "artifactId" ]
+        self.version = map[ "version" ]
+
+    def __str__( self ):
+        value = self.group + ":" + self.artifact + ":" + self.version
+        return value
+
+class ContinuumDeveloper:
+    def __init__( self, map ):
+        self.id = map[ "continuumId" ]
+        self.name = map[ "name" ]
+        self.email = map[ "email" ]
+
+    def __str__( self ):
+        value = "id: " + self.id + os.linesep +\
+                "name: " + self.name + os.linesep +\
+                "email: " + self.email
+
+        return value
+
+class ContinuumNotifier:
+    def __init__( self, map=None ):
+        self.type = None
+        self.configuration = {}
+
+        if ( map == None ):
+            return
+
+        self.type = map[ "type" ]
+
+        if ( map.has_key( "configuration" ) ):
+            self.configuration = map[ "configuration" ]
+
+    def __str__( self ):
+        value = "type: " + self.type
+
+        return value

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+
+import cli
+import continuum
+import time
+
+##########################################################
+# Build your commands in this class.  Each method that
+# starts with "do_" is exposed as a shell command, and
+# its doc string is used when the user types 'help' or
+# 'man'.  A command that does not return None, will
+# cause the shell to terminate.
+#
+# The first line of the docstring is used when help is
+# typed by itself to give a summary, and then if the
+# user requests specific help on a command, the full
+# text is supplied.
+#
+# If your system has the GNU readline stuff on it, then
+# pressing tab will do tab completion of the commands.
+# You will also get much nicer command line editing
+# just like using your shell, as well as command
+# history.
+##########################################################
+
+def isEmpty( str ):
+    return str == None or str == ""
+
+class ContinuumXmlRpcCli(cli.cli):
+    def __init__(self):
+        cli.cli.__init__(self)
+
+    def do_quit(self, args):
+        """Exit the command interpreter.
+        Use this command to quit the demo shell."""
+
+        return 1
+
+    def do_version(self, args):
+        """Display the version of the shell.
+        Prints the version of this software on the command line."""
+
+        print "Version 1.0"
+
+    def do_addMavenTwoProject(self, args):
+        """Add a Maven 2.x project."""
+
+        projectIds = c.addMavenTwoProject( args[0] )
+
+        print "Added " + str( len( projectIds ) ) + " projects."
+        for id in projectIds:
+            print " id: " + id
+
+    def do_addMavenOneProject(self, args):
+        """Add a Maven 1.x project."""
+
+        projectId = c.addMavenOneProject( args[0] )
+
+        print "Added project, id: " + projectId
+
+    # TODO: addAntProject
+    # TODO: addShellProject
+
+    def do_showProject(self, args):
+        """Shows Continuum project.
+        Use this command to show the details of a Continuum project."""
+
+        project = c.getProject( int( args[0])  )
+
+        print "Project details:"
+        print "Id: " + project.id
+        print "Name:               " + project.name
+        print "Version:            " + project.version
+        print "Working directory:  " + project.workingDirectory
+        print "State:              " + continuum.decodeState( project.state )
+        print "Executor type:      " + project.executorId
+        print "SCM URL:            " + project.scmUrl
+
+        builds = c.getBuildsForProject( int( project.id ) )
+        print ""
+        print "Project Builds:"
+        print "|  Id  |  State |           Start time            |             End time            | Build time |"
+        for build in builds:
+            build.state = continuum.decodeState( build.state )
+            print "| %(id)4s | %(state)6s | %(startTime)s | %(endTime)s | %(totalTime)10s |" % { 'id': build.id, 'state': build.state, 'startTime' : time.strftime( "%a, %d %b %Y %H:%M:%S +0000", build.startTime ), 'endTime': time.strftime( "%a, %d %b %Y %H:%M:%S +0000", build.endTime ), 'totalTime': build.totalTime }
+
+        print ""
+        print "Notifiers:"
+        for notifier in project.notifiers:
+            print " type: " + notifier.type
+            print " configuration: " + str( notifier.configuration )
+
+    def do_showProjects(self, args):
+        """Shows all Continuum projects registeret.
+        Use this command to list all Continuum projects."""
+
+        projects = c.getAllProjects()
+
+        print ""
+        print "Projects:"
+        print "  Id |    State     | Executor | Name"
+        for project in projects:
+#            project.state = continuum.decodeState( project.state ) 
+# | %(state)12s
+            print "%(id)4s  | %(executorId)s | %(name)s" % project.map
+
+    def do_removeProject(self,args):
+        """Removes a project."""
+
+        c.removeProject( args[0] )
+
+    def do_buildProject(self, args):
+        """Build a Continuum project.
+        Use this command to signal a build for a Continuum project."""
+
+        c.buildProject( args[ 0 ] )
+
+        print "Enqueued project"
+
+    def do_showBuild( self, args ):
+        """Shows the result of a build."""
+
+        build = c.getBuild( int( args[ 0 ] ) )
+
+        print build
+
+        if ( build.updateScmResult != None and len( build.updateScmResult.updatedFiles ) > 0 ):
+            print "Updated files:"
+            print build.updateScmResult
+        print ""
+
+        buildResult = c.getBuildResultForBuild( args[ 0 ] );
+
+        print "Build result:"
+        print buildResult
+
+    def do_run(self, args):
+        """Run a script of commands.
+        Use this command to run a script of commands."""
+        
+        commands = open( args[0], "r" ).readlines()
+        
+        for command in commands:
+            cli.cli.onecmd( self, command )
+        
+##########################################################
+# Main loop
+##########################################################
+
+c = continuum.Continuum( "http://localhost:8000" )
+
+try:
+    ContinuumXmlRpcCli().cmdloop()
+
+except Exception, e:
+    print "Error:", e
+

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/continuum_cli.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,97 @@
+import continuum
+import os
+import shutil
+import sys
+import time
+import traceback
+from it_utils import *
+
+print "############################################################"
+print "Running integration tests"
+print ""
+print "NOTE:"
+print "When running these integration tests you will get some"
+print "stacktraces. This is normal and expected."
+print "############################################################"
+print ""
+
+continuum = continuum.Continuum( "http://localhost:8000" )
+
+progress( "Initializing SCM repositories." )
+
+basedir = os.getcwd() + "/target"
+cvsroot = basedir + "/cvsroot"
+svnroot = basedir + "/svnroot"
+maven1Project = basedir + "/maven-1"
+maven2Project = basedir + "/maven-2"
+antProject = basedir + "/ant"
+shellProject = basedir + "/shell"
+coDir = basedir + "/tmp-co"
+
+cleanDirectory( basedir )
+os.makedirs( basedir )
+os.makedirs( cvsroot )
+os.makedirs( svnroot )
+
+execute( os.getcwd(), "cvs -d " + cvsroot + " init" )
+execute( os.getcwd(), "svnadmin create " + svnroot )
+
+startTime = int( time.time() )
+
+#####################################################################
+#
+#####################################################################
+
+if 0:
+    progress( "Adding a project with a URL pointing to a nonexisting host" )
+
+    try:
+        continuum.addMavenTwoProject( "http://thishostnameshoulddefinitelyeverberesolvedorillfreakout/bar" )
+
+        fail( "Expected XmlRpcException" )
+    except continuum.XmlRpcException:
+        pass
+
+#####################################################################
+#
+#####################################################################
+
+if 0:
+    progress( "Adding a project with a malformed URL" )
+
+    try:
+        continuum.addMavenTwoProject( "blah://foo/bar" )
+
+        fail( "Expected XmlRpcException" )
+    except continuum.XmlRpcException:
+        pass
+
+#####################################################################
+#
+#####################################################################
+
+if 1:
+    progress( "Adding a project with a malformed SCM URL (invalid SCM type)" )
+
+    writeMavenOnePom( basedir + "/project.xml", "foo", "scm:crap:", "foo@bar" )
+
+    projectIds = continuum.addMavenOneProject( "file://" + basedir + "/project.xml" )
+
+    project = waitForCheckOut( continuum, projectIds[ 0 ] )
+
+#    assertEquals( "The project state should be error.", continuum.STATE_ERROR, project.state )
+    assertEquals( "The error message wasn't as expected.", "No such provider: 'crap'.", project.checkOutErrorMessage )
+
+#####################################################################
+#
+#####################################################################
+
+endTime = int( time.time() )
+
+print ""
+print "##############################################"
+print "ALL TESTS PASSED"
+print "##############################################"
+print "Time elapsed: " + str( endTime - startTime ) + "s."
+print "##############################################"
+print ""

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it-2.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/it.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/it.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/it.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/it.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,214 @@
+from continuum import Continuum, MavenTwoProject, MavenOneProject, AntProject, ShellProject, makeMailNotifier
+import os
+import shutil
+import sys
+import time
+import traceback
+
+print "############################################################"
+print "Running integration tests"
+print ""
+print "NOTE:"
+print "When running these integration tests you will get some"
+print "stacktraces. This is normal and expected."
+print "############################################################"
+print ""
+
+c = Continuum( "http://localhost:8000" )
+
+from it_utils import *
+
+progress( "Initializing SCM repositories." )
+
+cvsroot = basedir + "/cvsroot"
+svnroot = basedir + "/svnroot"
+maven1Project = basedir + "/maven-1"
+maven2Project = basedir + "/maven-2"
+antProject = basedir + "/ant"
+shellProject = basedir + "/shell"
+coDir = basedir + "/tmp-co"
+
+cleanDirectory( basedir )
+os.makedirs( basedir )
+os.makedirs( cvsroot )
+os.makedirs( svnroot )
+
+execute( os.getcwd(), "cvs -d " + cvsroot + " init" )
+execute( os.getcwd(), "svnadmin create " + svnroot )
+
+startTime = int( time.time() )
+
+if 1:
+    progress( "Initializing Maven 1 CVS project" )
+    initMaven1Project( maven1Project, "cvs", cvsroot, "maven-1" )
+    progress( "Adding Maven 1 project" )
+    maven1Id = getProjectId( c.addMavenOneProject( "file:" + maven1Project + "/project.xml" ) )
+    waitForSuccessfulCheckOut( c, maven1Id );
+    maven1 = c.getProject( maven1Id )
+    assertProject( maven1Id, "Maven 1 Project", email, "1.0", "", "maven-1", maven1 )
+    assertCheckedOutFiles( maven1, [ "/project.xml", "/src/main/java/Foo.java" ] )
+
+    progress( "Building Maven 1 project" )
+    buildId = buildProject( c, maven1.id ).id
+    assertSuccessfulMaven1Build( c, buildId )
+
+    progress( "Testing that the POM is updated before each build." )
+    cleanDirectory( coDir )
+    cvsCheckout( cvsroot, "maven-1", coDir )
+    pom = file( coDir + "/project.xml", "r" )
+    value = pom.read()
+    pom.close()
+
+    value = value.replace( "Maven 1 Project", "Maven 1 Project - Changed" )
+    value = value.replace( "1.0", "1.1" )
+
+    pom = file( coDir + "/project.xml", "w+" )
+    pom.write( value )
+    pom.close()
+
+    cvsCommit( coDir )
+
+    #c.updateProjectFromScm( maven1.id )
+    #maven1 = c.getProject( maven1.id )
+    #assertEquals( "The project name wasn't changed.", "Maven 1 Project - Changed", maven1.name )
+    #assertEquals( "The project version wasn't changed.", "1.1", maven1.version )
+
+    removeProject( c, maven1.id );
+
+if 1:
+    progress( "Initializing Maven 2 CVS project" )
+    initMaven2Project( maven2Project, cvsroot, "maven-2" )
+    progress( "Adding Maven 2 project" )
+    maven2Id = getProjectId( c.addMavenTwoProject( "file:" + maven2Project + "/pom.xml" ) )
+    waitForSuccessfulCheckOut( c, maven2Id );
+    maven2 = c.getProject( maven2Id )
+    assertProject( maven2Id, "Maven 2 Project", email, "2.0-SNAPSHOT", "-N -B", "maven2", maven2 )
+
+    progress( "Building Maven 2 project" )
+    buildId = buildProject( c, maven2.id ).id
+    assertSuccessfulMaven2Build( c, buildId )
+
+    progress( "Test that a build without any files changed won't execute the executor" )
+    expectedSize = len( c.getBuildsForProject( maven2.id ) )
+    c.buildProject( maven2.id, False )
+    time.sleep( 3.0 )
+    actualSize = len( c.getBuildsForProject( maven2.id ) )
+    assertEquals( "A build has unexpectedly been executed.", expectedSize, actualSize )
+
+    progress( "Test that a forced build without any files changed executes the executor" )
+    buildId = buildProject( c, maven2.id, True ).id
+    build = assertSuccessfulMaven2Build( c, buildId )
+    assertTrue( "The 'build forced' flag wasn't true", build.forced );
+    build = c.getBuild( buildId )
+
+    removeProject( c, maven2Id )
+
+if 1:
+    progress( "Initializing Ant SVN project" )
+    initAntProject( antProject )
+    svnImport( antProject, svnroot, "ant-svn" )
+
+    progress( "Adding Ant SVN project" )
+    p = AntProject()
+    p.scmUrl = "scm:svn:file://" + svnroot + "/ant-svn"
+    p.name = "Ant SVN Project"
+    p.notifiers.append( makeMailNotifier( email ) )
+    p.version = "3.0"
+    p.commandLineArguments = "-v"
+    p.executable = "ant"
+    p.targets = "clean build"
+    antSvnId = getProjectId( c.addAntProject( p ) )
+    waitForSuccessfulCheckOut( c, antSvnId );
+    antSvn = c.getProject( antSvnId )
+    assertProject( antSvnId, "Ant SVN Project", None, "3.0", "-v", "ant", antSvn )
+    progress( "Building SVN Ant project" )
+    buildId = buildProject( c, antSvn.id ).id
+    assertSuccessfulAntBuild( c, buildId )
+
+    removeProject( c, antSvnId )
+
+if 1:
+    progress( "Initializing Ant CVS project" )
+    initAntProject( antProject )
+    cvsImport( antProject, cvsroot, "ant-cvs" )
+
+    p = AntProject()
+    p.scmUrl = "scm:cvs:local:" + basedir + "/cvsroot:ant-cvs"
+    p.name = "Ant CVS Project"
+    p.notifiers.append( makeMailNotifier( email ) )
+    p.version = "3.0"
+    p.commandLineArguments = "-d"
+    p.executable = "ant"
+    p.targets = "clean build"
+    antCvsId = getProjectId( c.addAntProject( p ) )
+    waitForSuccessfulCheckOut( c, antCvsId );
+
+    antCvs = c.getProject( antCvsId )
+    assertProject( antCvsId, "Ant CVS Project", None, "3.0", "-d", "ant", antCvs )
+    progress( "Building CVS Ant project" )
+    buildId = buildProject( c, antCvs.id ).id
+    assertSuccessfulAntBuild( c, buildId )
+    removeProject( c, antCvsId )
+
+if 1:
+    progress( "Initializing Shell CVS project" )
+    initShellProject( shellProject )
+    cvsImport( shellProject, cvsroot, "shell" )
+
+    progress( "Adding CVS Shell project" )
+    p = ShellProject()
+    p.scmUrl = "scm:cvs:local:" + basedir + "/cvsroot:shell"
+    p.name = "Shell Project"
+    p.notifiers.append( makeMailNotifier( email ) )
+    p.version = "3.0"
+    p.commandLineArguments = ""
+    p.executable = "script.sh"
+    shellId = getProjectId( c.addShellProject( p ) )
+    waitForSuccessfulCheckOut( c, shellId );
+    shell = c.getProject( shellId )
+    assertProject( shellId, "Shell Project", None, "3.0", "", "shell", shell )
+
+    progress( "Building Shell project" )
+    buildId = buildProject( c, shell.id ).id
+    assertSuccessfulShellBuild( c, buildId, "" )
+
+    # Test project reconfiguration
+    # Test that a project will be built after a changed file is committed
+    progress( "Building Shell project with alternative configuration" )
+
+    cleanDirectory( coDir )
+    cvsCheckout( cvsroot, "shell", coDir )
+    script = file( coDir + "/script.sh", "r" )
+    value = script.read() + "# Extra line" + os.linesep
+    script.close()
+
+    script = file( coDir + "/script.sh", "w+" )
+    script.write( value )
+    script.close()
+
+    output = cvsCommit( coDir )
+
+    #c.updateProject( shell.id, shell.name, shell.scmUrl, shell.nagEmailAddress, shell.version, "a b" )
+    shell = c.getProject( shell.id )
+    shell.commandLineArguments = "a b";
+    c.updateShellProject( shell )
+    shell = c.getProject( shell.id )
+    assertEquals( "Updated command line arguments doesn't match", "a b", shell.commandLineArguments );
+
+    buildId = buildProject( c, shell.id ).id
+    assertSuccessfulShellBuild( c, buildId, """a
+b
+""" )
+    removeProject( c, shellId )
+
+# TODO: Add project failure tests
+
+endTime = int( time.time() )
+
+print ""
+print "##############################################"
+print "ALL TESTS PASSED"
+print "##############################################"
+print "Time elapsed: " + str( endTime - startTime ) + "s."
+print "##############################################"
+print ""

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py?rev=430041&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py (added)
+++ maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py Wed Aug  9 05:18:59 2006
@@ -0,0 +1,374 @@
+#import continuum
+import os
+import shutil
+import sys
+import time
+import traceback
+
+#####################################################################
+# Configuration
+#####################################################################
+
+email = "trygvis@codehaus.org"
+basedir = os.getcwd() + "/target"
+
+#####################################################################
+#
+#####################################################################
+
+def progress( message ):
+    print "[" + time.strftime( "%c" ) + "] * " + message
+
+def fail( message ):
+    print "FAILURE: " + message
+    sys.exit( -1 )
+
+def assertEquals( message, expected, actual ):
+    if ( expected == None and actual != None ):
+        assertionFailed( message, "None", actual )
+
+    if ( expected != None and actual == None ):
+        assertionFailed( message, expected, "None" )
+
+    if( expected == actual ):
+        return
+
+    assertionFailed( message, expected, actual )
+
+def assertionFailed( message, expected, actual ):
+    print
+    print "##############################################"
+    print "ASSERTION FAILURE!"
+    print "##############################################"
+    print "Message: " + message
+    print "Expected: " + str( expected )
+    print "Actual: " + str( actual )
+    print "##############################################"
+    print "Traceback"
+    print "##############################################"
+    traceback.print_stack()
+    print "##############################################"
+    print
+
+    sys.exit( -1 )
+
+def assertTrue( message, condition ):
+    assertEquals( message, True, condition )
+
+def assertFalse( message, condition ):
+    assertEquals( message, False, condition )
+
+def assertNotNull( message, condition ):
+    if ( condition != None ):
+        return
+
+    assertionFailed( message, "Not None", condition )
+
+def assertProject( projectId, name, nagEmailAddress, version, commandLineArguments, executorId, project ):
+    assertNotNull( "project.id", projectId )
+    assertEquals( "project.name", name, project.name )
+#    assertEquals( "project.state", state, project.state )
+    assertEquals( "project.version", version, project.version )
+    assertEquals( "project.commandLineArguments", commandLineArguments, project.commandLineArguments )
+    assertEquals( "project.executorId", executorId, project.executorId )
+
+    if ( nagEmailAddress == None ):
+        assertEquals( "project.notifiers.size", 0, len( project.notifiers ) )
+    else:
+        assertEquals( "project.notifiers.size", 1, len( project.notifiers ) )
+        assertEquals( "project.notifiers[0].type", "mail", project.notifiers[0].type )
+        print str( project.notifiers[0].configuration )
+        assertTrue( "project.notifiers[0].configuration.has_key('address')", project.notifiers[0].configuration.has_key('address') )
+        assertEquals( "project.notifiers[0].configuration['address']", nagEmailAddress, project.notifiers[0].configuration['address'] )
+
+def assertCheckedOutFiles( project, expectedCheckedOutFiles ):
+    actualCheckedOutFiles = project.checkOutScmResult.checkedOutFiles
+    if ( len( expectedCheckedOutFiles ) != len( actualCheckedOutFiles ) ):
+        print "Expected files: "
+        for expectedFile in expectedCheckedOutFiles:
+            print " " + expectedFile
+
+        print "Actual files: "
+        for actualFile in actualCheckedOutFiles:
+            print " " + actualFile.path
+
+    assertEquals( "The expected and actual lists of checked out files doesn't have the same length.", 
+                  len( expectedCheckedOutFiles ),
+                  len( actualCheckedOutFiles ) )
+
+    i = 0
+    for expectedFile in expectedCheckedOutFiles:
+        actualFile = actualCheckedOutFiles[ i ]
+        i += 1
+
+        assertEquals( "File #" + str( i ) + " doesn't match the expected path.", expectedFile, actualFile.path )
+
+def assertSuccessfulNoBuildPerformed( continuum, buildId ):
+    build = waitForBuild( continuum, buildId )
+    assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+    assertTrue( "The build wasn't successful", build.success )
+
+def assertSuccessfulMaven1Build( continuum, buildId ):
+    build = waitForBuild( continuum, buildId )
+    assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+    assertTrue( "The build wasn't successful", build.success )
+    assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", build.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+    assertEquals( "Standard error wasn't empty.", 0, len( build.standardError ) )
+
+def assertSuccessfulMaven2Build( continuum, buildId ):
+    build = waitForBuild( continuum, buildId )
+    assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+    assertTrue( "The build wasn't successful", build.success )
+    assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", build.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+    assertEquals( "Standard error wasn't empty.", 0, len( build.standardError ) )
+
+    return build
+
+def assertSuccessfulAntBuild( continuum, buildId ):
+    build = waitForBuild( continuum, buildId )
+    assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+    assertTrue( "The build wasn't successful", build.success )
+    assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", build.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+    assertEquals( "Standard error wasn't empty.", 0, len( build.standardError ) )
+
+def assertSuccessfulShellBuild( continuum, buildId, expectedStandardOutput ):
+    build = waitForBuild( continuum, buildId )
+    assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+    assertTrue( "The build wasn't successful", build.success )
+    assertEquals( "Standard output didn't contain the expected output.", expectedStandardOutput, build.standardOutput )
+    assertEquals( "Standard error wasn't empty.", 0, len( build.standardError ) )
+
+def buildProject( continuum, projectId, force=False ):
+    count = 600;
+
+    originalSize = len( continuum.getBuildsForProject( projectId ) )
+
+    continuum.buildProject( projectId, force )
+
+    while( True ):
+        builds = continuum.getBuildsForProject( projectId )
+
+        size = len( builds )
+
+        count = count - 1
+        if ( count == 0 ):
+            fail( "Timeout while waiting for build result." )
+
+        if ( size == originalSize ):
+            time.sleep( 0.1 )
+            continue
+
+        return builds[ 0 ]
+
+    # This will never happen, it is just to make pychecker shut up
+    return None
+
+def removeProject( continuum, projectId ):
+    time.sleep( 0.5 )
+    continuum.removeProject( projectId )
+
+    result = continuum.server.continuum.getProject( projectId )
+
+    if ( result[ "result" ] != "failure" ):
+        print result
+        fail( "Expected a failure when removing project." )
+
+def execute( workingDirectory, command ):
+    cwd = os.getcwd()
+    os.chdir( workingDirectory )
+    f = os.popen( command )
+    os.chdir( cwd )
+
+    output = f.read()
+
+    ret = f.close()
+
+    if ( ret != None ):
+        print output
+        print "ret: " + str( ret )
+        fail( "The command didn't return 0." )
+
+    return output
+
+def waitForBuild( continuum, buildId ):
+    timeout = 120                # seconds
+    sleepInterval = 0.1
+
+    build = continuum.getBuild( buildId )
+
+    while( build.state == continuum.STATE_UPDATING or
+           build.state == continuum.STATE_BUILDING ):
+
+        if ( timeout <= 0 ):
+            fail( "Timeout while waiting for build (id=%(id)s) to complete" % { "id" : buildId } )
+
+        time.sleep( sleepInterval )
+
+        timeout -= sleepInterval
+
+        build = continuum.getBuild( buildId )
+
+    return build
+
+def waitForSuccessfulCheckOut( continuum, projectId ):
+    project = waitForCheckOut( continuum, projectId )
+
+#    assertEquals( "The check out was not successful for project #" + project.id, continuum.STATE_NEW, project.state )
+    assertEquals( "The check out was not successful for project #" + project.id, None, project.checkOutErrorMessage )
+    assertEquals( "The check out was not successful for project #" + project.id, None, project.checkOutErrorException )
+    assertTrue( "The check out was not successful for project #" + project.id, project.checkOutScmResult.success )
+
+    return project
+
+def waitForCheckOut( continuum, projectId ):
+    timeout = 60
+    sleepInterval = 0.1
+
+    project = continuum.getProject( projectId )
+
+    while( project.checkOutScmResult == None and
+           project.checkOutErrorMessage == None and
+           project.checkOutErrorException == None ):
+        project = continuum.getProject( projectId )
+        time.sleep( sleepInterval )
+        timeout -= sleepInterval
+
+        if ( timeout <= 0 ):
+            fail( "Timeout while waiting for checkout (project id=%(id)s) to complete" % { "id" : project.id } )
+
+    return project
+
+def cleanDirectory( dir ):
+    if ( os.path.isdir( dir ) ):
+        shutil.rmtree( dir )
+
+def cvsCommit( basedir ):
+    return execute( basedir, "cvs commit -m ''" );
+
+def cvsCheckout( cvsroot, module, coDir ):
+    return execute( basedir, "cvs -d " + cvsroot + " checkout -d " + coDir + " " + module );
+
+def cvsImport( basedir, cvsroot, artifactId ):
+    return execute( basedir, "cvs -d " + cvsroot + " import -m '' " + artifactId + " continuum_test start" )
+
+def svnImport( basedir, svnroot, artifactId ):
+    return execute( basedir, "svn import -m '' . file://" + svnroot + "/" + artifactId )
+
+def makeScmUrl( scm, scmroot, artifactId ):
+    if ( scm == "cvs" ):
+        return "scm:cvs:local:%(scmroot)s:%(module)s" % { "scmroot" : scmroot , "module" : artifactId }
+    elif ( scm == "svn" ):
+        return "scm:svn:file:%(scmroot)s/%(artifactId)s" % { "scmroot" : scmroot , "module" : artifactId }
+
+    raise Exception( "Unknown SCM type '" + scm + "'" )
+
+def getProjectId( projectIds ):
+    if ( len( projectIds ) != 1 ):
+        fail( "When adding a project only a single project was expected to be added, project ids: " + str( projectIds ) );
+
+    return projectIds[ 0 ]
+
+def writeMavenOnePom( filename, artifactId, scmUrl, email ):
+    pom = file( "/" + filename, "w+" )
+    pom.write( """
+<project>
+  <pomVersion>3</pomVersion>
+  <groupId>continuum</groupId>
+  <artifactId>%(artifactId)s</artifactId>
+  <currentVersion>1.0</currentVersion>
+  <name>Maven 1 Project</name>
+  <repository>
+    <connection>%(scmUrl)s</connection>
+  </repository>
+  <build>
+    <nagEmailAddress>%(email)s</nagEmailAddress>
+  </build>
+</project>
+""" % {
+        "artifactId" : artifactId,
+        "scmUrl" : scmUrl,
+        "email" : email
+      } )
+    pom.close()
+
+def initMaven1Project( basedir, scm, cvsroot, artifactId ):
+    cleanDirectory( basedir )
+    os.makedirs( basedir )
+    writeMavenOnePom( basedir + "/project.xml", artifactId, makeScmUrl( scm, cvsroot, artifactId ), email )
+
+    os.makedirs( basedir + "/src/main/java" )
+    foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+    foo.write( "class Foo { }" )
+    foo.close()
+
+    cvsImport( basedir, cvsroot, artifactId )
+
+def initMaven2Project( basedir, cvsroot, artifactId ):
+    cleanDirectory( basedir )
+    os.makedirs( basedir )
+    pom = file( basedir + "/pom.xml", "w+" )
+    pom.write( """
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>continuum</groupId>
+  <artifactId>%(artifactId)s</artifactId>
+  <version>2.0-SNAPSHOT</version>
+  <name>Maven 2 Project</name>
+  <ciManagement>
+    <notifiers>
+      <notifier>
+        <type>mail</type>
+        <configuration>
+          <address>%(email)s</address>
+        </configuration>
+      </notifier>
+    </notifiers>
+  </ciManagement>
+  <scm>
+    <connection>scm:cvs:local:%(cvsroot)s:%(artifactId)s</connection>
+  </scm>
+</project>
+""" % { "artifactId" : artifactId, "cvsroot" : cvsroot, "email" : email } )
+    pom.close()
+
+    os.makedirs( basedir + "/src/main/java" )
+    foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+    foo.write( "class Foo { }" )
+    foo.close()
+
+    cvsImport( basedir, cvsroot, artifactId )
+
+def initAntProject( basedir ):
+    cleanDirectory( basedir )
+    os.makedirs( basedir )
+    buildXml = file( basedir + "/build.xml", "w+" )
+    buildXml.write( """
+<project>
+  <target name="build">
+    <property name="classes" value="target/classes"/>
+    <mkdir dir="${classes}"/>
+    <javac srcdir="src/main/java" destdir="${classes}"/>
+  </target>
+  <target name="clean">
+    <delete dir="${classes}"/>
+  </target>
+</project>""" )
+    buildXml.close()
+
+    os.makedirs( basedir + "/src/main/java" )
+    foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+    foo.write( "class Foo { }" )
+    foo.close()
+
+def initShellProject( basedir ):
+    cleanDirectory( basedir )
+    os.makedirs( basedir )
+    script = file( basedir + "/script.sh", "w+" )
+    script.write( """#!/bin/sh
+for arg in "$@"
+do
+  echo $arg
+  done
+""" )
+    script.close()
+    os.system( "chmod +x " + basedir + "/script.sh" )

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-sandbox/continuum-python/it_utils.py
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message