Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 76271 invoked from network); 13 Jun 2005 16:46:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2005 16:46:19 -0000 Received: (qmail 77450 invoked by uid 500); 13 Jun 2005 16:46:19 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 77426 invoked by uid 500); 13 Jun 2005 16:46:19 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 77406 invoked by uid 99); 13 Jun 2005 16:46:19 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 13 Jun 2005 09:46:13 -0700 Received: (qmail 76035 invoked by uid 65534); 13 Jun 2005 16:45:50 -0000 Message-ID: <20050613164550.75983.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r190423 [2/2] - /maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core-it /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1 /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2 /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/shell /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1 /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-model/src/main/resources /maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc /maven/continuum/trunk/continuum-xmlrpc/src/test/java/org/apache/maven/continuum/xmlrpc Date: Mon, 13 Jun 2005 16:45:43 -0000 To: continuum-commits@maven.apache.org From: trygvis@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/mav= en/continuum/store/ModelloJPoxContinuumStoreTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.j= ava?rev=3D190423&r1=3D190422&r2=3D190423&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStoreTest.java (original) +++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStoreTest.java Mon Jun 13 09:45:42 2005 @@ -26,6 +26,7 @@ =20 import org.apache.maven.continuum.execution.shell.ShellBuildResult; import org.apache.maven.continuum.execution.ContinuumBuildExecutor; +import org.apache.maven.continuum.execution.ant.AntBuildResult; import org.apache.maven.continuum.project.ContinuumBuild; import org.apache.maven.continuum.project.ContinuumBuildResult; import org.apache.maven.continuum.project.ContinuumJPoxStore; @@ -175,8 +176,7 @@ "1.0", "a b", "maven2", - "/tmp", - configuration ); + "/tmp" ); =20 String projectId =3D store.addProject( makeProject( "Test Project", "scm:local:src/t= est/repo", @@ -184,8 +184,7 @@ "1.0", "a b", "maven2", - "/tmp", - configuration ) = ); + "/tmp" ) ); =20 assertNotNull( "The project id is null.", projectId ); =20 @@ -223,7 +222,6 @@ String commandLineArguments =3D ""; String builderId =3D "maven2"; String workingDirectory =3D "/tmp"; - Properties properties =3D new Properties(); =20 String projectId =3D store.addProject( makeProject( name, scmUrl, @@ -231,8 +229,7 @@ version, commandLineArgum= ents, builderId, - workingDirectory, - properties ) ); + workingDirectory= ) ); =20 // ---------------------------------------------------------------= ------- // @@ -269,7 +266,6 @@ String nagEmailAddress2 =3D "2@bar"; String version2 =3D "v2"; String commandLineArguments2 =3D ""; - Properties properties2 =3D new Properties(); =20 store.updateProject( projectId, name2, @@ -288,7 +284,6 @@ commandLineArguments2, builderId, workingDirectory, - properties2, project ); =20 // ---------------------------------------------------------------= ------- @@ -325,7 +320,6 @@ String commandLineArguments1 =3D ""; String builderId1 =3D "maven2"; String workingDirectory1 =3D "/tmp"; - Properties configuration1 =3D new Properties(); =20 String id1 =3D addProject( store, name1, @@ -334,8 +328,7 @@ version1, commandLineArguments1, builderId1, - workingDirectory1, - configuration1 ); + workingDirectory1 ); =20 String name2 =3D "Test Project 2"; String scmUrl2 =3D "scm:local:src/test/repo/bar"; @@ -344,7 +337,6 @@ String commandLineArguments2 =3D ""; String builderId2 =3D "maven2"; String workingDirectory2 =3D "/tmp"; - Properties configuration2 =3D new Properties(); =20 String id2 =3D addProject( store, name2, @@ -353,8 +345,7 @@ version2, commandLineArguments2, builderId2, - workingDirectory2, - configuration2 ); + workingDirectory2 ); =20 Map projects =3D new HashMap(); =20 @@ -379,7 +370,6 @@ commandLineArguments1, builderId1, workingDirectory1, - configuration1, project1 ); =20 ContinuumProject project2 =3D (ContinuumProject) projects.get( nam= e2 ); @@ -392,41 +382,40 @@ commandLineArguments2, builderId2, workingDirectory2, - configuration2, project2 ); } =20 - public void testUpdateProjectConfiguration() - throws Exception - { - ContinuumStore store =3D (ContinuumStore) lookup( ContinuumStore.R= OLE ); - - String projectId =3D addProject( "Update Test Project", "scm:updat= e-project" ); - - ContinuumProject project =3D store.getProject( projectId ); - - assertEquals( 0, project.getConfiguration().size() ); - - // ---------------------------------------------------------------= ------- - // - // ---------------------------------------------------------------= ------- - - Properties expected =3D new Properties(); - - expected.put( "key", "value" ); - - store.updateProjectConfiguration( projectId, expected ); - - Properties actual =3D store.getProject( projectId ).getConfigurati= on(); - - assertNotNull( "The configuration is null", actual ); - - assertEquals( expected.size(), actual.size() ); - - assertTrue( actual.containsKey( "key" ) ); - - assertEquals( "value", actual.getProperty( "key" ) ); - } +// public void testUpdateProjectConfiguration() +// throws Exception +// { +// ContinuumStore store =3D (ContinuumStore) lookup( ContinuumStore= .ROLE ); +// +// String projectId =3D addProject( "Update Test Project", "scm:upd= ate-project" ); +// +// ContinuumProject project =3D store.getProject( projectId ); +// +// assertEquals( 0, project.getConfiguration().size() ); +// +// // -------------------------------------------------------------= --------- +// // +// // -------------------------------------------------------------= --------- +// +// Properties expected =3D new Properties(); +// +// expected.put( "key", "value" ); +// +// store.updateProjectConfiguration( projectId, expected ); +// +// Properties actual =3D store.getProject( projectId ).getConfigura= tion(); +// +// assertNotNull( "The configuration is null", actual ); +// +// assertEquals( expected.size(), actual.size() ); +// +// assertTrue( actual.containsKey( "key" ) ); +// +// assertEquals( "value", actual.getProperty( "key" ) ); +// } =20 public void testRemoveProject() throws Exception @@ -473,8 +462,40 @@ =20 store.setUpdateDone( projectId ); =20 + // ---------------------------------------------------------------= ------- + // Construct a build object + // ---------------------------------------------------------------= ------- + String buildId =3D store.createBuild( projectId, false ); =20 + UpdateScmResult updateScmResult =3D new UpdateScmResult(); + + updateScmResult.setCommandOutput( "commandOutput" ); + + updateScmResult.setProviderMessage( "providerMessage" ); + + updateScmResult.setSuccess( true ); + + ScmFile scmFile =3D new ScmFile(); + + scmFile.setPath( "/foo" ); + + updateScmResult.getUpdatedFiles().add( scmFile ); + + AntBuildResult buildResult =3D new AntBuildResult(); + + buildResult.setExitCode( 10 ); + + buildResult.setStandardError( "stderr" ); + + buildResult.setStandardOutput( "stdout" ); + + store.setBuildComplete( buildId, updateScmResult, buildResult ); + + // ---------------------------------------------------------------= ------- + // Store and check the build object + // ---------------------------------------------------------------= ------- + Collection builds =3D store.getBuildsForProject( projectId, 0, 0 ); =20 assertNotNull( "The collection with all builds was null.", builds = ); @@ -589,6 +610,8 @@ assertEquals( build.getId(), (String) expectedBuilds.get( 9 ) ); =20 Collection actualBuilds =3D store.getBuildsForProject( projectId, = 0, 0 ); + + assertEquals( 10, actualBuilds.size() ); } =20 public void testBuildResult() @@ -718,8 +741,7 @@ "1.0", "", ContinuumBuildExecutor.MAVEN_TWO_EXECUTOR_ID, - "/tmp", - new Properties() ); + "/tmp" ); } =20 public static ContinuumProject makeProject( String name, @@ -728,8 +750,7 @@ String version, String commandLineArgument= s, String executorId, - String workingDirectory, - Properties configuration ) + String workingDirectory ) { ContinuumProject project =3D new MavenTwoProject(); =20 @@ -740,7 +761,6 @@ project.setCommandLineArguments( commandLineArguments ); project.setExecutorId( executorId ); project.setWorkingDirectory( workingDirectory ); - project.setConfiguration( configuration ); =20 return project; } @@ -754,6 +774,16 @@ =20 checkOutScmResult.setSuccess( true ); =20 + checkOutScmResult.setCommandOutput( "commandOutput" ); + + checkOutScmResult.setProviderMessage( "providerMessage" ); + + ScmFile scmFile =3D new ScmFile(); + + scmFile.setPath( "/foo" ); + + checkOutScmResult.addCheckedOutFile( scmFile ); + store.setCheckoutDone( projectId, checkOutScmResult, null, null ); =20 project =3D store.getProject( projectId ); @@ -784,8 +814,7 @@ String version, String commandLineArguments, String executorId, - String workingDirectory, - Properties configuration ) + String workingDirectory ) throws Exception { // String projectId =3D store.addProject( name, @@ -802,8 +831,7 @@ version, commandLineArgum= ents, executorId, - workingDirectory, - configuration ) = ); + workingDirectory= ) ); =20 CheckOutScmResult checkOutScmResult =3D new CheckOutScmResult(); =20 @@ -851,7 +879,6 @@ expected.getCommandLineArguments(), expected.getExecutorId(), expected.getWorkingDirectory(), - expected.getConfiguration(), actual ); } =20 @@ -863,7 +890,6 @@ String commandLineArguments, String builderId, String workingDirectory, - Properties configuration, ContinuumProject actual ) { assertEquals( "project.id", projectId, actual.getId() ); @@ -882,15 +908,15 @@ =20 assertEquals( "project.workingDirectory", workingDirectory, actual= .getWorkingDirectory() ); =20 - for ( Iterator it =3D configuration.keySet().iterator(); it.hasNex= t(); ) - { - String key =3D (String) it.next(); - - String value =3D actual.getConfiguration().getProperty( key ); - - assertNotNull( "Value for key '" + key + "' was null.", value = ); - - assertEquals( "The values for '" + key + "' doesn't match.", c= onfiguration.getProperty( key ), value ); - } +// for ( Iterator it =3D configuration.keySet().iterator(); it.hasN= ext(); ) +// { +// String key =3D (String) it.next(); +// +// String value =3D actual.getConfiguration().getProperty( key = ); +// +// assertNotNull( "Value for key '" + key + "' was null.", valu= e ); +// +// assertEquals( "The values for '" + key + "' doesn't match.",= configuration.getProperty( key ), value ); +// } } } Modified: maven/continuum/trunk/continuum-model/src/main/resources/continuu= m=2Emdo URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/sr= c/main/resources/continuum.mdo?rev=3D190423&r1=3D190422&r2=3D190423&view=3D= diff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo = (original) +++ maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo = Mon Jun 13 09:45:42 2005 @@ -65,6 +65,7 @@ 1.0.0 String + builds 1.0.0 Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/m= aven/continuum/xmlrpc/ContinuumXmlRpc.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/s= rc/main/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpc.java?rev=3D1= 90423&r1=3D190422&r2=3D190423&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/ContinuumXmlRpc.java (original) +++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/ContinuumXmlRpc.java Mon Jun 13 09:45:42 2005 @@ -37,8 +37,8 @@ =20 Hashtable removeProject( String projectId ); =20 - Hashtable updateProjectConfiguration( String projectId, - Hashtable configuration ); +// Hashtable updateProjectConfiguration( String projectId, +// Hashtable configuration ); =20 Hashtable getProject( String projectId ); =20 @@ -87,15 +87,21 @@ =20 Hashtable addMavenOneProject( Hashtable mavenOneProject ); =20 + Hashtable updateMavenOneProject( Hashtable mavenOneProject ); + // -------------------------------------------------------------------= --- // Ant projects // -------------------------------------------------------------------= --- =20 Hashtable addAntProject( Hashtable antProject ); =20 + Hashtable updateAntProject( Hashtable antProject ); + // -------------------------------------------------------------------= --- // Shell projects // -------------------------------------------------------------------= --- =20 Hashtable addShellProject( Hashtable shellProject ); + + Hashtable updateShellProject( Hashtable shellProject ); } Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/m= aven/continuum/xmlrpc/DefaultContinuumXmlRpc.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/s= rc/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?= rev=3D190423&r1=3D190422&r2=3D190423&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultContinuumXmlRpc.java (original) +++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultContinuumXmlRpc.java Mon Jun 13 09:45:42 2005 @@ -24,8 +24,6 @@ import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; -import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.Vector; =20 @@ -83,30 +81,30 @@ } } =20 - public Hashtable updateProjectConfiguration( String projectId, - Hashtable configuration ) - { - try - { - Properties configurationProperties =3D new Properties(); - - for ( Iterator it =3D configuration.entrySet().iterator(); it.= hasNext(); ) - { - Map.Entry entry =3D (Map.Entry) it.next(); - - configurationProperties.put( entry.getKey().toString(), en= try.getValue().toString() ); - } - - continuum.updateProjectConfiguration( projectId, configuration= Properties ); - - return makeHashtable(); - } - catch ( Throwable e ) - { - return handleException( "ContinuumXmlRpc.updateProjectConfigur= ation()", - "Project id: '" + projectId + "'.", e = ); - } - } +// public Hashtable updateProjectConfiguration( String projectId, +// Hashtable configuration= ) +// { +// try +// { +// Properties configurationProperties =3D new Properties(); +// +// for ( Iterator it =3D configuration.entrySet().iterator(); i= t=2EhasNext(); ) +// { +// Map.Entry entry =3D (Map.Entry) it.next(); +// +// configurationProperties.put( entry.getKey().toString(), = entry.getValue().toString() ); +// } +// +// continuum.updateProjectConfiguration( projectId, configurati= onProperties ); +// +// return makeHashtable(); +// } +// catch ( Throwable e ) +// { +// return handleException( "ContinuumXmlRpc.updateProjectConfig= uration()", +// "Project id: '" + projectId + "'.", = e ); +// } +// } =20 public Hashtable getProject( String projectId ) { @@ -277,6 +275,83 @@ } =20 // -------------------------------------------------------------------= --- + // Maven 2.x projects + // -------------------------------------------------------------------= --- + + public Hashtable addMavenTwoProject( String url ) + { + try + { + // TODO: Get the added projects and return the IDs + ContinuumProjectBuildingResult result =3D continuum.addMavenTw= oProject( url ); + + Collection projects =3D result.getProjects(); + + Collection projectIds =3D new Vector( projects.size() ); + + for ( Iterator it =3D projects.iterator(); it.hasNext(); ) + { + ContinuumProject project =3D (ContinuumProject) it.next(); + + projectIds.add( project.getId() ); + + getLogger().info( "project id: " + project.getId() ); + } + + return makeHashtable( "projectIds", xmlRpcHelper.collectionToV= ector( projectIds, false ) ); + } + catch ( Throwable e ) + { + return handleException( "ContinuumXmlRpc.addMavenTwoProject()", + "URL: '" + url + "'.", e ); + } + } + + public Hashtable addMavenTwoProject( Hashtable mavenTwoProject ) + { + try + { + MavenTwoProject project =3D new MavenTwoProject(); + + xmlRpcHelper.hashtableToObject( mavenTwoProject, project ); + + String projectId =3D continuum.addMavenTwoProject( project ); + + // TODO: Get the added projects and return the IDs + Collection projectIds =3D new Vector(); + + projectIds.add( projectId ); + + getLogger().info( "project id: " + projectId ); + + return makeHashtable( "projectIds", xmlRpcHelper.collectionToV= ector( projectIds, false ) ); + } + catch ( Throwable e ) + { + return handleException( "ContinuumXmlRpc.addMavenTwoProject()"= , null, e ); + } + } + + public Hashtable updateMavenTwoProject( Hashtable mavenTwoProject ) + { + MavenTwoProject project =3D new MavenTwoProject(); + + try + { + xmlRpcHelper.hashtableToObject( mavenTwoProject, project ); + + continuum.updateMavenTwoProject( project ); + + return makeHashtable(); + } + catch ( Throwable e ) + { + return handleException( "ContinuumXmlRpc.updateMavenTwoProject= ()", + "Project id: " + project.getId(), e ); + } + } + + // -------------------------------------------------------------------= --- // Maven 1.x projects // -------------------------------------------------------------------= --- =20 @@ -331,6 +406,30 @@ } } =20 + public Hashtable updateMavenOneProject( Hashtable mavenOneProject ) + { + MavenOneProject project =3D new MavenOneProject(); + + try + { + xmlRpcHelper.hashtableToObject( mavenOneProject, project ); + + continuum.updateMavenOneProject( project ); + + return makeHashtable(); + } + catch ( Throwable e ) + { + return handleException( "ContinuumXmlRpc.updateMavenTwoProject= ()", + "Project id: " + project.getId(), e ); + } + + } + + // -------------------------------------------------------------------= --- + // Ant Projects + // -------------------------------------------------------------------= --- + public Hashtable addAntProject( Hashtable antProject ) { try @@ -354,94 +453,71 @@ } } =20 - public Hashtable addShellProject( Hashtable shellProject ) + public Hashtable updateAntProject( Hashtable antProject ) { + AntProject project =3D new AntProject(); + try { - ShellProject project =3D new ShellProject(); - - xmlRpcHelper.hashtableToObject( shellProject, project ); - - String projectId =3D continuum.addShellProject( project ); + xmlRpcHelper.hashtableToObject( antProject, project ); =20 - Collection projectIds =3D new ArrayList(); + continuum.updateAntProject( project ); =20 - projectIds.add( projectId ); - - return makeHashtable( "projectIds", xmlRpcHelper.collectionToV= ector( projectIds, false ) ); + return makeHashtable(); } catch ( Throwable e ) { - return handleException( "ContinuumXmlRpc.ShellProject()", - null, e ); + return handleException( "ContinuumXmlRpc.updateMavenTwoProject= ()", + "Project id: " + project.getId(), e ); } } =20 // -------------------------------------------------------------------= --- - // Maven 2.x projects + // Shell Projects // -------------------------------------------------------------------= --- =20 - public Hashtable addMavenTwoProject( String url ) + public Hashtable addShellProject( Hashtable shellProject ) { - getLogger().info( "addMavenTwoProject( String url )" ); try { - // TODO: Get the added projects and return the IDs - ContinuumProjectBuildingResult result =3D continuum.addMavenTw= oProject( url ); - - Collection projects =3D result.getProjects(); + ShellProject project =3D new ShellProject(); =20 - Collection projectIds =3D new Vector( projects.size() ); + xmlRpcHelper.hashtableToObject( shellProject, project ); =20 - for ( Iterator it =3D projects.iterator(); it.hasNext(); ) - { - ContinuumProject project =3D (ContinuumProject) it.next(); + String projectId =3D continuum.addShellProject( project ); =20 - projectIds.add( project.getId() ); + Collection projectIds =3D new ArrayList(); =20 - getLogger().info( "project id: " + project.getId() ); - } + projectIds.add( projectId ); =20 return makeHashtable( "projectIds", xmlRpcHelper.collectionToV= ector( projectIds, false ) ); } catch ( Throwable e ) { - return handleException( "ContinuumXmlRpc.addMavenTwoProject()", - "URL: '" + url + "'.", e ); + return handleException( "ContinuumXmlRpc.ShellProject()", + null, e ); } } =20 - public Hashtable addMavenTwoProject( Hashtable mavenTwoProject ) + public Hashtable updateShellProject( Hashtable shellProject ) { - getLogger().info( "addMavenTwoProject( Hashtable mavenTwoProject )= " ); + ShellProject project =3D new ShellProject(); + try { - MavenTwoProject project =3D new MavenTwoProject(); - - xmlRpcHelper.hashtableToObject( mavenTwoProject, project ); - - String projectId =3D continuum.addMavenTwoProject( project ); - - // TODO: Get the added projects and return the IDs - Collection projectIds =3D new Vector(); - - projectIds.add( projectId ); + xmlRpcHelper.hashtableToObject( shellProject, project ); =20 - getLogger().info( "project id: " + projectId ); + continuum.updateShellProject( project ); =20 - return makeHashtable( "projectIds", xmlRpcHelper.collectionToV= ector( projectIds, false ) ); + return makeHashtable(); } catch ( Throwable e ) { - return handleException( "ContinuumXmlRpc.addMavenTwoProject()"= , null, e ); + return handleException( "ContinuumXmlRpc.updateMavenTwoProject= ()", + "Project id: " + project.getId(), e ); } } =20 - public Hashtable updateMavenTwoProject( Hashtable mavenTwoProject ) - { - throw new RuntimeException( "NOT IMPLEMENTED" ); - } - // -------------------------------------------------------------------= --- // Object to Hashtable converters // -------------------------------------------------------------------= --- @@ -461,18 +537,18 @@ =20 Hashtable hashtable =3D xmlRpcHelper.objectToHashtable( project, e= xcludedProperties ); =20 - Properties configuration =3D project.getConfiguration(); - - Hashtable configurationHashtable =3D new Hashtable(); - - for ( Iterator it =3D configuration.entrySet().iterator(); it.hasN= ext(); ) - { - Map.Entry entry =3D (Map.Entry) it.next(); - - configurationHashtable.put( entry.getKey().toString(), entry.g= etValue().toString() ); - } - - hashtable.put( "configuration", configurationHashtable ); +// Properties configuration =3D project.getConfiguration(); +// +// Hashtable configurationHashtable =3D new Hashtable(); +// +// for ( Iterator it =3D configuration.entrySet().iterator(); it.ha= sNext(); ) +// { +// Map.Entry entry =3D (Map.Entry) it.next(); +// +// configurationHashtable.put( entry.getKey().toString(), entry= .getValue().toString() ); +// } +// +// hashtable.put( "configuration", configurationHashtable ); =20 return hashtable; } Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/m= aven/continuum/xmlrpc/DefaultXmlRpcHelper.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/s= rc/main/java/org/apache/maven/continuum/xmlrpc/DefaultXmlRpcHelper.java?rev= =3D190423&r1=3D190422&r2=3D190423&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultXmlRpcHelper.java (original) +++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultXmlRpcHelper.java Mon Jun 13 09:45:42 2005 @@ -122,6 +122,14 @@ // { // } =20 + value =3D convertValueToSetterType( setter.getParameterTypes()= [ 0 ], value ); + + if ( value =3D=3D null ) + { + continue; + } + + getLogger().info( "Invoking " + setter.toString() + " with " += value.getClass().getName() ); setter.invoke( target, new Object[]{value} ); } } @@ -302,6 +310,8 @@ { getLogger().warn( "No setter for field '" + key + "' on the cl= ass '" + clazz.getName() + "'. " + "The class has multiple setters for the fiel= d=2E" ); + + return null; } =20 return setter; @@ -335,5 +345,48 @@ } =20 return map; + } + + private Object convertValueToSetterType( Class type, Object value ) + { + if ( value.equals( type.getClass() ) ) + { + return value; + } + + if ( type =3D=3D String.class ) + { + return value; + } + + if ( type.getClass().equals( Integer.class ) || type.equals( int.c= lass ) ) + { + if ( value.getClass().equals( String.class ) ) + { + return new Integer( (String) value ); + } + + if ( value.getClass().equals( Integer.class ) || value.getClas= s().equals( int.class ) ) + { + return value; + } + } + + if ( type.getClass().equals( Boolean.class ) || type.equals( boole= an.class ) ) + { + if ( value.getClass().equals( String.class ) ) + { + return new Boolean( (String) value ); + } + + if ( value.getClass().equals( Boolean.class ) || value.getClas= s().equals( boolean.class ) ) + { + return value; + } + } + + getLogger().error( "Could not convert a " + value.getClass().getNa= me() + " to a " + type.getName() ); + + return null; } } Modified: maven/continuum/trunk/continuum-xmlrpc/src/test/java/org/apache/m= aven/continuum/xmlrpc/XmlRpcHelperTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/s= rc/test/java/org/apache/maven/continuum/xmlrpc/XmlRpcHelperTest.java?rev=3D= 190423&r1=3D190422&r2=3D190423&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-xmlrpc/src/test/java/org/apache/maven/c= ontinuum/xmlrpc/XmlRpcHelperTest.java (original) +++ maven/continuum/trunk/continuum-xmlrpc/src/test/java/org/apache/maven/c= ontinuum/xmlrpc/XmlRpcHelperTest.java Mon Jun 13 09:45:42 2005 @@ -17,6 +17,7 @@ */ =20 import java.util.Hashtable; +import java.util.Date; =20 import org.codehaus.plexus.PlexusTestCase; =20 @@ -121,6 +122,10 @@ public void getBar( int value ) { } + + public void setNonConvertableField( Date date ) + { + } } =20 public void testSimpleBean() @@ -229,6 +234,34 @@ xmlRpcHelper.hashtableToObject( hashtable, bean ); =20 assertEquals( "foo", bean.getFoo() ); + + assertEquals( 17, bean.getBar() ); + + assertEquals( true, bean.isBool() ); + } + + public void testHashtableToObjectWithStringArguments() + throws Exception + { + XmlRpcHelper xmlRpcHelper =3D (XmlRpcHelper) lookup( XmlRpcHelper.= ROLE ); + + SimleBean bean =3D new SimleBean(); + + Hashtable hashtable =3D new Hashtable(); + + hashtable.put( "foo", "foo" ); + + hashtable.put( "bar", new Integer( 17 ).toString() ); + + hashtable.put( "bool", Boolean.TRUE.toString() ); + + xmlRpcHelper.hashtableToObject( hashtable, bean ); + + assertEquals( "foo", bean.getFoo() ); + + assertEquals( 17, bean.getBar() ); + + assertEquals( true, bean.isBool() ); } =20 // -------------------------------------------------------------------= ---