index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "buildDefinitionTemplateDao" )
@Component( role = org.apache.continuum.dao.BuildDefinitionTemplateDao.class )
public class BuildDefinitionTemplateDaoImpl
extends AbstractDao
implements BuildDefinitionTemplateDao
{
public List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
throws ContinuumStoreException
{
return getAllObjectsDetached( BuildDefinitionTemplate.class, BUILD_TEMPLATE_BUILD_DEFINITIONS );
}
public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
Query query = pm.newQuery( extent );
query.setFilter( "continuumDefault == true" );
pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
List result = (List) query.execute();
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
throws ContinuumStoreException
{
return getObjectById( BuildDefinitionTemplate.class, id,
BUILD_TEMPLATE_BUILD_DEFINITIONS );
}
public BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
throws ContinuumStoreException
{
return addObject( buildDefinitionTemplate );
}
public BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
throws ContinuumStoreException
{
updateObject( buildDefinitionTemplate );
return buildDefinitionTemplate;
}
public void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
throws ContinuumStoreException
{
removeObject( buildDefinitionTemplate );
}
public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String type" );
query.setFilter( "this.type == type" );
pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
List result = (List) query.execute( type );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String type" );
query.setFilter( "continuumDefault == true && this.type == type" );
pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
List result = (List) query.execute( type );
if ( result == null || result.isEmpty() )
{
return null;
}
return (BuildDefinitionTemplate) pm.detachCopy( result.get( 0 ) );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
Query query = pm.newQuery( extent );
query.setFilter( "continuumDefault == true" );
List result = (List) query.execute();
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
}
| 5,200 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/NotifierDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.springframework.stereotype.Repository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "notifierDao" )
public class NotifierDaoImpl
extends AbstractDao
implements NotifierDao
{
public void removeNotifier( ProjectNotifier notifier )
throws ContinuumStoreException
{
attachAndDelete( notifier );
}
public ProjectNotifier storeNotifier( ProjectNotifier notifier )
throws ContinuumStoreException
{
updateObject( notifier );
return notifier;
}
}
| 5,201 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java | package org.apache.continuum.dao;
import org.apache.continuum.model.repository.DistributedRepositoryPurgeConfiguration;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collections;
import java.util.List;
@Repository( "distributedRepositoryPurgeConfigurationDao" )
public class DistributedRepositoryPurgeConfigurationDaoImpl
extends AbstractDao
implements DistributedRepositoryPurgeConfigurationDao
{
public List<DistributedRepositoryPurgeConfiguration> getAllDistributedRepositoryPurgeConfigurations()
{
return getAllObjectsDetached( DistributedRepositoryPurgeConfiguration.class );
}
public DistributedRepositoryPurgeConfiguration addDistributedRepositoryPurgeConfiguration(
DistributedRepositoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
return addObject( purgeConfiguration );
}
public void removeDistributedRepositoryPurgeConfiguration(
DistributedRepositoryPurgeConfiguration purgeConfiguration )
{
removeObject( purgeConfiguration );
}
public DistributedRepositoryPurgeConfiguration getDistributedRepositoryPurgeConfiguration( int configId )
throws ContinuumStoreException
{
return getObjectById( DistributedRepositoryPurgeConfiguration.class, configId );
}
public void updateDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
throws ContinuumStoreException
{
updateObject( purgeConfig );
}
public List<DistributedRepositoryPurgeConfiguration> getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DistributedRepositoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
} | 5,202 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/InstallationDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "installationDao" )
@Component( role = org.apache.continuum.dao.InstallationDao.class )
public class InstallationDaoImpl
extends AbstractDao
implements InstallationDao
{
public Installation addInstallation( Installation installation )
{
return addObject( installation );
}
public List<Installation> getAllInstallations()
{
return getAllObjectsDetached( Installation.class, "name ascending", null );
}
public void removeInstallation( Installation installation )
throws ContinuumStoreException
{
// first delete link beetwen profile and this installation
// then removing this
//attachAndDelete( installation );
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
// this must be done in the same transaction
tx.begin();
// first removing linked jdk
Extent extent = pm.getExtent( Profile.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.jdk.name == name" );
Collection<Profile> result = (Collection) query.execute( installation.getName() );
if ( result.size() != 0 )
{
for ( Profile profile : result )
{
profile.setJdk( null );
pm.makePersistent( profile );
}
}
// removing linked builder
query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.builder.name == name" );
result = (Collection) query.execute( installation.getName() );
if ( result.size() != 0 )
{
for ( Profile profile : result )
{
profile.setBuilder( null );
pm.makePersistent( profile );
}
}
// removing linked env Var
query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareImports( "import " + Installation.class.getName() );
query.declareParameters( "Installation installation" );
query.setFilter( "environmentVariables.contains(installation)" );
//query = pm
// .newQuery( "SELECT FROM profile WHERE environmentVariables.contains(installation) && installation.name == name" );
result = (Collection) query.execute( installation );
if ( result.size() != 0 )
{
for ( Profile profile : result )
{
List<Installation> newEnvironmentVariables = new ArrayList<Installation>();
for ( Installation current : (Iterable<Installation>) profile.getEnvironmentVariables() )
{
if ( !StringUtils.equals( current.getName(), installation.getName() ) )
{
newEnvironmentVariables.add( current );
}
}
profile.setEnvironmentVariables( newEnvironmentVariables );
pm.makePersistent( profile );
}
}
pm.deletePersistent( installation );
tx.commit();
}
finally
{
rollback( tx );
}
}
public void updateInstallation( Installation installation )
throws ContinuumStoreException
{
updateObject( installation );
}
public Installation getInstallation( int installationId )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Installation.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int installationId" );
query.setFilter( "this.installationId == installationId" );
Collection result = (Collection) query.execute( installationId );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (Installation) object;
}
finally
{
rollback( tx );
}
}
public Installation getInstallation( String installationName )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Installation.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.name == name" );
Collection result = (Collection) query.execute( installationName );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (Installation) object;
}
finally
{
rollback( tx );
}
}
}
| 5,203 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/ScheduleDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.Schedule;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "scheduleDao" )
@Component( role = org.apache.continuum.dao.ScheduleDao.class )
public class ScheduleDaoImpl
extends AbstractDao
implements ScheduleDao
{
public List<Schedule> getAllSchedulesByName()
{
return getAllObjectsDetached( Schedule.class, "name ascending", null );
}
public Schedule addSchedule( Schedule schedule )
{
return addObject( schedule );
}
public Schedule getScheduleByName( String name )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Schedule.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.name == name" );
Collection result = (Collection) query.execute( name );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (Schedule) object;
}
finally
{
rollback( tx );
}
}
public Schedule storeSchedule( Schedule schedule )
throws ContinuumStoreException
{
updateObject( schedule );
return schedule;
}
public void updateSchedule( Schedule schedule )
throws ContinuumStoreException
{
updateObject( schedule );
}
public void removeSchedule( Schedule schedule )
{
removeObject( schedule );
}
public Schedule getSchedule( int scheduleId )
throws ContinuumStoreException
{
return getObjectById( Schedule.class, scheduleId );
}
}
| 5,204 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/RepositoryPurgeConfigurationDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import java.util.Collections;
import java.util.List;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "repositoryPurgeConfigurationDao" )
@Component( role = org.apache.continuum.dao.RepositoryPurgeConfigurationDao.class )
public class RepositoryPurgeConfigurationDaoImpl
extends AbstractDao
implements RepositoryPurgeConfigurationDao
{
public List<RepositoryPurgeConfiguration> getAllRepositoryPurgeConfigurations()
{
return getAllObjectsDetached( RepositoryPurgeConfiguration.class );
}
public List<RepositoryPurgeConfiguration> getRepositoryPurgeConfigurationsBySchedule( int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<RepositoryPurgeConfiguration> getEnableRepositoryPurgeConfigurationsBySchedule( int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<RepositoryPurgeConfiguration> getRepositoryPurgeConfigurationsByLocalRepository( int repositoryId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int repositoryId" );
query.setFilter( "this.repository.id == repositoryId" );
List result = (List) query.execute( repositoryId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public RepositoryPurgeConfiguration getRepositoryPurgeConfiguration( int configurationId )
throws ContinuumStoreException
{
return getObjectById( RepositoryPurgeConfiguration.class, configurationId );
}
public RepositoryPurgeConfiguration addRepositoryPurgeConfiguration(
RepositoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
return addObject( purgeConfiguration );
}
public void updateRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
updateObject( purgeConfiguration );
}
public void removeRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
removeObject( purgeConfiguration );
}
}
| 5,205 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/DirectoryPurgeConfigurationDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "directoryPurgeConfigurationDao" )
@Component( role = org.apache.continuum.dao.DirectoryPurgeConfigurationDao.class )
public class DirectoryPurgeConfigurationDaoImpl
extends AbstractDao
implements DirectoryPurgeConfigurationDao
{
public List<DirectoryPurgeConfiguration> getAllDirectoryPurgeConfigurations()
{
return getAllObjectsDetached( DirectoryPurgeConfiguration.class );
}
public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsBySchedule( int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<DirectoryPurgeConfiguration> getEnableDirectoryPurgeConfigurationsBySchedule( int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByLocation( String location )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String location" );
query.setFilter( "this.location == location" );
List result = (List) query.execute( location );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByType( String type )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String type" );
query.setFilter( "this.directoryType == type" );
List result = (List) query.execute( type );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public DirectoryPurgeConfiguration getDirectoryPurgeConfiguration( int configurationId )
throws ContinuumStoreException
{
return getObjectById( DirectoryPurgeConfiguration.class, configurationId );
}
public DirectoryPurgeConfiguration addDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
return addObject( purgeConfiguration );
}
public void updateDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
updateObject( purgeConfiguration );
}
public void removeDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
removeObject( purgeConfiguration );
}
}
| 5,206 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/LocalRepositoryDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "localRepositoryDao" )
@Component( role = org.apache.continuum.dao.LocalRepositoryDao.class )
public class LocalRepositoryDaoImpl
extends AbstractDao
implements LocalRepositoryDao
{
public LocalRepository addLocalRepository( LocalRepository repository )
throws ContinuumStoreException
{
return addObject( repository );
}
public void updateLocalRepository( LocalRepository repository )
throws ContinuumStoreException
{
updateObject( repository );
}
public void removeLocalRepository( LocalRepository repository )
throws ContinuumStoreException
{
removeObject( repository );
}
public List<LocalRepository> getAllLocalRepositories()
{
return getAllObjectsDetached( LocalRepository.class );
}
public List<LocalRepository> getLocalRepositoriesByLayout( String layout )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( LocalRepository.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String layout" );
query.setFilter( "this.layout == layout" );
List result = (List) query.execute( layout );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public LocalRepository getLocalRepository( int repositoryId )
throws ContinuumStoreException
{
return getObjectById( LocalRepository.class, repositoryId );
}
public LocalRepository getLocalRepositoryByName( String name )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( LocalRepository.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.name == name" );
Collection result = (Collection) query.execute( name );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (LocalRepository) object;
}
finally
{
rollback( tx );
}
}
public LocalRepository getLocalRepositoryByLocation( String location )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( LocalRepository.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String location" );
query.setFilter( "this.location == location" );
Collection result = (Collection) query.execute( location );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (LocalRepository) object;
}
finally
{
rollback( tx );
}
}
}
| 5,207 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.continuum.model.release.ContinuumReleaseResult;
import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
import org.apache.maven.continuum.model.project.BuildQueue;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectDependency;
import org.apache.maven.continuum.model.project.ProjectDeveloper;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.model.project.Schedule;
import org.apache.maven.continuum.model.scm.ChangeFile;
import org.apache.maven.continuum.model.scm.ChangeSet;
import org.apache.maven.continuum.model.scm.ScmResult;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
import org.apache.maven.continuum.model.system.SystemConfiguration;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.jdo.PlexusJdoUtils;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.jdo.Extent;
import javax.jdo.JDOUserException;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "daoUtils" )
@Component( role = org.apache.continuum.dao.DaoUtils.class )
public class DaoUtilsImpl
extends AbstractDao
implements DaoUtils
{
@Resource
@Requirement( role = org.apache.continuum.dao.ProjectDao.class )
private ProjectDao projectDao;
public void closeStore()
{
closePersistenceManagerFactory( getContinuumPersistenceManagerFactory(), 1 );
}
public void eraseDatabase()
{
PlexusJdoUtils.removeAll( getPersistenceManager(), BuildResult.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), BuildDefinitionTemplate.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ContinuumReleaseResult.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectScmRoot.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectGroup.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), Project.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), BuildDefinition.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), RepositoryPurgeConfiguration.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), LocalRepository.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), DirectoryPurgeConfiguration.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), Schedule.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), BuildQueue.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), Profile.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), Installation.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ScmResult.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), SystemConfiguration.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectNotifier.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectDeveloper.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectDependency.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ChangeSet.class );
PlexusJdoUtils.removeAll( getPersistenceManager(), ChangeFile.class );
}
public void rebuildStore() {
closeStore();
storeUtilities.buildFactory();
}
/**
* Close the PersistenceManagerFactory.
*
* @param numTry The number of try. The maximum try is 5.
*/
private void closePersistenceManagerFactory( PersistenceManagerFactory pmf, int numTry )
{
if ( pmf != null )
{
if ( !pmf.isClosed() )
{
try
{
pmf.close();
}
catch ( JDOUserException e )
{
if ( numTry < 5 )
{
try
{
Thread.currentThread().wait( 1000 );
}
catch ( InterruptedException ie )
{
// nothing to do
}
closePersistenceManagerFactory( pmf, numTry + 1 );
}
else
{
throw e;
}
}
}
}
}
/**
* get the combined list of projectId and build definitions, including the
* ones inherited by their project group
*
* @param scheduleId
* @return mapping of project ids to lists of build definition ids
* @throws org.apache.maven.continuum.store.ContinuumStoreException
* @todo Move to a better place
*/
public Map<Integer, Object> getAggregatedProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
throws ContinuumStoreException
{
Map<Integer, Object> projectSource = getProjectIdsAndBuildDefinitionsIdsBySchedule( scheduleId );
Map<Integer, Object> projectGroupSource = getProjectGroupIdsAndBuildDefinitionsIdsBySchedule( scheduleId );
Map<Integer, Object> aggregate = new HashMap<Integer, Object>();
// Pre-load result with definitions from projects with the schedule id
if ( projectSource != null )
{
aggregate.putAll( projectSource );
}
// Ensure project group definitions are used only if project build definitions do not exist
if ( projectGroupSource != null )
{
for ( Integer projectGroupId : projectGroupSource.keySet() )
{
List<Project> projectsInGroup = projectDao.getProjectsInGroup( projectGroupId );
for ( Project p : projectsInGroup )
{
Integer projectId = p.getId();
if ( !aggregate.keySet().contains( projectId ) )
{
aggregate.put( projectId, projectGroupSource.get( projectGroupId ) );
}
}
}
}
return aggregate;
}
/**
* @param scheduleId
* @return
* @throws ContinuumStoreException
* @todo Move to a better place
*/
public Map<Integer, Object> getProjectIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Project.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.declareImports( "import org.apache.maven.continuum.model.project.BuildDefinition" );
query.declareVariables( "BuildDefinition buildDef" );
query.setFilter( "buildDefinitions.contains(buildDef) && buildDef.schedule.id == scheduleId" );
query.setResult( "this.id, buildDef.id" );
List result = (List) query.execute( scheduleId );
Map projects = new HashMap();
if ( result != null && !result.isEmpty() )
{
for ( Iterator i = result.iterator(); i.hasNext(); )
{
Object[] obj = (Object[]) i.next();
List buildDefinitions;
if ( projects.get( obj[0] ) != null )
{
buildDefinitions = (List) projects.get( obj[0] );
}
else
{
buildDefinitions = new ArrayList();
projects.put( obj[0], buildDefinitions );
}
buildDefinitions.add( obj[1] );
}
return projects;
}
if ( !projects.isEmpty() )
{
return projects;
}
}
finally
{
tx.commit();
rollback( tx );
}
return null;
}
/**
* @param scheduleId
* @return mapping of project group ids to lists of corresponding build definition ids
* @throws ContinuumStoreException
* @todo Move to a better place
*/
public Map<Integer, Object> getProjectGroupIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ProjectGroup.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.declareImports( "import org.apache.maven.continuum.model.project.BuildDefinition" );
query.declareVariables( "BuildDefinition buildDef" );
query.setFilter( "buildDefinitions.contains(buildDef) && buildDef.schedule.id == scheduleId" );
query.setResult( "this.id, buildDef.id" );
List result = (List) query.execute( scheduleId );
Map projectGroups = new HashMap();
if ( result != null && !result.isEmpty() )
{
for ( Iterator i = result.iterator(); i.hasNext(); )
{
Object[] obj = (Object[]) i.next();
List buildDefinitions;
if ( projectGroups.get( obj[0] ) != null )
{
buildDefinitions = (List) projectGroups.get( obj[0] );
}
else
{
buildDefinitions = new ArrayList();
projectGroups.put( obj[0], buildDefinitions );
}
buildDefinitions.add( obj[1] );
}
return projectGroups;
}
}
finally
{
tx.commit();
rollback( tx );
}
return null;
}
}
| 5,208 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/ProjectScmRootDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
/**
* @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
*/
@Repository( "projectScmRootDao" )
@Component( role = org.apache.continuum.dao.ProjectScmRootDao.class )
public class ProjectScmRootDaoImpl
extends AbstractDao
implements ProjectScmRootDao
{
public ProjectScmRoot addProjectScmRoot( ProjectScmRoot projectScmRoot )
throws ContinuumStoreException
{
return addObject( projectScmRoot );
}
public List<ProjectScmRoot> getAllProjectScmRoots()
{
return getAllObjectsDetached( ProjectScmRoot.class );
}
public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ProjectScmRoot.class, true );
Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
List result = (List) query.execute();
result = (List) pm.detachCopyAll( result );
tx.commit();
return result;
}
finally
{
rollback( tx );
}
}
public void removeProjectScmRoot( ProjectScmRoot projectScmRoot )
throws ContinuumStoreException
{
removeObject( projectScmRoot );
}
public void updateProjectScmRoot( ProjectScmRoot projectScmRoot )
throws ContinuumStoreException
{
updateObject( projectScmRoot );
}
public ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ProjectScmRoot.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "int projectGroupId, String scmRootAddress" );
query.setFilter( "this.projectGroup.id == projectGroupId && this.scmRootAddress == scmRootAddress" );
Object[] params = new Object[2];
params[0] = projectGroupId;
params[1] = scmRootAddress;
Collection result = (Collection) query.executeWithArray( params );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (ProjectScmRoot) object;
}
finally
{
rollback( tx );
}
}
public ProjectScmRoot getProjectScmRoot( int projectScmRootId )
throws ContinuumObjectNotFoundException, ContinuumStoreException
{
return getObjectById( ProjectScmRoot.class, projectScmRootId );
}
}
| 5,209 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collections;
import java.util.List;
@Repository( "distributedDirectoryPurgeConfigurationDao" )
@Component( role = org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao.class )
public class DistributedDirectoryPurgeConfigurationDaoImpl
extends AbstractDao
implements DistributedDirectoryPurgeConfigurationDao
{
public List<DistributedDirectoryPurgeConfiguration> getAllDistributedDirectoryPurgeConfigurations()
{
return getAllObjectsDetached( DistributedDirectoryPurgeConfiguration.class );
}
public List<DistributedDirectoryPurgeConfiguration> getDistributedDirectoryPurgeConfigurationsBySchedule(
int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DistributedDirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule(
int scheduleId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DistributedDirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareParameters( "int scheduleId" );
query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
List result = (List) query.execute( scheduleId );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public List<DistributedDirectoryPurgeConfiguration> getDistributedDirectoryPurgeConfigurationsByType( String type )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( DistributedDirectoryPurgeConfiguration.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String type" );
query.setFilter( "this.directoryType == type" );
List result = (List) query.execute( type );
return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int configurationId )
throws ContinuumStoreException
{
return getObjectById( DistributedDirectoryPurgeConfiguration.class, configurationId );
}
public DistributedDirectoryPurgeConfiguration addDistributedDirectoryPurgeConfiguration(
DistributedDirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
return addObject( purgeConfiguration );
}
public void updateDistributedDirectoryPurgeConfiguration(
DistributedDirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
updateObject( purgeConfiguration );
}
public void removeDistributedDirectoryPurgeConfiguration(
DistributedDirectoryPurgeConfiguration purgeConfiguration )
throws ContinuumStoreException
{
removeObject( purgeConfiguration );
}
}
| 5,210 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.BuildQueue;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
*/
@Repository( "buildQueueDao" )
@Component( role = org.apache.continuum.dao.BuildQueueDao.class )
public class BuildQueueDaoImpl
extends AbstractDao
implements BuildQueueDao
{
private static Logger log = LoggerFactory.getLogger( BuildQueueDaoImpl.class );
public BuildQueue addBuildQueue( BuildQueue buildQueue )
throws ContinuumStoreException
{
return addObject( buildQueue );
}
public List<BuildQueue> getAllBuildQueues()
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildQueue.class, true );
Query query = pm.newQuery( extent );
List result = (List) query.execute();
return result == null ? Collections.EMPTY_LIST : (List<BuildQueue>) pm.detachCopyAll( result );
}
finally
{
tx.commit();
rollback( tx );
}
}
public BuildQueue getBuildQueue( int buildQueueId )
throws ContinuumStoreException
{
return getObjectById( BuildQueue.class, buildQueueId );
}
public BuildQueue getBuildQueueByName( String name )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildQueue.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.name == name" );
Collection result = (Collection) query.execute( name );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (BuildQueue) object;
}
finally
{
rollback( tx );
}
}
public void removeBuildQueue( BuildQueue buildQueue )
throws ContinuumStoreException
{
removeObject( buildQueue );
}
public BuildQueue storeBuildQueue( BuildQueue buildQueue )
throws ContinuumStoreException
{
updateObject( buildQueue );
return buildQueue;
}
}
| 5,211 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.release.ContinuumReleaseResult;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collection;
import java.util.List;
/**
* @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
*/
@Repository( "continuumReleaseResultDao" )
@Component( role = org.apache.continuum.dao.ContinuumReleaseResultDao.class )
public class ContinuumReleaseResultDaoImpl
extends AbstractDao
implements ContinuumReleaseResultDao
{
public ContinuumReleaseResult addContinuumReleaseResult( ContinuumReleaseResult releaseResult )
throws ContinuumStoreException
{
return addObject( releaseResult );
}
public List<ContinuumReleaseResult> getAllContinuumReleaseResults()
{
return getAllObjectsDetached( ContinuumReleaseResult.class );
}
public ContinuumReleaseResult getContinuumReleaseResult( int releaseResultId )
throws ContinuumObjectNotFoundException, ContinuumStoreException
{
return getObjectById( ContinuumReleaseResult.class, releaseResultId );
}
public ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal, long startTime,
long endTime )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "int projectId, String releaseGoal, long startTime, long endTime" );
query.setFilter(
"this.project.id == projectId && this.releaseGoal == releaseGoal && this.startTime == startTime && this.endTime == endTime" );
Object[] params = new Object[4];
params[0] = projectId;
params[1] = releaseGoal;
params[2] = startTime;
params[3] = endTime;
Collection result = (Collection) query.executeWithArray( params );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (ContinuumReleaseResult) object;
}
finally
{
rollback( tx );
}
}
public List<ContinuumReleaseResult> getContinuumReleaseResultsByProjectGroup( int projectGroupId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
List result = (List) query.execute();
result = (List) pm.detachCopyAll( result );
tx.commit();
return result;
}
finally
{
rollback( tx );
}
}
public List<ContinuumReleaseResult> getContinuumReleaseResultsByProject( int projectId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
Query query = pm.newQuery( extent, "project.id == " + projectId );
List result = (List) query.execute();
result = (List) pm.detachCopyAll( result );
tx.commit();
return result;
}
finally
{
rollback( tx );
}
}
public void removeContinuumReleaseResult( ContinuumReleaseResult releaseResult )
throws ContinuumStoreException
{
removeObject( releaseResult );
}
}
| 5,212 |
0 | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-store/src/main/java/org/apache/continuum/dao/ProfileDaoImpl.java | package org.apache.continuum.dao;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.system.Profile;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.component.annotations.Component;
import org.springframework.stereotype.Repository;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Collection;
import java.util.List;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
@Repository( "profileDao" )
@Component( role = org.apache.continuum.dao.ProfileDao.class )
public class ProfileDaoImpl
extends AbstractDao
implements ProfileDao
{
public Profile getProfileByName( String profileName )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Profile.class, true );
Query query = pm.newQuery( extent );
query.declareImports( "import java.lang.String" );
query.declareParameters( "String name" );
query.setFilter( "this.name == name" );
Collection result = (Collection) query.execute( profileName );
if ( result.size() == 0 )
{
tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
tx.commit();
return (Profile) object;
}
finally
{
rollback( tx );
}
}
public List<Profile> getAllProfilesByName()
{
return getAllObjectsDetached( Profile.class, "name ascending", null );
}
public Profile addProfile( Profile profile )
{
return addObject( profile );
}
public Profile getProfile( int profileId )
throws ContinuumStoreException
{
return getObjectById( Profile.class, profileId );
}
public void updateProfile( Profile profile )
throws ContinuumStoreException
{
updateObject( profile );
}
public void removeProfile( Profile profile )
{
removeObject( profile );
}
}
| 5,213 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractInstallationTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = { "buildEnvironment" } )
public class BuildEnvironmentTest
extends AbstractInstallationTest
{
public static final String INSTALLATION_NAME = "varForBuildEnv";
private static final String INSTALLATION_BUILD_ENV = "installationBuildEnv";
private static final String NEW_BUILD_ENV = "NEW_BUILD_ENV";
private String buildEnvName;
@BeforeClass(alwaysRun = true)
public void setUp()
{
buildEnvName = getProperty( "BUILD_ENV_NAME" );
}
public void testAddBuildEnvironment()
{
goToAddBuildEnvironment();
addBuildEnvironment( buildEnvName, new String[]{ }, true );
}
public void testAddInvalidBuildEnvironment()
{
goToAddBuildEnvironment();
addBuildEnvironment( "", new String[]{ }, false );
assertTextPresent( "You must define a name" );
}
public void testAddBuildEnvironmentWithXSS()
{
goToAddBuildEnvironment();
addBuildEnvironment( "<script>alert('gotcha')</script>", new String[]{ }, false );
assertTextPresent( "Build environment name contains invalid characters." );
}
@Test( dependsOnMethods = { "testAddBuildEnvironment" } )
public void testEditInvalidBuildEnvironment()
{
goToEditBuildEnvironment( buildEnvName );
editBuildEnvironment( "", new String[]{ }, false );
assertTextPresent( "You must define a name" );
}
@Test( dependsOnMethods = { "testAddBuildEnvironment" } )
public void testAddDuplicatedBuildEnvironment()
{
goToAddBuildEnvironment();
addBuildEnvironment( buildEnvName, new String[]{ }, false );
assertTextPresent( "A Build Environment with the same name already exists" );
}
@Test( dependsOnMethods = { "testAddBuildEnvironment" } )
public void testEditBuildEnvironment()
{
String newName = "new_name";
goToEditBuildEnvironment( buildEnvName );
editBuildEnvironment( newName, new String[]{ }, true );
goToEditBuildEnvironment( newName );
editBuildEnvironment( buildEnvName, new String[]{ }, true );
}
@Test( dependsOnMethods = { "testAddBuildEnvironment" })
public void testAddInstallationToBuildEnvironment()
{
addBuildEnvironment( INSTALLATION_BUILD_ENV, new String[]{ }, true );
goToInstallationPage();
if ( !isTextPresent( INSTALLATION_NAME ) )
{
goToAddInstallationVariable();
addInstallation( INSTALLATION_NAME, "VAR_BUILD_ENV", "var_value", false, false, true );
}
goToEditBuildEnvironment( INSTALLATION_BUILD_ENV );
editBuildEnvironment( INSTALLATION_BUILD_ENV, new String[] { INSTALLATION_NAME }, true );
}
@Test( dependsOnMethods = { "testAddInstallationToBuildEnvironment" })
public void testEditInstallationOnBuildEnvironment()
{
goToEditBuildEnvironment( INSTALLATION_BUILD_ENV );
clickLinkWithText( INSTALLATION_NAME );
assertEditInstallationVariablePage();
assert INSTALLATION_NAME.equals( getFieldValue( "installation.name" ) );
}
@Test( dependsOnMethods = { "testEditInstallationOnBuildEnvironment" })
public void testRemoveInstallationOnBuildEnvironment()
{
goToEditBuildEnvironment( INSTALLATION_BUILD_ENV );
assertLinkPresent( INSTALLATION_NAME );
clickImgWithAlt( "Delete" );
assertEditBuildEnvironmentPage( INSTALLATION_BUILD_ENV );
assertLinkNotPresent( INSTALLATION_NAME );
}
@Test( dependsOnMethods = { "testEditInvalidBuildEnvironment", "testEditBuildEnvironment",
"testAddDuplicatedBuildEnvironment", "testEditInvalidBuildEnvironment" } )
public void testDeleteBuildEnvironment()
{
removeBuildEnvironment( buildEnvName );
}
@Test( dependsOnMethods = { "testAddBuildEnvironment" } )
public void testEditDuplicatedBuildEnvironmentParallelBuilds()
{
goToAddBuildEnvironment();
addBuildEnvironment( NEW_BUILD_ENV, new String[]{ }, true );
goToEditBuildEnvironment( NEW_BUILD_ENV );
editBuildEnvironment( buildEnvName, new String[]{ }, false );
assertTextPresent( "A Build Environment with the same name already exists" );
}
protected void addBuildEnvironment( String name, String[] installations, boolean success )
{
setFieldValue( "profile.name", name );
submit();
editBuildEnvironment( name, installations, success );
}
protected void editBuildEnvironment( String name, String[] installations, boolean success )
{
setFieldValue( "profile.name", name );
for ( String i : installations )
{
selectValue( "installationId", i );
clickButtonWithValue( "Add" );
}
submit();
if ( success )
{
assertBuildEnvironmentPage();
}
else
{
assertAddBuildEnvironmentPage();
}
}
@AfterClass(alwaysRun = true)
public void tearDown()
{
removeBuildEnvironment( buildEnvName, false );
removeBuildEnvironment( INSTALLATION_BUILD_ENV, false );
removeBuildEnvironment( NEW_BUILD_ENV, false );
}
}
| 5,214 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MvnProjectBuilderReleaseTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.IOException;
/**
* This tests that a project that requires variable interpolation in the pom can successfully be prepared for release.
* This was originally reported as CONTINUUM-2094.
*/
@Test( groups = { "release" } )
public class MvnProjectBuilderReleaseTest
extends AbstractReleaseTest
{
private String projectGroupName;
private String projectGroupId;
private String tagBase;
private String tag;
private String releaseVersion;
private String developmentVersion;
@BeforeClass
public void createAndBuildProject()
{
projectGroupName = getProperty( "RELEASE_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "RELEASE_PROJECT_GROUP_ID" );
String description = "Release test projects";
loginAsAdmin();
String pomUrl = getProperty( "MAVEN2_MODULES_WITH_VARS_PROJECT_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
String projectName = getProperty( "MAVEN2_MODULES_WITH_VARS_PROJECT_NAME" );
removeProjectGroup( projectGroupName, false );
addProjectGroup( projectGroupName, projectGroupId, description, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectGroup( projectGroupName, projectGroupId, "", projectName, true );
}
}
@BeforeMethod
public void setUp()
throws IOException
{
tagBase = getProperty( "RELEASE_PROJECT_TAGBASE" );
tag = getProperty( "MAVEN2_MODULES_WITH_VARS_TAG" );
releaseVersion = getProperty( "MAVEN2_MODULES_WITH_VARS_VERSION" );
developmentVersion = getProperty( "MAVEN2_MODULES_WITH_VARS_DEVELOPMENT_VERSION" );
}
public void testReleasePrepareProjectWithVersionExpression()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, "" );
assertReleasePhaseSuccess();
}
@AfterClass
public void removeProject() {
removeProjectGroup( projectGroupName, false );
}
}
| 5,215 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildResultTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test( groups = { "buildResult" } )
public class BuildResultTest
extends AbstractAdminTest
{
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String projectName;
@BeforeClass
public void createProjects()
{
projectGroupName = getProperty( "MAVEN2_BUILD_RESULT_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN2_BUILD_RESULT_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN2_BUILD_RESULT_PROJECT_GROUP_DESCRIPTION" );
projectName = getProperty( "MAVEN2_TAIL_PROJECT_NAME" );
String projectPomUrl = getProperty( "MAVEN2_TAIL_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
loginAsAdmin();
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( projectPomUrl, pomUsername, pomPassword, projectGroupName, true );
}
}
private void assertText( String locator, String pattern )
throws InterruptedException
{
for ( int second = 0; ; second++ )
{
if ( second >= Integer.parseInt( maxWaitTimeInMs ) )
Assert.fail(
String.format( "timed out waiting for %s text to match '%s'", locator, pattern ) );
try
{
if ( getSelenium().getText( locator ).matches( pattern ) )
break;
}
catch ( Exception e )
{
}
Thread.sleep( 1000 );
}
}
/**
* A rough test that verifies the ability to tail build output.
*
* @throws InterruptedException
*/
public void testTailBuildOutput()
throws InterruptedException
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickAndWait( "css=img[alt=\"Build Now\"]" );
// Wait on group page until updating icon (normally immediately after clicking build)
waitForElementPresent( "xpath=(//img[@alt='Updating'])[2]" );
clickAndWait( "link=" + projectName );
clickAndWait( "link=Builds" );
// Matches and clicks first result
clickAndWait( "css=img[alt=\"Building\"]" );
assertPage( "Continuum - Build result" );
assertElementPresent( "css=img[alt=\"Building\"]" ); // confirm build is still in progress
assertElementPresent( "id=outputArea" ); // confirm text area is in page
assertText( "id=outputArea", ".*Sleeping[.][.][.].*" ); // wait for conditions that should stream in
assertText( "id=outputArea", ".*Woke Up[.].*" );
assertText( "id=outputArea", ".*BUILD SUCCESS.*" );
waitForElementPresent( "css=img[alt=\"Success\"]" ); // Verifies page is reloaded on completion
assertElementPresent( "link=Surefire Report" ); // Check that the surefire link is present too
}
}
| 5,216 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ShellProjectTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on AddShellProjectTestCase of Emmanuel Venisse.
*
* @author José Morales Martínez
*/
@Test( groups = {"shellProject"} )
public class ShellProjectTest
extends AbstractAdminTest
{
private String projectGroupId;
private String projectGroupName;
private String projectGroupDescription;
private String scmPassword;
private String scmUsername;
private String scmUrl;
private String scmTag;
private String projectVersion;
private String projectDescription;
private String projectName;
@BeforeMethod
public void setUp()
{
projectGroupId = getProperty( "SHELL_PROJECT_GROUP_ID" );
projectGroupName = getProperty( "SHELL_PROJECT_GROUP_NAME" );
projectGroupDescription = getProperty( "SHELL_PROJECT_GROUP_DESCRIPTION" );
projectName = getProperty( "SHELL_NAME" );
projectDescription = getProperty( "SHELL_DESCRIPTION" );
projectVersion = getProperty( "SHELL_VERSION" );
scmUrl = getProperty( "SHELL_SCM_URL" );
scmUsername = getProperty( "SHELL_SCM_USERNAME" );
scmPassword = getProperty( "SHELL_SCM_PASSWORD" );
scmTag = getProperty( "SHELL_TAG" );
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
}
@AfterClass
public void cleanup()
{
removeProjectGroup( projectGroupName );
}
public void testAddShellProject()
throws Exception
{
goToAddShellProjectPage();
addProject( projectName, projectDescription, projectVersion, scmUrl, scmUsername, scmPassword, scmTag,
projectGroupName, true, "shell" );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
}
public void testAddShellProjectWithInvalidValues()
throws Exception
{
String projectName = "!@#$<>?etc";
String description = "![]<>'^&etc";
String version = "<>whitespaces!#etc";
String tag = "!<>*%etc";
String scmUrl = "!<>*%etc";
goToAddShellProjectPage();
addProject( projectName, description, version, scmUrl, scmUsername, scmPassword, tag, projectGroupName, false,
"shell" );
assertTextPresent( "Name contains invalid characters." );
assertTextPresent( "Version contains invalid characters." );
assertTextPresent( "SCM Url contains invalid characters." );
assertTextPresent( "SCM Tag contains invalid characters." );
}
public void testSubmitEmptyForm()
{
goToAddShellProjectPage();
submit();
assertAddProjectPage( "shell" );
assertTextPresent( "Name is required and cannot contain null or spaces only" );
assertTextPresent( "Version is required and cannot contain null or spaces only" );
assertTextPresent( "SCM Url is required and cannot contain null or spaces only" );
}
@Test( dependsOnMethods = {"testAddShellProject"} )
public void testAddDuplicateShellProject()
throws Exception
{
goToAddShellProjectPage();
addProject( projectName, projectDescription, projectVersion, scmUrl, scmUsername, scmPassword, scmTag, null,
false, "shell" );
assertTextPresent( "Project name already exist" );
}
}
| 5,217 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LocalRepositoriesTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractLocalRepositoryTest;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = {"repository"} )
public class LocalRepositoriesTest
extends AbstractLocalRepositoryTest
{
public void testAddLocalRepository()
{
String LOCAL_REPOSITORY_NAME = getProperty( "LOCAL_REPOSITORY_NAME" );
String LOCAL_REPOSITORY_LOCATION = getProperty( "LOCAL_REPOSITORY_LOCATION" );
goToAddLocalRepository();
addEditLocalRepository( LOCAL_REPOSITORY_NAME, LOCAL_REPOSITORY_LOCATION, true );
}
public void testAddInvalidLocalRepository()
{
goToAddLocalRepository();
addEditLocalRepository( "", "", false );
assertTextPresent( "You must define a name." );
assertTextPresent( "You must define a local repository directory." );
}
public void testAddLocalRepositoryWithXSS()
{
String invalidName = "Repo <script>alert('gotcha')</script> name";
String invalidLocation = "/Users/continuum/<script>alert('gotcha')</script>/dir";
goToAddLocalRepository();
addEditLocalRepository( invalidName, invalidLocation, false );
assertTextPresent( "Local repository name contains invalid characters." );
assertTextPresent( "Local repository location contains invalid characters." );
}
@Test( dependsOnMethods = {"testAddLocalRepository"} )
public void testAddDuplicatedLocalRepository()
{
String LOCAL_REPOSITORY_NAME = getProperty( "LOCAL_REPOSITORY_NAME" );
String LOCAL_REPOSITORY_LOCATION = getProperty( "LOCAL_REPOSITORY_LOCATION" );
goToAddLocalRepository();
addEditLocalRepository( LOCAL_REPOSITORY_NAME, LOCAL_REPOSITORY_LOCATION, false );
assertTextPresent( "Local repository name must be unique" );
assertTextPresent( "Local repository location must be unique" );
}
@Test( dependsOnMethods = {"testAddDuplicatedLocalRepository"} )
public void testAddDuplicateLocalRepositoryWithTrailingWhitespaces()
{
String duplicateRepositoryName = addTrailingWhitespace( getProperty( "LOCAL_REPOSITORY_NAME" ) );
String duplicateRepositoryLocation = addTrailingWhitespace( getProperty( "LOCAL_REPOSITORY_LOCATION" ) );
goToAddLocalRepository();
addEditLocalRepository( duplicateRepositoryName, duplicateRepositoryLocation, false );
assertTextPresent( "Local repository name must be unique" );
assertTextPresent( "Local repository location must be unique" );
}
@Test( dependsOnMethods = {"testAddDuplicateLocalRepositoryWithTrailingWhitespaces"} )
public void testEditLocalRepository()
{
String LOCAL_REPOSITORY_NAME = getProperty( "LOCAL_REPOSITORY_NAME" );
String LOCAL_REPOSITORY_LOCATION = getProperty( "LOCAL_REPOSITORY_LOCATION" );
String newName = "new_name";
String newLocation = "new_location";
goToEditLocalRepository( LOCAL_REPOSITORY_NAME, LOCAL_REPOSITORY_LOCATION );
addEditLocalRepository( newName, newLocation, true );
goToEditLocalRepository( newName, newLocation );
addEditLocalRepository( LOCAL_REPOSITORY_NAME, LOCAL_REPOSITORY_LOCATION, true );
}
@Test( dependsOnMethods = {"testEditLocalRepository"} )
public void testDeleteLocalRepository()
{
String LOCAL_REPOSITORY_NAME = getProperty( "LOCAL_REPOSITORY_NAME" );
removeLocalRepository( LOCAL_REPOSITORY_NAME );
}
private String addTrailingWhitespace( String str )
{
String WHITESPACE = " ";
return WHITESPACE.concat( str.concat( WHITESPACE ) );
}
}
| 5,218 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import java.util.Arrays;
public abstract class AbstractReleaseTest
extends AbstractAdminTest
{
protected static final String RELEASE_BUTTON_TEXT = "Release";
protected static final String PROVIDE_RELEASE_PARAMETERS_TEXT = "Provide Release Parameters";
protected void releasePrepareProject( String username, String password, String tagBase, String tag,
String releaseVersion, String developmentVersion, String buildEnv )
{
goToReleasePreparePage();
setFieldValue( "scmUsername", username );
setFieldValue( "scmPassword", password );
setFieldValue( "scmTag", tag );
setFieldValue( "scmTagBase", tagBase );
setFieldValue( "prepareGoals", "clean" );
selectValue( "profileId", buildEnv );
setFieldValue( "relVersions", releaseVersion );
setFieldValue( "devVersions", developmentVersion );
submit();
waitForRelease();
}
protected void releasePerformProjectWithProvideParameters( String username, String password, String tagBase,
String tag, String scmUrl, String buildEnv )
{
goToReleasePerformProvideParametersPage();
setFieldValue( "scmUrl", scmUrl );
setFieldValue( "scmUsername", username );
setFieldValue( "scmPassword", password );
setFieldValue( "scmTag", tag );
setFieldValue( "scmTagBase", tagBase );
setFieldValue( "goals", "clean deploy" );
selectValue( "profileId", buildEnv );
submit();
waitForRelease();
assertReleasePhaseError();
}
private void goToReleasePreparePage()
{
clickLinkWithLocator( "goal", false );
submit();
assertReleasePreparePage();
}
private void goToReleasePerformProvideParametersPage()
{
selectValue( "preparedReleaseId", PROVIDE_RELEASE_PARAMETERS_TEXT );
selectPerformAndSubmit();
assertReleasePerformProvideParametersPage();
}
protected void selectPerformAndSubmit()
{
clickLinkWithLocator( "//input[@name='goal' and @value='perform']", false );
submit();
}
void assertReleasePreparePage()
{
assertPage( "Continuum - Release Project" );
assertTextPresent( "Prepare Project for Release" );
assertTextPresent( "SCM Username" );
assertTextPresent( "SCM Password" );
assertTextPresent( "SCM Tag" );
assertTextPresent( "SCM Tag Base" );
assertTextPresent( "SCM Comment Prefix" );
assertTextPresent( "Preparation Goals" );
assertTextPresent( "Arguments" );
assertTextPresent( "Build Environment" );
assertTextPresent( "Release Version" );
assertTextPresent( "Next Development Version" );
assertButtonWithValuePresent( "Submit" );
}
void assertReleasePerformProvideParametersPage()
{
assertPage( "Continuum - Perform Project Release" );
assertTextPresent( "Perform Project Release" );
assertTextPresent( "SCM Connection URL" );
assertTextPresent( "SCM Username" );
assertTextPresent( "SCM Password" );
assertTextPresent( "SCM Tag" );
assertTextPresent( "SCM Tag Base" );
assertTextPresent( "Perform Goals" );
assertTextPresent( "Arguments" );
assertTextPresent( "Build Environment" );
assertButtonWithValuePresent( "Submit" );
}
void assertReleaseError()
{
assertTextPresent( "Release Error" );
}
protected void assertReleasePhaseError()
{
assertButtonWithValuePresent( "Rollback changes" );
assertImgWithAlt( "Error" );
}
protected void assertReleasePhaseSuccess()
{
assertButtonWithValuePresent( "Rollback changes" );
assertElementNotPresent( "//img[@alt='Error']" );
}
protected void waitForRelease()
{
String doneButtonLocator = "//input[@id='releaseCleanup_0']";
String errorTextLocator = "//h3[text()='Release Error']";
// condition for release is complete; "Done" button or "Release Error" in page is present
waitForOneOfElementsPresent( Arrays.asList( doneButtonLocator, errorTextLocator ), true );
}
}
| 5,219 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/CSRFSecurityTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.Test;
/**
* Test actions that are vulnerable to CSRF.
*/
@Test( groups = {"csrf"} )
public class CSRFSecurityTest
extends AbstractAdminTest
{
public void testCSRFDeleteProject()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/deleteProject_default.action?projectGroupId=2&projectId=2" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveProjectBuildDefinition()
{
getSelenium().open( baseUrl );
getSelenium().open(
baseUrl + "/removeProjectBuildDefinition.action?projectId=1&buildDefinitionId=9&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveGroupBuildDefinition()
{
getSelenium().open( baseUrl );
getSelenium().open(
baseUrl + "/removeGroupBuildDefinition.action?projectGroupId=2&buildDefinitionId=8&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveProjectGroup()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/removeProjectGroup.action?projectGroupId=2" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveBuildResult()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/removeBuildResult.action?projectId=1&buildId=1&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveSchedule()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/removeSchedule.action?id=1&name=DEFAULT_SCHEDULE" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveReleaseResults()
{
getSelenium().open( baseUrl );
getSelenium().open(
baseUrl + "/removeReleaseResults.action?projectGroupId=2&selectedReleaseResults=1&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFSaveFooter()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/admin/saveFooter.action?footer=testValue" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFSaveCompanyPOM()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/admin/saveCompanyPom.action" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteBuildEnvironment()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/deleteBuildEnv.action?profile.id=1" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteBuildDefinitionTemplate()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl +
"/deleteDefinitionTemplate.action?buildDefinitionTemplate.id=5&buildDefinitionTemplate.name=Test+Template" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteBuildQueue()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/deleteBuildQueue.action?buildQueue.id=3&buildQueue.name=TEST_BUILD_QUEUE" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemoveLocalRepository()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/removeRepository.action?repository.id=2" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFRemovePurgeConfiguration()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl + "/removePurgeConfig.action?purgeConfigId=2&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteBuildAgent()
{
getSelenium().open( baseUrl );
getSelenium().open( baseUrl +
"/security/deleteBuildAgent.action?buildAgent.url=http%3A%2F%2Flocalhost%3A8181%2Fcontinuum-buildagent%2Fxmlrpc&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteBuildAgentGroup()
{
getSelenium().open( baseUrl );
getSelenium().open(
baseUrl + "/security/deleteBuildAgentGroup.action?buildAgentGroup.name=Test+Agent+Group&confirmed=true" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
public void testCSRFDeleteProjectGroupNotifier()
{
getSelenium().open( baseUrl );
getSelenium().open(
baseUrl + "/deleteProjectGroupNotifier.action?projectGroupId=2¬ifierId=1¬ifierType=mail" );
assertTextPresent( "Security Alert - Invalid Token Found" );
assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
}
}
| 5,220 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/IvyJUnitProjectTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test( groups = { "antProject" } )
public class IvyJUnitProjectTest
extends AbstractAdminTest
{
private String projectName;
private String projectDescription;
private String projectVersion;
private String projectTag;
private String scmUrl;
private String scmUsername;
private String scmPassword;
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
@BeforeMethod
protected void setUp()
throws Exception
{
projectName = getProperty( "IVYJU_NAME" );
projectDescription = getProperty( "IVYJU_DESCRIPTION" );
projectVersion = getProperty( "IVYJU_VERSION" );
projectTag = getProperty( "IVYJU_TAG" );
scmUrl = getProperty( "IVYJU_SCM_URL" );
scmUsername = getProperty( "IVYJU_SCM_USERNAME" );
scmPassword = getProperty( "IVYJU_SCM_PASSWORD" );
projectGroupName = getProperty( "ANT_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "ANT_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "ANT_PROJECT_GROUP_DESCRIPTION" );
// create project group, if it doesn't exist
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
}
@AfterMethod
public void tearDown()
throws Throwable
{
removeProjectGroup( projectGroupName, false );
}
public void testJUnitReportsArchived()
throws Exception
{
goToAddAntProjectPage();
addProject( projectName, projectDescription, projectVersion, scmUrl, scmUsername, scmPassword, projectTag,
projectGroupName, true, "ant" );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
clickAndWait( "css=img[alt=\"Build Now\"]" );
clickAndWait( "link=" + projectName );
clickAndWait( "link=Builds" );
clickAndWait( "css=img[alt=\"Building\"]" );
waitForElementPresent( "css=img[alt=\"Failed\"]" );
clickAndWait( "link=Surefire Report" );
assertCellValueFromTable( "2", "id=ec_table", 1, 0 );
assertCellValueFromTable( "1", "id=ec_table", 1, 2 );
assertCellValueFromTable( "50.0", "id=ec_table", 1, 3 );
}
}
| 5,221 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractContinuumTest;
import org.testng.annotations.Test;
/*
* Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
* http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
* Waiting 5.9 release. It's comming soon.
*/
/**
* Based on LoginTest of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
@Test( groups = {"login"} )
public class LoginTest
extends AbstractContinuumTest
{
public void testWithBadUsername()
{
goToLoginPage();
getSelenium().type( "loginForm_username", "badUsername" );
getSelenium().type( "loginForm_username", getProperty( "ADMIN_PASSWORD" ) );
getSelenium().click( "//input[@value='Login']" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
assertTextPresent( "You have entered an incorrect username and/or password" );
}
public void testWithBadPassword()
{
login( getProperty( "ADMIN_USERNAME" ), "badPassword" );
assertTextPresent( "You have entered an incorrect username and/or password" );
}
public void testWithEmptyUsername()
{
goToLoginPage();
getSelenium().type( "loginForm_password", "password" );
getSelenium().click( "//input[@value='Login']" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
assertTextPresent( "User Name is required" );
}
public void testWithEmptyPassword()
{
goToLoginPage();
getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
getSelenium().click( "//input[@value='Login']" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
assertTextPresent( "You have entered an incorrect username and/or password" );
}
public void testWithCorrectUsernamePassword()
{
String username = getProperty( "ADMIN_USERNAME" );
String password = getProperty( "ADMIN_PASSWORD" );
login( username, password );
assertTextPresent( "Edit Details" );
assertTextPresent( "Logout" );
assertTextPresent( username );
}
}
| 5,222 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReportTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test( groups = { "report" } )
public class ReportTest
extends AbstractAdminTest
{
private String projectGroupName;
private String failedProjectGroupName;
@BeforeClass
public void createProject()
{
projectGroupName = getProperty( "REPORT_PROJECT_GROUP_NAME" );
String projectGroupId = getProperty( "REPORT_PROJECT_GROUP_ID" );
String projectGroupDescription = getProperty( "REPORT_PROJECT_GROUP_DESCRIPTION" );
String projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
String projectPomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
loginAsAdmin();
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( projectPomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
}
}
@BeforeMethod
protected void setUp()
throws Exception
{
failedProjectGroupName = getProperty( "MAVEN2_FAILING_PROJECT_POM_PROJECT_GROUP_NAME" );
}
@AfterMethod
public void tearDown()
{
removeProjectGroup( failedProjectGroupName, false );
}
public void testViewBuildsReportWithSuccessfulBuild()
throws Exception
{
goToProjectBuildsReport();
selectValue( "buildStatus", "Ok" );
clickButtonWithValue( "View Report" );
assertProjectBuildReportWithResult();
assertTextPresent( projectGroupName );
assertImgWithAlt( "Success" );
}
public void testBuildsReportWithInvalidDates()
{
goToProjectBuildsReport();
setFieldValue( "startDate", "05/25/2010" );
setFieldValue( "endDate", "05/24/2010" );
clickButtonWithValue( "View Report" );
assertProjectBuildReportWithFieldError();
assertTextPresent( "Invalid date range: start date must be earlier than the end date." );
}
public void testViewBuildsReportWithFailedBuild()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_FAILING_PROJECT_POM_URL" );
String pomUsername = "";
String pomPassword = "";
String failedProjectGroupId = getProperty( "MAVEN2_FAILING_PROJECT_POM_PROJECT_GROUP_ID" );
String failedProjectGroupDescription = getProperty( "MAVEN2_FAILING_PROJECT_POM_PROJECT_GROUP_DESCRIPTION" );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( failedProjectGroupName, failedProjectGroupId, failedProjectGroupDescription );
buildProjectGroup( failedProjectGroupName, failedProjectGroupId, failedProjectGroupDescription,
failedProjectGroupName, false );
goToProjectBuildsReport();
selectValue( "buildStatus", "Failed" );
clickButtonWithValue( "View Report" );
assertProjectBuildReportWithResult();
assertImgWithAlt( "Failed" );
assertTextPresent( failedProjectGroupName );
}
public void testViewBuildsReportWithErrorBuild()
{
goToProjectBuildsReport();
selectValue( "buildStatus", "Error" );
clickButtonWithValue( "View Report" );
assertProjectBuildReportWithNoResult();
}
}
| 5,223 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on ProjectGroupTest of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
@Test( groups = {"projectGroup"} )
public class ProjectGroupTest
extends AbstractAdminTest
{
public static final String TEST_PROJECT_NAME = "ContinuumBuildQueueTestData";
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
@BeforeMethod
protected void setUp()
throws Exception
{
projectGroupName = getProperty( "TEST_PROJ_GRP_NAME" );
projectGroupId = getProperty( "TEST_PROJ_GRP_ID" );
projectGroupDescription = getProperty( "TEST_PROJ_GRP_DESCRIPTION" );
}
@AfterClass
public void tearDown()
{
removeProjectGroup( projectGroupName, false );
}
public void testAddProjectGroup()
throws Exception
{
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true );
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
}
public void testAddProjectGroupWithInvalidValues()
throws Exception
{
String name = "!@#$<>?etch";
String groupId = "-!@#<>etc";
String description = "![]<>'^&etc";
addProjectGroup( name, groupId, description, false );
assertTextPresent( "Name contains invalid characters." );
assertTextPresent( "Id contains invalid characters." );
}
public void testAddProjectGroupWithDashedGroupId()
throws Exception
{
String name = "Test Project Group with Dashes";
String groupId = "com.example.this-is-a-long-group-id";
String description = "";
try {
addProjectGroup( name, groupId, description, true );
} finally {
removeProjectGroup( name, false );
}
}
public void testAddProjectGroupWithPunctuation()
throws Exception
{
String name = "Test :: Test Project Group (with Punctuation)";
String groupId = "com.example.test";
String description = "";
try {
addProjectGroup( name, groupId, description, true );
} finally {
removeProjectGroup( name, false );
}
}
public void testAddProjectGroupWithEmptyString()
throws Exception
{
addProjectGroup( "", "", "", false );
assertTextPresent( "Project Group Name is required" );
assertTextPresent( "Project Group ID is required" );
}
public void testAddProjectGroupWithWhitespaceString()
throws Exception
{
addProjectGroup( " ", " ", " ", false );
assertTextPresent( "Project Group Name is required" );
assertTextPresent( "Project Group ID is required" );
}
@Test( dependsOnMethods = {"testAddProjectGroup"} )
public void testEditProjectGroupWithValidValues()
throws Exception
{
final String newName = "Test :: New Project Group Name (with valid values)";
final String newDescription = "New Project Group Description";
editProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, newName, newDescription );
assertProjectGroupSummaryPage( newName, projectGroupId, newDescription );
editProjectGroup( newName, projectGroupId, newDescription, projectGroupName, projectGroupDescription );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
}
@Test( dependsOnMethods = {"testAddProjectGroup"} )
public void testEditProjectGroupWithInvalidValues()
throws Exception
{
editProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, " ", projectGroupDescription );
assertTextPresent( "Project Group Name is required" );
}
@Test( dependsOnMethods = {"testAddProjectGroup"} )
public void testEditProjectGroupWithXSS()
throws Exception
{
String newName = "<script>alert('XSS')</script>";
String newDescription = "<script>alert('XSS')</script>";
editProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, newName, newDescription );
assertTextPresent( "Name contains invalid characters." );
}
public void testDeleteProjectGroup()
throws Exception
{
String name = getProperty( "TEST_DELETE_GRP_NAME" );
String groupId = getProperty( "TEST_DELETE_GRP_ID" );
String description = getProperty( "TEST_DELETE_GRP_DESCRIPTION" );
// delete group - delete icon
addProjectGroup( name, groupId, description, true );
assertLinkPresent( name );
clickLinkWithXPath( "//tbody/tr['0']/td['4']/a/img[@alt='Delete Group']" );
assertTextPresent( "Project Group Removal" );
clickButtonWithValue( "Delete" );
assertProjectGroupsSummaryPage();
assertLinkNotPresent( name );
// delete group - "Delete Group" button
addProjectGroup( name, groupId, description, true );
assertLinkPresent( name );
removeProjectGroup( name );
assertLinkNotPresent( name );
assertProjectGroupsSummaryPage();
assertLinkNotPresent( name );
}
public void testProjectGroupMembers()
throws Exception
{
String name1 = getProperty( "TEST_PROJ_GRP_NAME_ONE" );
String groupId1 = getProperty( "TEST_PROJ_GRP_ID_ONE" );
String description1 = getProperty( "TEST_PROJ_GRP_DESCRIPTION_ONE" );
String name2 = getProperty( "TEST_PROJ_GRP_NAME_TWO" );
String groupId2 = getProperty( "TEST_PROJ_GRP_ID_TWO" );
String description2 = getProperty( "TEST_PROJ_GRP_DESCRIPTION_TWO" );
String name3 = getProperty( "TEST_PROJ_GRP_NAME_THREE" );
String groupId3 = getProperty( "TEST_PROJ_GRP_ID_THREE" );
String description3 = getProperty( "TEST_PROJ_GRP_DESCRIPTION_THREE" );
addProjectGroup( name1, groupId1, description1, true, false );
assertLinkPresent( name1 );
addProjectGroup( name2, groupId2, description2, true, false );
assertLinkPresent( name2 );
addProjectGroup( name3, groupId3, description3, true, false );
assertLinkPresent( name3 );
createAndAddUserAsDeveloperToGroup( "username1", "user1", "user1@something.com", name1 );
createAndAddUserAsDeveloperToGroup( "username2", "user2", "user2@something.com", name1 );
createAndAddUserAsDeveloperToGroup( "username3", "user3", "user3@something.com", name2 );
createAndAddUserAsDeveloperToGroup( "username4", "user4", "user4@something.com", name3 );
showMembers( name1, groupId1, description1 );
assertUserPresent( "username1", "user1", "user1@something.com" );
assertUserPresent( "username2", "user2", "user2@something.com" );
assertUserNotPresent( "username3", "user3", "user3@something.com" );
assertUserNotPresent( "username4", "user4", "user4@something.com" );
showMembers( name2, groupId2, description2 );
assertUserNotPresent( "username1", "user1", "user1@something.com" );
assertUserNotPresent( "username2", "user2", "user2@something.com" );
assertUserPresent( "username3", "user3", "user3@something.com" );
assertUserNotPresent( "username4", "user4", "user4@something.com" );
showMembers( name3, groupId3, description3 );
assertUserNotPresent( "username1", "user1", "user1@something.com" );
assertUserNotPresent( "username2", "user2", "user2@something.com" );
assertUserNotPresent( "username3", "user3", "user3@something.com" );
assertUserPresent( "username4", "user4", "user4@something.com" );
removeProjectGroup( name1 );
assertLinkNotPresent( name1 );
removeProjectGroup( name2 );
assertLinkNotPresent( name2 );
removeProjectGroup( name3 );
assertLinkNotPresent( name3 );
}
public void testRemoveProjectFromMembers()
{
goToProjectGroupsSummaryPage();
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
if ( !isLinkPresent( TEST_PROJECT_NAME ) )
{
clickButtonWithValue( "Add" );
assertAddMavenTwoProjectPage();
setFieldValue( "m2PomUrl", getProperty( "M2_POM_URL" ) );
clickButtonWithValue( "Add" );
waitAddProject( "Continuum - Project Group" );
assertTextPresent( TEST_PROJECT_NAME );
waitForProjectCheckout();
}
clickLinkWithText( "Members" );
assertTextPresent( TEST_PROJECT_NAME );
clickImgWithAlt( "Delete" );
assertTextPresent( "Delete Continuum Project" );
clickButtonWithValue( "Delete" );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
assertTextNotPresent( TEST_PROJECT_NAME );
}
}
| 5,224 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AntProjectTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on AddAntProjectTestCase of Emmanuel Venisse.
*
* @author José Morales Martínez
*/
@Test( groups = {"antProject"} )
public class AntProjectTest
extends AbstractAdminTest
{
private String projectName;
private String projectDescription;
private String projectVersion;
private String projectTag;
private String scmUrl;
private String scmUsername;
private String scmPassword;
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
@BeforeMethod
protected void setUp()
throws Exception
{
projectName = getProperty( "ANT_NAME" );
projectDescription = getProperty( "ANT_DESCRIPTION" );
projectVersion = getProperty( "ANT_VERSION" );
projectTag = getProperty( "ANT_TAG" );
scmUrl = getProperty( "ANT_SCM_URL" );
scmUsername = getProperty( "ANT_SCM_USERNAME" );
scmPassword = getProperty( "ANT_SCM_PASSWORD" );
projectGroupName = getProperty( "ANT_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "ANT_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "ANT_PROJECT_GROUP_DESCRIPTION" );
// create project group, if it doesn't exist
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
}
@AfterMethod
public void tearDown()
throws Throwable
{
removeProjectGroup( projectGroupName, false );
}
public void testAddAntProject()
throws Exception
{
goToAddAntProjectPage();
addProject( projectName, projectDescription, projectVersion, scmUrl, scmUsername, scmPassword, projectTag,
projectGroupName, true, "ant" );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
}
public void testAddAntProjectWithInvalidValues()
throws Exception
{
String name = "!@#$<>?etc";
String description = "![]<>'^&etc";
String version = "<>whitespaces!#etc";
String tag = "!<>*%etc";
String scmUrl = "!<>*%etc";
goToAddAntProjectPage();
addProject( name, description, version, scmUrl, scmUsername, scmPassword, tag, projectGroupName, false, "ant" );
assertTextPresent( "Name contains invalid characters." );
assertTextPresent( "Version contains invalid characters." );
assertTextPresent( "SCM Url contains invalid characters." );
assertTextPresent( "SCM Tag contains invalid characters." );
}
public void testSubmitEmptyForm()
{
goToAddAntProjectPage();
submit();
assertAddProjectPage( "ant" );
assertTextPresent( "Name is required and cannot contain null or spaces only" );
assertTextPresent( "Version is required and cannot contain null or spaces only" );
assertTextPresent( "SCM Url is required and cannot contain null or spaces only" );
}
public void testAddDuplicateAntProject()
throws Exception
{
testAddAntProject();
goToAddAntProjectPage();
addProject( projectName, projectDescription, projectVersion, scmUrl, scmUsername, scmPassword, projectTag, null,
false, "ant" );
assertTextPresent( "Project name already exist" );
}
}
| 5,225 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildResultsTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test( groups = { "buildResults" } )
public class BuildResultsTest
extends AbstractAdminTest
{
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String projectName;
@BeforeClass
public void createProject()
{
projectGroupName = getProperty( "BUILD_RESULTS_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "BUILD_RESULTS_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "BUILD_RESULTS_PROJECT_GROUP_DESCRIPTION" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
String projectPomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
loginAsAdmin();
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( projectPomUrl, pomUsername, pomPassword, projectGroupName, true );
}
}
public void testDeleteBuildResult()
{
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
// go to build results page
clickAndWait( "css=img[title='Build History']" );
assertPage( "Continuum - Build results" );
assertElementPresent( "css=tbody.tableBody tr" );
assertElementPresent( "selectedBuildResults_selector" );
getSelenium().click( "selectedBuildResults_selector" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Delete Build Results" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Build results" );
assertElementNotPresent( "css=tbody.tableBody tr" );
}
}
| 5,226 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MultiModuleUploadTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import static org.testng.Assert.assertTrue;
/**
* This tests functionality relating to file upload for multi-module maven2+ projects.
*/
@Test( groups = { "upload" } )
public class MultiModuleUploadTest
extends AbstractAdminTest
{
public static final String BAD_IMPORT_TYPE_MSG = "requires single multi-module project import type";
private String projectGroupName;
private String projectName;
private String projectGroupId;
private File projectPom;
@BeforeClass( alwaysRun = true )
@Parameters( { "sampleProjectsDir" } )
public void initialize( @Optional( "src/test/example-projects" ) String projectsDir )
{
File dir = new File( projectsDir );
assertTrue( dir.exists() && dir.isDirectory() );
projectPom = new File( dir, getProperty( "MAVEN2_MODULES_WITH_VARS_PROJECT_RELPATH" ) );
assertTrue( projectPom.exists() && projectPom.isFile() && projectPom.canRead() );
projectGroupName = getProperty( "UPLOAD_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "UPLOAD_PROJECT_GROUP_ID" );
projectName = getProperty( "MAVEN2_MODULES_WITH_VARS_PROJECT_NAME" );
loginAsAdmin();
}
@BeforeMethod
public void setUp()
throws IOException
{
addProjectGroup( projectGroupName, projectGroupId, "Upload test projects", true, false );
}
@AfterMethod
public void tearDown()
{
removeProjectGroup( projectGroupName, false );
}
public void testMultiModuleUpload()
throws Exception
{
clickLinkWithText( projectGroupName );
assertLinkNotPresent( projectName );
uploadMavenTwoProject( projectPom, projectGroupName, "SINGLE_MULTI_MODULE", true );
buildProjectGroup( projectGroupName, projectGroupId, "", projectName, true );
}
public void testMultiModuleUploadFailsWithSeparateScm()
throws Exception
{
clickLinkWithText( projectGroupName );
assertLinkNotPresent( projectName );
uploadMavenTwoProject( projectPom, projectGroupName, "SEPARATE_SCM", false );
assertTextPresent( BAD_IMPORT_TYPE_MSG );
}
public void testMultiModuleUploadFailsWithSingleScm()
throws Exception
{
clickLinkWithText( projectGroupName );
assertLinkNotPresent( projectName );
uploadMavenTwoProject( projectPom, projectGroupName, "SINGLE_SCM", false );
assertTextPresent( BAD_IMPORT_TYPE_MSG );
}
}
| 5,227 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ConfigurationTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = { "configuration" } )
public class ConfigurationTest
extends AbstractAdminTest
{
private String WORKING_DIRECTORY;
private String BASE_URL;
private String BUILD_OUTPUT_DIRECTORY;
private String RELEASE_OUTPUT_DIRECTORY;
private String DEPLOYMENT_REPOSITORY_DIRECTORY;
private String NUMBER_ALLOWED_PARALLEL;
public void defaultConfiguration()
{
goToConfigurationPage();
WORKING_DIRECTORY = getFieldValue( "workingDirectory" );
BASE_URL = getFieldValue( "baseUrl" );
BUILD_OUTPUT_DIRECTORY = getFieldValue( "buildOutputDirectory" );
RELEASE_OUTPUT_DIRECTORY = getFieldValue( "releaseOutputDirectory" );
DEPLOYMENT_REPOSITORY_DIRECTORY = getFieldValue( "deploymentRepositoryDirectory" );
NUMBER_ALLOWED_PARALLEL = getFieldValue( "numberOfAllowedBuildsinParallel" );
}
@Test( dependsOnMethods = { "defaultConfiguration" } )
public void editConfiguration()
{
String newWorking = "newWorking";
String newUrl = "http://localhost:8181";
String newBuildOutput = "newBuildOutput";
String newReleaseOutput = "newReleaseOutput";
String newDeployRepository = "newDeployRepository";
String newNumberParallel = "9";
goToConfigurationPage();
submitConfiguration( newWorking, newBuildOutput, newReleaseOutput, newDeployRepository, newUrl,
newNumberParallel, true, true );
clickButtonWithValue( "Edit" );
submitConfiguration( WORKING_DIRECTORY, BUILD_OUTPUT_DIRECTORY, RELEASE_OUTPUT_DIRECTORY,
DEPLOYMENT_REPOSITORY_DIRECTORY, BASE_URL, NUMBER_ALLOWED_PARALLEL, false, true );
}
public void setInvalidConfiguration()
{
goToConfigurationPage();
submitConfiguration( "", "", "", "", "", "", true, false );
assertTextPresent( "You must define a working directory" );
assertTextPresent( "You must define a build output directory" );
assertTextPresent( "You must define a URL" );
}
public void setZeroParallelBuilds()
{
setMaxBuildQueue( 0 );
assertTextPresent( "Number of Allowed Builds in Parallel must be greater than zero" );
}
public void testSetConfigurationWithXSS()
{
String invalidString = "<script>alert('gotcha')</script>";
goToConfigurationPage();
submitConfiguration( invalidString, invalidString, invalidString, invalidString, invalidString, invalidString,
true, false );
assertTextPresent( "Working directory contains invalid characters." );
assertTextPresent( "Build output directory contains invalid characters." );
assertTextPresent( "Release output directory contains invalid characters." );
assertTextPresent( "Deployment repository directory contains invalid characters." );
assertTextPresent( "You must define a valid URL." );
}
public void testSetFooterXSS()
{
goToAppearancePage();
setFieldValue( "saveFooter_footer",
"Copyright <SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=\"javascript:alert('XSS');\"> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=JaVaScRiPt:alert('XSS')> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=javascript:alert("XSS")> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
// unicode
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=javascript:alert('XSS')> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
// utf-8
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=javascript:alert('XSS')> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
// hex encoding
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=javascript:alert('XSS')> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=\"jav ascript:alert('XSS');\"> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <IMG SRC=\"jav	ascript:alert('XSS');\"> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
setFieldValue( "saveFooter_footer",
"Copyright <STYLE>@import'http://ha.ckers.org/xss.css';</STYLE> 2005-2011 The Apache Software Foundation" );
submit();
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "Copyright 2005-2011 The Apache Software Foundation" );
}
void assertEditedConfigurationPage( String working, String buildOutput, String releaseOutput,
String deploymentRepository, String baseUrl, String numberBuildParallel )
{
assertPage( "Continuum - Configuration" );
assertTextPresent( "General Configuration " );
assertTextPresent( "Working Directory" );
assertElementNotPresent( "workingDirectory" );
assertTextPresent( working );
assertTextPresent( "Build Output Directory" );
assertElementNotPresent( "buildOutputDirectory" );
assertTextPresent( buildOutput );
assertTextPresent( "Release Output Directory" );
assertElementNotPresent( "releaseOutputDirectory" );
assertTextPresent( releaseOutput );
assertTextPresent( "Deployment Repository Directory" );
assertElementNotPresent( "deploymentRepositoryDirectory" );
assertTextPresent( deploymentRepository );
assertTextPresent( "Base URL" );
assertElementNotPresent( "baseUrl" );
assertTextPresent( baseUrl );
assertTextPresent( "Number of Allowed Builds in Parallel" );
assertElementNotPresent( "numberOfAllowedBuildsinParallel" );
assertTextPresent( numberBuildParallel );
assertTextPresent( "Enable Distributed Builds" );
assertElementNotPresent( "distributedBuildEnabled" );
assertButtonWithValuePresent( "Edit" );
}
protected void submitConfiguration( String working, String buildOutput, String releaseOutput,
String deploymentRepository, String baseUrl, String numberBuildParallel,
boolean distributed, boolean success )
{
setFieldValue( "workingDirectory", working );
setFieldValue( "buildOutputDirectory", buildOutput );
setFieldValue( "releaseOutputDirectory", releaseOutput );
setFieldValue( "deploymentRepositoryDirectory", deploymentRepository );
setFieldValue( "baseUrl", baseUrl );
setFieldValue( "numberOfAllowedBuildsinParallel", numberBuildParallel );
setFieldValue( "sharedSecretPassword", SHARED_SECRET );
if ( distributed )
{
checkField( "distributedBuildEnabled" );
}
else
{
uncheckField( "distributedBuildEnabled" );
}
submit();
if ( success )
{
assertEditedConfigurationPage( working, buildOutput, releaseOutput, deploymentRepository, baseUrl,
numberBuildParallel );
}
else
{
assertEditConfigurationPage();
}
}
}
| 5,228 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ScheduleTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = { "schedule" } )
public class ScheduleTest
extends AbstractAdminTest
{
public void testAddScheduleNoBuildQueueToBeUsed()
{
String SCHEDULE_NAME = getProperty( "SCHEDULE_NAME" );
String SCHEDULE_DESCRIPTION = getProperty( "SCHEDULE_DESCRIPTION" );
String SCHEDULE_EXPR_SECOND = getProperty( "SCHEDULE_EXPR_SECOND" );
String SCHEDULE_EXPR_MINUTE = getProperty( "SCHEDULE_EXPR_MINUTE" );
String SCHEDULE_EXPR_HOUR = getProperty( "SCHEDULE_EXPR_HOUR" );
String SCHEDULE_EXPR_DAY_MONTH = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String SCHEDULE_EXPR_MONTH = getProperty( "SCHEDULE_EXPR_MONTH" );
String SCHEDULE_EXPR_DAY_WEEK = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String SCHEDULE_EXPR_YEAR = getProperty( "SCHEDULE_EXPR_YEAR" );
String SCHEDULE_MAX_TIME = getProperty( "SCHEDULE_MAX_TIME" );
String SCHEDULE_PERIOD = getProperty( "SCHEDULE_PERIOD" );
goToAddSchedule();
addEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD, false, false );
assertTextPresent( "Used Build Queues cannot be empty" );
}
@Test( dependsOnMethods = { "testAddScheduleNoBuildQueueToBeUsed" } )
public void testAddSchedule()
{
String SCHEDULE_NAME = getProperty( "SCHEDULE_NAME" );
String SCHEDULE_DESCRIPTION = getProperty( "SCHEDULE_DESCRIPTION" );
String SCHEDULE_EXPR_SECOND = getProperty( "SCHEDULE_EXPR_SECOND" );
String SCHEDULE_EXPR_MINUTE = getProperty( "SCHEDULE_EXPR_MINUTE" );
String SCHEDULE_EXPR_HOUR = getProperty( "SCHEDULE_EXPR_HOUR" );
String SCHEDULE_EXPR_DAY_MONTH = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String SCHEDULE_EXPR_MONTH = getProperty( "SCHEDULE_EXPR_MONTH" );
String SCHEDULE_EXPR_DAY_WEEK = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String SCHEDULE_EXPR_YEAR = getProperty( "SCHEDULE_EXPR_YEAR" );
String SCHEDULE_MAX_TIME = getProperty( "SCHEDULE_MAX_TIME" );
String SCHEDULE_PERIOD = getProperty( "SCHEDULE_PERIOD" );
goToAddSchedule();
addEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD, true, true );
}
@Test( dependsOnMethods = { "testAddScheduleNoBuildQueueToBeUsed" } )
public void testAddScheduleWithInvalidValues()
{
String SCHEDULE_NAME = "!@#$<>?etc";
String SCHEDULE_DESCRIPTION = "![]<>'^&etc";
String SCHEDULE_EXPR_SECOND = getProperty( "SCHEDULE_EXPR_SECOND" );
String SCHEDULE_EXPR_MINUTE = getProperty( "SCHEDULE_EXPR_MINUTE" );
String SCHEDULE_EXPR_HOUR = getProperty( "SCHEDULE_EXPR_HOUR" );
String SCHEDULE_EXPR_DAY_MONTH = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String SCHEDULE_EXPR_MONTH = getProperty( "SCHEDULE_EXPR_MONTH" );
String SCHEDULE_EXPR_DAY_WEEK = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String SCHEDULE_EXPR_YEAR = getProperty( "SCHEDULE_EXPR_YEAR" );
String SCHEDULE_MAX_TIME = getProperty( "SCHEDULE_MAX_TIME" );
String SCHEDULE_PERIOD = getProperty( "SCHEDULE_PERIOD" );
goToAddSchedule();
addEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD, true, false );
assertTextPresent( "Name contains invalid characters." );
}
public void testAddInvalidSchedule()
{
goToAddSchedule();
addEditSchedule( "", "", "", "", "", "", "", "", "", "", "", true, false );
assertTextPresent( "Invalid cron expression value(s)" );
assertTextPresent( "Name is required and cannot contain spaces only" );
assertTextPresent( "Description is required and cannot contain spaces only" );
}
@Test( dependsOnMethods = { "testAddSchedule" } )
public void testAddDuplicatedSchedule()
{
String SCHEDULE_NAME = getProperty( "SCHEDULE_NAME" );
String SCHEDULE_DESCRIPTION = getProperty( "SCHEDULE_DESCRIPTION" );
String SCHEDULE_EXPR_SECOND = getProperty( "SCHEDULE_EXPR_SECOND" );
String SCHEDULE_EXPR_MINUTE = getProperty( "SCHEDULE_EXPR_MINUTE" );
String SCHEDULE_EXPR_HOUR = getProperty( "SCHEDULE_EXPR_HOUR" );
String SCHEDULE_EXPR_DAY_MONTH = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String SCHEDULE_EXPR_MONTH = getProperty( "SCHEDULE_EXPR_MONTH" );
String SCHEDULE_EXPR_DAY_WEEK = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String SCHEDULE_EXPR_YEAR = getProperty( "SCHEDULE_EXPR_YEAR" );
String SCHEDULE_MAX_TIME = getProperty( "SCHEDULE_MAX_TIME" );
String SCHEDULE_PERIOD = getProperty( "SCHEDULE_PERIOD" );
goToAddSchedule();
addEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD, true, false );
assertTextPresent( "A Schedule with the same name already exists" );
}
@Test( dependsOnMethods = { "testAddDuplicatedSchedule" } )
public void testEditSchedule()
{
String SCHEDULE_NAME = getProperty( "SCHEDULE_NAME" );
String SCHEDULE_DESCRIPTION = getProperty( "SCHEDULE_DESCRIPTION" );
String SCHEDULE_EXPR_SECOND = getProperty( "SCHEDULE_EXPR_SECOND" );
String SCHEDULE_EXPR_MINUTE = getProperty( "SCHEDULE_EXPR_MINUTE" );
String SCHEDULE_EXPR_HOUR = getProperty( "SCHEDULE_EXPR_HOUR" );
String SCHEDULE_EXPR_DAY_MONTH = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String SCHEDULE_EXPR_MONTH = getProperty( "SCHEDULE_EXPR_MONTH" );
String SCHEDULE_EXPR_DAY_WEEK = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String SCHEDULE_EXPR_YEAR = getProperty( "SCHEDULE_EXPR_YEAR" );
String SCHEDULE_MAX_TIME = getProperty( "SCHEDULE_MAX_TIME" );
String SCHEDULE_PERIOD = getProperty( "SCHEDULE_PERIOD" );
String name = "new_name";
String description = "new_description";
String second = "1";
String minute = "20";
String hour = "15";
String dayMonth = "20";
String month = "9";
String dayWeek = "?";
String year = "";
String maxTime = "9000";
String period = "0";
goToEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD );
addEditSchedule( name, description, second, minute, hour, dayMonth, month, dayWeek, year, maxTime, period,
false, true );
goToEditSchedule( name, description, second, minute, hour, dayMonth, month, dayWeek, year, maxTime, period );
addEditSchedule( SCHEDULE_NAME, SCHEDULE_DESCRIPTION, SCHEDULE_EXPR_SECOND, SCHEDULE_EXPR_MINUTE,
SCHEDULE_EXPR_HOUR, SCHEDULE_EXPR_DAY_MONTH, SCHEDULE_EXPR_MONTH, SCHEDULE_EXPR_DAY_WEEK,
SCHEDULE_EXPR_YEAR, SCHEDULE_MAX_TIME, SCHEDULE_PERIOD, false, true );
}
@Test( dependsOnMethods = { "testEditSchedule" } )
public void testDeleteSchedule()
{
String SCHEDULE_NAME = getProperty( "SCHEDULE_NAME" );
removeSchedule( SCHEDULE_NAME );
}
}
| 5,229 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/QueueTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = { "queue" } )
public class QueueTest
extends AbstractAdminTest
{
private String buildQueueName;
@BeforeMethod
protected void setUp()
throws Exception
{
buildQueueName = getProperty( "BUILD_QUEUE_NAME" );
}
@AfterClass
protected void tearDown()
{
goToBuildQueuePage();
removeBuildQueue( buildQueueName );
}
public void testAddBuildQueue()
{
setMaxBuildQueue( 2 );
addBuildQueue( buildQueueName );
}
public void testQueuePageWithoutBuild()
{
clickAndWait( "link=Queues" );
assertPage( "Continuum - Build Queue" );
assertTextPresent( "Nothing is building" );
assertTextNotPresent( "Project Name* Build Definition" );
assertTextPresent( "Current Build" );
assertTextPresent( "Build Queue" );
assertTextPresent( "Current Checkout" );
assertTextPresent( "Checkout Queue " );
assertTextPresent( "Current Prepare Build" );
assertTextPresent( "Prepare Build Queue" );
}
@Test( dependsOnMethods = { "testAddBuildQueue" } )
public void testAddBuildQueueToSchedule()
{
String scheduleName = getProperty( "QUEUE_SCHEDULE_NAME" );
String scheduleDescription = getProperty( "SCHEDULE_DESCRIPTION" );
String second = getProperty( "SCHEDULE_EXPR_SECOND" );
String minute = getProperty( "SCHEDULE_EXPR_MINUTE" );
String hour = getProperty( "SCHEDULE_EXPR_HOUR" );
String dayOfMonth = getProperty( "SCHEDULE_EXPR_DAY_MONTH" );
String month = getProperty( "SCHEDULE_EXPR_MONTH" );
String dayOfWeek = getProperty( "SCHEDULE_EXPR_DAY_WEEK" );
String year = getProperty( "SCHEDULE_EXPR_YEAR" );
String maxTime = getProperty( "SCHEDULE_MAX_TIME" );
String period = getProperty( "SCHEDULE_PERIOD" );
goToAddSchedule();
addEditSchedule( scheduleName, scheduleDescription, second, minute, hour, dayOfMonth, month, dayOfWeek, year,
maxTime, period, true, true );
try {
goToEditSchedule( scheduleName, scheduleDescription, second, minute, hour, dayOfMonth, month, dayOfWeek, year,
maxTime, period );
getSelenium().addSelection( "saveSchedule_availableBuildQueuesIds", "label=" + buildQueueName );
getSelenium().click( "//input[@value='->']" );
submit();
} finally {
removeSchedule( scheduleName );
}
}
@Test( dependsOnMethods = { "testAddBuildQueue" } )
public void testAddNotAllowedBuildQueue()
{
setMaxBuildQueue( 1 );
String secondQueue = "second_queue_name";
addBuildQueue( secondQueue, false );
assertTextPresent( "You are only allowed 1 number of builds in parallel." );
}
@Test( dependsOnMethods = { "testAddBuildQueue" } )
public void testAddAlreadyExistBuildQueue()
{
setMaxBuildQueue( 3 );
addBuildQueue( buildQueueName, false );
assertTextPresent( "Build queue name already exists." );
}
public void testAddEmptyBuildQueue()
{
setMaxBuildQueue( 3 );
addBuildQueue( "", false, false );
assertTextPresent( "You must define a name" );
}
public void testDeleteBuildQueue()
{
setMaxBuildQueue( 3 );
goToBuildQueuePage();
String testBuildQueue = "test_build_queue";
addBuildQueue( testBuildQueue );
removeBuildQueue( testBuildQueue );
assertTextNotPresent( testBuildQueue );
}
@Test( dependsOnMethods = { "testQueuePageWithoutBuild" } )
public void testQueuePageWithProjectCurrentlyBuilding()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_QUEUE_TEST_POM_URL" );
String pomUsername = getProperty( "MAVEN2_QUEUE_TEST_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_QUEUE_TEST_POM_PASSWORD" );
String projectGroupName = getProperty( "MAVEN2_QUEUE_TEST_POM_PROJECT_GROUP_NAME" );
String projectGroupId = getProperty( "MAVEN2_QUEUE_TEST_POM_PROJECT_GROUP_ID" );
String projectGroupDescription = getProperty( "MAVEN2_QUEUE_TEST_POM_PROJECT_GROUP_DESCRIPTION" );
goToProjectGroupsSummaryPage();
if ( !isLinkPresent( projectGroupName ) )
{
//build a project
goToAddMavenTwoProjectPage();
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
}
buildProjectForQueuePageTest( projectGroupName, projectGroupId, projectGroupDescription );
String location = getSelenium().getLocation();
//check queue page while building
getSelenium().open( baseUrl + "/admin/displayQueues.action" );
assertPage( "Continuum - Build Queue" );
assertTextPresent( "Current Build" );
assertTextPresent( "Build Queue" );
assertTextPresent( "Current Checkout" );
assertTextPresent( "Checkout Queue " );
assertTextPresent( "Current Prepare Build" );
assertTextPresent( "Prepare Build Queue" );
assertElementPresent( "//table[@id='ec_table']/tbody/tr/td[4]" );
assertTextPresent( projectGroupName );
getSelenium().open( location );
waitPage();
waitForElementPresent( "//img[@alt='Success']" );
}
protected void goToBuildQueuePage()
{
clickLinkWithText( "Build Queue" );
assertBuildQueuePage();
}
void assertBuildQueuePage()
{
assertPage( "Continuum - Parallel Build Queue" );
assertTextPresent( "Parallel Build Queue" );
assertTextPresent( "Name" );
assertTextPresent( "DEFAULT_BUILD_QUEUE" );
assertButtonWithValuePresent( "Add" );
}
protected void removeBuildQueue( String queueName )
{
clickLinkWithXPath(
"(//a[contains(@href,'deleteBuildQueue.action') and contains(@href, '" + queueName + "')])//img" );
assertTextPresent( "Delete Parallel Build Queue" );
assertTextPresent( "Are you sure you want to delete the build queue \"" + queueName + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildQueuePage();
}
void assertAddBuildQueuePage()
{
assertPage( "Continuum - Add/Edit Parallel Build Queue" );
assertTextPresent( "Add/Edit Parallel Build Queue" );
assertTextPresent( "Name*" );
assertElementPresent( "name" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addBuildQueue( String name )
{
addBuildQueue( name, true );
}
protected void addBuildQueue( String name, boolean success )
{
addBuildQueue( name, success, true );
}
protected void addBuildQueue( String name, boolean success, boolean waitForError )
{
goToBuildQueuePage();
assertBuildQueuePage();
submit();
assertAddBuildQueuePage();
setFieldValue( "name", name );
if ( success )
{
submit();
assertBuildQueuePage();
assertTextPresent( name );
}
else
{
submit( waitForError );
assertAddBuildQueuePage();
}
}
}
| 5,230 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.UnsupportedEncodingException;
@Test( groups = {"agent"} )
public class BuildAgentsTest
extends AbstractAdminTest
{
private String buildAgentGroup;
private String buildAgentDescription;
private String badAgentUrl;
@BeforeMethod
public void setUp()
{
enableDistributedBuilds();
buildAgentGroup = getProperty( "BUILD_AGENT_GROUPNAME" );
buildAgentDescription = getProperty( "BUILD_AGENT_DESCRIPTION" );
badAgentUrl = "http://localhost:8585/bad-continuum-buildagent/xmlrpc";
}
@AfterMethod
public void tearDown()
throws Exception
{
removeBuildAgentGroup( buildAgentGroup, false );
removeBuildAgent( buildAgentUrl, false );
removeBuildAgent( badAgentUrl, false );
disableDistributedBuilds();
}
public void testAddBuildAgent()
{
goToAddBuildAgent();
addBuildAgent( buildAgentUrl, buildAgentDescription, true, true, true );
}
public void testAddBuildAgentWithXSS()
{
String invalidUrl = "http://sampleagent/<script>alert('gotcha')</script>";
String invalidDescription = "blah blah <script>alert('gotcha')</script> blah blah";
goToAddBuildAgent();
addBuildAgent( invalidUrl, invalidDescription, false, true, false );
assertTextPresent( "Build agent url is invalid." );
}
public void testViewBuildAgentInstallationXSS()
{
String url = baseUrl +
"/security/viewBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "<script>alert('xss')</script>" );
}
public void testEditBuildAgentXSS()
{
String url = baseUrl +
"/security/editBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
}
public void testAddAnExistingBuildAgent()
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgent();
addBuildAgent( buildAgentUrl, buildAgentDescription, false, false, true );
assertTextPresent( "Build agent already exists" );
}
public void testEditBuildAgent()
throws Exception
{
// reset agent to expected state
addBuildAgent( buildAgentUrl, buildAgentDescription );
String new_agentDescription = "new_agentDescription";
goToEditBuildAgent( buildAgentUrl, buildAgentDescription );
addEditBuildAgent( buildAgentUrl, new_agentDescription );
goToEditBuildAgent( buildAgentUrl, new_agentDescription );
addEditBuildAgent( buildAgentUrl, buildAgentDescription );
}
public void testAddBadBuildAgent()
throws Exception
{
String description = "down agent";
goToAddBuildAgent();
addBuildAgent( badAgentUrl, description, true, true, false );
goToBuildAgentPage();
assertLinkNotPresent( badAgentUrl );
}
public void testEnableBadBuildAgent()
throws Exception
{
// Note: relying on behaviour of being able to add a disabled agent without a test, if that changes in future we
// might need to force its configuration
String description = "down agent";
goToAddBuildAgent();
addBuildAgent( badAgentUrl, description, true, false, true );
goToEditBuildAgent( badAgentUrl, description );
addBuildAgent( badAgentUrl, description, true, true, false );
goToBuildAgentPage();
assertLinkPresent( badAgentUrl );
}
public void testDeleteBuildAgent()
throws Exception
{
addBuildAgent( buildAgentUrl, buildAgentDescription );
removeBuildAgent( buildAgentUrl );
assertTextNotPresent( buildAgentUrl );
}
public void testAddEmptyBuildAgent()
{
goToAddBuildAgent();
addBuildAgent( "", buildAgentDescription, false, false, false );
assertTextPresent( "Build agent url is required." );
}
//TESTS FOR BUILD AGENT GROUPS
public void testAddBuildAgentGroupXSS()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( "%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E", new String[]{}, new String[]{},
false );
assertTextPresent( "Build agent group name contains invalid characters" );
}
public void testEditBuildAgentGroupXSS()
{
String url = baseUrl +
"/security/editBuildAgentGroup.action?buildAgentGroup.name=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
}
public void testAddBuildAgentGroup()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
}
public void testEditBuildAgentGroup()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
String newName = "new_agentgroupname";
goToEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl} );
addEditBuildAgentGroup( newName, new String[]{}, new String[]{buildAgentUrl}, true );
goToEditBuildAgentGroup( newName, new String[]{} );
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
}
public void testAddAnExistingBuildAgentGroup()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, false );
assertTextPresent( "Build agent group already exists." );
}
public void testAddEmptyBuildAgentGroupName()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( "", new String[]{}, new String[]{}, false );
assertTextPresent( "Build agent group name is required." );
}
public void testDeleteBuildAgentGroup()
throws UnsupportedEncodingException
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
removeBuildAgentGroup( buildAgentGroup );
}
public void testAddBuildAgentGroupWithEmptyBuildAgent()
throws Exception
{
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroup, new String[]{}, new String[]{}, true );
}
}
| 5,231 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractBuildDefinitionTemplateTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = {"buildDefinitionTemplate"} )
public class BuildDefinitionTemplateTest
extends AbstractBuildDefinitionTemplateTest
{
private String templateName;
@BeforeClass
public void setUp()
{
templateName = getProperty( "TEMPLATE_NAME" );
}
public void testAddTemplate()
throws Exception
{
goToAddTemplate();
addEditTemplate( templateName,
new String[]{"Default Maven Build Definition", "Default Maven 1 Build Definition"},
new String[]{}, true );
}
public void testAddInvalidTemplate()
throws Exception
{
goToAddTemplate();
addEditTemplate( "", new String[] { "Default Maven Build Definition" }, new String[] {}, false );
assertTextPresent( "Name is required" );
}
public void testAddTemplateWithXSS()
throws Exception
{
goToAddTemplate();
addEditTemplate( "Name <script>alert('gotcha')</script>", new String[]{ "Default Maven Build Definition" }, new String[]{}, false );
assertTextPresent( "Name contains invalid characters" );
}
@Test( dependsOnMethods = {"testAddTemplate"} )
public void testEditTemplate()
throws Exception
{
String newName = "new_name";
goToEditTemplate( templateName,
new String[]{"Default Maven Build Definition", "Default Maven 1 Build Definition"} );
addEditTemplate( newName, new String[]{"Default Shell Build Definition"},
new String[]{"Default Maven Build Definition"}, true );
goToEditTemplate( newName, new String[]{"Default Maven 1 Build Definition", "Default Shell Build Definition"} );
addEditTemplate( templateName, new String[]{"Default Maven Build Definition"},
new String[]{"Default Shell Build Definition"}, true );
}
@Test( dependsOnMethods = {"testEditTemplate"} )
public void testDeleteTemplate()
{
removeTemplate( templateName );
}
public void testAddBuildDefinitionTemplate()
throws Exception
{
String TEMPLATE_BUILD_POM_NAME = getProperty( "TEMPLATE_BUILD_POM_NAME" );
String TEMPLATE_BUILD_GOALS = getProperty( "TEMPLATE_BUILD_GOALS" );
String TEMPLATE_BUILD_ARGUMENTS = getProperty( "TEMPLATE_BUILD_ARGUMENTS" );
String TEMPLATE_BUILD_DESCRIPTION = getProperty( "TEMPLATE_BUILD_DESCRIPTION" );
goToAddBuildDefinitionTemplate();
addEditBuildDefinitionTemplate( TEMPLATE_BUILD_POM_NAME, TEMPLATE_BUILD_GOALS, TEMPLATE_BUILD_ARGUMENTS,
TEMPLATE_BUILD_DESCRIPTION, true, true, true, true );
}
public void testAddInvalidBuildDefinitionTemplate()
throws Exception
{
goToAddBuildDefinitionTemplate();
addEditBuildDefinitionTemplate( "", "", "", "", true, true, true, false );
assertTextPresent( "BuildFile is required" );
assertTextPresent( "Goals are required" );
assertTextPresent( "Description is required" );
}
public void testAddBuildDefinitionTemplateWithXSS()
throws Exception
{
String invalidString = "<script>alert('gotcha')</script>";
goToAddBuildDefinitionTemplate();
addEditBuildDefinitionTemplate( invalidString, invalidString, invalidString, invalidString, true, true, true,
false );
assertTextPresent( "BuildFile contains invalid characters" );
assertTextPresent( "Goals contain invalid characters" );
assertTextPresent( "Arguments contain invalid characters" );
}
@Test( dependsOnMethods = {"testAddBuildDefinitionTemplate"} )
public void testEditBuildDefinitionTemplate()
throws Exception
{
String TEMPLATE_BUILD_POM_NAME = getProperty( "TEMPLATE_BUILD_POM_NAME" );
String TEMPLATE_BUILD_GOALS = getProperty( "TEMPLATE_BUILD_GOALS" );
String TEMPLATE_BUILD_ARGUMENTS = getProperty( "TEMPLATE_BUILD_ARGUMENTS" );
String TEMPLATE_BUILD_DESCRIPTION = getProperty( "TEMPLATE_BUILD_DESCRIPTION" );
goToEditBuildDefinitionTemplate( TEMPLATE_BUILD_DESCRIPTION );
addEditBuildDefinitionTemplate( TEMPLATE_BUILD_POM_NAME, TEMPLATE_BUILD_GOALS, TEMPLATE_BUILD_ARGUMENTS,
TEMPLATE_BUILD_DESCRIPTION, false, false, false, true );
}
@Test( dependsOnMethods = {"testEditBuildDefinitionTemplate"} )
public void testDeleteBuildDefinitionTemplate()
{
String TEMPLATE_BUILD_DESCRIPTION = getProperty( "TEMPLATE_BUILD_DESCRIPTION" );
removeBuildDefinitionTemplate( TEMPLATE_BUILD_DESCRIPTION );
}
public void testAddTemplateWithEmptyBuildDefinitions()
throws Exception
{
goToAddTemplate();
addEditTemplate( templateName, new String[] {}, new String[] {}, false );
}
@AfterClass
public void tearDown()
{
removeTemplate( templateName, false );
}
}
| 5,232 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AppearanceTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test(groups = { "appearance" })
public class AppearanceTest
extends AbstractAdminTest
{
public void testAppearancePage()
{
goToAppearancePage();
}
@Test(dependsOnMethods = { "testAppearancePage" })
public void testSaveFooter()
{
goToAppearancePage();
getSelenium().type( "saveFooter_footer",
"<div class=\"xright\">Continuum Test Footer</div> <div class=\"clear\"><hr/></div>" );
clickButtonWithValue( "Save" );
assertTextPresent( "Successfully saved footer content." );
String SAVE_FOOTER_URL = getProperty( "APPEARANCE_SAVE_FOOTER_URL" );
Assert.assertEquals( getSelenium().getLocation(), SAVE_FOOTER_URL );
}
}
| 5,233 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Arrays;
@Test( groups = {"release"} )
public class ReleaseTest
extends AbstractReleaseTest
{
private String projectGroupName;
private String projectGroupId;
private String tagBase;
private String tag;
private String releaseVersion;
private String developmentVersion;
private String releaseProjectScmUrl;
@BeforeClass
public void createAndBuildProject()
{
projectGroupName = getProperty( "RELEASE_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "RELEASE_PROJECT_GROUP_ID" );
String description = "Release test projects";
loginAsAdmin();
String pomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
String projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
removeProjectGroup( projectGroupName, false );
addProjectGroup( projectGroupName, projectGroupId, description, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectGroup( projectGroupName, projectGroupId, "", projectName, true );
}
}
@BeforeMethod
public void setUp()
throws IOException
{
tagBase = getProperty( "RELEASE_PROJECT_TAGBASE" );
tag = getProperty( "RELEASE_PROJECT_TAG" );
releaseVersion = getProperty( "RELEASE_PROJECT_VERSION" );
developmentVersion = getProperty( "RELEASE_PROJECT_DEVELOPMENT_VERSION" );
releaseProjectScmUrl = getProperty( "RELEASE_PROJECT_SCM_URL" );
}
@AfterMethod
public void tearDown()
throws Exception
{
}
// can't test u/p locally and don't have a suitable SVN server to test against
@Test( enabled = false )
public void testReleasePrepareProjectWithInvalidUsernamePassword()
throws Exception
{
String releaseUsername = "invalid";
String releasePassword = "invalid";
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( releaseUsername, releasePassword, tagBase, "simple-example-13.0", "13.0",
"13.1-SNAPSHOT", null );
assertReleasePhaseError();
}
public void testReleasePrepareProject()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, "" );
assertReleasePhaseSuccess();
}
@Test( dependsOnMethods = {"testReleasePrepareProject"} )
public void testReleasePerformUsingProvidedParameters()
throws Exception
{
String releaseUsername = "invalid";
String releasePassword = "invalid";
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePerformProjectWithProvideParameters( releaseUsername, releasePassword, tagBase, tag,
releaseProjectScmUrl, "" );
}
// avoid the above test running between these so that the list of prepared releases is correct
@Test( dependsOnMethods = {"testReleasePrepareProject"} )
public void testReleasePrepareWithoutInterveningPerform()
throws IOException
{
// CONTINUUM-2687
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
// first attempt
releasePrepareProject( "", "", tagBase, "simple-example-10.1", "10.1", "10.2-SNAPSHOT", "" );
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// second attempt
releasePrepareProject( "", "", tagBase, "simple-example-10.2", "10.2", "10.3-SNAPSHOT", "" );
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// check that two versions are present
Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
"10.0", "10.1", "10.2", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
// check that 10.2 is selected by default
Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "10.2" );
// test perform on 10.2
selectPerformAndSubmit();
setFieldValue( "goals", "clean validate" );
submit();
waitForRelease();
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// verify that it is removed from the list again
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
"10.0", "10.1", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "10.1" );
}
}
| 5,234 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedPurgeTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractPurgeTest;
import org.codehaus.plexus.util.FileUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import static org.testng.Assert.assertTrue;
/**
* Confirms that distributed repositories populate when used and appropriate purge configurations function.
*/
@Test( groups = { "distributed", "purge" } )
public class DistributedPurgeTest
extends AbstractPurgeTest
{
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String pomUrl;
private String pomUsername;
private String pomPassword;
private String projectName;
private String agentRepoName;
private File agentRepo;
private String purgeDescription;
@BeforeClass
@Parameters( { "agentRepoName", "agentRepo" } )
public void setupClass(
@Optional( "purgeable" ) String repoName,
@Optional( "target/data/build-agent/.m2/repository" ) String repoPath )
{
loginAsAdmin();
enableDistributedBuilds();
addBuildAgent( buildAgentUrl );
this.agentRepoName = repoName;
agentRepo = new File( repoPath );
assertTrue( !agentRepo.exists() );
purgeDescription = "Wipe entire repo";
projectGroupName = getProperty( "DISTRIBUTED_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "DISTRIBUTED_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "DISTRIBUTED_PROJECT_GROUP_DESCRIPTION" );
pomUrl = getProperty( "MAVEN2_POM_URL" );
pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
addLocalRepository( repoName, agentRepo.getAbsolutePath(), true );
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, repoName, true, true );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
}
@AfterClass
public void tearDownClass()
throws Throwable
{
removeProjectGroup( projectGroupName, false );
removeBuildAgent( buildAgentUrl );
disableDistributedBuilds();
removeProjectGroup( projectGroupName, false );
removeLocalRepository( agentRepoName );
}
@BeforeMethod
public void setup()
{
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
assertTrue( agentRepo.exists() );
}
@AfterMethod
public void tearDown()
throws IOException
{
FileUtils.deleteDirectory( agentRepo );
removeRepositoryPurge( purgeDescription, true );
}
public void testDistributedRepositoryPurgeAll()
throws Exception
{
addAgentPurgeConfigDeleteAll( agentRepoName, purgeDescription, buildAgentUrl );
triggerRepoPurge( purgeDescription );
assertTrue( agentRepo.exists() && agentRepo.list().length == 0 );
}
private void triggerRepoPurge( String configDesc )
throws UnsupportedEncodingException
{
goToGeneralPurgePage();
String purgeLocator =
String.format( "//preceding::td[text()='%s']//following::img[@alt='Purge']", configDesc );
clickLinkWithXPath( purgeLocator );
assertGeneralPurgePage();
assertTextPresent( "Purge successfully requested" );
}
private void addAgentPurgeConfigDeleteAll( String agentRepoName, String configDesc, String agentUrl )
{
goToAddRepositoryPurge( true );
selectValue( "repositoryName", agentRepoName );
getSelenium().click( "id=saveDistributedPurgeConfig_deleteAll" );
setFieldValue( "description", configDesc );
selectValue( "buildAgentUrl", agentUrl );
submit();
assertGeneralPurgePage();
assertTextPresent( configDesc );
}
/*
Defining these locally since we can't use AbstractLocalRepositoryTest code.
A very real effect of using inheritance rather than composition to share code.
Having injectable components for shared web test code would make more sense.
*/
private void addLocalRepository( String repoName, String repoPath, boolean b )
{
goToLocalRepositoryPage();
submit();
assertPage( "Continuum - Add/Edit Local Repository" );
setFieldValue( "repository.name", repoName );
setFieldValue( "repository.location", repoPath );
submit();
assertPage( "Continuum - Local Repositories" );
assertTextPresent( repoName );
}
private void goToLocalRepositoryPage()
{
clickLinkWithText( "Local Repositories" );
assertLocalRepositoryPage();
}
private void assertLocalRepositoryPage()
{
assertPage( "Continuum - Local Repositories" );
}
private void removeLocalRepository( String repoName )
{
goToLocalRepositoryPage();
String deleteLocator = String.format( "//preceding::td[text()='%s']//following::img[@alt='Delete']", repoName );
clickLinkWithXPath( deleteLocator );
assertTextPresent( "Delete Local Repository" );
assertTextPresent( "Are you sure you want to delete Local Repository \"" + repoName + "\" ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertLocalRepositoryPage();
assertTextNotPresent( repoName );
}
}
| 5,235 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.io.IOUtils;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
@Test( groups = {"distributedRelease"} )
public class DistributedReleaseTest
extends AbstractReleaseTest
{
private static final String RELEASE_BUTTON_TEXT = "Release";
private static final String PROVIDE_RELEASE_PARAMETERS_TEXT = "Provide Release Parameters";
private String appserverBase;
private String projectGroupName;
private String projectGroupId;
private String releaseBuildEnvironment;
private String releaseBuildAgentGroup;
private String tagBase;
private String tag;
private String releaseVersion;
private String developmentVersion;
private String errorMessageNoAgent;
private String releaseProjectScmUrl;
@BeforeClass
@Parameters( { "appserverBase" } )
public void createAndBuildProject( @Optional( "target" ) String appserverBase )
{
this.appserverBase = appserverBase;
projectGroupName = getProperty( "DIST_RELEASE_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "DIST_RELEASE_PROJECT_GROUP_ID" );
String description = "Distributed Release test projects";
loginAsAdmin();
enableDistributedBuilds();
addBuildAgent( buildAgentUrl );
String pomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
String projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
removeProjectGroup( projectGroupName, false );
addProjectGroup( projectGroupName, projectGroupId, description, true );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectGroup( projectGroupName, projectGroupId, "", projectName, true );
}
}
@BeforeMethod
public void setUp()
throws IOException
{
releaseBuildEnvironment = getProperty( "DIST_RELEASE_BUILD_ENV" );
releaseBuildAgentGroup = getProperty( "DIST_RELEASE_BUILD_AGENT_GROUP" );
errorMessageNoAgent = getProperty( "DIST_RELEASE_NO_AGENT_MESSAGE" );
tagBase = getProperty( "DIST_RELEASE_PROJECT_TAGBASE" );
tag = getProperty( "DIST_RELEASE_PROJECT_TAG" );
releaseVersion = getProperty( "DIST_RELEASE_PROJECT_VERSION" );
developmentVersion = getProperty( "DIST_RELEASE_PROJECT_DEVELOPMENT_VERSION" );
releaseProjectScmUrl = getProperty( "DIST_RELEASE_PROJECT_SCM_URL" );
File file = getPreparedReleasesFile();
if ( file.exists() && !file.delete() )
{
throw new IOException( "Unable to delete existing prepared-releases.xml file" );
}
enableDistributedBuilds();
addBuildAgent( buildAgentUrl );
createBuildEnvAndBuildagentGroup( releaseBuildEnvironment, releaseBuildAgentGroup );
}
@AfterMethod
public void tearDown()
throws Exception
{
removeBuildagentGroupFromBuildEnv( releaseBuildAgentGroup );
removeBuildAgentGroup( releaseBuildAgentGroup );
// enable agent if disabled
goToBuildAgentPage();
clickImgWithAlt( "Edit" );
enableDisableBuildAgent( buildAgentUrl, true );
disableDistributedBuilds();
}
public void testDistributedReleasePrepareWithoutInterveningPerform()
throws IOException
{
// CONTINUUM-2687
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
// first attempt
releasePrepareProject( "", "", tagBase, "simple-example-1.1", "1.1", "1.2-SNAPSHOT", releaseBuildEnvironment );
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// second attempt
releasePrepareProject( "", "", tagBase, "simple-example-1.2", "1.2", "1.3-SNAPSHOT", releaseBuildEnvironment );
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// check prepared releases content (timestamp version)
String str = getPreparedReleasesContent();
Assert.assertTrue( str.contains( "<releaseId>org.apache.continuum.examples.simple:simple-example:" ) );
// check that two versions are present
Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
"1.1", "1.2", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
// check that 1.2 is selected by default
Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "1.2" );
// test perform on 1.2
selectPerformAndSubmit();
setFieldValue( "goals", "clean validate" );
submit();
waitForRelease();
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
// verify that it is removed from the list again
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
"1.1", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "1.1" );
}
public void testReleasePrepareWhenAgentGoesDown()
throws IOException
{
// CONTINUUM-2686
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, "simple-example-2.0", "2.0", "2.1-SNAPSHOT", releaseBuildEnvironment );
assertReleasePhaseSuccess();
// disable agent
goToBuildAgentPage();
clickImgWithAlt( "Edit" );
enableDisableBuildAgent( buildAgentUrl, false );
// check prepared releases content
String str = getPreparedReleasesContent();
Assert.assertTrue( str.contains( "<releaseId>org.apache.continuum.examples.simple:simple-example" ) );
// go back to release page
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
// check that the version is present
Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
"2.0", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
}
// can't test u/p locally and don't have a suitable SVN server to test against
@Test( enabled = false )
public void testReleasePrepareProjectWithInvalidUsernamePasswordInDistributedBuilds()
throws Exception
{
String releaseUsername = "invalid";
String releasePassword = "invalid";
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( releaseUsername, releasePassword, tagBase, "simple-example-3.0", "3.0", "3.1-SNAPSHOT",
releaseBuildEnvironment );
assertReleasePhaseError();
assertPreparedReleasesFileContainsBuildAgent();
}
/*
* Test release prepare with no build agent configured in the selected build environment.
*/
public void testReleasePrepareProjectWithNoBuildagentInBuildEnvironment()
throws Exception
{
detachBuildagentFromGroup( releaseBuildAgentGroup );
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, releaseBuildEnvironment );
assertReleaseError();
assertTextPresent( errorMessageNoAgent );
}
/*
* Test release prepare with no build agent group in the selected build environment.
*/
public void testReleasePrepareProjectWithNoBuildagentGroupInBuildEnvironment()
throws Exception
{
removeBuildagentGroupFromBuildEnv( releaseBuildEnvironment );
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, releaseBuildEnvironment );
assertReleaseError();
assertTextPresent( errorMessageNoAgent );
}
/*
* Test release prepare with no build environment selected.
*/
public void testReleasePrepareProjectWithNoBuildEnvironment()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, "" );
assertReleasePhaseSuccess();
clickButtonWithValue( "Done" );
assertPreparedReleasesFileContainsBuildAgent();
// test subsequent perform
selectPerformAndSubmit();
setFieldValue( "goals", "clean validate" );
submit();
waitForRelease();
assertReleasePhaseSuccess();
}
@Test( dependsOnMethods = {"testReleasePrepareProjectWithNoBuildEnvironment"} )
public void testReleasePerformUsingProvidedParametersWithDistributedBuilds()
throws Exception
{
String releaseUsername = "invalid";
String releasePassword = "invalid";
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePerformProjectWithProvideParameters( releaseUsername, releasePassword, tagBase, tag,
releaseProjectScmUrl, releaseBuildEnvironment );
assertPreparedReleasesFileContainsBuildAgent();
}
@Test( dependsOnMethods = {"testReleasePrepareProjectWithNoBuildEnvironment"} )
public void testReleasePerformUsingProvidedParametersWithNoBuildEnvironment()
throws Exception
{
String releaseUsername = "invalid";
String releasePassword = "invalid";
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePerformProjectWithProvideParameters( releaseUsername, releasePassword, tagBase, tag,
releaseProjectScmUrl, "" );
assertPreparedReleasesFileContainsBuildAgent();
}
private void createBuildEnvAndBuildagentGroup( String projectBuildEnv, String projectAgentGroup )
{
// add build agent group no agents
goToBuildAgentPage();
if ( !isTextPresent( projectAgentGroup ) )
{
clickAndWait( "//input[@id='editBuildAgentGroup_0']" );
setFieldValue( "saveBuildAgentGroup_buildAgentGroup_name", projectAgentGroup );
clickButtonWithValue( "Save" );
}
// add build environment with build agent group
clickLinkWithText( "Build Environments" );
if ( !isTextPresent( projectBuildEnv ) )
{
clickAndWait( "//input[@id='addBuildEnv_0']" );
setFieldValue( "saveBuildEnv_profile_name", projectBuildEnv );
clickButtonWithValue( "Save" );
}
attachBuildagentGroupToBuildEnv( releaseBuildEnvironment, releaseBuildAgentGroup );
// attach build agent in build agent group created
attachBuildagentInGroup( releaseBuildAgentGroup );
}
private void attachBuildagentGroupToBuildEnv( String projectBuildEnv, String projectAgentGroup )
{
clickLinkWithText( "Build Environments" );
String xPath = "//preceding::td[text()='" + projectBuildEnv + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
selectValue( "profile.buildAgentGroup", projectAgentGroup );
clickButtonWithValue( "Save" );
}
private void removeBuildagentGroupFromBuildEnv( String projectBuildEnv )
{
clickLinkWithText( "Build Environments" );
String xPath = "//preceding::td[text()='" + projectBuildEnv + "']//following::img[@alt='Edit']";
if ( isElementPresent( "xpath=" + xPath ) )
{
clickLinkWithXPath( xPath );
selectValue( "profile.buildAgentGroup", "" );
clickButtonWithValue( "Save" );
}
}
private void attachBuildagentInGroup( String projectAgentGroup )
{
String buildAgent = buildAgentUrl;
clickLinkWithText( "Build Agents" );
String xPath = "//preceding::td[text()='" + projectAgentGroup + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
if ( isElementPresent(
"xpath=//select[@id='saveBuildAgentGroup_buildAgentIds']/option[@value='" + buildAgent + "']" ) )
{
selectValue( "buildAgentIds", buildAgent );
clickLinkWithXPath( "//input[@value='->']", false );
submit();
}
}
private void detachBuildagentFromGroup( String projectAgentGroup )
{
String buildAgent = buildAgentUrl;
clickLinkWithText( "Build Agents" );
String xPath = "//preceding::td[text()='" + projectAgentGroup + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
if ( isElementPresent(
"xpath=//select[@id='saveBuildAgentGroup_selectedBuildAgentIds']/option[@value='" + buildAgent + "']" ) )
{
selectValue( "selectedBuildAgentIds", buildAgent );
clickLinkWithXPath( "//input[@value='<-']", false );
submit();
}
}
private void assertPreparedReleasesFileContainsBuildAgent()
throws Exception
{
String str = getPreparedReleasesContent();
Assert.assertTrue( str.contains( "<buildAgentUrl>" + buildAgentUrl + "</buildAgentUrl>" ),
"prepared-releases.xml was not populated" );
}
private String getPreparedReleasesContent()
throws IOException
{
File file = getPreparedReleasesFile();
Assert.assertTrue( file.exists(), "prepared-releases.xml was not created" );
FileInputStream fis = null;
BufferedReader reader = null;
try
{
fis = new FileInputStream( file );
reader = new BufferedReader( new InputStreamReader( fis ) );
String strLine;
StringBuilder str = new StringBuilder();
while ( ( strLine = reader.readLine() ) != null )
{
str.append( strLine );
}
return str.toString();
}
finally
{
IOUtils.closeQuietly( reader );
IOUtils.closeQuietly( fis );
}
}
private File getPreparedReleasesFile()
{
return new File( appserverBase, "conf/prepared-releases.xml" );
}
}
| 5,236 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenOneProjectTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on AddMavenOneProjectTestCase of Emmanuel Venisse.
*
* @author José Morales Martínez
*/
@Test( groups = {"mavenOneProject"} )
public class MavenOneProjectTest
extends AbstractAdminTest
{
private String pomUrl;
private String pomUsername;
private String projectGroupId;
private String projectGroupDescription;
private String projectGroupName;
private String pomPassword;
private String pomUrlMissingElement;
private String pomUrlWithExtend;
private String pomUrlUnparseableContent;
private String malformedPomUrl;
private String inaccessiblePomUrl;
@BeforeMethod
protected void setUp()
throws Exception
{
pomUrl = getProperty( "MAVEN1_POM_URL" );
pomUsername = getProperty( "MAVEN1_POM_USERNAME" );
pomPassword = getProperty( "MAVEN1_POM_PASSWORD" );
projectGroupName = getProperty( "MAVEN1_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN1_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN1_PROJECT_GROUP_DESCRIPTION" );
pomUrlMissingElement = getProperty( "MAVEN1_MISSING_REPO_POM_URL" );
pomUrlWithExtend = getProperty( "MAVEN1_EXTENDED_POM_URL" );
pomUrlUnparseableContent = getProperty( "MAVEN1_UNPARSEABLE_POM_URL" );
malformedPomUrl = "aaa";
inaccessiblePomUrl = baseUrl + "/inaccessible-pom/";
}
@AfterMethod
protected void tearDown()
{
removeProjectGroup( projectGroupName, false );
}
public void testAddMavenOneProjectToProjectGroup()
throws Exception
{
goToProjectGroupsSummaryPage();
String defaultProjectGroupName = getProperty( "DEFAULT_PROJECT_GROUP_NAME" );
clickLinkWithText( defaultProjectGroupName );
selectValue( "preferredExecutor", "Add M1 Project" );
clickButtonWithValue( "Add" );
assertAddMavenOneProjectPage( defaultProjectGroupName );
// rest is tested by other methods
}
public void testAddMavenOneProjectWithNoDefaultBuildDefinitionFromTemplate()
throws Exception
{
removeDefaultBuildDefinitionFromTemplate( "maven1" );
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
// Re-add default build definition of template
addDefaultBuildDefinitionFromTemplate( "maven1" );
}
/**
* test with valid pom url
*/
public void testValidPomUrl()
throws Exception
{
// Enter values into Add Maven Two Project fields, and submit
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
}
/**
* test with no pom file or pom url specified
*/
public void testNoPomSpecified()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( "", "", "", null, false );
assertTextPresent( "Either POM URL or Upload POM is required." );
}
/**
* test with missing <repository> element in the pom file
*/
public void testMissingElementInPom()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrlMissingElement, pomUsername, pomPassword, null, false );
assertTextPresent( "Missing 'repository' element in the POM." );
}
/**
* test with <extend> element present in pom file
*/
public void testWithExtendElementPom()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrlWithExtend, pomUsername, pomPassword, null, false );
assertTextPresent( "Cannot use a POM with an 'extend' element" );
}
/**
* test with unparseable xml content for pom file
*/
public void testUnparseableXmlContent()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrlUnparseableContent, pomUsername, pomPassword, null, false );
assertTextPresent( "The XML content of the POM can not be parsed." );
}
/**
* test with a malformed pom url
*/
public void testMalformedPomUrl()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( malformedPomUrl, "", "", null, false );
assertTextPresent(
"The specified resource cannot be accessed. Please try again later or contact your administrator." );
}
/**
* test with an inaccessible pom url
*/
public void testInaccessiblePomUrl()
throws Exception
{
goToAddMavenOneProjectPage();
addMavenOneProject( inaccessiblePomUrl, "", "", null, false );
assertTextPresent(
"POM file does not exist. Either the POM you specified or one of its modules does not exist." );
}
/**
* test cancel button
*/
public void testCancelButton()
{
goToAboutPage();
goToAddMavenOneProjectPage();
clickButtonWithValue( "Cancel" );
assertAboutPage();
}
public void testDeleteMavenOneProject()
throws Exception
{
// setup
goToProjectGroupsSummaryPage();
addMaven1Project( projectGroupName, pomUrl, pomUsername, pomPassword );
// delete project - delete icon
clickLinkWithText( projectGroupName );
clickLinkWithXPath( "//tbody/tr['0']/td['10']/a/img[@alt='Delete']" );
assertTextPresent( "Delete Continuum Project" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Project Group" );
assertLinkNotPresent( projectGroupName );
}
public void testDeleteMavenOneProjects()
throws Exception
{
// setup
goToProjectGroupsSummaryPage();
addMaven1Project( projectGroupName, pomUrl, pomUsername, pomPassword );
// delete project - "Delete Project(s)" button
clickLinkWithText( projectGroupName );
checkField( "//tbody/tr['0']/td['0']/input[@name='selectedProjects']" );
clickButtonWithValue( "Delete Project(s)" );
assertTextPresent( "Delete Continuum Projects" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Project Group" );
assertLinkNotPresent( projectGroupName );
}
private void addMaven1Project( String groupName, String pomUrl, String pomUsername, String pomPassword )
{
assertLinkNotPresent( groupName );
goToAddMavenOneProjectPage();
addMavenOneProject( pomUrl, pomUsername, pomPassword, null, true );
goToProjectGroupsSummaryPage();
assertLinkPresent( groupName );
}
}
| 5,237 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/PurgeTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractPurgeTest;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = {"purge"} )
public class PurgeTest
extends AbstractPurgeTest
{
public void testAddRepositoryPurge()
{
String PURGE_REPOSITORY_DESCRIPTION = getProperty( "PURGE_REPOSITORY_DESCRIPTION" );
String PURGE_REPOSITORY_DAYS = getProperty( "PURGE_REPOSITORY_DAYS" );
String PURGE_REPOSITORY_RETETION = getProperty( "PURGE_REPOSITORY_RETETION" );
goToAddRepositoryPurge();
addEditRepositoryPurge( PURGE_REPOSITORY_DAYS, PURGE_REPOSITORY_RETETION, PURGE_REPOSITORY_DESCRIPTION, true );
}
public void testAddInvalidRepositoryPurge()
{
String PURGE_REPOSITORY_DESCRIPTION = getProperty( "PURGE_REPOSITORY_DESCRIPTION" );
goToAddRepositoryPurge();
addEditRepositoryPurge( "", "", PURGE_REPOSITORY_DESCRIPTION, false );
assertTextPresent( "Retention Count must be greater than 0." );
}
@Test( dependsOnMethods = {"testAddRepositoryPurge"} )
public void testEditRepositoryPurge()
{
String PURGE_REPOSITORY_DESCRIPTION = getProperty( "PURGE_REPOSITORY_DESCRIPTION" );
String PURGE_REPOSITORY_DAYS = getProperty( "PURGE_REPOSITORY_DAYS" );
String PURGE_REPOSITORY_RETETION = getProperty( "PURGE_REPOSITORY_RETETION" );
String newDescription = "new_description";
String newDays = "45";
String newRetention = "4";
goToEditRepositoryPurge( PURGE_REPOSITORY_DAYS, PURGE_REPOSITORY_RETETION, PURGE_REPOSITORY_DESCRIPTION );
addEditRepositoryPurge( newDays, newRetention, newDescription, true );
goToEditRepositoryPurge( newDays, newRetention, newDescription );
addEditRepositoryPurge( PURGE_REPOSITORY_DAYS, PURGE_REPOSITORY_RETETION, PURGE_REPOSITORY_DESCRIPTION, true );
}
@Test( dependsOnMethods = {"testEditRepositoryPurge"} )
public void testDeleteRepositoryPurge()
{
String PURGE_REPOSITORY_DESCRIPTION = getProperty( "PURGE_REPOSITORY_DESCRIPTION" );
removeRepositoryPurge( PURGE_REPOSITORY_DESCRIPTION );
}
public void testAddDirectoryPurge()
{
String PURGE_DIRECTORY_DESCRIPTION = getProperty( "PURGE_DIRECTORY_DESCRIPTION" );
String PURGE_DIRECTORY_DAYS = getProperty( "PURGE_DIRECTORY_DAYS" );
String PURGE_DIRECTORY_RETETION = getProperty( "PURGE_DIRECTORY_RETETION" );
goToAddDirectoryPurge();
addEditDirectoryPurge( PURGE_DIRECTORY_DAYS, PURGE_DIRECTORY_RETETION, PURGE_DIRECTORY_DESCRIPTION, true );
}
public void testAddInvalidDirectoryPurge()
{
String PURGE_DIRECTORY_DESCRIPTION = getProperty( "PURGE_DIRECTORY_DESCRIPTION" );
goToAddDirectoryPurge();
addEditDirectoryPurge( "", "", PURGE_DIRECTORY_DESCRIPTION, false );
assertTextPresent( "Retention Count must be greater than 0." );
}
@Test( dependsOnMethods = {"testAddDirectoryPurge"} )
public void testEditDirectoryPurge()
{
String PURGE_DIRECTORY_DESCRIPTION = getProperty( "PURGE_DIRECTORY_DESCRIPTION" );
String PURGE_DIRECTORY_DAYS = getProperty( "PURGE_DIRECTORY_DAYS" );
String PURGE_DIRECTORY_RETETION = getProperty( "PURGE_DIRECTORY_RETETION" );
String newDescription = "new_description";
String newDays = "45";
String newRetention = "4";
goToEditDirectoryPurge( PURGE_DIRECTORY_DAYS, PURGE_DIRECTORY_RETETION, PURGE_DIRECTORY_DESCRIPTION );
addEditDirectoryPurge( newDays, newRetention, newDescription, true );
goToEditDirectoryPurge( newDays, newRetention, newDescription );
addEditDirectoryPurge( PURGE_DIRECTORY_DAYS, PURGE_DIRECTORY_RETETION, PURGE_DIRECTORY_DESCRIPTION, true );
}
@Test( dependsOnMethods = {"testEditDirectoryPurge"} )
public void testDeleteDirectoryPurge()
{
String PURGE_DIRECTORY_DESCRIPTION = getProperty( "PURGE_DIRECTORY_DESCRIPTION" );
removeDirectoryPurge( PURGE_DIRECTORY_DESCRIPTION );
}
}
| 5,238 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/NotifierTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* @author José Morales Martínez
*/
@Test( groups = { "notifier" } )
public class NotifierTest
extends AbstractAdminTest
{
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String projectName;
private String mailNotifierAddress;
private String ircNotifierHost;
private String ircNotifierChannel;
private String jabberNotifierHost;
private String jabberNotifierLogin;
private String jabberNotifierPassword;
private String jabberNotifierAddress;
private String msnNotifierAddress;
private String msnNotifierLogin;
private String msnNotifierPassword;
private String wagonNotifierUrl;
private String wagonServerId;
@BeforeClass
public void createProject()
{
projectGroupName = getProperty( "NOTIFIER_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "NOTIFIER_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "NOTIFIER_PROJECT_GROUP_DESCRIPTION" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
String projectPomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
loginAsAdmin();
removeProjectGroup( projectGroupName, false );
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, true );
clickLinkWithText( projectGroupName );
addMavenTwoProject( projectPomUrl, pomUsername, pomPassword, projectGroupName, true );
}
@BeforeMethod
protected void setUp()
throws Exception
{
mailNotifierAddress = getProperty( "MAIL_NOTIFIER_ADDRESS" );
ircNotifierHost = getProperty( "IRC_NOTIFIER_HOST" );
ircNotifierChannel = getProperty( "IRC_NOTIFIER_CHANNEL" );
jabberNotifierHost = getProperty( "JABBER_NOTIFIER_HOST" );
jabberNotifierLogin = getProperty( "JABBER_NOTIFIER_LOGIN" );
jabberNotifierPassword = getProperty( "JABBER_NOTIFIER_PASSWORD" );
jabberNotifierAddress = getProperty( "JABBER_NOTIFIER_ADDRESS" );
msnNotifierAddress = getProperty( "MSN_NOTIFIER_ADDRESS" );
msnNotifierLogin = getProperty( "MSN_NOTIFIER_LOGIN" );
msnNotifierPassword = getProperty( "MSN_NOTIFIER_PASSWORD" );
wagonNotifierUrl = getProperty( "WAGON_NOTIFIER_URL" );
wagonServerId = getProperty( "WAGON_SERVER_ID" );
}
public void testAddValidMailProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addMailNotifier( projectGroupName, projectName, mailNotifierAddress, true );
}
public void testAddValidMailProjectNotifierWithInvalidValue()
throws Exception
{
String mailNotifierAddress = "<script>alert('xss')</script>";
goToProjectNotifier( projectGroupName, projectName );
addMailNotifier( projectGroupName, projectName, mailNotifierAddress, false );
assertTextPresent( "Address is invalid" );
}
@Test( dependsOnMethods = { "testAddValidMailProjectNotifier" } )
public void testEditValidMailProjectNotifier()
throws Exception
{
String newMail = "newmail@mail.com";
goToProjectInformationPage( projectGroupName, projectName );
editMailNotifier( projectGroupName, projectName, mailNotifierAddress, newMail, true );
editMailNotifier( projectGroupName, projectName, newMail, mailNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMailProjectNotifier" } )
public void testEditInvalidMailProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
editMailNotifier( projectGroupName, projectName, mailNotifierAddress, "invalid_email_add", false );
}
public void testAddInvalidMailProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addMailNotifier( projectGroupName, projectName, "invalid_email_add", false );
}
public void testAddValidMailGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addMailNotifier( projectGroupName, null, mailNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMailGroupNotifier" } )
public void testEditValidMailGroupNotifier()
throws Exception
{
String newMail = "newmail@mail.com";
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editMailNotifier( projectGroupName, null, mailNotifierAddress, newMail, true );
editMailNotifier( projectGroupName, null, newMail, mailNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMailGroupNotifier" } )
public void testEditInvalidMailGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editMailNotifier( projectGroupName, null, mailNotifierAddress, "invalid_email_add", false );
}
public void testAddInvalidMailGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addMailNotifier( projectGroupName, null, "invalid_email_add", false );
}
public void testAddValidIrcProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addIrcNotifier( projectGroupName, projectName, ircNotifierHost, ircNotifierChannel, true );
}
public void testAddProjectNotifierWithInvalidValues()
throws Exception
{
String ircNotifierHost = "!@#$<>?etc";
String ircNotifierChannel = "!@#$<>?etc";
goToProjectNotifier( projectGroupName, projectName );
addIrcNotifier( projectGroupName, projectName, ircNotifierHost, ircNotifierChannel, false );
assertTextPresent( "Host contains invalid character" );
assertTextPresent( "Channel contains invalid character" );
}
@Test( dependsOnMethods = { "testAddValidIrcProjectNotifier" } )
public void testEditValidIrcProjectNotifier()
throws Exception
{
String newHost = "new.test.com";
String newChannel = "new_test_channel";
goToProjectInformationPage( projectGroupName, projectName );
editIrcNotifier( projectGroupName, projectName, ircNotifierHost, ircNotifierChannel, newHost, newChannel, true );
editIrcNotifier( projectGroupName, projectName, newHost, newChannel, ircNotifierHost, ircNotifierChannel, true );
}
@Test( dependsOnMethods = { "testAddValidIrcProjectNotifier" } )
public void testEditInvalidIrcProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
editIrcNotifier( projectGroupName, projectName, ircNotifierHost, ircNotifierChannel, "", "", false );
}
public void testAddInvalidIrcProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addIrcNotifier( projectGroupName, projectName, "", "", false );
assertTextPresent( "Host is required" );
assertTextPresent( "Channel is required" );
}
public void testAddValidIrcGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addIrcNotifier( projectGroupName, null, ircNotifierHost, ircNotifierChannel, true );
}
@Test( dependsOnMethods = { "testAddValidIrcGroupNotifier" } )
public void testEditValidIrcGroupNotifier()
throws Exception
{
String newHost = "new.test.com";
String newChannel = "new_test_channel";
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editIrcNotifier( projectGroupName, null, ircNotifierHost, ircNotifierChannel, newHost, newChannel, true );
editIrcNotifier( projectGroupName, null, newHost, newChannel, ircNotifierHost, ircNotifierChannel, true );
}
@Test( dependsOnMethods = { "testAddValidIrcGroupNotifier" } )
public void testEditInvalidIrcGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editIrcNotifier( projectGroupName, null, ircNotifierHost, ircNotifierChannel, "", "", false );
}
public void testAddInvalidIrcGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addIrcNotifier( projectGroupName, null, "", "", false );
assertTextPresent( "Host is required" );
assertTextPresent( "Channel is required" );
}
public void testAddValidJabberProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addJabberNotifier( projectGroupName, projectName, jabberNotifierHost, jabberNotifierLogin,
jabberNotifierPassword, jabberNotifierAddress, true );
}
public void testAddJabberProjectNotifierWithInvalidValues()
throws Exception
{
String jabberNotifierHost = "!@#$<>?etc";
String jabberNotifierAddress = "!@#$<>?etc";
goToProjectNotifier( projectGroupName, projectName );
addJabberNotifier( projectGroupName, projectName, jabberNotifierHost, jabberNotifierLogin,
jabberNotifierPassword, jabberNotifierAddress, false );
assertTextPresent( "Host contains invalid characters" );
assertTextPresent( "Address is invalid" );
}
@Test( dependsOnMethods = { "testAddValidJabberProjectNotifier" } )
public void testEditValidJabberProjectNotifier()
throws Exception
{
String newHost = "new_test";
String newLogin = "new_test_login";
String newPassword = "new_password";
String newAddress = "new.test@mail.com";
goToProjectInformationPage( projectGroupName, projectName );
editJabberNotifier( projectGroupName, projectName, jabberNotifierHost, jabberNotifierLogin,
jabberNotifierAddress, newHost, newLogin, newPassword, newAddress, true );
editJabberNotifier( projectGroupName, projectName, newHost, newLogin, newAddress, jabberNotifierHost,
jabberNotifierLogin, jabberNotifierPassword, jabberNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidJabberProjectNotifier" } )
public void testEditInvalidJabberProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
editJabberNotifier( projectGroupName, projectName, jabberNotifierHost, jabberNotifierLogin,
jabberNotifierAddress, "", "", "", "", false );
}
public void testAddInvalidJabberProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addJabberNotifier( projectGroupName, projectName, "", "", "", "", false );
assertTextPresent( "Host is required" );
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
public void testAddValidJabberGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addJabberNotifier( projectGroupName, null, jabberNotifierHost, jabberNotifierLogin, jabberNotifierPassword,
jabberNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidJabberGroupNotifier" } )
public void testEditValidJabberGroupNotifier()
throws Exception
{
String newHost = "new_test";
String newLogin = "new_test_login";
String newPassword = "new_password";
String newAddress = "new.test@mail.com";
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editJabberNotifier( projectGroupName, null, jabberNotifierHost, jabberNotifierLogin, jabberNotifierAddress,
newHost, newLogin, newPassword, newAddress, true );
editJabberNotifier( projectGroupName, null, newHost, newLogin, newAddress, jabberNotifierHost,
jabberNotifierLogin, jabberNotifierPassword, jabberNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidJabberGroupNotifier" } )
public void testEditInvalidJabberGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editJabberNotifier( projectGroupName, null, jabberNotifierHost, jabberNotifierLogin, jabberNotifierAddress, "",
"", "", "", false );
}
public void testAddInvalidJabberGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addJabberNotifier( projectGroupName, null, "", "", "", "", false );
assertTextPresent( "Host is required" );
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
public void testAddValidMsnProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addMsnNotifier( projectGroupName, projectName, msnNotifierLogin, msnNotifierPassword, msnNotifierAddress, true );
}
public void testAddMsnProjectNotifierWithInvalidValues()
throws Exception
{
String msnNotifierAddress = "!@#$<>?etc";
goToProjectNotifier( projectGroupName, projectName );
addMsnNotifier( projectGroupName, projectName, msnNotifierLogin, msnNotifierPassword, msnNotifierAddress,
false );
assertTextPresent( "Address is invalid" );
}
@Test( dependsOnMethods = { "testAddValidMsnProjectNotifier" } )
public void testEditValidMsnProjectNotifier()
throws Exception
{
String newLogin = "new_test_login";
String newPassword = "new_password";
String newAddress = "new.test@mail.com";
goToProjectInformationPage( projectGroupName, projectName );
editMsnNotifier( projectGroupName, projectName, msnNotifierLogin, msnNotifierAddress, newLogin, newPassword,
newAddress, true );
editMsnNotifier( projectGroupName, projectName, newLogin, newAddress, msnNotifierLogin, msnNotifierPassword,
msnNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMsnProjectNotifier" } )
public void testEditInvalidMsnProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
editMsnNotifier( projectGroupName, projectName, msnNotifierLogin, msnNotifierAddress, "", "", "", false );
}
public void testAddInvalidMsnProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addMsnNotifier( projectGroupName, projectName, "", "", "", false );
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
public void testAddValidMsnGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addMsnNotifier( projectGroupName, null, msnNotifierLogin, msnNotifierPassword, msnNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMsnGroupNotifier" } )
public void testEditValidMsnGroupNotifier()
throws Exception
{
String newLogin = "new_test_login";
String newPassword = "new_password";
String newAddress = "new.test@mail.com";
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editMsnNotifier( projectGroupName, null, msnNotifierLogin, msnNotifierAddress, newLogin, newPassword,
newAddress, true );
editMsnNotifier( projectGroupName, null, newLogin, newAddress, msnNotifierLogin, msnNotifierPassword,
msnNotifierAddress, true );
}
@Test( dependsOnMethods = { "testAddValidMsnGroupNotifier" } )
public void testEditInvalidMsnGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editMsnNotifier( projectGroupName, null, msnNotifierLogin, msnNotifierAddress, "", "", "", false );
}
public void testAddInvalidMsnGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addMsnNotifier( projectGroupName, null, "", "", "", false );
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
public void testAddValidWagonProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addWagonNotifierPage( projectGroupName, projectName, wagonNotifierUrl, wagonServerId, true );
}
public void testAddInvalidURLWagonProjectNotifier()
throws Exception
{
String wagonNotifierUrl = "!@#$<>?etc";
goToProjectNotifier( projectGroupName, projectName );
addWagonNotifierPage( projectGroupName, projectName, wagonNotifierUrl, wagonServerId, false );
assertTextPresent( "Destination URL is invalid" );
}
@Test( dependsOnMethods = { "testAddValidWagonProjectNotifier" } )
public void testEditValidWagonProjectNotifier()
throws Exception
{
String newId = "newId";
goToProjectInformationPage( projectGroupName, projectName );
editWagonNotifier( projectGroupName, projectName, wagonNotifierUrl, wagonServerId, wagonNotifierUrl, newId,
true );
editWagonNotifier( projectGroupName, projectName, wagonNotifierUrl, newId, wagonNotifierUrl, wagonServerId,
true );
}
@Test( dependsOnMethods = { "testAddValidWagonProjectNotifier" } )
public void testEditInvalidWagonProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
editWagonNotifier( projectGroupName, projectName, wagonNotifierUrl, wagonServerId, "", "", false );
}
public void testAddInvalidWagonProjectNotifier()
throws Exception
{
goToProjectNotifier( projectGroupName, projectName );
addWagonNotifierPage( projectGroupName, projectName, "", "", false );
assertTextPresent( "Destination URL is required" );
assertTextPresent( "Server Id is required" );
}
public void testAddValidWagonGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addWagonNotifierPage( projectGroupName, null, wagonNotifierUrl, wagonServerId, true );
}
@Test( dependsOnMethods = { "testAddValidWagonGroupNotifier" } )
public void testEditValidWagonGroupNotifier()
throws Exception
{
String newId = "newId";
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editWagonNotifier( projectGroupName, null, wagonNotifierUrl, wagonServerId, wagonNotifierUrl, newId, true );
editWagonNotifier( projectGroupName, null, wagonNotifierUrl, newId, wagonNotifierUrl, wagonServerId, true );
}
@Test( dependsOnMethods = { "testAddValidWagonGroupNotifier" } )
public void testEditInvalidWagonGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
editWagonNotifier( projectGroupName, null, wagonNotifierUrl, wagonServerId, "", "", false );
}
public void testAddInvalidWagonGroupNotifier()
throws Exception
{
goToGroupNotifier( projectGroupName, projectGroupId, projectGroupDescription );
addWagonNotifierPage( projectGroupName, null, "", "", false );
assertTextPresent( "Destination URL is required" );
assertTextPresent( "Server Id is required" );
}
@Test( dependsOnMethods = { "testEditValidMailGroupNotifier", "testEditInvalidMailGroupNotifier" } )
public void testDeleteGroupNotifier()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
clickLinkWithXPath( "(//a[contains(@href,'deleteProjectGroupNotifier') and contains(@href,'mail')])//img" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertGroupNotifierPage( projectGroupName );
}
@Test( dependsOnMethods = { "testEditValidMailProjectNotifier", "testEditInvalidMailProjectNotifier" } )
public void testDeleteProjectNotifier()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
// Delete
clickLinkWithXPath( "(//a[contains(@href,'deleteProjectNotifier') and contains(@href,'mail')])//img" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertProjectInformationPage();
}
public void testDeleteProjectNotifierFromGroupNotifierPage()
throws Exception
{
String mailNotifierAddress = "testDeleteProjectNotifierFromGroupNotifierPage@test.com";
goToProjectGroupsSummaryPage();
goToProjectNotifier( projectGroupName, projectName );
addMailNotifier( projectGroupName, projectName, mailNotifierAddress, true );
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
// Delete
clickLinkWithXPath( "//preceding::td[text()='" + mailNotifierAddress + "']//following::img[@alt='Delete']" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertGroupNotifierPage( projectGroupName );
assertTextNotPresent( mailNotifierAddress );
}
protected void assertGroupNotifierPage( String projectGroupName )
{
assertTextPresent( "Project Group Notifiers of group " + projectGroupName );
}
void assertAddNotifierPage()
{
assertPage( "Continuum - Add Notifier" );
assertTextPresent( "Add Notifier" );
assertTextPresent( "Type" );
assertElementPresent( "notifierType" );
assertElementPresent( "Cancel" );
}
void assertAddEditMailNotifierPage()
{
assertPage( "Continuum - Add/Edit Mail Notifier" );
assertTextPresent( "Add/Edit Mail Notifier" );
assertTextPresent( "Mail Recipient Address" );
assertTextPresent( "Send a mail to latest committers" );
assertTextPresent( "Send on Success" );
assertTextPresent( "Send on Failure" );
assertTextPresent( "Send on Error" );
assertTextPresent( "Send on Warning" );
assertTextPresent( "Send on SCM Failure" );
assertElementPresent( "address" );
assertElementPresent( "Cancel" );
}
void assertAddEditIrcNotifierPage()
{
assertPage( "Continuum - Add/Edit IRC Notifier" );
assertTextPresent( "IRC Host" );
assertElementPresent( "host" );
assertTextPresent( "IRC port" );
assertElementPresent( "port" );
assertTextPresent( "IRC channel" );
assertElementPresent( "channel" );
assertTextPresent( "Nick Name" );
assertElementPresent( "nick" );
assertTextPresent( "Alternate Nick Name" );
assertElementPresent( "alternateNick" );
assertTextPresent( "User Name" );
assertElementPresent( "username" );
assertTextPresent( "Full Name" );
assertElementPresent( "fullName" );
assertTextPresent( "Password" );
assertElementPresent( "password" );
assertTextPresent( "SSL" );
assertTextPresent( "Send on Success" );
assertTextPresent( "Send on Failure" );
assertTextPresent( "Send on Error" );
assertTextPresent( "Send on Warning" );
assertTextPresent( "Send on SCM Failure" );
}
void assertAddEditJabberPage()
{
assertPage( "Continuum - Add/Edit Jabber Notifier" );
assertTextPresent( "Jabber Host" );
assertElementPresent( "host" );
assertTextPresent( "Jabber port" );
assertElementPresent( "port" );
assertTextPresent( "Jabber login" );
assertElementPresent( "login" );
assertTextPresent( "Jabber Password" );
assertElementPresent( "password" );
assertTextPresent( "Jabber Domain Name" );
assertElementPresent( "domainName" );
assertTextPresent( "Jabber Recipient Address" );
assertElementPresent( "address" );
assertTextPresent( "Is it a SSL connection?" );
assertTextPresent( "Is it a Jabber group?" );
assertTextPresent( "Send on Success" );
assertTextPresent( "Send on Failure" );
assertTextPresent( "Send on Error" );
assertTextPresent( "Send on Warning" );
assertTextPresent( "Send on SCM Failure" );
}
void assertAddEditMsnPage()
{
assertPage( "Continuum - Add/Edit MSN Notifier" );
assertTextPresent( "MSN login" );
assertElementPresent( "login" );
assertTextPresent( "MSN Password" );
assertElementPresent( "password" );
assertTextPresent( "MSN Recipient Address" );
assertElementPresent( "address" );
assertTextPresent( "Send on Success" );
assertTextPresent( "Send on Failure" );
assertTextPresent( "Send on Error" );
assertTextPresent( "Send on Warning" );
assertTextPresent( "Send on SCM Failure" );
}
void assertAddEditWagonPage()
{
assertPage( "Continuum - Add/Edit Wagon Notifier" );
assertTextPresent( "Project Site URL" );
assertTextPresent( "Server Id (defined in your settings.xml for authentication)" );
assertElementPresent( "url" );
assertElementPresent( "id" );
assertTextPresent( "Send on Success" );
assertTextPresent( "Send on Failure" );
assertTextPresent( "Send on Error" );
assertTextPresent( "Send on Warning" );
}
protected void goToGroupNotifier( String projectGroupName, String projectGroupId, String projectGroupDescription )
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
clickLinkWithText( "Notifiers" );
assertGroupNotifierPage( projectGroupName );
clickButtonWithValue( "Add" );
assertAddNotifierPage();
}
protected void goToProjectNotifier( String projectGroupName, String projectName )
{
goToProjectInformationPage( projectGroupName, projectName );
clickLinkWithXPath( "//input[contains(@id,'addProjectNotifier') and @type='submit']" );
assertAddNotifierPage();
}
protected void addMailNotifier( String projectGroupName, String projectName, String email, boolean isValid )
{
selectValue( "//select", "Mail" );
clickButtonWithValue( "Submit" );
assertAddEditMailNotifierPage();
setFieldValue( "address", email );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Address is invalid" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
protected void editMailNotifier( String projectGroupName, String projectName, String oldMail, String newMail,
boolean isValid )
{
if ( projectName == null )
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'mail')])//img" );
}
else
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'mail')])//img" );
}
assertAddEditMailNotifierPage();
assertFieldValue( oldMail, "address" );
setFieldValue( "address", newMail );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Address is invalid" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
protected void addIrcNotifier( String projectGroupName, String projectName, String host, String channel,
boolean isValid )
{
selectValue( "//select", "IRC" );
clickButtonWithValue( "Submit" );
assertAddEditIrcNotifierPage();
setFieldValue( "host", host );
setFieldValue( "channel", channel );
clickButtonWithValue( "Save" );
if ( isValid )
{
if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
}
protected void editIrcNotifier( String projectGroupName, String projectName, String oldHost, String oldChannel,
String newHost, String newChannel, boolean isValid )
{
if ( projectName == null )
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'irc')])//img" );
}
else
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'irc')])//img" );
}
assertAddEditIrcNotifierPage();
assertFieldValue( oldHost, "host" );
assertFieldValue( oldChannel, "channel" );
setFieldValue( "host", newHost );
setFieldValue( "channel", newChannel );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Host is required" );
assertTextPresent( "Channel is required" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
protected void addJabberNotifier( String projectGroupName, String projectName, String host, String login,
String password, String address, boolean isValid )
{
selectValue( "//select", "Jabber" );
clickButtonWithValue( "Submit" );
assertAddEditJabberPage();
setFieldValue( "host", host );
setFieldValue( "login", login );
setFieldValue( "password", password );
setFieldValue( "address", address );
clickButtonWithValue( "Save" );
if ( isValid )
{
if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
}
protected void editJabberNotifier( String projectGroupName, String projectName, String oldHost, String oldLogin,
String oldAddress, String newHost, String newLogin, String newPassword,
String newAddress, boolean isValid )
{
if ( projectName == null )
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'jabber')])//img" );
}
else
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'jabber')])//img" );
}
assertAddEditJabberPage();
assertFieldValue( oldHost, "host" );
assertFieldValue( oldLogin, "login" );
assertFieldValue( oldAddress, "address" );
setFieldValue( "host", newHost );
setFieldValue( "login", newLogin );
setFieldValue( "password", newPassword );
setFieldValue( "address", newAddress );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Host is required" );
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
protected void addMsnNotifier( String projectGroupName, String projectName, String login, String password,
String recipientAddress, boolean isValid )
{
selectValue( "//select", "MSN" );
clickButtonWithValue( "Submit" );
assertAddEditMsnPage();
setFieldValue( "login", login );
setFieldValue( "password", password );
setFieldValue( "address", recipientAddress );
clickButtonWithValue( "Save" );
if ( isValid )
{
if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
}
protected void editMsnNotifier( String projectGroupName, String projectName, String oldLogin, String oldAddress,
String newLogin, String newPassword, String newAddress, boolean isValid )
{
if ( projectName == null )
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'msn')])//img" );
}
else
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'msn')])//img" );
}
assertAddEditMsnPage();
assertFieldValue( oldLogin, "login" );
assertFieldValue( oldAddress, "address" );
setFieldValue( "login", newLogin );
setFieldValue( "password", newPassword );
setFieldValue( "address", newAddress );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Login is required" );
assertTextPresent( "Password is required" );
assertTextPresent( "Address is required" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
protected void addWagonNotifierPage( String projectGroupName, String projectName, String siteUrl, String serverId,
boolean isValid )
{
selectValue( "//select", "Wagon" );
clickButtonWithValue( "Submit" );
assertAddEditWagonPage();
setFieldValue( "url", siteUrl );
setFieldValue( "id", serverId );
clickButtonWithValue( "Save" );
if ( isValid )
{
if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
}
protected void editWagonNotifier( String projectGroupName, String projectName, String oldUrl, String oldId,
String newUrl, String newId, boolean isValid )
{
if ( projectName == null )
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'wagon')])//img" );
}
else
{
clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'wagon')])//img" );
}
assertAddEditWagonPage();
assertFieldValue( oldUrl, "url" );
assertFieldValue( oldId, "id" );
setFieldValue( "url", newUrl );
setFieldValue( "id", newId );
clickButtonWithValue( "Save" );
if ( !isValid )
{
assertTextPresent( "Destination URL is required" );
assertTextPresent( "Server Id is required" );
}
else if ( projectName != null )
{
assertProjectInformationPage();
}
else
{
assertGroupNotifierPage( projectGroupName );
}
}
}
| 5,239 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Based on MyAccountTest of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
@Test( groups = {"myAccount"} )
public class MyAccountTest
extends AbstractAdminTest
{
private static final String NEW_FULL_NAME = "Admin_FullName";
private static final String NEW_EMAIL = "new_admin@mail.com";
public void testMyAccountEdit()
throws Exception
{
clickLinkWithText( "Edit Details" );
String email = getFieldValue( "user.email" );
String fullName = getFieldValue( "user.fullName" );
setFieldValue( "user.fullName", NEW_FULL_NAME );
setFieldValue( "user.email", NEW_EMAIL );
submit();
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
Assert.assertEquals( "Continuum - Group Summary", getTitle() );
clickLinkWithText( "Edit Details" );
assertFieldValue( NEW_FULL_NAME, "user.fullName" );
assertFieldValue( NEW_EMAIL, "user.email" );
setFieldValue( "user.fullName", fullName );
setFieldValue( "user.email", email );
submit();
clickLinkWithText( "Edit Details" );
assertFieldValue( fullName, "user.fullName" );
assertFieldValue( email, "user.email" );
}
}
| 5,240 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/InstallationTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractInstallationTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Arrays;
/**
* @author José Morales Martínez
*/
@Test( groups = {"installation"} )
public class InstallationTest
extends AbstractInstallationTest
{
private static final String JDK_VAR_NAME = "JDK";
private static final String MAVEN_VAR_NAME = "Maven";
private String jdkName;
private String jdkPath;
private String varName;
private String varVariableName;
private String varPath;
private String mavenName;
private String mavenPath;
private String varNameNoBE;
private String varNameOptions;
@BeforeMethod
protected void setUp()
throws Exception
{
jdkName = getProperty( "INSTALL_TOOL_JDK_NAME" );
jdkPath = getProperty( "INSTALL_TOOL_JDK_PATH" );
varName = getProperty( "INSTALL_VAR_NAME" );
varVariableName = getProperty( "INSTALL_VAR_VARIABLE_NAME" );
varPath = getProperty( "INSTALL_VAR_PATH" );
mavenName = getProperty( "INSTALL_TOOL_MAVEN_NAME" );
mavenPath = getProperty( "INSTALL_TOOL_MAVEN_PATH" );
varNameNoBE = "var_without_build_environment";
varNameOptions = "var_with_options";
}
@AfterClass
public void cleanup()
{
for ( String installation : Arrays.asList( jdkName, varName, mavenName, varNameNoBE, varNameOptions ) )
{
removeInstallation( installation, false );
removeBuildEnvironment( installation, false );
}
}
public void testAddJdkToolWithoutBuildEnvironment()
{
goToAddInstallationTool();
addInstallation( jdkName, JDK_VAR_NAME, jdkPath, false, true, true );
}
public void testAddJdkToolWithoutBuildEnvironmentWithInvalidValues()
{
String jdkName = "!@#$<>?etc";
String jdkPath = "!@#$<>?etc";
goToAddInstallationTool();
addInstallation( jdkName, JDK_VAR_NAME, jdkPath, false, true, false );
assertTextPresent( "Installation name contains invalid characters." );
assertTextPresent( "Installation value contains invalid characters." );
}
public void testAddMavenToolWithBuildEnvironment()
{
goToAddInstallationTool();
addInstallation( mavenName, MAVEN_VAR_NAME, mavenPath, true, true, true );
// TODO: Validate build environment
}
public void testAddInstallationVariableWithBuildEnvironment()
{
goToAddInstallationVariable();
addInstallation( varName, varVariableName, varPath, true, false, true );
// TODO: Validate build environment
}
public void testAddInstallationVariableWithoutBuildEnvironment()
{
String varVariableName = "var_name";
String varPath = "path";
goToAddInstallationVariable();
addInstallation( varNameNoBE, varVariableName, varPath, false, false, true );
}
public void testAddInstallationVariableWithOtherOptions()
{
String varVariableName = "JAVA_OPTS";
String varPath = "-XX:+CompressedOops";
goToAddInstallationVariable();
addInstallation( varNameOptions, varVariableName, varPath, false, false, true );
}
public void testAddInstallationVariableWithoutBuildEnvironmentWithInvalidValues()
{
String varName = "!@#$<>?etc";
String varVariableName = "!@#$<>?etc";
String varPath = "!@#$<>?etc";
goToAddInstallationVariable();
addInstallation( varName, varVariableName, varPath, false, false, false );
assertTextPresent( "Installation name contains invalid characters." );
assertTextPresent( "Environment variable name contains invalid characters." );
assertTextPresent( "Installation value contains invalid characters." );
}
public void testAddInvalidInstallationTool()
{
goToAddInstallationTool();
addInstallation( "", JDK_VAR_NAME, "", false, true, false );
assertTextPresent( "You must define a name" );
assertTextPresent( "You must define a value" );
}
public void testAddInvalidPathInstallationTool()
{
goToAddInstallationTool();
addInstallation( "name", JDK_VAR_NAME, "invalid_path", false, true, false );
assertTextPresent( "Failed to validate installation, check server log" );
}
public void testAddInvalidInstallationVariable()
{
goToAddInstallationVariable();
addInstallation( "", "", "", false, false, false );
assertTextPresent( "You must define a name" );
assertTextPresent( "You must define a value" );
}
public void testAddInvalidVarNameInstallationVariable()
{
goToAddInstallationVariable();
addInstallation( "name", "", "path", false, false, false );
assertTextPresent( "You must define an environment variable" );
}
@Test( dependsOnMethods = {"testAddJdkToolWithoutBuildEnvironment"} )
public void testAddDuplicatedInstallationTool()
{
goToAddInstallationTool();
addInstallation( jdkName, JDK_VAR_NAME, jdkPath, false, true, false );
assertTextPresent( "Installation name already exists" );
}
@Test( dependsOnMethods = {"testAddInstallationVariableWithBuildEnvironment"} )
public void testAddDuplicatedInstallationVariable()
{
goToAddInstallationVariable();
addInstallation( varName, varVariableName, varPath, false, false, false );
assertTextPresent( "Installation name already exists" );
}
@Test( dependsOnMethods = {"testAddJdkToolWithoutBuildEnvironment"} )
public void testEditInstallationTool()
{
String newName = "new_name";
goToEditInstallation( jdkName, JDK_VAR_NAME, jdkPath, true );
editInstallation( newName, JDK_VAR_NAME, jdkPath, true, true );
goToEditInstallation( newName, JDK_VAR_NAME, jdkPath, true );
editInstallation( jdkName, JDK_VAR_NAME, jdkPath, true, true );
}
@Test( dependsOnMethods = {"testAddInstallationVariableWithBuildEnvironment"} )
public void testEditInstallationVariable()
{
String newName = "new_name";
String newVarName = "new_var_name";
String newPath = "new_path";
goToEditInstallation( varName, varVariableName, varPath, false );
editInstallation( newName, newVarName, newPath, false, true );
goToEditInstallation( newName, newVarName, newPath, false );
editInstallation( varName, varVariableName, varPath, false, true );
}
@Test( dependsOnMethods = {"testEditInstallationTool", "testAddDuplicatedInstallationTool"} )
public void testDeleteInstallationTool()
{
removeInstallation( jdkName, true );
}
@Test( dependsOnMethods = {"testEditInstallationVariable", "testAddDuplicatedInstallationVariable"} )
public void testDeleteInstallationVariable()
{
removeInstallation( varName, true );
}
}
| 5,241 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.testng.Assert.assertTrue;
/**
* @author José Morales Martínez
*/
@Test( groups = { "buildDefinition" } )
public class BuildDefinitionTest
extends AbstractAdminTest
{
private String defaultProjectGroupName;
private String defaultProjectGroupId;
private String defaultProjectGroupDescription;
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String buildDefinitionPomName;
private String buildDefinitionGoals;
private String buildDefinitionArguments;
private String buildDefinitionDescription;
private String projectName;
private String antProjectName;
private String buildDefinitionId;
@BeforeClass
public void createProject()
{
projectGroupName = getProperty( "BUILD_DEFINITION_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "BUILD_DEFINITION_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "BUILD_DEFINITION_PROJECT_GROUP_DESCRIPTION" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
String projectPomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
antProjectName = getProperty( "BUILD_DEFINITION_ANT_PROJECT_NAME" );
String antProjectDescription = getProperty( "ANT_DESCRIPTION" );
String antProjectVersion = getProperty( "ANT_VERSION" );
String antProjectTag = getProperty( "ANT_TAG" );
String antScmUrl = getProperty( "ANT_SCM_URL" );
String antScmUsername = getProperty( "ANT_SCM_USERNAME" );
String antScmPassword = getProperty( "ANT_SCM_PASSWORD" );
loginAsAdmin();
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
clickLinkWithText( projectGroupName );
if ( !isLinkPresent( projectName ) )
{
addMavenTwoProject( projectPomUrl, pomUsername, pomPassword, projectGroupName, true );
}
if ( !isLinkPresent( antProjectName ) )
{
goToAddAntProjectPage();
addProject( antProjectName, antProjectDescription, antProjectVersion, antScmUrl, antScmUsername,
antScmPassword, antProjectTag, projectGroupName, true, "ant" );
}
}
@BeforeMethod
protected void setUp()
throws Exception
{
defaultProjectGroupName = getProperty( "DEFAULT_PROJECT_GROUP_NAME" );
defaultProjectGroupId = getProperty( "DEFAULT_PROJECT_GROUP_ID" );
defaultProjectGroupDescription = getProperty( "DEFAULT_PROJECT_GROUP_DESCRIPTION" );
buildDefinitionPomName = getProperty( "BUILD_DEFINITION_POM_NAME" );
buildDefinitionGoals = getProperty( "BUILD_DEFINITION_GOALS" );
buildDefinitionArguments = getProperty( "BUILD_DEFINITION_ARGUMENTS" );
buildDefinitionDescription = getProperty( "BUILD_DEFINITION_DESCRIPTION" );
}
public void testDefaultGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( defaultProjectGroupName, defaultProjectGroupId, defaultProjectGroupDescription );
String tableElement = "ec_table";
assertCellValueFromTable( "Goals", tableElement, 0, 0 );
assertCellValueFromTable( "Arguments", tableElement, 0, 1 );
assertCellValueFromTable( "Build File", tableElement, 0, 2 );
assertCellValueFromTable( "Schedule", tableElement, 0, 3 );
assertCellValueFromTable( "Build Environment", tableElement, 0, 4 );
assertCellValueFromTable( "From", tableElement, 0, 5 );
assertCellValueFromTable( "Build Fresh", tableElement, 0, 6 );
assertCellValueFromTable( "Default", tableElement, 0, 7 );
assertCellValueFromTable( "Description", tableElement, 0, 8 );
assertCellValueFromTable( "Type", tableElement, 0, 9 );
assertCellValueFromTable( "Always Build", tableElement, 0, 10 );
assertCellValueFromTable( "clean install", tableElement, 1, 0 );
assertCellValueFromTable( "--batch-mode --non-recursive", tableElement, 1, 1 );
assertCellValueFromTable( "pom.xml", tableElement, 1, 2 );
assertCellValueFromTable( "DEFAULT_SCHEDULE", tableElement, 1, 3 );
assertCellValueFromTable( "GROUP", tableElement, 1, 5 );
assertCellValueFromTable( "false", tableElement, 1, 6 );
assertCellValueFromTable( "true", tableElement, 1, 7 );
assertCellValueFromTable( "Default Maven Build Definition", tableElement, 1, 8 );
assertCellValueFromTable( "maven2", tableElement, 1, 9 );
assertCellValueFromTable( "false", tableElement, 1, 10 );
assertImgWithAlt( "Edit" );
assertImgWithAlt( "Delete" );
assertImgWithAlt( "Build" );
}
public void testAddInvalidGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickButtonWithValue( "Add" );
setFieldValue( "buildFile", "" );
setFieldValue( "goals", "" );
clickButtonWithValue( "Save" );
assertTextPresent( "Build file is required and cannot contain spaces only" );
assertTextPresent( "Goals are required" );
}
public void testAddGroupBuildDefinitionWithXSS()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickButtonWithValue( "Add" );
setFieldValue( "buildFile", "<script>alert('xss')</script>" );
setFieldValue( "description", "<script>alert('xss')</script>" );
clickButtonWithValue( "Save" );
assertTextPresent( "Build file contains invalid characters." );
}
public void testBuildFromGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickImgWithAlt( "Build" );
assertGroupBuildDefinitionPage( projectGroupName );
assertTextPresent( "successfully queued builds" );
}
public void testAddDefaultGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickButtonWithValue( "Add" );
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, buildDefinitionDescription, true, false, true,
MAVEN_PROJECT_TYPE, true );
}
public void testAddNotDefaultGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickButtonWithValue( "Add" );
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, buildDefinitionDescription, false, false, false,
MAVEN_PROJECT_TYPE, true );
}
@Test( dependsOnMethods = { "testAddNotDefaultGroupBuildDefinition" } )
public void testEditGroupBuildDefinition()
throws Exception
{
String newPom = "newpom.xml";
String newGoals = "new goals";
String newArguments = "new arguments";
String newDescription = "new description";
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickImgWithAlt( "Edit" );
addEditGroupBuildDefinition( projectGroupName, newPom, newGoals, newArguments, newDescription, false, false,
false, MAVEN_PROJECT_TYPE, true );
clickImgWithAlt( "Edit" );
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, buildDefinitionDescription, true, true, false,
MAVEN_PROJECT_TYPE, true );
clickImgWithAlt( "Edit" );
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, buildDefinitionDescription, false, true, false,
MAVEN_PROJECT_TYPE, true );
}
@Test( dependsOnMethods = { "testEditGroupBuildDefinition" } )
public void testDeleteGroupBuildDefinition()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
// Click in Delete Image
clickLinkWithXPath( "(//a[contains(@href,'removeGroupBuildDefinition')])//img" );
assertDeleteBuildDefinitionPage( buildDefinitionDescription, buildDefinitionGoals );
clickButtonWithValue( "Delete" );
assertGroupBuildDefinitionPage( projectGroupName );
}
public void testAddNotDefaultProjectBuildDefinition()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
addEditGroupBuildDefinition( null, buildDefinitionPomName, buildDefinitionGoals, buildDefinitionArguments,
buildDefinitionDescription, false, false, false, MAVEN_PROJECT_TYPE, true );
String value = getSelenium().getAttribute(
"xpath=(//a[contains(@href,'removeProjectBuildDefinition')])[last()]/@href" );
Matcher m = Pattern.compile( "^.*buildDefinitionId=([0-9]+).*$" ).matcher( value );
assertTrue( m.matches() );
buildDefinitionId = m.group( 1 );
}
public void testAddNotDefaultProjectBuildDefinitionWithLongMavenGoal()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
addEditGroupBuildDefinition( null, buildDefinitionPomName,
"clean org.apache.maven.plugins:maven-compile-plugin:2.4:compile",
buildDefinitionArguments, buildDefinitionDescription, false, false, false,
MAVEN_PROJECT_TYPE, true );
}
@Test( dependsOnMethods = { "testAddNotDefaultProjectBuildDefinition" } )
public void testDeleteProjectBuildDefinition()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
// Click in Delete Image
String locator = "id=remove-build-definition-" + buildDefinitionId;
assertElementPresent( locator );
clickLinkWithLocator( locator );
assertDeleteBuildDefinitionPage( buildDefinitionDescription, buildDefinitionGoals );
clickButtonWithValue( "Delete" );
assertProjectInformationPage();
assertElementNotPresent( locator );
}
public void testAddNotDefaultProjectBuildDefinitionAnt()
throws Exception
{
goToProjectInformationPage( projectGroupName, antProjectName );
clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
addEditGroupBuildDefinition( null, "build-other.xml", "package", "", "other build file", false, false, false,
ANT_PROJECT_TYPE, true );
}
public void testAddNotDefaultProjectBuildDefinitionAntWithPathBuildFile()
throws Exception
{
goToProjectInformationPage( projectGroupName, antProjectName );
clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
addEditGroupBuildDefinition( null, "Quartz/path\\build.xml", "package", "", "build file with path", false,
false, false, ANT_PROJECT_TYPE, true );
}
public void testAddNotDefaultProjectBuildDefinitionAntWithInvalidBuildFile()
throws Exception
{
goToProjectInformationPage( projectGroupName, antProjectName );
clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
addEditGroupBuildDefinition( null, "<script>alert('xss');</script>", "package", "", "invalid build file",
false, false, false, ANT_PROJECT_TYPE, false );
assertTextPresent( "Build file contains invalid characters" );
// confirm error page contains the right fields still
assertTextPresent( "Ant build filename*:" );
assertTextPresent( "Targets:" );
}
public void testEditBuildDefinitionFromSummary()
throws Exception
{
goToProjectInformationPage( projectGroupName, projectName );
clickLinkWithLocator( "buildDefinition_0" ); // Add button for project build definition
String description = "testEditBuildDefinitionFromSummary";
addEditGroupBuildDefinition( null, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, description, false, false,
false, MAVEN_PROJECT_TYPE, true );
assertProjectInformationPage();
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
addEditGroupBuildDefinition( null, buildDefinitionPomName, "new goals", buildDefinitionArguments,
description, false, false, false, MAVEN_PROJECT_TYPE, true );
assertProjectInformationPage();
assertTextPresent( "new goals" );
}
public void testEditGroupBuildDefinitionFromSummary()
throws Exception
{
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickButtonWithValue( "Add" );
String description = "testEditGroupBuildDefinitionFromSummary";
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, buildDefinitionGoals,
buildDefinitionArguments, description, false, false,
false, MAVEN_PROJECT_TYPE, true );
goToProjectInformationPage( projectGroupName, projectName );
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
addEditGroupBuildDefinition( projectGroupName, buildDefinitionPomName, "new goals", buildDefinitionArguments,
description, false, false, false, MAVEN_PROJECT_TYPE, true );
assertTextPresent( "new goals" );
}
}
| 5,242 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractUserRolesManagementTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
@Test( groups = {"userroles"}, sequential = true )
public class UserRolesManagementTest
extends AbstractUserRolesManagementTest
{
public static final String TEST_GROUP = "UserRoles Test Group";
private List<String> usernames = new ArrayList<String>();
public void testBasicAddDeleteUser()
{
username = getProperty( "GUEST_USERNAME" );
fullname = getProperty( "GUEST_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
deleteUser( username );
clickLinkWithText( "Logout" );
}
/*
* GUEST USER ROLE
* Guest Role could only view the About Page. Project Groups should not be shown when clicking
* Show Project Group link.
*/
@Test( dependsOnMethods = {"testBasicAddDeleteUser"} )
public void testAddUserWithGuestRole()
{
username = getProperty( "GUEST_USERNAME" );
fullname = getProperty( "GUEST_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
//checkUserRoleWithValue( fullname );
clickLinkWithLocator( "addRolesToUser_addNDSelectedRoles", false );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
//assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testAddUserWithGuestRole"} )
public void testGuestUserRoleFunction()
{
username = getProperty( "GUEST_USERNAME" );
fullname = getProperty( "GUEST_FULLNAME" );
loginAs( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
goToAboutPage();
clickLinkWithText( "Show Project Groups" );
assertTextPresent( "Project Groups list is empty" );
clickLinkWithText( "Logout" );
}
/*
* REGISTERED USER ROLE
* Registered User Role could only view the About Page. Project Groups should not be shown when clicking
* Show Project Group link.
*/
@Test( dependsOnMethods = {"testBasicAddDeleteUser", "testGuestUserRoleFunction"} )
public void testAddUserWithRegisteredUserRole()
{
username = getProperty( "REGISTERED_USERNAME" );
fullname = getProperty( "REGISTERED_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
// assertTextPresent("You are already logged in.");
}
@Test( dependsOnMethods = {"testAddUserWithRegisteredUserRole"} )
public void testRegisteredRoleFunction()
{
username = getProperty( "REGISTERED_USERNAME" );
fullname = getProperty( "REGISTERED_FULLNAME" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
goToAboutPage();
clickLinkWithText( "Show Project Groups" );
assertTextPresent( "Project Groups list is empty." );
clickLinkWithText( "Logout" );
}
/*
* SYSTEM ADMINISTRATOR ROLE
* Has access to all functions in the application.
*
* The following tests only asserts elements that could be shown
* when system admin user is logged in since the user that is used
* to test the other functionalities is a system admin user.
*/
@Test( dependsOnMethods = {"testBasicAddDeleteUser", "testRegisteredRoleFunction"} )
public void testAddUserWithSystemAdminRole()
{
username = getProperty( "SYSAD_USERNAME" );
fullname = getProperty( "SYSAD_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testAddUserWithSystemAdminRole"} )
public void testSystemAdminRoleFunction()
{
username = getProperty( "SYSAD_USERNAME" );
fullname = getProperty( "SYSAD_FULLNAME" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Show Project Groups" );
assertTextNotPresent( "Project Groups list is empty." );
assertLinkPresent( "Default Project Group" );
clickLinkWithText( "Logout" );
}
/*
* USER ADMIN ROLE
* User Admin role could only add/edit/delete users and can view user Roles. Cannot view Project Groups
* but can assign a User to a project.
*
*/
@Test( dependsOnMethods = {"testBasicAddDeleteUser", "testSystemAdminRoleFunction"} )
public void testAddUserWithUserAdminRole()
{
username = getProperty( "USERADMIN_USERNAME" );
fullname = getProperty( "USERADMIN_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testAddUserWithUserAdminRole"} )
public void testUserAdminFunction()
{
username = getProperty( "USERADMIN_USERNAME" );
fullname = getProperty( "USERADMIN_FULLNAME" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Show Project Groups" );
assertTextPresent( "Project Groups list is empty." );
// add user
clickLinkWithText( "Users" );
clickButtonWithValue( "Create New User" );
assertCreateUserPage();
setFieldValue( "user.username", "guest0" );
setFieldValue( "user.fullName", "guest0" );
setFieldValue( "user.email", "guest0@guest0.com" );
setFieldValue( "user.password", "pass" );
setFieldValue( "user.confirmPassword", "pass" );
submit();
assertUserRolesPage();
clickButtonWithValue( "Submit" );
selectValue( "name=ec_rd", "50" );
waitPage();
// delete user
deleteUser( "guest0" );
// TODO edit user
clickLinkWithText( "Logout" );
}
/*
* CONTINUUM GROUP PROJECT ADMIN
* - Can Add/Edit/Delete Project Group, can Add/Edit/Delete projects, can assign Users
* roles to existing projects, can add/edit/delete schedules, can view existing roles for the
* projects, can build/release projects
* - Cannot add users, --- --- ---
*/
@Test( dependsOnMethods = {"testBasicAddDeleteUser", "testUserAdminFunction"} )
public void testAddUserWithContinuumGroupProjectAdminRole()
{
username = getProperty( "GROUPPROJECTADMIN_USERNAME" );
fullname = getProperty( "GROUPPROJECTADMIN_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
// enable distributed build
clickLinkWithText( "Configuration" );
checkField( "distributedBuildEnabled" );
clickButtonWithValue( "Save" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
assertProjectAdministratorAccess();
clickLinkWithText( "Logout" );
loginAsAdmin();
// disable distributed build
clickLinkWithText( "Configuration" );
uncheckField( "distributedBuildEnabled" );
clickButtonWithValue( "Save" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertProjectAdministratorAccess();
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testAddUserWithContinuumGroupProjectAdminRole"} )
public void testContinuumGroupProjectAdmin_AddProjectGroup()
throws Exception
{
username = getProperty( "GROUPPROJECTADMIN_USERNAME" );
fullname = getProperty( "GROUPPROJECTADMIN_FULLNAME" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Show Project Groups" );
assertTextNotPresent( "Project Groups list is empty." );
// test add project group
clickButtonWithValue( "Add Project Group" );
setFieldValue( "name", TEST_GROUP );
setFieldValue( "groupId", TEST_GROUP );
setFieldValue( "description", "testing project group" );
submit();
}
@Test( dependsOnMethods = {"testContinuumGroupProjectAdmin_AddProjectGroup"} )
public void testContinuumGroupProjectAdmin_AddProjectToProjectGroup()
throws Exception
{
clickLinkWithText( TEST_GROUP );
clickButtonWithValue( "Add" );
assertAddMavenTwoProjectPage();
setFieldValue( "m2PomUrl", getProperty( "M2_POM_URL" ) );
clickButtonWithValue( "Add" );
waitAddProject( "Continuum - Project Group" );
assertTextPresent( "ContinuumBuildQueueTestData" );
waitForProjectCheckout();
}
@Test( dependsOnMethods = {"testContinuumGroupProjectAdmin_AddProjectToProjectGroup"} )
public void testContinuumGroupProjectAdmin_BuildProject()
throws Exception
{
buildProjectGroup( TEST_GROUP, TEST_GROUP, "testing project group", "ContinuumBuildQueueTestData", true );
}
@Test( dependsOnMethods = {"testContinuumGroupProjectAdmin_BuildProject"} )
public void testContinuumGroupProjectAdmin_AssignUserToAGroup()
{
clickLinkWithText( "Users" );
clickLinkWithText( "guest1" );
clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( "Guest" );
checkResourceRoleWithValue( "Project Developer - " + TEST_GROUP );
submit();
clickLinkWithText( "Logout" );
}
/*
* Uncomment the lines below to release a Project provided that you add
* the values under RELEASE A PROJECT in testng.properties file (project's pom url, access to project to be released.)
@Test( dependsOnMethods = { "testContinuumGroupProjectAdmin_AssignUserToAGroup" } )
public void testContinuumGroupProjectAdmin_ReleaseProject() throws Exception
{
String projectUrl = getProperty( "PROJECT_URL_TO_BE_RELEASED" );
String projectName = getProperty( "PROJECT_NAME_TO_BE_RELEASED" );
String projectUsername = getProperty( "PROJECT_USERNAME" );
String projectPassword = getProperty( "PROJECT_USERNAME" );
// add a project group
clickLinkWithText( "Show Project Groups" );
clickButtonWithValue( "Add Project Group" );
setFieldValue( "name", "Project Group" );
setFieldValue( "groupId", "Project Group" );
setFieldValue( "description", "project group for projects to be released" );
submit();
// add a project to a project group
clickLinkWithText( "Project Group" );
clickButtonWithValue( "Add" );
assertAddMavenTwoProjectPage();
setFieldValue( "m2PomUrl", projectUrl );
// set username and password here
setFieldValue( "scmUsername", projectUsername );
setFieldValue( "scmPassword", projectPassword );
clickButtonWithValue( "Add" );
String title;
boolean success = true;
if ( success )
{
title = "Continuum - Project Group";
}
else
{
title = "Continuum - Add Maven Project";
}
waitAddProject( title );
// build the project added in the project group
buildProjectGroup( "Project Group", "Project Group", "project group for projects to be released", projectName );
// release the project
clickButtonWithValue( "Release" );
clickLinkWithText( "Logout" );
login( getAdminUsername(), getAdminPassword() );
}
*/
@Test( dependsOnMethods = {"testContinuumGroupProjectAdmin_AssignUserToAGroup"} )
public void testUserWithContinuumGroupProjectDeveloperRole()
{
username = getProperty( "GROUPPROJECTDEVELOPER_USERNAME" );
fullname = getProperty( "GROUPPROJECTDEVELOPER_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumGroupProjectDeveloperRole"} )
public void testUserWithContinuumGroupProjectUserRole()
{
username = getProperty( "GROUPPROJECTUSER_USERNAME" );
fullname = getProperty( "GROUPPROJECTUSER_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumGroupProjectUserRole"} )
public void testUserWithContinuumManageBuildEnvironmentRole()
{
username = getProperty( "MANAGEBUILDENVIRONMENT_USERNAME" );
fullname = getProperty( "MANAGEBUILDENVIRONMENT_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageBuildEnvironmentRole"} )
public void testUserWithContinuumManageBuildTemplatesRole()
{
username = getProperty( "MANAGEBUILDTEMPLATES_USERNAME" );
fullname = getProperty( "MANAGEBUILDTEMPLATES_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageBuildTemplatesRole"} )
public void testUserWithContinuumManageInstallationsRole()
{
username = getProperty( "MANAGEINSTALLATIONS_USERNAME" );
fullname = getProperty( "MANAGEINSTALLATIONS_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageInstallationsRole"} )
public void testUserWithContinuumManageLocalRepoRole()
{
username = getProperty( "MANAGELOCALREPOS_USERNAME" );
fullname = getProperty( "MANAGELOCALREPOS_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageLocalRepoRole"} )
public void testUserWithContinuumManagePurgingRole()
{
username = getProperty( "MANAGEPURGING_USERNAME" );
fullname = getProperty( "MANAGEPURGING_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManagePurgingRole"} )
public void testUserWithContinuumManageQueuesRole()
{
username = getProperty( "MANAGEQUEUES_USERNAME" );
fullname = getProperty( "MANAGEQUEUES_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageQueuesRole"} )
public void testUserWithContinuumManageSchedulingRole()
{
username = getProperty( "MANAGESCHEDULING_USERNAME" );
fullname = getProperty( "MANAGESCHEDULING_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithContinuumManageSchedulingRole"} )
public void testUserWithProjectAdminDefaultProjectGroup()
{
username = getProperty( "PROJECTADMINISTRATOR_DEFAULTPROJECTGROUP_USERNAME" );
fullname = getProperty( "PROJECTADMINISTRATOR_DEFAULTPROJECTGROUP_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkResourceRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithProjectAdminDefaultProjectGroup"} )
public void testUserWithProjectDevDefaultProjectGroup()
{
username = getProperty( "PROJECTDEVELOPER_DEFAULTPROJECTGROUP_USERNAME" );
fullname = getProperty( "PROJECTDEVELOPER_DEFAULTPROJECTGROUP_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkResourceRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@Test( dependsOnMethods = {"testUserWithProjectDevDefaultProjectGroup"} )
public void testUserWithProjectUserDefaultProjectGroup()
{
username = getProperty( "PROJECTUSER_DEFAULTPROJECTGROUP_USERNAME" );
fullname = getProperty( "PROJECTUSER_DEFAULTPROJECTGROUP_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword() );
assertCreatedUserInfo( username );
checkResourceRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
clickLinkWithText( "Logout" );
login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword() );
assertTextPresent( "Password successfully changed" );
clickLinkWithText( "Logout" );
login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname );
clickLinkWithText( "Logout" );
}
@AfterMethod
public void trackUserToDelete()
{
// record to delete at end, as some are used across dependent tests
// TODO: refactor!
usernames.add( username );
}
@AfterClass
public void cleanup()
{
loginAsAdmin();
if ( !isTextPresent( "List of Users" ) )
{
clickLinkWithText( "Users" );
}
for ( String username : usernames )
{
deleteUser( username, false );
}
removeProjectGroup( TEST_GROUP, false );
}
}
| 5,243 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractContinuumTest;
import org.testng.annotations.Test;
/**
* Based on AboutTest of Wendy Smoak test.
*
* @author José Morales Martínez
*/
@Test( groups = {"about"}, alwaysRun = true )
public class AboutTest
extends AbstractContinuumTest
{
public void displayAboutPage()
{
goToAboutPage();
}
} | 5,244 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on AddMavenTwoProjectTest of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
@Test( groups = { "mavenTwoProject" } )
public class MavenTwoProjectTest
extends AbstractAdminTest
{
private String pomUrl;
private String pomUsername;
private String pomPassword;
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String projectGroupScmRootUrl;
private String projectName;
@BeforeMethod
protected void setUp()
throws Exception
{
pomUrl = getProperty( "MAVEN2_POM_URL" );
pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
projectGroupName = getProperty( "MAVEN2_POM_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN2_POM_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN2_POM_PROJECT_GROUP_DESCRIPTION" );
projectGroupScmRootUrl = getProperty( "MAVEN2_POM_PROJECT_GROUP_SCM_ROOT_URL" );
}
@AfterMethod
public void tearDown()
{
removeProjectGroup( projectGroupName, false );
}
public void testAddMavenTwoProject()
throws Exception
{
// Enter values into Add Maven Two Project fields, and submit
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
// Wait Struts Listener
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
assertTextPresent( projectGroupScmRootUrl );
}
@Test( dependsOnMethods = { "testAddMavenTwoProject" } )
public void testEditProjectName()
throws Exception
{
// Create a project to use
testAddMavenTwoProject();
// Navigate to project's edit page
clickLinkWithText(projectName);
clickButtonWithValue("Edit");
assertPage("Continuum - Update Continuum Project");
// Edit the name of the project and save it
String newName = "New Name";
setFieldValue("projectSave_name", newName);
clickButtonWithValue("Save");
// Verify that the save succeeded
assertPage("Continuum - Continuum Project");
assertTextPresent(String.format("Continuum Project \"%s\"", newName));
}
/**
* Test flat multi module project with names that start with the same letter
*/
public void testAddMavenTwoProjectModuleNameWithSameLetter()
throws Exception
{
pomUrl = getProperty( "MAVEN2_SAME_LETTER_FLAT_POM_URL" );
pomUsername = "";
pomPassword = "";
projectGroupName = getProperty( "MAVEN2_SAME_LETTER_FLAT_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN2_SAME_LETTER_FLAT_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN2_SAME_LETTER_FLAT_PROJECT_GROUP_DESCRIPTION" );
projectGroupScmRootUrl = getProperty( "MAVEN2_SAME_LETTER_FLAT_PROJECT_GROUP_SCM_ROOT_URL" );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
assertTextPresent( projectGroupScmRootUrl );
}
public void testAddMavenTwoProjectFromRemoteSourceToNonDefaultProjectGroup()
throws Exception
{
projectGroupName = getProperty( "MAVEN2_NON_DEFAULT_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN2_NON_DEFAULT_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN2_NON_DEFAULT_PROJECT_GROUP_DESCRIPTION" );
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
assertTextPresent( projectGroupScmRootUrl );
}
public void testMoveProject()
throws Exception
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
assertTextPresent( projectGroupScmRootUrl );
String targetGroupName = getProperty( "MAVEN2_MOVE_PROJECT_TARGET_PROJECT_GROUP_NAME" );
String targetGroupId = getProperty( "MAVEN2_MOVE_PROJECT_TARGET_PROJECT_GROUP_ID" );
String targetGroupDescription = getProperty( "MAVEN2_MOVE_PROJECT_TARGET_PROJECT_GROUP_DESCRIPTION" );
addProjectGroup( targetGroupName, targetGroupId, targetGroupDescription, true );
try {
// Move the project
moveProjectToProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName,
targetGroupName );
showProjectGroup( targetGroupName, targetGroupId, targetGroupDescription );
assertTextPresent( "Member Projects" );
assertTextPresent( projectName );
showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
assertTextNotPresent( "Member Projects" );
} finally {
removeProjectGroup( targetGroupName, false );
}
}
/**
* Test invalid pom url
*/
public void testNoPomSpecified()
throws Exception
{
submitAddMavenTwoProjectPage( "" );
assertTextPresent( "Either POM URL or Upload POM is required." );
}
/**
* Test when scm element is missing from pom
*/
public void testMissingScmElementPom()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_NO_SCM_POM_URL" );
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent( "Missing ''scm'' element in the POM, project Maven Two Project" );
}
/**
* test with a malformed pom url
*/
public void testMalformedPomUrl()
throws Exception
{
String pomUrl = "aaa";
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent(
"The specified resource cannot be accessed. Please try again later or contact your administrator." );
}
/**
* Test when the connection element is missing from the scm tag
*/
public void testMissingConnectionElement()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_MISS_CONNECTION_POM_URL" );
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent( "Missing 'connection' sub-element in the 'scm' element in the POM." );
}
/**
* test unallowed file protocol
*/
public void testNotAllowedProtocol()
throws Exception
{
String pomUrl = "file:///pom.xml";
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent( "The specified resource isn't a file or the protocol used isn't allowed." );
}
/**
* Test when the parent pom is missing or not yet added in continuum
*/
public void testMissingParentPom()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_MISS_PARENT_POM_URL" );
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent(
"Missing artifact trying to build the POM. Check that its parent POM is available or add it first in Continuum." );
}
/**
* Test when the modules/subprojects specified in the pom are not found
*/
public void testMissingModules()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_MISS_SUBPRO_POM_URL" );
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent( "Unknown error trying to build POM." );
}
/**
* test with an inaccessible pom url
*/
public void testInaccessiblePomUrl()
throws Exception
{
String pomUrl = baseUrl + "/inaccessible-pom/";
submitAddMavenTwoProjectPage( pomUrl );
assertTextPresent(
"POM file does not exist. Either the POM you specified or one of its modules does not exist." );
}
/**
* test cancel button
*/
public void testCancelButton()
{
goToAboutPage();
goToAddMavenTwoProjectPage();
clickButtonWithValue( "Cancel" );
assertAboutPage();
}
public void testDeleteMavenTwoProject()
throws Exception
{
goToProjectGroupsSummaryPage();
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
goToProjectGroupsSummaryPage();
assertLinkPresent( projectGroupName );
clickLinkWithText( projectGroupName );
assertPage( "Continuum - Project Group" );
assertTextPresent( projectGroupScmRootUrl );
// wait for project to finish checkout
waitForProjectCheckout();
waitPage();
clickLinkWithXPath( "//tbody/tr['0']/td['10']/a/img[@alt='Delete']" );
assertTextPresent( "Delete Continuum Project" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Project Group" );
assertTextNotPresent( "Unable to delete project" );
assertLinkNotPresent( projectGroupName );
assertTextNotPresent( projectGroupScmRootUrl );
}
public void testDeleteMavenTwoProjects()
throws Exception
{
goToProjectGroupsSummaryPage();
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
goToProjectGroupsSummaryPage();
assertLinkPresent( projectGroupName );
clickLinkWithText( projectGroupName );
assertPage( "Continuum - Project Group" );
//wait for project to finish checkout
waitForProjectCheckout();
waitPage();
checkField( "//tbody/tr['0']/td['0']/input[@name='selectedProjects']" );
clickButtonWithValue( "Delete Project(s)" );
assertTextPresent( "Delete Continuum Projects" );
clickButtonWithValue( "Delete" );
assertPage( "Continuum - Project Group" );
assertTextNotPresent( "Unable to delete project" );
assertLinkNotPresent( projectGroupName );
assertTextNotPresent( projectGroupScmRootUrl );
}
public void testBuildMaven2ProjectWithTag()
throws Exception
{
pomUrl = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_URL" );
pomUsername = "";
pomPassword = "";
projectGroupName = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_PROJECT_GROUP_DESCRIPTION" );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectGroupName, true );
}
}
| 5,245 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java | package org.apache.continuum.web.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Based on AddMavenTwoProjectTest of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
@Test( groups = {"distributed"} )
public class DistributedBuildTest
extends AbstractAdminTest
{
private String projectGroupName;
private String projectGroupId;
private String projectGroupDescription;
private String pomUrl;
private String pomUsername;
private String pomPassword;
private String projectName;
private String buildEnvName;
private String buildAgentGroupName;
private String newBuildEnv;
@BeforeMethod
public void setUp()
{
enableDistributedBuilds();
addBuildAgent( buildAgentUrl );
projectGroupName = getProperty( "DISTRIBUTED_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "DISTRIBUTED_PROJECT_GROUP_ID" );
projectGroupDescription = getProperty( "DISTRIBUTED_PROJECT_GROUP_DESCRIPTION" );
addProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, true, false );
pomUrl = getProperty( "MAVEN2_POM_URL" );
pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
buildAgentGroupName = getProperty( "DISTRIBUTED_BUILD_AGENT_GROUP_NAME" );
buildEnvName = getProperty( "DISTRIBUTED_BUILD_ENV_NAME" );
newBuildEnv = getProperty( "DISTRIBUTED_DUPLICATE_BUILD_ENV" );
}
@AfterMethod
public void tearDown()
throws Throwable
{
removeProjectGroup( projectGroupName, false );
removeBuildEnvironment( buildEnvName, false );
removeBuildEnvironment( newBuildEnv, false );
removeBuildAgentGroup( buildAgentGroupName, false );
disableDistributedBuilds();
}
public void testBuildProjectGroupNoBuildAgentConfigured()
throws Exception
{
goToBuildAgentPage();
removeBuildAgent( buildAgentUrl, false );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
goToProjectGroupsSummaryPage();
assertLinkPresent( projectGroupName );
clickLinkWithText( projectGroupName );
assertPage( "Continuum - Project Group" );
clickButtonWithValue( "Build all projects" );
assertTextPresent( "Unable to build projects because no build agent is configured" );
}
public void testProjectGroupAllBuildSuccessWithDistributedBuilds()
throws Exception
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
}
public void testBuildMaven2ProjectWithTagDistributedBuild()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_URL" );
String pomUsername = "";
String pomPassword = "";
String projectName = getProperty( "MAVEN2_PROJECT_WITH_TAG_POM_PROJECT_NAME" );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
}
public void testBuildShellProjectWithDistributedBuildsEnabled()
throws Exception
{
String projectName = getProperty( "SHELL_PROJECT_NAME" );
String projectDescription = getProperty( "SHELL_PROJECT_DESCRIPTION" );
String projectVersion = getProperty( "SHELL_PROJECT_VERSION" );
String projectTag = getProperty( "SHELL_PROJECT_TAG" );
String projectScmUrl = getProperty( "SHELL_PROJECT_SCM_URL" );
String projectScmUsername = getProperty( "SHELL_PROJECT_SCM_USERNAME" );
String projectScmPassword = getProperty( "SHELL_PROJECT_SCM_PASSWORD" );
goToAddShellProjectPage();
addProject( projectName, projectDescription, projectVersion, projectScmUrl, projectScmUsername,
projectScmPassword, projectTag, projectGroupName, true, "shell" );
assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription );
goToProjectGroupsSummaryPage();
clickLinkWithText( projectGroupName );
clickLinkWithText( "Build Definitions" );
clickLinkWithXPath( "//table[@id='ec_table']/tbody/tr/td[14]/a/img" );
editBuildDefinitionShellType();
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
}
public void testQueuePageWithProjectCurrentlyBuildingInDistributedBuilds()
throws Exception
{
String pomUrl = getProperty( "MAVEN2_QUEUE_TEST_POM_URL" );
String pomUsername = getProperty( "MAVEN2_QUEUE_TEST_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_QUEUE_TEST_POM_PASSWORD" );
goToAddMavenTwoProjectPage();
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
buildProjectForQueuePageTest( projectGroupName, projectGroupId, projectGroupDescription );
//check queue page while building
getSelenium().open( baseUrl + "/admin/displayQueues.action" );
assertPage( "Continuum - View Distributed Builds" );
assertTextPresent( "Current Build" );
assertTextPresent( "Build Queue" );
assertTextPresent( "Current Prepare Build" );
assertTextPresent( "Prepare Build Queue" );
assertTextPresent( projectGroupName );
assertTextPresent( "Build Agent URL" );
}
public void testAddBuildEnvironmentWithBuildAgentGroup()
{
addBuildAgentGroupAndEnvironment( new String[]{buildAgentUrl} );
}
public void testProjectGroupNoBuildAgentConfiguredInBuildAgentGroup()
throws Exception
{
addBuildAgentGroupAndEnvironment( new String[]{} );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
goToGroupBuildDefinitionPage( projectGroupName, projectGroupId, projectGroupDescription );
clickImgWithAlt( "Edit" );
assertAddEditBuildDefinitionPage( MAVEN_PROJECT_TYPE );
selectValue( "profileId", buildEnvName );
submit();
assertGroupBuildDefinitionPage( projectGroupName );
clickLinkWithText( "Project Group Summary" );
clickButtonWithValue( "Build all projects" );
assertTextPresent( "Unable to build projects because no build agent is configured in the build agent group" );
}
public void testEditDuplicatedBuildEnvironmentDistributedBuilds()
{
addBuildAgentGroupAndEnvironment( new String[]{buildAgentUrl} );
goToAddBuildEnvironment();
addBuildEnvironmentWithBuildAgentGroup( newBuildEnv, new String[]{}, buildAgentGroupName );
goToEditBuildEnvironment( newBuildEnv );
editBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{}, buildAgentGroupName, false );
assertTextPresent( "A Build Environment with the same name already exists" );
}
@Test( enabled = false )
public void testBuildSuccessWithDistributedBuildsAfterDisableEnableOfBuildAgent()
throws Exception
{
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
// disable then enable build agent
goToBuildAgentPage();
clickImgWithAlt( "Edit" );
enableDisableBuildAgent( buildAgentUrl, false );
clickImgWithAlt( "Edit" );
enableDisableBuildAgent( buildAgentUrl, true );
buildProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, projectName, true );
}
private void addBuildAgentGroupAndEnvironment( String[] buildAgents )
{
// create build agent group
goToAddBuildAgentGroup();
addEditBuildAgentGroup( buildAgentGroupName, buildAgents, new String[]{}, true );
goToAddBuildEnvironment();
addBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{}, buildAgentGroupName );
}
private void editBuildDefinitionShellType()
{
setFieldValue( "buildFile", isWindows() ? "build.bat" : "build.sh" );
setFieldValue( "arguments", "" );
setFieldValue( "description", "description" );
setFieldValue( "buildDefinitionType", "shell" );
checkField( "alwaysBuild" );
submit();
}
}
| 5,246 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java | package org.apache.continuum.web.test.listener;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.thoughtworks.selenium.Selenium;
import org.apache.commons.io.FileUtils;
import org.apache.continuum.web.test.parent.AbstractSeleniumTest;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
public class CaptureScreenShotsListener
extends TestListenerAdapter
{
@Override
public void onTestStart( ITestResult tr )
{
System.out.print( "Test " + tr.getName() + "... " );
super.onTestStart( tr );
}
@Override
public void onTestSkipped( ITestResult tr )
{
System.out.println( "Skipped" );
super.onTestSkipped( tr );
}
@Override
public void onTestFailure( ITestResult tr )
{
captureError( tr );
System.out.println( "Failed" );
super.onTestFailure( tr );
}
@Override
public void onTestSuccess( ITestResult tr )
{
System.out.println( "Success" );
super.onTestFailure( tr );
}
private void captureError( ITestResult tr )
{
captureScreenshotAndSource( tr.getTestClass().getName(), tr.getThrowable() );
}
public static void captureScreenshotAndSource( String cName, Throwable throwable )
{
Selenium selenium = AbstractSeleniumTest.getSelenium();
if ( selenium == null )
{
// avoid swallowing exception
System.err.println( "Not capturing screenshot as Selenium is not initialised" );
return;
}
String locator = "link=Show/hide Stack Trace";
if ( selenium.isElementPresent( locator ) )
{
selenium.click( locator );
}
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
String time = sdf.format( new Date() );
File targetPath = new File( "target", "screenshots" );
StackTraceElement trace = getStackTraceOfCallingClass( cName, throwable.getStackTrace() );
String methodName;
int lNumber;
if ( trace == null )
{
System.err.println( "Unable to determine the calling method from class " + cName );
throwable.printStackTrace();
methodName = "unknown";
lNumber = 0;
}
else
{
methodName = trace.getMethodName();
lNumber = trace.getLineNumber();
}
String lineNumber = Integer.toString( lNumber );
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
if ( !targetPath.exists() && !targetPath.mkdirs() )
{
System.out.println( "Unable to create screenshots directory" );
return;
}
String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
System.out.println( "Capturing screenshot at " + fileBaseName + ".png" );
try
{
selenium.windowMaximize();
File fileName = getFileName( targetPath, fileBaseName, ".png" );
selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "" );
}
catch ( RuntimeException e )
{
System.out.println( "Error when take screenshot of error: " + e.getMessage() );
}
try
{
File fileName = getFileName( targetPath, fileBaseName, ".html" );
FileUtils.writeStringToFile( fileName, selenium.getHtmlSource() );
}
catch ( IOException ioe )
{
System.out.println( "Error writing HTML of error: " + ioe.getMessage() );
}
}
private static File getFileName( File targetPath, String fileBaseName, String ext )
{
File fileName = new File( targetPath, fileBaseName + ext );
int count = 0;
while ( fileName.exists() )
{
count++;
fileName = new File( targetPath, fileBaseName + "_" + count + ext );
}
return fileName;
}
private static StackTraceElement getStackTraceOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )
{
StackTraceElement lastMatch = null;
for ( StackTraceElement el : stackTrace )
{
String className = el.getClassName();
if ( Pattern.matches( nameOfClass, className ) )
{
lastMatch = el;
}
}
return lastMatch;
}
}
| 5,247 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public abstract class AbstractAdminTest
extends AbstractContinuumTest
{
protected String buildAgentUrl;
@BeforeMethod( alwaysRun = true )
public void loginAsAdmin()
{
loginAs( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
}
protected void loginAs( String username, String password )
{
if ( !getSelenium().isElementPresent( "//span[@class='username' and text()='" + username + "']" ) )
{
login( username, password );
assertElementPresent( "//span[@class='username' and text()='" + username + "']" );
}
}
public void goToConfigurationPage()
{
clickLinkWithText( "Configuration" );
assertEditConfigurationPage();
}
protected void enableDisableBuildAgent( String agentName, boolean enable )
{
assertFieldValue( agentName, "saveBuildAgent_buildAgent_url" );
if ( enable )
{
checkField( "saveBuildAgent_buildAgent_enabled" );
}
else
{
uncheckField( "saveBuildAgent_buildAgent_enabled" );
}
submit();
assertBuildAgentPage();
assertTextPresent( Boolean.toString( enable ) );
}
protected void goToAddBuildAgentGroup()
{
goToBuildAgentPage();
clickAndWait( "editBuildAgentGroup_0" ); //add button
String[] options = new String[]{"--- Available Build Agents ---"};
assertAddEditBuildAgentGroupPage( options, null );
}
protected void addEditBuildAgentGroup( String name, String[] addBuildAgents, String[] removeBuildAgents,
boolean success )
{
setFieldValue( "saveBuildAgentGroup_buildAgentGroup_name", name );
if ( addBuildAgents != null && addBuildAgents.length > 0 )
{
for ( String ba : addBuildAgents )
{
selectValue( "buildAgentIds", ba );
clickButtonWithValue( "->", false );
}
}
if ( removeBuildAgents != null && removeBuildAgents.length > 0 )
{
for ( String ba : removeBuildAgents )
{
selectValue( "selectedBuildAgentIds", ba );
clickButtonWithValue( "<-", false );
}
}
submit();
if ( success )
{
assertBuildAgentPage();
}
else
{
assertAddEditBuildAgentGroupPage( null, null );
}
}
void assertAddEditBuildAgentGroupPage( String[] availableBuildAgents, String[] usedBuildAgents )
{
assertPage( "Continuum - Add/Edit Build Agent Group" );
assertTextPresent( "Add/Edit Build Agent Group" );
assertTextPresent( "Name*:" );
assertTextPresent( "Configure the used Build Agents:" );
assertElementPresent( "buildAgentGroup.name" );
if ( availableBuildAgents != null && availableBuildAgents.length > 0 )
{
assertOptionPresent( "buildAgentIds", availableBuildAgents );
}
if ( usedBuildAgents != null && usedBuildAgents.length > 0 )
{
assertOptionPresent( "selectedBuildAgentIds", usedBuildAgents );
}
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void goToEditBuildAgentGroup( String name, String[] buildAgents )
{
goToBuildAgentPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddEditBuildAgentGroupPage( null, buildAgents );
assertFieldValue( name, "buildAgentGroup.name" );
}
protected void removeBuildAgentGroup( String name )
throws UnsupportedEncodingException
{
removeBuildAgentGroup( name, true );
}
protected void removeBuildAgentGroup( String name, boolean failIfMissing )
throws UnsupportedEncodingException
{
goToBuildAgentPage();
if ( isTextPresent( name ) || failIfMissing )
{
clickLinkWithXPath(
"(//a[contains(@href,'deleteBuildAgentGroup.action') and contains(@href, '" + URLEncoder.encode( name,
"UTF-8" ) +
"')])//img" );
assertPage( "Continuum - Delete Build Agent Group" );
assertTextPresent( "Delete Build Agent" );
assertTextPresent( "Are you sure you want to delete build agent group " + name + " ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildAgentPage();
assertTextNotPresent( name );
}
}
protected void addBuildAgent( String buildAgentUrl )
{
addBuildAgent( buildAgentUrl, "Default description" );
}
protected void addBuildAgent( String buildAgentUrl, String description )
{
goToBuildAgentPage();
assertBuildAgentPage();
if ( !isElementPresent( "link=" + buildAgentUrl ) )
{
clickAndWait( "editBuildAgent_0" ); //add button
assertAddEditBuildAgentPage( true );
setFieldValue( "saveBuildAgent_buildAgent_url", buildAgentUrl );
setFieldValue( "saveBuildAgent_buildAgent_description", description );
checkField( "saveBuildAgent_buildAgent_enabled" );
submit();
assertBuildAgentPage();
assertElementPresent( "link=" + buildAgentUrl );
}
}
protected void goToAddBuildAgent()
{
goToBuildAgentPage();
assertBuildAgentPage();
clickAndWait( "editBuildAgent_0" ); //add button
assertAddEditBuildAgentPage( true );
}
void assertAddEditBuildAgentPage( boolean isChecked )
{
assertPage( "Continuum - Add/Edit Build Agent" );
assertTextPresent( "Add/Edit Build Agent" );
assertTextPresent( "Build Agent URL*:" );
assertTextPresent( "Description:" );
assertTextPresent( "Enabled" );
assertElementPresent( "saveBuildAgent_buildAgent_url" );
assertElementPresent( "saveBuildAgent_buildAgent_description" );
if ( isChecked )
{
assertIsChecked( "saveBuildAgent_buildAgent_enabled" );
}
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
@BeforeClass( alwaysRun = true )
@Parameters( { "buildAgentUrl" } )
public void initializeBuildAgent(
@Optional( "http://localhost:9595/continuum-buildagent/xmlrpc" ) String buildAgentUrl )
{
this.buildAgentUrl = buildAgentUrl;
}
protected void enableDistributedBuilds()
{
goToConfigurationPage();
setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
if ( !isChecked( "distributedBuildEnabled" ) )
{
// must use click here so the JavaScript enabling the shared secret gets triggered
click( "distributedBuildEnabled" );
}
setFieldValue( "sharedSecretPassword", SHARED_SECRET );
clickAndWait( "css=input[value='Save']" );
assertTextPresent( "true" );
assertTextPresent( "Distributed Builds" );
assertElementPresent( "link=Build Agents" );
}
protected void disableDistributedBuilds()
{
goToConfigurationPage();
setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
if ( isChecked( "distributedBuildEnabled" ) )
{
uncheckField( "distributedBuildEnabled" );
}
submit();
assertTextPresent( "false" );
assertElementNotPresent( "link=Build Agents" );
}
protected void goToBuildAgentPage()
{
clickAndWait( "link=Build Agents" );
assertPage( "Continuum - Build Agents" );
}
void assertBuildAgentPage()
{
assertPage( "Continuum - Build Agents" );
assertTextPresent( "Build Agents" );
assertTextPresent( "Build Agent Groups" );
assertButtonWithValuePresent( "Add" );
}
protected void removeBuildAgent( String agentName )
throws Exception
{
goToBuildAgentPage();
removeBuildAgent( agentName, true );
}
protected void removeBuildAgent( String agentName, boolean failIfMissing )
throws Exception
{
String deleteButton = "//a[contains(@href,'deleteBuildAgent.action') and contains(@href, '" + URLEncoder.encode(
agentName, "UTF-8" ) + "')]/img";
if ( failIfMissing || isElementPresent( deleteButton ) )
{
clickLinkWithXPath( deleteButton );
assertPage( "Continuum - Delete Build Agent" );
assertTextPresent( "Delete Build Agent" );
assertTextPresent( "Are you sure you want to delete build agent " + agentName + " ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildAgentPage();
assertElementNotPresent( deleteButton );
}
}
protected void addBuildAgent( String agentURL, String description, boolean success, boolean enabled,
boolean pingOk )
{
setFieldValue( "saveBuildAgent_buildAgent_url", agentURL );
setFieldValue( "saveBuildAgent_buildAgent_description", description );
if ( enabled )
{
checkField( "saveBuildAgent_buildAgent_enabled" );
}
else
{
uncheckField( "saveBuildAgent_buildAgent_enabled" );
}
submit();
if ( success )
{
if ( pingOk )
{
assertBuildAgentPage();
assertElementPresent( "link=" + agentURL );
clickLinkWithText( agentURL );
if ( enabled )
{
assertTextPresent( "true" );
}
}
else
{
assertTextPresent( "Unable to ping" );
assertAddEditBuildAgentPage( true );
}
}
else
{
assertAddEditBuildAgentPage( enabled );
}
}
protected void goToEditBuildAgent( String name, String description )
{
goToBuildAgentPage();
clickImgWithAlt( "Edit" );
assertAddEditBuildAgentPage( false );
assertFieldValue( name, "saveBuildAgent_buildAgent_url" );
assertFieldValue( description, "saveBuildAgent_buildAgent_description" );
}
protected void addEditBuildAgent( String agentName, String newDesc )
{
assertFieldValue( agentName, "saveBuildAgent_buildAgent_url" );
setFieldValue( "saveBuildAgent_buildAgent_description", newDesc );
submit();
assertBuildAgentPage();
assertTextPresent( newDesc );
}
protected void removeSchedule( String name )
{
goToSchedulePage();
clickLinkWithXPath( "(//a[contains(@href,'removeSchedule.action') and contains(@href, '" + name + "')])//img" );
assertPage( "Continuum - Delete Schedule" );
assertTextPresent( "Delete Schedule" );
assertTextPresent( "Are you sure you want to delete the schedule \"" + name + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertSchedulePage();
}
}
| 5,248 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
public abstract class AbstractUserRolesManagementTest
extends AbstractAdminTest
{
protected String username;
protected String fullname;
protected String getUserEmail()
{
return getProperty( "USERROLE_EMAIL" );
}
protected String getUserRolePassword()
{
return getProperty( "USERROLE_PASSWORD" );
}
protected String getUserRoleNewPassword()
{
return getProperty( "NEW_USERROLE_PASSWORD" );
}
////////////////////////////
// Assertions
////////////////////////////
protected void assertCreateUserPage()
{
assertPage( "[Admin] User Create" );
assertTextPresent( "[Admin] User Create" );
assertTextPresent( "Username*:" );
assertElementPresent( "user.username" );
assertTextPresent( "Full Name*:" );
assertElementPresent( "user.fullName" );
assertTextPresent( "Email Address*:" );
assertElementPresent( "user.email" );
assertTextPresent( "Password*:" );
assertElementPresent( "user.password" );
assertTextPresent( "Confirm Password*:" );
assertElementPresent( "user.confirmPassword" );
assertButtonWithValuePresent( "Create User" );
}
protected void assertUserRolesPage()
{
assertPage( "[Admin] User Edit" );
assertTextPresent( "[Admin] User Roles" );
String userRoles =
"Username,Full Name,Email,Guest,Registered User,System Administrator,User Administrator,Continuum Group Project Administrator,Continuum Group Project Developer,Continuum Group Project User,Continuum Manage Build Environments,Continuum Manage Build Templates,Continuum Manage Installations,Continuum Manage Local Repositories,Continuum Manage Purging,Continuum Manage Queues,Continuum Manage Scheduling,Project Administrator,Project Developer,Project User,Default Project Group";
String[] arrayUserRoles = userRoles.split( "," );
for ( String userroles : arrayUserRoles )
{
assertTextPresent( userroles );
}
}
protected void assertCreatedUserInfo( String username )
{
selectValue( "name=ec_rd", "50" );
waitPage();
clickLinkWithText( username );
clickLinkWithText( "Edit Roles" );
}
void assertUserRoleCheckBoxPresent( String value )
{
getSelenium().isElementPresent(
"xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" +
value + "']" );
}
void assertResourceRolesCheckBoxPresent( String value )
{
getSelenium().isElementPresent( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
}
protected void checkUserRoleWithValue( String value )
{
assertUserRoleCheckBoxPresent( value );
getSelenium().click(
"xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" +
value + "']" );
}
protected void checkResourceRoleWithValue( String value )
{
assertResourceRolesCheckBoxPresent( value );
getSelenium().click( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
}
protected void assertLeftNavMenuWithRole( String role )
{
if ( "System Administrator".equals( role ) )
{
String navMenu =
"About,Show Project Groups,Maven Project,Maven 1.x Project,Ant Project,Shell Project,Local Repositories,Purge Configurations,Schedules,Installations,Build Environments,Build Definition Templates,Configuration,Appearance,Users,Roles,Build Queue";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "User Administrator".equals( role ) )
{
String navMenu = "About,Show Project Groups,Users,Roles";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Group Project Administrator".equals( role ) )
{
String navMenu =
"About,Show Project Groups,Maven Project,Maven 1.x Project,Ant Project,Shell Project,Schedules,Users,Roles";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Group Project Developer".equals( role ) )
{
String navMenu = "About,Show Project Groups";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Group Project User".equals( role ) )
{
String navMenu = "About,Show Project Groups";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Build Environments".equals( role ) )
{
String navMenu = "About,Show Project Groups,Build Environments";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Build Templates".equals( role ) )
{
String navMenu = "About,Show Project Groups,Build Definition Templates";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Installations".equals( role ) )
{
String navMenu = "About,Show Project Groups,Installations";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Local Repositories".equals( role ) )
{
String navMenu = "About,Show Project Groups,Local Repositories";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Purging".equals( role ) )
{
String navMenu = "About,Show Project Groups,Purge Configurations";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Queues".equals( role ) )
{
String navMenu = "About,Show Project Groups,Queues";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Continuum Manage Scheduling".equals( role ) )
{
String navMenu = "About,Show Project Groups,Schedules";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Project Administrator - Default Project Group".equals( role ) )
{
String navMenu = "About,Show Project Groups,Users,Roles";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else if ( "Project Developer - Default Project Group".equals( role ) ||
"Project User - Default Project Group".equals( role ) )
{
String navMenu = "About,Show Project Groups";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
}
else
{
String navMenu = "About,Show Project Groups";
String[] arrayNavMenu = navMenu.split( "," );
for ( String navmenu : arrayNavMenu )
{
assertLinkPresent( navmenu );
}
assertTextPresent( "Project Groups" );
//assertTextPresent( "Project Groups list is empty." );
}
}
void assertDeleteUserPage( String username )
{
assertPage( "[Admin] User Delete" );
assertTextPresent( "[Admin] User Delete" );
assertTextPresent( "The following user will be deleted:" );
assertTextPresent( "Username: " + username );
assertButtonWithValuePresent( "Delete User" );
}
protected void assertProjectAdministratorAccess()
{
assertLinkPresent( "About" );
assertLinkPresent( "Show Project Groups" );
assertLinkPresent( "Maven Project" );
assertLinkPresent( "Maven 1.x Project" );
assertLinkPresent( "Ant Project" );
assertLinkPresent( "Shell Project" );
assertLinkPresent( "Schedules" );
assertLinkPresent( "Users" );
assertLinkPresent( "Roles" );
assertLinkNotPresent( "Local Repositories" );
assertLinkNotPresent( "Purge Configurations" );
assertLinkNotPresent( "Installations" );
assertLinkNotPresent( "Build Environments" );
assertLinkNotPresent( "Build Definition Templates" );
assertLinkNotPresent( "Configuration" );
assertLinkNotPresent( "Appearance" );
assertLinkNotPresent( "Build Queue" );
assertLinkNotPresent( "Build Agent" );
}
/////////////////////////////////////////
// User Roles Management
/////////////////////////////////////////
protected void changePassword( String oldPassword, String newPassword )
{
assertPage( "Change Password" );
setFieldValue( "existingPassword", oldPassword );
setFieldValue( "newPassword", newPassword );
setFieldValue( "newPasswordConfirm", newPassword );
clickButtonWithValue( "Change Password" );
}
protected void createUser( String userName, String fullName, String email, String password )
{
createUser( userName, fullName, email, password, password );
}
private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword )
{
loginAsAdmin();
clickLinkWithText( "Users" );
clickButtonWithValue( "Create New User" );
assertCreateUserPage();
setFieldValue( "user.username", userName );
setFieldValue( "user.fullName", fullName );
setFieldValue( "user.email", emailAd );
setFieldValue( "user.password", password );
setFieldValue( "user.confirmPassword", confirmPassword );
submit();
assertUserRolesPage();
clickButtonWithValue( "Submit" );
}
protected void deleteUser( String userName )
{
deleteUser( userName, true );
}
protected void deleteUser( String userName, boolean failIfMissing )
{
String xpath = "//tr[.//a[text()='" + userName + "']]/td/a[@title='delete user']";
if ( failIfMissing || isElementPresent( "xpath=" + xpath ) )
{
clickLinkWithXPath( xpath );
assertDeleteUserPage( userName );
submit();
assertElementNotPresent( userName );
}
}
}
| 5,249 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractPurgeTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* @author José Morales Martínez
*/
public abstract class AbstractPurgeTest
extends AbstractAdminTest
{
protected void goToGeneralPurgePage()
{
clickLinkWithText( "Purge Configurations" );
assertGeneralPurgePage();
}
protected void assertGeneralPurgePage()
{
assertPage( "Continuum - Purge Configurations" );
assertTextPresent( "Repository Purge Configurations" );
assertTextPresent( "Directory Purge Configurations" );
assertButtonWithValuePresent( "Add" );
}
protected void removeRepositoryPurge( String purgeDescription )
{
removeRepositoryPurge( purgeDescription, false );
}
protected void removeRepositoryPurge( String purgeDescription, boolean distributed )
{
goToGeneralPurgePage();
String action = distributed ? "removeDistributedPurgeConfig" : "removePurgeConfig";
String xpath = String.format( "(//a[contains(@href,'%s.action') and contains(@href, '%s')])//img",
action, urlEncode( purgeDescription ) );
clickLinkWithXPath( xpath );
assertTextPresent( "Delete Purge Configuration" );
assertTextPresent( "Are you sure you want to delete Purge Configuration \"" + purgeDescription + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertGeneralPurgePage();
}
private String urlEncode( String s )
{
try
{
return URLEncoder.encode( s, "UTF-8" );
}
catch ( UnsupportedEncodingException e )
{
return s;
}
}
protected void removeDirectoryPurge( String purgeDescription )
{
goToGeneralPurgePage();
clickLinkWithXPath(
"(//a[contains(@href,'removePurgeConfig.action') and contains(@href, '" + purgeDescription + "')])//img" );
assertTextPresent( "Delete Purge Configuration" );
assertTextPresent( "Are you sure you want to delete Purge Configuration \"" + purgeDescription + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertGeneralPurgePage();
}
void assertAddRepositoryPurgePage()
{
assertAddRepositoryPurgePage( false );
}
void assertAddRepositoryPurgePage( boolean distributed )
{
assertPage( "Continuum - Add/Edit Purge Configuration" );
assertTextPresent( "Add/Edit Purge Configuration" );
assertTextPresent( "Repository" );
if ( distributed )
{
assertElementPresent( "repositoryName" );
}
else
{
assertElementPresent( "repositoryId" );
}
assertTextPresent( "Days Older" );
assertElementPresent( "daysOlder" );
assertTextPresent( "Retention Count" );
assertElementPresent( "retentionCount" );
assertElementPresent( "deleteAll" );
assertElementPresent( "deleteReleasedSnapshots" );
if ( !distributed )
{
assertElementPresent( "defaultPurgeConfiguration" );
}
assertTextPresent( "Schedule" );
assertElementPresent( "scheduleId" );
assertTextPresent( "Description" );
assertElementPresent( "description" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
void assertAddEditDirectoryPurgePage()
{
assertPage( "Continuum - Add/Edit Purge Configuration" );
assertTextPresent( "Add/Edit Purge Configuration" );
assertTextPresent( "Directory Type" );
assertElementPresent( "directoryType" );
assertTextPresent( "Days Older" );
assertElementPresent( "daysOlder" );
assertTextPresent( "Retention Count" );
assertElementPresent( "retentionCount" );
assertElementPresent( "deleteAll" );
assertElementPresent( "defaultPurgeConfiguration" );
assertTextPresent( "Schedule" );
assertElementPresent( "scheduleId" );
assertTextPresent( "Description" );
assertElementPresent( "description" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void goToAddRepositoryPurge()
{
goToAddRepositoryPurge( false );
}
protected void goToAddRepositoryPurge( boolean distributed )
{
goToGeneralPurgePage();
clickLinkWithXPath( "//form[@name='addRepoPurgeConfig']/input[@type='submit']" );
assertAddRepositoryPurgePage( distributed );
}
protected void goToEditRepositoryPurge( String daysOlder, String retentionCount, String description )
{
goToGeneralPurgePage();
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddRepositoryPurgePage();
assertFieldValue( daysOlder, "daysOlder" );
assertFieldValue( retentionCount, "retentionCount" );
assertFieldValue( description, "description" );
}
protected void goToEditDirectoryPurge( String daysOlder, String retentionCount, String description )
{
goToGeneralPurgePage();
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddEditDirectoryPurgePage();
assertFieldValue( daysOlder, "daysOlder" );
assertFieldValue( retentionCount, "retentionCount" );
assertFieldValue( description, "description" );
}
protected void addEditRepositoryPurge( String daysOlder, String retentionCount, String description,
boolean success )
{
setFieldValue( "daysOlder", daysOlder );
setFieldValue( "retentionCount", retentionCount );
setFieldValue( "description", description );
submit();
if ( success )
{
assertGeneralPurgePage();
}
else
{
assertAddRepositoryPurgePage();
}
}
protected void goToAddDirectoryPurge()
{
goToGeneralPurgePage();
clickLinkWithXPath( "//form[@name='addDirPurgeConfig']/input[@type='submit']" );
assertAddEditDirectoryPurgePage();
}
protected void addEditDirectoryPurge( String daysOlder, String retentionCount, String description, boolean success )
{
setFieldValue( "daysOlder", daysOlder );
setFieldValue( "retentionCount", retentionCount );
setFieldValue( "description", description );
submit();
if ( success )
{
assertGeneralPurgePage();
}
else
{
assertAddEditDirectoryPurgePage();
}
}
}
| 5,250 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author José Morales Martínez
*/
public abstract class AbstractBuildDefinitionTemplateTest
extends AbstractAdminTest
{
void goToBuildDefinitionTemplatePage()
{
clickLinkWithText( "Build Definition Templates" );
assertBuildDefinitionTemplatePage();
}
void assertBuildDefinitionTemplatePage()
{
assertPage( "Continuum - Build Definition Templates" );
assertTextPresent( "Available Templates" );
assertTextPresent( "Available Build Definitions" );
assertButtonWithIdPresent( "buildDefinitionTemplate_0" );
assertButtonWithIdPresent( "buildDefinitionAsTemplate_input_0" );
}
protected void goToAddTemplate()
{
goToBuildDefinitionTemplatePage();
clickSubmitWithLocator( "buildDefinitionTemplate_0" );
String[] options = new String[]{"--- Available Build Definitions ---", "Default Ant Build Definition",
"Default Maven 1 Build Definition", "Default Maven Build Definition", "Default Shell Build Definition"};
assertAddEditTemplatePage( options, null );
}
void assertAddEditTemplatePage( String[] pendingSelectBuild, String[] selectedBuild )
{
assertPage( "Continuum - Build Definition Template" );
assertTextPresent( "Build Definition Template" );
assertTextPresent( "Name" );
assertElementPresent( "buildDefinitionTemplate.name" );
assertTextPresent( "Configure the used Build Definitions" );
if ( pendingSelectBuild != null && pendingSelectBuild.length > 0 )
{
assertOptionPresent( "buildDefinitionIds", pendingSelectBuild );
}
if ( selectedBuild != null && selectedBuild.length > 0 )
{
assertOptionPresent( "selectedBuildDefinitionIds", selectedBuild );
}
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addEditTemplate( String name, String[] addBuildDefinitions, String[] removeBuildDefinitions,
boolean success )
{
boolean empty = false;
setFieldValue( "buildDefinitionTemplate.name", name );
if ( addBuildDefinitions != null && addBuildDefinitions.length > 0 )
{
for ( String bd : addBuildDefinitions )
{
selectValue( "buildDefinitionIds", bd );
clickButtonWithValue( "->", false );
}
}
else
{
empty = true;
}
if ( removeBuildDefinitions != null && removeBuildDefinitions.length > 0 )
{
for ( String bd : removeBuildDefinitions )
{
selectValue( "selectedBuildDefinitionIds", bd );
clickButtonWithValue( "<-", false );
}
}
submit();
if ( success )
{
assertBuildDefinitionTemplatePage();
}
else
{
if ( empty )
{
assertTextPresent( "Template requires at least one build definition" );
}
else
{
assertAddEditTemplatePage( null, null );
}
}
}
protected void goToEditTemplate( String name, String[] buildDefinitions )
{
goToBuildDefinitionTemplatePage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddEditTemplatePage( null, buildDefinitions );
assertFieldValue( name, "buildDefinitionTemplate.name" );
}
protected void removeTemplate( String name )
{
removeTemplate( name, true );
}
protected void removeTemplate( String name, boolean failIfMissing )
{
goToBuildDefinitionTemplatePage();
String xpath = "(//a[contains(@href,'deleteDefinitionTemplate') and contains(@href, '" + name + "')])//img";
if ( failIfMissing || isElementPresent( "xpath=" + xpath ) )
{
clickLinkWithXPath( xpath );
assertPage( "Continuum - Delete Build Definition Template" );
assertTextPresent( "Delete Build Definition Template" );
assertTextPresent( "Are you sure you want to delete build definition template \"" + name + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildDefinitionTemplatePage();
}
}
protected void goToAddBuildDefinitionTemplate()
{
goToBuildDefinitionTemplatePage();
clickSubmitWithLocator( "buildDefinitionAsTemplate_input_0" );
assertAddEditBuildDefinitionTemplatePage();
}
protected void goToEditBuildDefinitionTemplate( String description )
{
goToBuildDefinitionTemplatePage();
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddEditBuildDefinitionTemplatePage();
}
void assertAddEditBuildDefinitionTemplatePage()
{
assertPage( "Continuum - Build Definition Template" );
assertTextPresent( "Build Definition Template" );
assertTextPresent( "POM filename*:" );
assertElementPresent( "buildDefinition.buildFile" );
assertTextPresent( "Goals*:" );
assertElementPresent( "buildDefinition.goals" );
assertTextPresent( "Arguments:" );
assertElementPresent( "buildDefinition.arguments" );
assertTextPresent( "Build Fresh" );
assertElementPresent( "buildDefinition.buildFresh" );
assertTextPresent( "Always Build" );
assertElementPresent( "buildDefinition.alwaysBuild" );
assertTextPresent( "Is it default?" );
assertTextPresent( "Schedule:" );
assertElementPresent( "buildDefinition.schedule.id" );
assertTextPresent( "Description" );
assertElementPresent( "buildDefinition.description" );
assertTextPresent( "Type" );
assertElementPresent( "buildDefinition.type" );
assertTextPresent( "Build Environment" );
assertElementPresent( "buildDefinition.profile.id" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addEditBuildDefinitionTemplate( String buildFile, String goals, String arguments, String description,
boolean buildFresh, boolean alwaysBuild, boolean isDefault,
boolean success )
{
// Enter values into Add Build Definition fields, and submit
setFieldValue( "buildDefinition.buildFile", buildFile );
setFieldValue( "buildDefinition.goals", goals );
setFieldValue( "buildDefinition.arguments", arguments );
setFieldValue( "buildDefinition.description", description );
if ( buildFresh )
{
checkField( "buildDefinition.buildFresh" );
}
else
{
uncheckField( "buildDefinition.buildFresh" );
}
if ( isDefault )
{
checkField( "buildDefinition.defaultForProject" );
}
else
{
uncheckField( "buildDefinition.defaultForProject" );
}
if ( alwaysBuild )
{
checkField( "buildDefinition.alwaysBuild" );
}
else
{
uncheckField( "buildDefinition.alwaysBuild" );
}
submit();
if ( success )
{
assertBuildDefinitionTemplatePage();
}
else
{
assertAddEditBuildDefinitionTemplatePage();
}
}
protected void removeBuildDefinitionTemplate( String description )
{
goToBuildDefinitionTemplatePage();
String xPath = "//preceding::td[text()='" + description + "']//following::img[@alt='Delete']";
clickLinkWithXPath( xPath );
assertPage( "Continuum - Delete Build Definition Template" );
assertTextPresent( "Delete Build Definition Template" );
assertTextPresent( "Are you sure you want to delete build definition template \"" + description + "\"?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildDefinitionTemplatePage();
}
}
| 5,251 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import java.io.File;
import static org.testng.Assert.assertEquals;
/**
* Based on AbstractContinuumTestCase of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
public abstract class AbstractContinuumTest
extends AbstractSeleniumTest
{
protected static final String SHARED_SECRET = "continuum1234";
protected static final String ANT_PROJECT_TYPE = "ant";
protected static final String MAVEN_PROJECT_TYPE = "maven";
// ////////////////////////////////////
// Create Admin User
// ////////////////////////////////////
void assertCreateAdmin()
{
assertPage( "Create Admin User" );
assertTextPresent( "Username" );
assertFieldValue( "admin", "user.username" );
assertTextPresent( "Full Name*" );
assertElementPresent( "user.fullName" );
assertTextPresent( "Email Address*" );
assertElementPresent( "user.email" );
assertTextPresent( "Password*" );
assertElementPresent( "user.password" );
assertTextPresent( "Confirm Password*" );
assertElementPresent( "user.confirmPassword" );
assertButtonWithValuePresent( "Create Admin" );
}
void submitAdminData( String fullname, String email, String password )
{
setFieldValue( "user.fullName", fullname );
setFieldValue( "user.email", email );
setFieldValue( "user.password", password );
setFieldValue( "user.confirmPassword", password );
submit();
}
// ////////////////////////////////////
// About
// ////////////////////////////////////
protected void goToAboutPage()
{
getSelenium().open( baseUrl );
clickLinkWithText( "About" );
assertAboutPage();
}
protected void assertAboutPage()
{
assertPage( "Continuum - About" );
assertTextPresent( "About Continuum" );
assertTextPresent( "Version:" );
}
// ////////////////////////////////////
// Login
// ////////////////////////////////////
protected void goToLoginPage()
{
getSelenium().deleteAllVisibleCookies();
getSelenium().open( baseUrl );
clickLinkWithText( "Login" );
assertLoginPage();
}
void assertLoginPage()
{
assertPage( "Login Page" );
assertTextPresent( "Login" );
assertTextPresent( "Register" );
assertTextPresent( "Username" );
assertElementPresent( "username" );
assertTextPresent( "Password" );
assertElementPresent( "password" );
assertTextPresent( "Remember Me" );
assertElementPresent( "rememberMe" );
assertButtonWithValuePresent( "Login" );
assertButtonWithValuePresent( "Cancel" );
assertTextPresent( "Need an Account? Register!" );
assertTextPresent( "Forgot your Password? Request a password reset." );
}
void assertAutenticatedPage( String username )
{
assertTextPresent( "Current User" );
assertTextPresent( "Edit Details" );
assertTextPresent( "Logout" );
assertTextNotPresent( "Login" );
assertTextPresent( username );
}
// ////////////////////////////////////
// Configuration
// ////////////////////////////////////
protected void assertEditConfigurationPage()
{
assertPage( "Continuum - Configuration" );
assertTextPresent( "General Configuration " );
assertTextPresent( "Working Directory" );
assertElementPresent( "workingDirectory" );
assertTextPresent( "Build Output Directory" );
assertElementPresent( "buildOutputDirectory" );
assertTextPresent( "Release Output Directory" );
assertElementPresent( "releaseOutputDirectory" );
assertTextPresent( "Deployment Repository Directory" );
assertElementPresent( "deploymentRepositoryDirectory" );
assertTextPresent( "Base URL" );
assertElementPresent( "baseUrl" );
assertTextPresent( "Number of Allowed Builds in Parallel" );
assertElementPresent( "numberOfAllowedBuildsinParallel" );
assertTextPresent( "Enable Distributed Builds" );
assertElementPresent( "distributedBuildEnabled" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
// ////////////////////////////////////
// Build Queue
// ////////////////////////////////////
protected void setMaxBuildQueue( int maxBuildQueue )
{
clickLinkWithText( "Configuration" );
setFieldValue( "numberOfAllowedBuildsinParallel", String.valueOf( maxBuildQueue ) );
submit();
}
// ////////////////////////////////////
// Project Groups
// ////////////////////////////////////
protected void goToProjectGroupsSummaryPage()
{
getSelenium().open( baseUrl + "/groupSummary.action" );
waitPage();
assertProjectGroupsSummaryPage();
}
protected void assertProjectGroupsSummaryPage()
{
assertPage( "Continuum - Group Summary" );
assertTextPresent( "Project Groups" );
if ( isTextPresent( "Project Groups list is empty." ) )
{
assertTextNotPresent( "Name" );
assertTextNotPresent( "Group Id" );
}
else
{
assertTextPresent( "Name" );
assertTextPresent( "Group Id" );
}
}
// ////////////////////////////////////
// Project Group
// ////////////////////////////////////
protected void showProjectGroup( String name, String groupId, String description )
{
goToProjectGroupsSummaryPage();
// Checks the link to the created Project Group
assertLinkPresent( name );
clickLinkWithText( name );
assertProjectGroupSummaryPage( name, groupId, description );
}
protected void assertProjectGroupSummaryPage( String name, String groupId, String description )
{
assertPage( "Continuum - Project Group" );
assertTextPresent( "Project Group Name" );
assertTextPresent( name );
assertTextPresent( "Project Group Id" );
assertTextPresent( groupId );
assertTextPresent( "Description" );
assertTextPresent( description );
// Assert the available Project Group Actions
assertTextPresent( "Group Actions" );
assertElementPresent( "build" );
assertElementPresent( "edit" );
// assertElementPresent( "remove" );
assertTextPresent( "Project Group Scm Root" );
assertTextPresent( "Scm Root URL" );
if ( isTextPresent( "Member Projects" ) )
{
assertTextPresent( "Project Name" );
assertTextPresent( "Version" );
assertTextPresent( "Build" );
}
else
{
assertTextNotPresent( "Project Name" );
}
}
protected void addProjectGroup( String name, String groupId, String description, boolean success )
{
addProjectGroup( name, groupId, description, success, true );
}
protected void addProjectGroup( String name, String groupId, String description, boolean success,
boolean failIfExists )
{
addProjectGroup( name, groupId, description, null, success, failIfExists );
}
protected void addProjectGroup( String name, String groupId, String description, String repo, boolean success,
boolean failIfExists )
{
goToProjectGroupsSummaryPage();
if ( failIfExists )
{
assertLinkNotPresent( name );
}
else
{
if ( isLinkPresent( name ) )
{
return;
}
}
// Go to Add Project Group Page
clickButtonWithValue( "Add Project Group" );
assertAddProjectGroupPage();
// Enter values into Add Project Group fields, and submit
setFieldValue( "name", name );
setFieldValue( "groupId", groupId );
if ( repo != null )
{
selectValue( "repositoryId", repo );
}
setFieldValue( "description", description );
submit();
if ( success )
{
assertProjectGroupsSummaryPage();
}
else
{
assertAddProjectGroupPage();
}
}
void assertAddProjectGroupPage()
{
assertPage( "Continuum - Add Project Group" );
assertTextPresent( "Add Project Group" );
assertTextPresent( "Project Group Name" );
assertElementPresent( "name" );
assertTextPresent( "Project Group Id" );
assertElementPresent( "groupId" );
assertTextPresent( "Description" );
assertElementPresent( "description" );
}
protected void removeProjectGroup( String groupName )
{
removeProjectGroup( groupName, true );
}
protected void removeProjectGroup( String groupName, boolean failIfMissing )
{
goToProjectGroupsSummaryPage();
if ( failIfMissing || isLinkPresent( groupName ) )
{
clickLinkWithText( groupName );
clickButtonWithValue( "Delete Group" );
assertTextPresent( "Project Group Removal" );
clickButtonWithValue( "Delete" );
assertProjectGroupsSummaryPage();
}
}
protected void editProjectGroup( String name, String groupId, String description, String newName,
String newDescription )
{
showProjectGroup( name, groupId, description );
clickButtonWithValue( "Edit" );
assertEditGroupPage( groupId );
setFieldValue( "name", newName );
setFieldValue( "description", newDescription );
clickButtonWithValue( "Save" );
}
void assertEditGroupPage( String groupId )
{
assertPage( "Continuum - Update Project Group" );
assertTextPresent( "Update Project Group" );
assertTextPresent( "Project Group Name" );
assertTextPresent( "Project Group Id" );
assertFieldValue( groupId, "projectGroup.groupId" );
assertTextPresent( "Description" );
assertTextPresent( "Homepage Url" );
assertTextPresent( "Local Repository" );
assertElementPresent( "css=input[value='Save']" );
assertElementPresent( "Cancel" );
}
protected void buildProjectGroup( String projectGroupName, String groupId, String description, String projectName,
boolean success )
{
showProjectGroup( projectGroupName, groupId, description );
waitForProjectUpdate();
clickButtonWithValue( "Build all projects" );
// wait for project to finish building
waitForProjectBuild();
// wait for the success status of project
if ( success )
{
if ( !isElementPresent( "//a/img[@alt='Success']" ) )
{
waitForElementPresent( "//a/img[@alt='Success']" );
}
}
else
{
if ( !isElementPresent( "//a/img[@alt='Failed']" ) )
{
waitForElementPresent( "//a/img[@alt='Failed']" );
}
}
// wait for the projectName link
if ( !isLinkPresent( projectName ) )
{
waitForElementPresent( "link=" + projectName );
}
clickLinkWithText( projectName );
waitForElementPresent( "link=Builds" );
clickLinkWithText( "Builds" );
if ( success )
{
clickAndWait( "css=img[alt=\"Success\"]" );
}
else
{
clickAndWait( "css=img[alt=\"Failed\"]" );
}
assertPage( "Continuum - Build result" );
assertTextPresent( "Build result for " + projectName );
if ( success )
{
assertImgWithAlt( "Success" );
}
else
{
assertImgWithAlt( "Failed" );
}
clickLinkWithText( "Project Group Summary" );
}
protected void assertReleaseChoicePage()
{
assertTextPresent( "Choose Release Goal for " );
assertTextPresent( "Prepare project for release " );
assertTextPresent( "Perform project release" );
assertElementPresent( "goal" );
assertElementPresent( "preparedReleaseId" );
assertButtonWithValuePresent( "Submit" );
}
protected void goToGroupBuildDefinitionPage( String projectGroupName, String groupId, String description )
{
showProjectGroup( projectGroupName, groupId, description );
clickLinkWithText( "Build Definitions" );
assertGroupBuildDefinitionPage( projectGroupName );
}
protected void assertGroupBuildDefinitionPage( String projectGroupName )
{
assertTextPresent( "Project Group Build Definitions of " + projectGroupName + " group" );
}
protected void assertDeleteBuildDefinitionPage( String description, String goals )
{
assertTextPresent(
"Are you sure you want to delete the build definition with description \"" + description + "\", goals \"" +
goals + "\" and id" );
isButtonWithValuePresent( "Cancel" );
isButtonWithValuePresent( "Delete" );
}
protected void assertAddEditBuildDefinitionPage( String type )
{
assertTextPresent( "Add/Edit Build Definition" );
if ( MAVEN_PROJECT_TYPE.equals( type ) )
{
assertTextPresent( "POM filename*:" );
assertTextPresent( "Goals*:" );
}
else if ( ANT_PROJECT_TYPE.equals( type ) )
{
assertTextPresent( "Ant build filename*:" );
assertTextPresent( "Targets:" );
}
else
{
throw new UnsupportedOperationException( "check not implemented for type: " + type );
}
assertElementPresent( "buildFile" );
assertElementPresent( "goals" );
assertTextPresent( "Arguments:" );
assertElementPresent( "arguments" );
assertTextPresent( "Build Fresh" );
assertElementPresent( "buildFresh" );
assertTextPresent( "Always Build" );
assertElementPresent( "alwaysBuild" );
assertTextPresent( "Is it default?" );
assertTextPresent( "Schedule:" );
assertElementPresent( "scheduleId" );
assertTextPresent( "Description" );
assertElementPresent( "description" );
assertTextPresent( "Type" );
assertElementPresent( "buildDefinitionType" );
assertTextPresent( "Build Environment" );
assertElementPresent( "profileId" );
assertEnabled();
}
protected void addEditGroupBuildDefinition( String groupName, String buildFile, String goals, String arguments,
String description, boolean buildFresh, boolean alwaysBuild,
boolean isDefault, String type, boolean success )
{
assertAddEditBuildDefinitionPage( type );
// Enter values into Add Build Definition fields, and submit
setFieldValue( "buildFile", buildFile );
setFieldValue( "goals", goals );
setFieldValue( "arguments", arguments );
setFieldValue( "description", description );
if ( buildFresh )
{
if ( isChecked( "buildFresh" ) )
{
uncheckField( "buildFresh" );
}
// need to do this for the onclick event
click( "buildFresh" );
}
else
{
if ( !isChecked( "buildFresh" ) )
{
checkField( "buildFresh" );
}
// need to do this for the onclick event
click( "buildFresh" );
}
assertEnabled();
if ( isElementPresent( "defaultBuildDefinition" ) )
{
if ( isDefault )
{
checkField( "defaultBuildDefinition" );
}
else
{
uncheckField( "defaultBuildDefinition" );
}
}
if ( alwaysBuild )
{
checkField( "alwaysBuild" );
}
else
{
uncheckField( "alwaysBuild" );
}
selectValue( "scheduleId", "DEFAULT_SCHEDULE" );
submit();
if ( !success )
{
assertAddEditBuildDefinitionPage( type );
}
else
{
if ( groupName != null )
{
assertGroupBuildDefinitionPage( groupName );
}
else
{
assertProjectInformationPage();
}
}
}
protected void goToProjectInformationPage( String projectGroupName, String projectName )
{
clickLinkWithText( "Show Project Groups" );
clickLinkWithText( projectGroupName );
clickLinkWithText( projectName );
assertProjectInformationPage();
}
protected void assertProjectInformationPage()
{
assertTextPresent( "Project Group Summary" );
assertTextPresent( "Project Information" );
assertTextPresent( "Builds" );
assertTextPresent( "Working Copy" );
assertTextPresent( "Build Definitions" );
assertTextPresent( "Notifiers" );
assertTextPresent( "Dependencies" );
assertTextPresent( "Developers" );
}
protected void moveProjectToProjectGroup( String groupName, String groupId, String groupDescription,
String projectName, String newProjectGroup )
{
showProjectGroup( groupName, groupId, groupDescription );
// wait for project not being used
waitForProjectBuild();
String id = getFieldValue( "name=projectGroupId" );
String url = baseUrl + "/editProjectGroup.action?projectGroupId=" + id;
getSelenium().open( url );
waitPage();
assertTextPresent( "Move to Group" );
String xPath = "//preceding::td/label[contains(text(),'" + projectName + "')]//following::select";
selectValue( xPath, newProjectGroup );
clickButtonWithValue( "Save" );
assertProjectGroupSummaryPage( groupName, groupId, groupDescription );
}
// ////////////////////////////////////
// Maven 2.0+ Project
// ////////////////////////////////////
protected void goToAddMavenTwoProjectPage()
{
clickLinkWithText( "Maven Project" );
assertAddMavenTwoProjectPage();
}
protected void assertAddMavenTwoProjectPage()
{
assertAddMavenTwoProjectPage( true );
}
protected void assertAddMavenTwoProjectPage( boolean isHttp )
{
if ( isHttp )
{
assertTextPresent( "POM Url" );
assertElementPresent( "m2PomUrl" );
assertTextPresent( "Username" );
assertElementPresent( "scmUsername" );
assertTextPresent( "Password" );
assertElementPresent( "scmPassword" );
}
else
{
assertTextPresent( "Upload POM" );
assertElementPresent( "m2PomFile" );
}
assertTextPresent( "Project Group" );
assertElementPresent( "selectedProjectGroup" );
}
protected void uploadMavenTwoProject( File pomFile, String projectGroup, String importType,
boolean success )
{
goToAddMavenTwoProjectPage();
click( "addMavenTwoProject_pomMethodFILE" );
assertAddMavenTwoProjectPage( false );
setFieldValue( "m2PomFile", pomFile.getAbsolutePath() );
if ( projectGroup != null )
{
selectValue( "addMavenTwoProject_selectedProjectGroup", projectGroup );
}
String typeRadioId = "addMavenTwoProject_importType" + importType;
click( typeRadioId );
submit();
waitForAddProjectResult( success );
}
protected void addMavenTwoProject( String pomUrl, String username, String password, String projectGroup,
boolean success )
{
goToAddMavenTwoProjectPage();
click( "addMavenTwoProject_pomMethodHTTP" );
// Enter values into Add Maven Two Project fields, and submit
setFieldValue( "m2PomUrl", pomUrl );
setFieldValue( "scmUsername", username );
setFieldValue( "scmPassword", password );
if ( projectGroup != null )
{
selectValue( "addMavenTwoProject_selectedProjectGroup", projectGroup );
}
submit();
waitForAddProjectResult( success );
}
private void waitForAddProjectResult( boolean success )
{
String title;
if ( success )
{
title = "Continuum - Project Group";
}
else
{
title = "Continuum - Add Maven Project";
}
waitAddProject( title );
}
protected void submitAddMavenTwoProjectPage( String m2PomUrl )
{
addMavenTwoProject( m2PomUrl, "", "", null, false );
}
// ////////////////////////////////////
// Maven 1.x Project
// ////////////////////////////////////
protected void goToAddMavenOneProjectPage()
{
clickLinkWithText( "Maven 1.x Project" );
assertAddMavenOneProjectPage();
}
protected void assertAddMavenOneProjectPage()
{
assertAddMavenOneProjectPage( null );
}
protected void assertAddMavenOneProjectPage( String existingProjectGroup )
{
assertAddMavenOneProjectPage( existingProjectGroup, true );
}
protected void assertAddMavenOneProjectPage( String existingProjectGroup, boolean isHttp )
{
assertPage( "Continuum - Add Maven 1 Project" );
assertTextPresent( "Add Maven 1.x Project" );
if ( isHttp )
{
assertTextPresent( "M1 POM Url" );
assertElementPresent( "m1PomUrl" );
assertTextPresent( "Username" );
assertElementPresent( "scmUsername" );
assertTextPresent( "Password" );
assertElementPresent( "scmPassword" );
}
else
{
assertTextPresent( "Upload POM" );
assertElementPresent( "m1PomFile" );
}
assertTextPresent( "Project Group" );
assertElementPresent( "selectedProjectGroup" );
if ( existingProjectGroup == null )
{
assertOptionPresent( "selectedProjectGroup", new String[] { "Defined by POM", "Default Project Group" } );
}
else
{
assert existingProjectGroup.equals( getFieldValue( "projectGroupName" ) );
}
assertTextPresent( "Build Definition Template" );
assertElementPresent( "buildDefinitionTemplateId" );
assertOptionPresent( "buildDefinitionTemplateId",
new String[] { "Default", "Default Ant Template", "Default Maven 1 Template",
"Default Maven Template", "Default Shell Template" } );
assertButtonWithValuePresent( "Add" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addMavenOneProject( String pomUrl, String username, String password, String projectGroup,
boolean success )
{
click( "addMavenOneProject_pomMethodHTTP" );
setFieldValue( "m1PomUrl", pomUrl );
setFieldValue( "scmUsername", username );
setFieldValue( "scmPassword", password );
if ( projectGroup != null )
{
selectValue( "selectedProjectGroup", projectGroup );
}
submit();
String title;
if ( success )
{
title = "Continuum - Project Group";
}
else
{
title = "Continuum - Add Maven 1 Project";
}
waitAddProject( title );
}
// ////////////////////////////////////
// ANT/SHELL Projects
// ////////////////////////////////////
protected void goToAddAntProjectPage()
{
clickLinkWithText( "Ant Project" );
assertAddProjectPage( "ant" );
}
protected void goToAddShellProjectPage()
{
clickLinkWithText( "Shell Project" );
assertAddProjectPage( "shell" );
}
protected void assertAddProjectPage( String type )
{
String title = type.substring( 0, 1 ).toUpperCase() + type.substring( 1 ).toLowerCase();
assertPage( "Continuum - Add " + title + " Project" );
assertTextPresent( "Add " + title + " Project" );
assertTextPresent( "Project Name" );
assertElementPresent( "projectName" );
assertTextPresent( "Description" );
assertElementPresent( "projectDescription" );
assertTextPresent( "Version" );
assertElementPresent( "projectVersion" );
assertTextPresent( "Scm Url" );
assertElementPresent( "projectScmUrl" );
assertLinkPresent( "Maven SCM URL" );
assertTextPresent( "Scm Username" );
assertElementPresent( "projectScmUsername" );
assertTextPresent( "Scm Password" );
assertElementPresent( "projectScmPassword" );
assertTextPresent( "Scm Branch/Tag" );
assertElementPresent( "projectScmTag" );
assertTextPresent( "Use SCM Credentials Cache, if available" );
assertElementPresent( "projectScmUseCache" );
assertTextPresent( "Project Group" );
assertElementPresent( "selectedProjectGroup" );
assertOptionPresent( "selectedProjectGroup", new String[] { "Default Project Group" } );
assertTextPresent( "Build Definition Template" );
assertElementPresent( "buildDefinitionTemplateId" );
assertOptionPresent( "buildDefinitionTemplateId",
new String[] { "Default", "Default Ant Template", "Default Maven 1 Template",
"Default Maven Template", "Default Shell Template" } );
assertButtonWithValuePresent( "Add" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addProject( String name, String description, String version, String scmUrl, String scmUser,
String scmPassword, String scmTag, String projectGroup, boolean success, String type )
{
setFieldValue( "projectName", name );
setFieldValue( "projectDescription", description );
setFieldValue( "projectVersion", version );
setFieldValue( "projectScmUrl", scmUrl );
setFieldValue( "projectScmUsername", scmUser );
setFieldValue( "projectScmPassword", scmPassword );
setFieldValue( "projectScmTag", scmTag );
if ( projectGroup != null )
{
selectValue( "selectedProjectGroup", projectGroup );
}
submit();
String title;
type = type.substring( 0, 1 ).toUpperCase() + type.substring( 1 ).toLowerCase();
if ( success )
{
title = "Continuum - Project Group";
}
else
{
title = "Continuum - Add " + type + " Project";
}
waitAddProject( title );
if ( success )
{
assertLinkPresent( name );
}
}
protected void waitAddProject( String title )
{
// the "adding project" interstitial page has an empty title, so we wait for a real title to appear
int currentIt = 1;
int maxIt = 12;
while ( getTitle().equals( "" ) && currentIt <= maxIt )
{
getSelenium().waitForPageToLoad( "10000" ); // 10s
currentIt++;
}
assertEquals( getTitle(), title );
}
protected void createAndAddUserAsDeveloperToGroup( String username, String name, String email, String groupName )
{
clickLinkWithText( "Users" );
assertPage( "[Admin] User List" );
selectValue( "xpath=//select[@name='ec_rd']", "100" );
waitPage();
if ( !isLinkPresent( username ) )
{
clickButtonWithValue( "Create New User" );
assertPage( "[Admin] User Create" );
setFieldValue( "user.fullName", name );
setFieldValue( "user.username", username );
setFieldValue( "user.email", email );
setFieldValue( "user.password", "password123" );
setFieldValue( "user.confirmPassword", "password123" );
clickButtonWithValue( "Create User" );
assertPage( "[Admin] User Edit" );
assignContinuumResourceRoleToUser( groupName );
clickButtonWithValue( "Submit" );
assertPage( "[Admin] User List" );
assertTextPresent( username );
assertTextPresent( name );
assertTextPresent( email );
}
}
protected void showMembers( String name, String groupId, String description )
{
showProjectGroup( name, groupId, description );
clickLinkWithText( "Members" );
assertTextPresent( "Member Projects of " + name + " group" );
assertTextPresent( "Users" );
}
protected void assertUserPresent( String username, String name, String email )
{
assertTextPresent( username );
assertTextPresent( name );
assertTextPresent( email );
}
protected void assertUserNotPresent( String username, String name, String email )
{
assertTextNotPresent( username );
assertTextNotPresent( name );
assertTextNotPresent( email );
}
protected void waitForProjectCheckout()
{
// wait for project to finish checking out
waitForElementPresent( "//img[@alt='Checking Out']", false );
}
void waitForProjectUpdate()
{
if ( isElementPresent( "//img[@alt='Checking Out']" ) )
{
waitForProjectCheckout();
}
// wait for project to finish updating
waitForElementPresent( "//img[@alt='Updating']", false );
}
void waitForProjectBuild()
{
if ( isElementPresent( "//img[@alt='Checking Out']" ) || isElementPresent( "//img[@alt='Updating']" ) )
{
waitForProjectUpdate();
}
// wait for project to finish building
waitForElementPresent( "//img[@alt='Building']", false );
}
void assignContinuumResourceRoleToUser( String groupName )
{
clickLinkWithXPath(
"//input[@name='addDSelectedRoles' and @value='" + "Project Developer" + " - " + groupName + "']", false );
}
protected void removeDefaultBuildDefinitionFromTemplate( String type )
{
goToEditBuildDefinitionTemplate( type );
clickLinkWithXPath( "//input[@value='<-']", false );
submit();
}
protected void addDefaultBuildDefinitionFromTemplate( String type )
{
goToEditBuildDefinitionTemplate( type );
if ( "maven2".equals( type ) )
{
getSelenium().addSelection( "saveBuildDefinitionTemplate_buildDefinitionIds",
"label=" + "Default Maven Build Definition" );
}
clickLinkWithXPath( "//input[@value='->']", false );
submit();
}
void goToEditBuildDefinitionTemplate( String type )
{
clickLinkWithText( "Build Definition Templates" );
assertBuildDefinitionTemplatesPage();
if ( "maven2".equals( type ) )
{
clickLinkWithXPath( "//table[@id='ec_table']/tbody/tr[3]/td[2]/a/img", true );
}
else if ( "maven1".equals( type ) )
{
clickLinkWithXPath( "//table[@id='ec_table']/tbody/tr[2]/td[2]/a/img", true );
}
else if ( "ant".equals( type ) )
{
clickLinkWithXPath( "//img[@alt='Edit']", true );
}
else
{
clickLinkWithXPath( "//table[@id='ec_table']/tbody/tr[4]/td[2]/a/img", true );
}
assertPage( "Continuum - Build Definition Template" );
}
void assertBuildDefinitionTemplatesPage()
{
assertPage( "Continuum - Build Definition Templates" );
assertTextPresent( "Default Ant Template" );
assertTextPresent( "Default Maven 1 Template" );
assertTextPresent( "Default Maven Template" );
assertTextPresent( "Default Shell Template" );
assertTextPresent( "Available Build Definitions" );
assertTextPresent( "Default Ant Build Definition" );
assertTextPresent( "Default Maven 1 Build Definition" );
assertTextPresent( "Default Maven Build Definition" );
assertTextPresent( "Default Shell Build Definition" );
}
// ////////////////////////////////////
// Reports
// ////////////////////////////////////
protected void goToProjectBuildsReport()
{
clickLinkWithText( "Project Builds" );
assertViewBuildsReportPage();
}
void assertViewBuildsReportPage()
{
assertPage( "Continuum - Project Builds Report" );
assertTextPresent( "Project Group" );
assertElementPresent( "projectGroupId" );
assertTextPresent( "Start Date" );
assertElementPresent( "startDate" );
assertTextPresent( "End Date" );
assertElementPresent( "endDate" );
assertTextPresent( "Triggered By" );
assertElementPresent( "triggeredBy" );
assertTextPresent( "Build Status" );
assertElementPresent( "buildStatus" );
assertButtonWithValuePresent( "View Report" );
assertTextNotPresent( "Results" );
assertTextNotPresent( "No Results Found" );
assertTextNotPresent( "Export to CSV" );
}
protected void assertProjectBuildReportWithResult()
{
assertTextPresent( "Results" );
assertTextPresent( "Project Group" );
assertTextPresent( "Project Name" );
assertTextPresent( "Build Number" );
assertTextPresent( "Build Date" );
assertTextPresent( "Triggered By" );
assertTextPresent( "Build Status" );
assertTextPresent( "Prev" );
assertTextPresent( "Next" );
assertTextPresent( "Export to CSV" );
}
protected void assertProjectBuildReportWithNoResult()
{
assertTextNotPresent( "Build Date" );
assertTextNotPresent( "Prev" );
assertTextNotPresent( "Next" );
assertTextNotPresent( "Export to CSV" );
assertTextPresent( "Results" );
assertTextPresent( "No Results Found" );
}
protected void assertProjectBuildReportWithFieldError()
{
assertTextNotPresent( "Build Date" );
assertTextNotPresent( "Prev" );
assertTextNotPresent( "Next" );
assertTextNotPresent( "Export to CSV" );
assertTextNotPresent( "Results" );
assertTextNotPresent( "No Results Found" );
}
@BeforeSuite( alwaysRun = true )
@Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } )
public void initializeContinuum( @Optional( "http://localhost:9595/continuum" ) String baseUrl,
@Optional( "*firefox" ) String browser,
@Optional( "localhost" ) String seleniumHost,
@Optional( "4444" ) int seleniumPort )
throws Exception
{
super.open( baseUrl, browser, seleniumHost, seleniumPort );
Assert.assertNotNull( getSelenium(), "Selenium is not initialized" );
getSelenium().open( baseUrl );
String title = getSelenium().getTitle();
if ( title.equals( "Create Admin User" ) )
{
assertCreateAdmin();
String fullname = getProperty( "ADMIN_FULLNAME" );
String username = getProperty( "ADMIN_USERNAME" );
String mail = getProperty( "ADMIN_MAIL" );
String password = getProperty( "ADMIN_PASSWORD" );
submitAdminData( fullname, mail, password );
assertAutenticatedPage( username );
assertEditConfigurationPage();
postAdminUserCreation();
disableDefaultSchedule();
clickLinkWithText( "Logout" );
}
}
private void postAdminUserCreation()
{
if ( getTitle().endsWith( "Continuum - Configuration" ) )
{
String workingDir = getFieldValue( "workingDirectory" );
String buildOutputDir = getFieldValue( "buildOutputDirectory" );
String releaseOutputDir = getFieldValue( "releaseOutputDirectory" );
String locationDir = "target/data";
String data = "data";
setFieldValue( "workingDirectory", workingDir.replaceFirst( data, locationDir ) );
setFieldValue( "buildOutputDirectory", buildOutputDir.replaceFirst( data, locationDir ) );
setFieldValue( "releaseOutputDirectory", releaseOutputDir.replaceFirst( data, locationDir ) );
setFieldValue( "baseUrl", baseUrl );
submit();
}
}
private void disableDefaultSchedule()
{
clickLinkWithText( "Schedules" );
String xPath = "//preceding::td[text()='DEFAULT_SCHEDULE']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
if ( isChecked( "saveSchedule_active" ) )
{
uncheckField( "saveSchedule_active" );
}
clickButtonWithValue( "Save" );
}
protected void login( String username, String password )
{
goToLoginPage();
getSelenium().type( "loginForm_username", username );
getSelenium().type( "loginForm_password", password );
getSelenium().click( "//input[@value='Login']" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
}
protected void goToSchedulePage()
{
clickLinkWithText( "Schedules" );
assertSchedulePage();
}
protected void assertSchedulePage()
{
assertPage( "Continuum - Schedules" );
assertTextPresent( "Schedules" );
assertTextPresent( "Name" );
assertTextPresent( "Description" );
assertTextPresent( "Quiet Period" );
assertTextPresent( "Cron Expression" );
assertTextPresent( "Max Job Time" );
assertTextPresent( "Active" );
assertTextPresent( "DEFAULT_SCHEDULE" );
assertImgWithAlt( "Edit" );
assertImgWithAlt( "Delete" );
assertButtonWithValuePresent( "Add" );
}
protected void assertAddSchedulePage()
{
assertPage( "Continuum - Edit Schedule" );
assertTextPresent( "Edit Schedule" );
assertTextPresent( "Name" );
assertElementPresent( "name" );
assertTextPresent( "Description" );
assertElementPresent( "description" );
assertTextPresent( "Cron Expression" );
assertTextPresent( "Second" );
assertElementPresent( "second" );
assertTextPresent( "Minute" );
assertElementPresent( "minute" );
assertTextPresent( "Hour" );
assertElementPresent( "hour" );
assertTextPresent( "Day of Month" );
assertElementPresent( "dayOfMonth" );
assertTextPresent( "Month" );
assertElementPresent( "month" );
assertTextPresent( "Day of Week" );
assertElementPresent( "dayOfWeek" );
assertTextPresent( "Year [optional]" );
assertElementPresent( "year" );
assertTextPresent( "Maximum job execution time" );
assertElementPresent( "maxJobExecutionTime" );
assertTextPresent( "Quiet Period (seconds):" );
assertElementPresent( "delay" );
assertTextPresent( "Add Build Queue" );
assertElementPresent( "availableBuildQueuesIds" );
assertElementPresent( "selectedBuildQueuesIds" );
assertElementPresent( "active" );
assertTextPresent( "Enable/Disable the schedule" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
public void goToEditSchedule( String name, String description, String second, String minute, String hour,
String dayMonth, String month, String dayWeek, String year, String maxTime,
String period )
{
goToSchedulePage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddSchedulePage();
assertFieldValue( name, "name" );
assertFieldValue( description, "description" );
assertFieldValue( second, "second" );
assertFieldValue( minute, "minute" );
assertFieldValue( hour, "hour" );
assertFieldValue( dayMonth, "dayOfMonth" );
assertFieldValue( month, "month" );
assertFieldValue( dayWeek, "dayOfWeek" );
assertFieldValue( year, "year" );
assertFieldValue( maxTime, "maxJobExecutionTime" );
assertFieldValue( period, "delay" );
}
protected void buildProjectForQueuePageTest( String projectGroupName, String groupId, String description )
{
showProjectGroup( projectGroupName, groupId, description );
clickButtonWithValue( "Build all projects" );
waitForElementPresent( "//img[@alt='Building']" );
}
protected void goToAddSchedule()
{
goToSchedulePage();
clickButtonWithValue( "Add" );
assertAddSchedulePage();
}
protected void addEditSchedule( String name, String description, String second, String minute, String hour,
String dayMonth, String month, String dayWeek, String year, String maxTime,
String period, boolean buildQueue, boolean success )
{
if ( buildQueue )
{
setFieldValue( "name", name );
setFieldValue( "description", description );
setFieldValue( "second", second );
setFieldValue( "minute", minute );
setFieldValue( "hour", hour );
setFieldValue( "dayOfMonth", dayMonth );
setFieldValue( "month", month );
setFieldValue( "dayOfWeek", dayWeek );
setFieldValue( "year", year );
setFieldValue( "maxJobExecutionTime", maxTime );
setFieldValue( "delay", period );
getSelenium().addSelection( "saveSchedule_availableBuildQueuesIds", "label=DEFAULT_BUILD_QUEUE" );
getSelenium().click( "//input[@value='->']" );
submit();
}
else
{
setFieldValue( "name", name );
setFieldValue( "description", description );
setFieldValue( "second", second );
setFieldValue( "minute", minute );
setFieldValue( "hour", hour );
setFieldValue( "dayOfMonth", dayMonth );
setFieldValue( "month", month );
setFieldValue( "dayOfWeek", dayWeek );
setFieldValue( "year", year );
setFieldValue( "maxJobExecutionTime", maxTime );
setFieldValue( "delay", period );
submit();
}
if ( success )
{
assertSchedulePage();
}
else
{
assertAddSchedulePage();
}
}
protected void goToBuildEnvironmentPage()
{
clickLinkWithText( "Build Environments" );
assertBuildEnvironmentPage();
}
protected void assertBuildEnvironmentPage()
{
assertPage( "Continuum - Build Environments" );
assertTextPresent( "Build Environments" );
assertButtonWithValuePresent( "Add" );
}
protected void goToAddBuildEnvironment()
{
goToBuildEnvironmentPage();
clickButtonWithValue( "Add" );
assertAddBuildEnvironmentPage();
}
protected void assertAddBuildEnvironmentPage()
{
assertPage( "Continuum - Build Environment" );
assertTextPresent( "Build Environment" );
assertTextPresent( "Build Environment Name" );
assertElementPresent( "profile.name" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addBuildEnvironmentWithBuildAgentGroup( String name, String[] installations,
String buildAgentGroupName )
{
setFieldValue( "profile.name", name );
submit();
editBuildEnvironmentWithBuildAgentGroup( name, installations, buildAgentGroupName, true );
}
protected void editBuildEnvironmentWithBuildAgentGroup( String name, String[] installations,
String buildAgentGroupName, boolean success )
{
setFieldValue( "profile.name", name );
selectValue( "profile.buildAgentGroup", buildAgentGroupName );
for ( String i : installations )
{
selectValue( "installationId", i );
clickButtonWithValue( "Add" );
}
submit();
if ( success )
{
assertBuildEnvironmentPage();
}
else
{
assertAddBuildEnvironmentPage();
}
}
protected void assertEditBuildEnvironmentPage( String name )
{
assertAddBuildEnvironmentPage();
assertTextPresent( "Installation Name" );
assertTextPresent( "Type" );
assertFieldValue( name, "profile.name" );
}
protected void goToEditBuildEnvironment( String name )
{
goToBuildEnvironmentPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertEditBuildEnvironmentPage( name );
}
protected void removeBuildEnvironment( String name )
{
removeBuildEnvironment( name, true );
}
protected void removeBuildEnvironment( String name, boolean failIfMissing )
{
goToBuildEnvironmentPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Delete']";
if ( failIfMissing || isElementPresent( "xpath=" + xPath ) )
{
clickLinkWithXPath( xPath );
assertPage( "Continuum - Delete Build Environment" );
assertTextPresent( "Delete Build Environment" );
assertTextPresent( "Are you sure you want to delete Build Environment \"" + name + "\" ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertBuildEnvironmentPage();
assertElementNotPresent( "xpath=" + xPath );
}
}
public static boolean isWindows()
{
String os = System.getProperty( "os.name" ).toLowerCase();
//windows
return os.contains( "win" );
}
// ////////////////////////////////////
// Appearance
// ////////////////////////////////////
protected void goToAppearancePage()
{
clickLinkWithText( "Appearance" );
assertAppearancePage();
}
protected void assertAppearancePage()
{
assertPage( "Configure Appearance" );
assertTextPresent( "Appearance" );
assertTextPresent( "Company Details" );
assertTextPresent( "Footer Content" );
assertButtonWithValuePresent( "Save" );
}
}
| 5,252 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractInstallationTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author José Morales Martínez
*/
public abstract class AbstractInstallationTest
extends AbstractAdminTest
{
protected void goToInstallationPage()
{
clickLinkWithText( "Installations" );
assertInstallationPage();
}
void assertInstallationPage()
{
assertPage( "Continuum - Installations" );
assertTextPresent( "Installations" );
assertButtonWithValuePresent( "Add" );
}
protected void goToAddInstallationTool()
{
goToInstallationPage();
clickButtonWithValue( "Add" );
assertAddChoiceTypeInstallation();
selectValue( "installationType", "Tool" );
clickButtonWithValue( "Add" );
assertAddInstallationToolPage();
}
protected void goToAddInstallationVariable()
{
goToInstallationPage();
clickButtonWithValue( "Add" );
assertAddChoiceTypeInstallation();
selectValue( "installationType", "Environment Variable" );
clickButtonWithValue( "Add" );
assertAddInstallationVariablePage();
}
void assertAddChoiceTypeInstallation()
{
assertPage( "Continuum - Installation Type Choice" );
assertTextPresent( "Installation Type Choice" );
assertTextPresent( "Installation Type" );
assertOptionPresent( "installationType", new String[]{"Tool", "Environment Variable"} );
assertButtonWithValuePresent( "Add" );
assertButtonWithValuePresent( "Cancel" );
}
void assertAddInstallationToolPage()
{
assertEditInstallationToolPage();
assertElementPresent( "automaticProfile" );
assertTextPresent( "Create a Build Environment with the Installation name" );
}
void assertEditInstallationToolPage()
{
assertPage( "Continuum - Installation" );
assertTextPresent( "Installation" );
assertTextPresent( "Name" );
assertElementPresent( "installation.name" );
assertTextPresent( "Type" );
assertOptionPresent( "installation.type", new String[]{"JDK", "Maven", "Maven 1", "ANT"} );
assertTextPresent( "Value/Path" );
assertElementPresent( "installation.varValue" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
void assertAddInstallationVariablePage()
{
assertEditInstallationVariablePage();
assertElementPresent( "automaticProfile" );
assertTextPresent( "Create a Build Environment with the Installation name" );
}
protected void assertEditInstallationVariablePage()
{
assertPage( "Continuum - Installation" );
assertTextPresent( "Installation" );
assertTextPresent( "Name" );
assertElementPresent( "installation.name" );
assertTextPresent( "Environment Variable Name" );
assertElementPresent( "installation.varName" );
assertTextPresent( "Value/Path" );
assertElementPresent( "installation.varValue" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void addInstallation( String name, String var, String path, boolean createBuildEnv, boolean tool,
boolean success )
{
if ( createBuildEnv )
{
checkField( "automaticProfile" );
}
else
{
uncheckField( "automaticProfile" );
}
editInstallation( name, var, path, tool, success );
}
protected void editInstallation( String name, String var, String path, boolean tool, boolean success )
{
setFieldValue( "installation.name", name );
setFieldValue( "installation.varValue", path );
if ( tool )
{
selectValue( "installation.type", var );
}
else
{
setFieldValue( "installation.varName", var );
}
submit();
if ( success )
{
assertInstallationPage();
}
else if ( tool )
{
assertAddInstallationToolPage();
}
else
{
assertAddInstallationVariablePage();
}
}
protected void goToEditInstallation( String name, String var, String path, boolean tool )
{
goToInstallationPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
if ( tool )
{
assertEditInstallationToolPage();
}
else
{
assertEditInstallationVariablePage();
assertFieldValue( var, "installation.varName" );
}
assertFieldValue( name, "installation.name" );
assertFieldValue( path, "installation.varValue" );
}
protected void removeInstallation( String name, boolean failIfMissing )
{
goToInstallationPage();
String xpath = "(//a[contains(@href,'deleteInstallation') and contains(@href, '" + name + "')])//img";
if ( isElementPresent( "xpath=" + xpath ) || failIfMissing )
{
clickLinkWithXPath( xpath );
assertPage( "Continuum - Delete Installation" );
assertTextPresent( "Delete Installation" );
assertTextPresent( "Are you sure you want to delete \"" + name + "\" installation ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertInstallationPage();
}
}
}
| 5,253 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractLocalRepositoryTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author José Morales Martínez
*/
public abstract class AbstractLocalRepositoryTest
extends AbstractAdminTest
{
void goToLocalRepositoryPage()
{
clickLinkWithText( "Local Repositories" );
assertLocalRepositoryPage();
}
void assertLocalRepositoryPage()
{
assertPage( "Continuum - Local Repositories" );
assertTextPresent( "Local Repositories" );
assertTextPresent( "Name" );
assertTextPresent( "Location" );
assertTextPresent( "Layout" );
assertImgWithAlt( "Edit" );
assertImgWithAlt( "Purge" );
assertImgWithAlt( "Delete" );
assertButtonWithValuePresent( "Add" );
}
void assertAddLocalRepositoryPage()
{
assertPage( "Continuum - Add/Edit Local Repository" );
assertTextPresent( "Add/Edit Local Repository" );
assertTextPresent( "Name" );
assertElementPresent( "repository.name" );
assertTextPresent( "Location" );
assertElementPresent( "repository.location" );
assertTextPresent( "Layout" );
assertElementPresent( "repository.layout" );
assertButtonWithValuePresent( "Save" );
assertButtonWithValuePresent( "Cancel" );
}
protected void removeLocalRepository( String name )
{
goToLocalRepositoryPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Delete']";
clickLinkWithXPath( xPath );
assertTextPresent( "Delete Local Repository" );
assertTextPresent( "Are you sure you want to delete Local Repository \"" + name + "\" ?" );
assertButtonWithValuePresent( "Delete" );
assertButtonWithValuePresent( "Cancel" );
clickButtonWithValue( "Delete" );
assertLocalRepositoryPage();
}
protected void goToAddLocalRepository()
{
goToLocalRepositoryPage();
clickButtonWithValue( "Add" );
assertAddLocalRepositoryPage();
}
protected void goToEditLocalRepository( String name, String location )
{
goToLocalRepositoryPage();
String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
clickLinkWithXPath( xPath );
assertAddLocalRepositoryPage();
assertFieldValue( name, "repository.name" );
assertFieldValue( location, "repository.location" );
}
protected void addEditLocalRepository( String name, String location, boolean success )
{
setFieldValue( "repository.name", name );
setFieldValue( "repository.location", location );
submit();
if ( success )
{
assertLocalRepositoryPage();
}
else
{
assertAddLocalRepositoryPage();
}
}
}
| 5,254 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test | Create_ds/continuum/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java | package org.apache.continuum.web.test.parent;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import org.apache.commons.io.IOUtils;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
/**
* Based on AbstractSeleniumTestCase of Emmanuel Venisse test.
*
* @author José Morales Martínez
*/
public abstract class AbstractSeleniumTest
{
protected static String baseUrl;
static String browser;
protected static String maxWaitTimeInMs;
private static final ThreadLocal<Selenium> selenium = new ThreadLocal<Selenium>();
private static Properties p;
private final static String PROPERTIES_SEPARATOR = "=";
private static String maxProjectWaitTimeInMs;
/**
* Initialize selenium
*/
void open( String baseUrl, String browser, String seleniumHost, int seleniumPort )
throws Exception
{
InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" );
p = new Properties();
p.load( input );
// for running in the IDE
String svnBaseUrl = "file://localhost/" + new File( "target/example-svn" ).getAbsolutePath();
for ( String key : p.stringPropertyNames() )
{
String value = p.getProperty( key );
String newValue = value.replace( "${svn.base.url}", svnBaseUrl );
newValue = newValue.replace( "${maven.home}", System.getProperty( "maven.home", "/usr/share/maven" ) );
p.setProperty( key, newValue );
}
maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" );
maxProjectWaitTimeInMs = getProperty( "MAX_PROJECT_WAIT_TIME_IN_MS" );
AbstractSeleniumTest.baseUrl = baseUrl;
AbstractSeleniumTest.browser = browser;
if ( getSelenium() == null )
{
DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
s.start();
s.setTimeout( maxWaitTimeInMs );
selenium.set( s );
}
}
public static Selenium getSelenium()
{
return selenium == null ? null : selenium.get();
}
protected String getProperty( String key )
{
return p.getProperty( key );
}
// TODO: look into removing this, as the issue should be fixed by upgrading the resources plugin to v2.4+
protected String getEscapeProperty( String key )
{
InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" );
String value = null;
List<String> lines;
try
{
lines = IOUtils.readLines( input );
}
catch ( IOException e )
{
lines = new ArrayList<String>();
}
for ( String l : lines )
{
if ( l != null && l.startsWith( key ) )
{
int indexSeparator = l.indexOf( PROPERTIES_SEPARATOR );
value = l.substring( indexSeparator + 1 ).trim();
break;
}
}
return value;
}
/**
* Close selenium session. Called from AfterSuite method of sub-class
*/
@AfterSuite( alwaysRun = true )
public void close()
throws Exception
{
if ( getSelenium() != null )
{
getSelenium().stop();
selenium.set( null );
}
}
// *******************************************************
// Auxiliar methods. This method help us and simplify test.
// *******************************************************
protected void assertFieldValue( String fieldValue, String fieldName )
{
assertElementPresent( fieldName );
Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
}
protected void assertPage( String title )
{
Assert.assertEquals( getTitle(), title );
}
protected String getTitle()
{
return getSelenium().getTitle();
}
protected void assertTextPresent( String text )
{
Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
}
protected void assertTextNotPresent( String text )
{
Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
}
protected void assertElementPresent( String elementLocator )
{
Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
}
protected void assertElementNotPresent( String elementLocator )
{
Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
}
protected void assertLinkPresent( String text )
{
Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." );
}
protected void assertLinkNotPresent( String text )
{
Assert.assertFalse( isElementPresent( "link=" + text ), "The link '" + text + "' is present." );
}
protected void assertImgWithAlt( String alt )
{
assertElementPresent( "//img[@alt='" + alt + "']" );
}
protected void assertCellValueFromTable( String expected, String tableElement, int row, int column )
{
Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
}
protected boolean isTextPresent( String text )
{
return getSelenium().isTextPresent( text );
}
protected boolean isLinkPresent( String text )
{
return isElementPresent( "link=" + text );
}
protected boolean isElementPresent( String locator )
{
return getSelenium().isElementPresent( locator );
}
protected void waitPage()
{
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
}
protected String getFieldValue( String fieldName )
{
return getSelenium().getValue( fieldName );
}
String getCellValueFromTable( String tableElement, int row, int column )
{
return getSelenium().getTable( tableElement + "." + row + "." + column );
}
protected void selectValue( String locator, String value )
{
getSelenium().select( locator, "label=" + value );
}
void assertOptionPresent( String selectField, String[] options )
{
assertElementPresent( selectField );
String[] optionsPresent = getSelenium().getSelectOptions( selectField );
List<String> expected = Arrays.asList( options );
List<String> present = Arrays.asList( optionsPresent );
Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" );
}
protected void submit()
{
submit( true );
}
protected void submit( boolean wait )
{
clickLinkWithXPath( "//input[@type='submit']", wait );
}
protected void assertButtonWithValuePresent( String text )
{
Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
}
void assertButtonWithIdPresent( String id )
{
Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
}
boolean isButtonWithValuePresent( String text )
{
return isElementPresent( "//button[@value='" + text + "']" ) || isElementPresent(
"//input[@value='" + text + "']" );
}
boolean isButtonWithIdPresent( String text )
{
return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" );
}
protected void clickButtonWithValue( String text )
{
clickButtonWithValue( text, true );
}
void clickButtonWithValue( String text, boolean wait )
{
assertButtonWithValuePresent( text );
if ( isElementPresent( "//button[@value='" + text + "']" ) )
{
clickLinkWithXPath( "//button[@value='" + text + "']", wait );
}
else
{
clickLinkWithXPath( "//input[@value='" + text + "']", wait );
}
}
void clickSubmitWithLocator( String locator )
{
clickLinkWithLocator( locator );
}
protected void clickImgWithAlt( String alt )
{
clickLinkWithLocator( "//img[@alt='" + alt + "']" );
}
protected void clickLinkWithText( String text )
{
clickLinkWithLocator( "link=" + text, true );
}
protected void clickLinkWithXPath( String xpath )
{
clickLinkWithXPath( xpath, true );
}
protected void clickLinkWithXPath( String xpath, boolean wait )
{
clickLinkWithLocator( "xpath=" + xpath, wait );
}
protected void clickLinkWithLocator( String locator )
{
clickLinkWithLocator( locator, true );
}
protected void clickLinkWithLocator( String locator, boolean wait )
{
getSelenium().click( locator );
if ( wait )
{
waitPage();
}
}
protected void setFieldValue( String fieldName, String value )
{
getSelenium().type( fieldName, value );
}
protected void checkField( String locator )
{
getSelenium().check( locator );
}
protected void uncheckField( String locator )
{
getSelenium().uncheck( locator );
}
boolean isChecked( String locator )
{
return getSelenium().isChecked( locator );
}
void assertIsChecked( String locator )
{
Assert.assertTrue( isChecked( locator ) );
}
void click( String locator )
{
getSelenium().click( locator );
}
protected void clickAndWait( String locator )
{
getSelenium().click( locator );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
}
protected void waitForElementPresent( String locator )
{
waitForElementPresent( locator, true );
}
/*
* This will wait for the condition to be met.
* * shouldBePresent - if the locator is expected or not (true or false respectively)
*/
void waitForElementPresent( String locator, boolean shouldBePresent )
{
waitForOneOfElementsPresent( Collections.singletonList( locator ), shouldBePresent );
}
protected void waitForOneOfElementsPresent( List<String> locators, boolean shouldBePresent )
{
int currentIt = 0;
int maxIt = Integer.valueOf( getProperty( "WAIT_TRIES" ) );
String pageLoadTimeInMs = maxWaitTimeInMs;
while ( currentIt < maxIt )
{
for ( String locator : locators )
{
if ( isElementPresent( locator ) == shouldBePresent )
{
return;
}
}
getSelenium().waitForPageToLoad( pageLoadTimeInMs );
currentIt++;
}
}
void assertEnabled()
{
Assert.assertTrue( getSelenium().isEditable( "alwaysBuild" ), "'" + "alwaysBuild" + "' is disabled" );
}
}
| 5,255 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2094-example/module/src/test/java | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2094-example/module/src/test/java/module/AppTest.java | package module;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| 5,256 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2094-example/module/src/main/java | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2094-example/module/src/main/java/module/App.java | package module;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| 5,257 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/flat-example/flat-core/src/test/java/com/example | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/flat-example/flat-core/src/test/java/com/example/flat/AppTest.java | package com.example.flat;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| 5,258 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/flat-example/flat-core/src/main/java/com/example | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/flat-example/flat-core/src/main/java/com/example/flat/App.java | package com.example.flat;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| 5,259 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-failing-project/src/test/java/org/apache | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-failing-project/src/test/java/org/apache/continuum/AppTest.java | package org.apache.continuum;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| 5,260 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-failing-project/src/main/java/org/apache | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-failing-project/src/main/java/org/apache/continuum/App.java | package org.apache.continuum;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" )
}
}
| 5,261 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-build-queue-test-data/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-build-queue-test-data/src/test/java/org/apache/continuum/examples/BasicThreadTest.java | package org.apache.continuum.examples;
import org.testng.annotations.Test;
public class BasicThreadTest {
@Test
public void testThread() {
try {
long numMillisecondsToSleep = 60000; // 1 * 60 seconds
Thread.sleep(numMillisecondsToSleep);
} catch (InterruptedException e) {
}
}
}
| 5,262 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/simple-example/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/simple-example/src/test/java/org/apache/continuum/examples/AppTest.java | package org.apache.continuum.examples;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| 5,263 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/simple-example/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/simple-example/src/main/java/org/apache/continuum/examples/App.java | package org.apache.continuum.examples;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| 5,264 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2437-example/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2437-example/src/test/java/org/apache/continuum/examples/AppTest.java | package org.apache.continuum.examples;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| 5,265 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2437-example/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/continuum-2437-example/src/main/java/org/apache/continuum/examples/App.java | package org.apache.continuum.examples;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| 5,266 |
0 | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/tail-output/src/test | Create_ds/continuum/continuum-webapp-test/src/test/example-projects/tail-output/src/test/java/SampleTest.java | import org.junit.*;
import static org.junit.Assert.*;
public class SampleTest {
@Before
public void setUp() {
}
@Test
public void tryOne() {
}
@Test
public void tryTwo() {
}
}
| 5,267 |
0 | Create_ds/continuum/continuum-base/continuum-configuration/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java | package org.apache.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.utils.file.DefaultFileSystemManager;
import org.apache.continuum.utils.file.FileSystemManager;
import org.apache.maven.continuum.PlexusSpringTestCase;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author <a href="mailto:olamy@apache.org">olamy</a>
* @since 17 juin 2008
*/
public class TestDefaultContinuumConfiguration
extends PlexusSpringTestCase
{
private static final Logger log = LoggerFactory.getLogger( TestDefaultContinuumConfiguration.class );
private static final String confFile = "target/test-classes/conf/continuum.xml";
private FileSystemManager fsManager;
@Before
public void setUp()
throws Exception
{
log.info( "appserver.base : " + System.getProperty( "appserver.base" ) );
fsManager = new DefaultFileSystemManager(); // can't lookup since we're before spring/plexus setup
File originalConf = new File( getBasedir(), "src/test/resources/conf/continuum.xml" );
File confUsed = new File( getBasedir(), confFile );
if ( confUsed.exists() )
{
confUsed.delete();
}
fsManager.copyFile( originalConf, confUsed );
}
@Test
public void testLoad()
throws Exception
{
ContinuumConfiguration configuration = (ContinuumConfiguration) lookup( ContinuumConfiguration.class,
"default" );
assertNotNull( configuration );
GeneralConfiguration generalConfiguration = configuration.getGeneralConfiguration();
assertNotNull( generalConfiguration );
assertNotNull( generalConfiguration.getBaseUrl() );
assertEquals( "http://test", generalConfiguration.getBaseUrl() );
assertEquals( new File( "myBuildOutputDir" ), generalConfiguration.getBuildOutputDirectory() );
assertTrue( generalConfiguration.isDistributedBuildEnabled() );
assertNotNull( generalConfiguration.getBuildAgents() );
org.apache.continuum.configuration.BuildAgentConfiguration buildAgentConfig =
generalConfiguration.getBuildAgents().get( 0 );
assertEquals( "http://buildagent/xmlrpc", buildAgentConfig.getUrl() );
assertEquals( "linux", buildAgentConfig.getDescription() );
assertTrue( buildAgentConfig.isEnabled() );
// agent group tests
assertNotNull( "agent group", generalConfiguration.getBuildAgentGroups() );
BuildAgentGroupConfiguration buildAgentGroupConfig = generalConfiguration.getBuildAgentGroups().get( 0 );
assertEquals( "group-agent-1", buildAgentGroupConfig.getName() );
BuildAgentConfiguration agentConfig = buildAgentGroupConfig.getBuildAgents().get( 0 );
assertEquals( "http://buildagent/xmlrpc", agentConfig.getUrl() );
assertEquals( "linux", agentConfig.getDescription() );
}
@Test
public void testDefaultConfiguration()
throws Exception
{
File conf = new File( getBasedir(), confFile );
if ( conf.exists() )
{
conf.delete();
}
ContinuumConfiguration configuration = (ContinuumConfiguration) lookup( ContinuumConfiguration.class,
"default" );
assertNotNull( configuration );
GeneralConfiguration generalConfiguration = new GeneralConfiguration();
generalConfiguration.setBaseUrl( "http://test/zloug" );
generalConfiguration.setProxyConfiguration( new ProxyConfiguration() );
generalConfiguration.getProxyConfiguration().setProxyHost( "localhost" );
generalConfiguration.getProxyConfiguration().setProxyPort( 8080 );
File targetDir = new File( getBasedir(), "target" );
generalConfiguration.setBuildOutputDirectory( targetDir );
BuildAgentConfiguration buildAgentConfiguration = new BuildAgentConfiguration();
buildAgentConfiguration.setUrl( "http://buildagent/test" );
buildAgentConfiguration.setDescription( "windows xp" );
buildAgentConfiguration.setEnabled( false );
BuildAgentConfiguration buildAgentConfiguration2 = new BuildAgentConfiguration();
buildAgentConfiguration2.setUrl( "http://buildagent-node-2/test" );
buildAgentConfiguration2.setDescription( "linux" );
buildAgentConfiguration2.setEnabled( true );
List<BuildAgentConfiguration> buildAgents = new ArrayList<BuildAgentConfiguration>();
buildAgents.add( buildAgentConfiguration );
buildAgents.add( buildAgentConfiguration2 );
BuildAgentGroupConfiguration buildAgentGroupConfiguration = new BuildAgentGroupConfiguration();
buildAgentGroupConfiguration.setName( "secret-agent" );
buildAgentGroupConfiguration.setBuildAgents( buildAgents );
List<BuildAgentGroupConfiguration> buildAgentGroups = new ArrayList<BuildAgentGroupConfiguration>();
buildAgentGroups.add( buildAgentGroupConfiguration );
generalConfiguration.setDistributedBuildEnabled( false );
generalConfiguration.setBuildAgents( buildAgents );
generalConfiguration.setBuildAgentGroups( buildAgentGroups );
configuration.setGeneralConfiguration( generalConfiguration );
configuration.save();
String contents = fsManager.fileContents( conf );
assertTrue( contents.indexOf( "http://test/zloug" ) > 0 );
assertTrue( contents.indexOf( "localhost" ) > 0 );
assertTrue( contents.indexOf( "8080" ) > 0 );
assertTrue( contents.indexOf( "http://buildagent/test" ) > 0 );
assertTrue( contents.indexOf( "windows xp" ) > 0 );
assertTrue( contents.indexOf( "http://buildagent-node-2/test" ) > 0 );
assertTrue( contents.indexOf( "linux" ) > 0 );
assertTrue( contents.indexOf( "secret-agent" ) > 0 );
configuration.reload();
assertEquals( "http://test/zloug", configuration.getGeneralConfiguration().getBaseUrl() );
assertEquals( "localhost", configuration.getGeneralConfiguration().getProxyConfiguration().getProxyHost() );
assertEquals( 8080, configuration.getGeneralConfiguration().getProxyConfiguration().getProxyPort() );
assertEquals( targetDir.getPath(),
configuration.getGeneralConfiguration().getBuildOutputDirectory().getPath() );
assertEquals( "http://buildagent/test", configuration.getGeneralConfiguration().getBuildAgents().get(
0 ).getUrl() );
assertFalse( configuration.getGeneralConfiguration().getBuildAgents().get( 0 ).isEnabled() );
assertEquals( "http://buildagent-node-2/test", configuration.getGeneralConfiguration().getBuildAgents().get(
1 ).getUrl() );
assertTrue( configuration.getGeneralConfiguration().getBuildAgents().get( 1 ).isEnabled() );
assertEquals( "secret-agent", configuration.getGeneralConfiguration().getBuildAgentGroups().get(
0 ).getName() );
assertEquals( "http://buildagent/test", configuration.getGeneralConfiguration().getBuildAgentGroups().get(
0 ).getBuildAgents().get( 0 ).getUrl() );
assertEquals( "http://buildagent-node-2/test",
configuration.getGeneralConfiguration().getBuildAgentGroups().get( 0 ).getBuildAgents().get(
1 ).getUrl() );
assertFalse( configuration.getGeneralConfiguration().isDistributedBuildEnabled() );
log.info( "generalConfiguration " + configuration.getGeneralConfiguration().toString() );
}
}
| 5,268 |
0 | Create_ds/continuum/continuum-base/continuum-configuration/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java | package org.apache.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.apache.continuum.configuration.model.ContinuumConfigurationModel;
import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Reader;
import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Writer;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:olamy@apache.org">olamy</a>
* @since 17 juin 2008
*/
public class DefaultContinuumConfiguration
implements ContinuumConfiguration
{
private static final Logger log = LoggerFactory.getLogger( DefaultContinuumConfiguration.class );
private File configurationFile;
private GeneralConfiguration generalConfiguration;
public static final String CONFIGURATION_FILE = "continuum.xml";
//----------------------------------------------------
// Initialize method configured in the Spring xml
// configuration file
//----------------------------------------------------
protected void initialize()
{
if ( log.isDebugEnabled() )
{
log.debug( "configurationFile null " + ( configurationFile.getPath() == null ) );
}
if ( configurationFile != null && configurationFile.exists() )
{
try
{
reload( configurationFile );
}
catch ( ContinuumConfigurationException e )
{
// skip this and only log a warn
log.warn( " error on loading configuration from file " + configurationFile.getPath() );
}
}
else
{
log.info( "configuration file not exists" );
this.generalConfiguration = new GeneralConfiguration();
}
}
public void reload()
throws ContinuumConfigurationException
{
this.initialize();
}
public void save()
throws ContinuumConfigurationException
{
if ( !configurationFile.exists() )
{
configurationFile.getParentFile().mkdirs();
}
save( configurationFile );
}
/**
* @see org.apache.continuum.configuration.ContinuumConfiguration#getGeneralConfiguration()
*/
public GeneralConfiguration getGeneralConfiguration()
throws ContinuumConfigurationException
{
return this.generalConfiguration;
}
public void setGeneralConfiguration( GeneralConfiguration generalConfiguration )
throws ContinuumConfigurationException
{
this.generalConfiguration = generalConfiguration;
}
public void reload( File file )
throws ContinuumConfigurationException
{
FileInputStream fis = null;
try
{
fis = new FileInputStream( file );
ContinuumConfigurationModelXpp3Reader configurationXpp3Reader = new ContinuumConfigurationModelXpp3Reader();
ContinuumConfigurationModel configuration = configurationXpp3Reader.read( new InputStreamReader( fis ) );
this.generalConfiguration = new GeneralConfiguration();
this.generalConfiguration.setNumberOfBuildsInParallel( configuration.getNumberOfBuildsInParallel() );
this.generalConfiguration.setBaseUrl( configuration.getBaseUrl() );
this.generalConfiguration.setSharedSecretPassword( configuration.getSharedSecretPassword() );
if ( StringUtils.isNotEmpty( configuration.getBuildOutputDirectory() ) )
{
// TODO take care if file exists ?
this.generalConfiguration.setBuildOutputDirectory( new File(
configuration.getBuildOutputDirectory() ) );
}
if ( StringUtils.isNotEmpty( configuration.getDeploymentRepositoryDirectory() ) )
{
// TODO take care if file exists ?
this.generalConfiguration.setDeploymentRepositoryDirectory( new File(
configuration.getDeploymentRepositoryDirectory() ) );
}
if ( StringUtils.isNotEmpty( configuration.getWorkingDirectory() ) )
{
// TODO take care if file exists ?
this.generalConfiguration.setWorkingDirectory( new File( configuration.getWorkingDirectory() ) );
}
if ( configuration.getProxyConfiguration() != null )
{
ProxyConfiguration proxyConfiguration = new ProxyConfiguration(
configuration.getProxyConfiguration().getProxyHost(),
configuration.getProxyConfiguration().getProxyPassword(),
configuration.getProxyConfiguration().getProxyPort(),
configuration.getProxyConfiguration().getProxyUser() );
this.generalConfiguration.setProxyConfiguration( proxyConfiguration );
}
if ( StringUtils.isNotEmpty( configuration.getReleaseOutputDirectory() ) )
{
// TODO take care if file exists?
this.generalConfiguration.setReleaseOutputDirectory( new File(
configuration.getReleaseOutputDirectory() ) );
}
// set the configuration for diistributedBuildEnabled
this.generalConfiguration.setDistributedBuildEnabled( configuration.isDistributedBuildEnabled() );
this.generalConfiguration.setInitialized( configuration.isInitialized() );
if ( configuration.getBuildAgents() != null )
{
List<BuildAgentConfiguration> buildAgents = new ArrayList<BuildAgentConfiguration>();
List<org.apache.continuum.configuration.model.BuildAgentConfiguration> agents =
configuration.getBuildAgents();
for ( org.apache.continuum.configuration.model.BuildAgentConfiguration agent : agents )
{
BuildAgentConfiguration buildAgent = new BuildAgentConfiguration( agent.getUrl(),
agent.getDescription(),
agent.isEnabled() );
buildAgents.add( buildAgent );
}
this.generalConfiguration.setBuildAgents( buildAgents );
}
if ( configuration.getBuildAgentGroups() != null )
{
List<BuildAgentGroupConfiguration> buildAgentGroups = new ArrayList<BuildAgentGroupConfiguration>();
List<org.apache.continuum.configuration.model.BuildAgentGroupConfiguration> groups =
configuration.getBuildAgentGroups();
for ( org.apache.continuum.configuration.model.BuildAgentGroupConfiguration group : groups )
{
List<BuildAgentConfiguration> agents = new ArrayList<BuildAgentConfiguration>();
List<org.apache.continuum.configuration.model.BuildAgentConfiguration> modelAgents =
group.getBuildAgents();
for ( org.apache.continuum.configuration.model.BuildAgentConfiguration modelAgent : modelAgents )
{
BuildAgentConfiguration buildAgent = new BuildAgentConfiguration( modelAgent.getUrl(),
modelAgent.getDescription(),
modelAgent.isEnabled() );
agents.add( buildAgent );
}
BuildAgentGroupConfiguration groupAgent = new BuildAgentGroupConfiguration( group.getName(),
agents );
buildAgentGroups.add( groupAgent );
}
this.generalConfiguration.setBuildAgentGroups( buildAgentGroups );
}
}
catch ( IOException e )
{
log.error( e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e );
}
catch ( XmlPullParserException e )
{
log.error( e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e );
}
finally
{
if ( fis != null )
{
IOUtil.close( fis );
}
}
}
public void save( File file )
throws ContinuumConfigurationException
{
try
{
ContinuumConfigurationModel configurationModel = new ContinuumConfigurationModel();
configurationModel.setBaseUrl( this.generalConfiguration.getBaseUrl() );
configurationModel.setNumberOfBuildsInParallel( this.generalConfiguration.getNumberOfBuildsInParallel() );
configurationModel.setSharedSecretPassword( this.generalConfiguration.getSharedSecretPassword() );
// normally not null but NPE free is better !
if ( this.generalConfiguration.getBuildOutputDirectory() != null )
{
configurationModel.setBuildOutputDirectory(
this.generalConfiguration.getBuildOutputDirectory().getPath() );
}
if ( this.generalConfiguration.getWorkingDirectory() != null )
{
configurationModel.setWorkingDirectory( this.generalConfiguration.getWorkingDirectory().getPath() );
}
if ( this.generalConfiguration.getDeploymentRepositoryDirectory() != null )
{
configurationModel.setDeploymentRepositoryDirectory(
this.generalConfiguration.getDeploymentRepositoryDirectory().getPath() );
}
if ( this.generalConfiguration.getProxyConfiguration() != null )
{
configurationModel.setProxyConfiguration(
new org.apache.continuum.configuration.model.ProxyConfiguration() );
configurationModel.getProxyConfiguration().setProxyHost(
this.generalConfiguration.getProxyConfiguration().getProxyHost() );
configurationModel.getProxyConfiguration().setProxyPassword(
this.generalConfiguration.getProxyConfiguration().getProxyPassword() );
configurationModel.getProxyConfiguration().setProxyPort(
this.generalConfiguration.getProxyConfiguration().getProxyPort() );
configurationModel.getProxyConfiguration().setProxyHost(
this.generalConfiguration.getProxyConfiguration().getProxyHost() );
}
if ( this.generalConfiguration.getReleaseOutputDirectory() != null )
{
configurationModel.setReleaseOutputDirectory(
this.generalConfiguration.getReleaseOutputDirectory().getPath() );
}
// set configuration for distributedBuildEnabled.
configurationModel.setDistributedBuildEnabled( this.generalConfiguration.isDistributedBuildEnabled() );
configurationModel.setInitialized( this.generalConfiguration.isInitialized() );
if ( this.generalConfiguration.getBuildAgents() != null )
{
List<org.apache.continuum.configuration.model.BuildAgentConfiguration> buildAgents =
new ArrayList<org.apache.continuum.configuration.model.BuildAgentConfiguration>();
for ( BuildAgentConfiguration agent : this.generalConfiguration.getBuildAgents() )
{
org.apache.continuum.configuration.model.BuildAgentConfiguration buildAgent =
new org.apache.continuum.configuration.model.BuildAgentConfiguration();
buildAgent.setUrl( agent.getUrl() );
buildAgent.setDescription( agent.getDescription() );
buildAgent.setEnabled( agent.isEnabled() );
buildAgents.add( buildAgent );
}
configurationModel.setBuildAgents( buildAgents );
}
if ( this.generalConfiguration.getBuildAgentGroups() != null )
{
List<org.apache.continuum.configuration.model.BuildAgentGroupConfiguration> buildAgentGroups =
new ArrayList<org.apache.continuum.configuration.model.BuildAgentGroupConfiguration>();
for ( BuildAgentGroupConfiguration group : this.generalConfiguration.getBuildAgentGroups() )
{
org.apache.continuum.configuration.model.BuildAgentGroupConfiguration buildAgentGroup =
new org.apache.continuum.configuration.model.BuildAgentGroupConfiguration();
buildAgentGroup.setName( group.getName() );
List<org.apache.continuum.configuration.model.BuildAgentConfiguration> buildAgents =
new ArrayList<org.apache.continuum.configuration.model.BuildAgentConfiguration>();
if ( group.getBuildAgents() != null )
{
for ( BuildAgentConfiguration agent : group.getBuildAgents() )
{
org.apache.continuum.configuration.model.BuildAgentConfiguration buildAgent =
new org.apache.continuum.configuration.model.BuildAgentConfiguration();
buildAgent.setUrl( agent.getUrl() );
buildAgent.setDescription( agent.getDescription() );
buildAgent.setEnabled( agent.isEnabled() );
buildAgents.add( buildAgent );
}
buildAgentGroup.setBuildAgents( buildAgents );
}
buildAgentGroups.add( buildAgentGroup );
}
configurationModel.setBuildAgentGroups( buildAgentGroups );
}
ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
FileWriter fileWriter = new FileWriter( file );
writer.write( fileWriter, configurationModel );
fileWriter.flush();
fileWriter.close();
}
catch ( IOException e )
{
throw new ContinuumConfigurationException( e.getMessage(), e );
}
}
// ----------------------------------------
// Spring injection
// ----------------------------------------
public File getConfigurationFile()
{
return configurationFile;
}
public void setConfigurationFile( File configurationFile )
{
this.configurationFile = configurationFile;
}
}
| 5,269 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/ContinuumScmUtilsTest.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
*/
public class ContinuumScmUtilsTest
{
@Test
public void testGitProviderWithSSHProtocolUsernameInUrl()
throws Exception
{
ContinuumScmConfiguration scmConfiguration = new ContinuumScmConfiguration();
scmConfiguration = ContinuumScmUtils.setSCMCredentialsforSSH( scmConfiguration,
"scm:git:ssh://sshUser@gitrepo.com/myproject.git",
"dummyuser", "dummypassword" );
assertEquals( "sshUser", scmConfiguration.getUsername() );
assertTrue( StringUtils.isBlank( scmConfiguration.getPassword() ) );
}
@Test
public void testGitProviderWithSSHProtocolUsernameAndPasswordInUrl()
throws Exception
{
ContinuumScmConfiguration scmConfiguration = new ContinuumScmConfiguration();
scmConfiguration = ContinuumScmUtils.setSCMCredentialsforSSH( scmConfiguration,
"scm:git:ssh://sshUser:sshPassword@gitrepo.com/myproject.git",
"dummyuser", "dummypassword" );
assertEquals( "sshUser", scmConfiguration.getUsername() );
assertEquals( "sshPassword", scmConfiguration.getPassword() );
}
@Test
public void testGitProviderWithSSHProtocolNoCredentialsInUrl()
throws Exception
{
ContinuumScmConfiguration scmConfiguration = new ContinuumScmConfiguration();
scmConfiguration = ContinuumScmUtils.setSCMCredentialsforSSH( scmConfiguration,
"scm:git:ssh://gitrepo.com/myproject.git",
"dummyuser", "dummypassword" );
assertEquals( "dummyuser", scmConfiguration.getUsername() );
assertEquals( "dummypassword", scmConfiguration.getPassword() );
}
@Test
public void testNotGitProvider()
throws Exception
{
ContinuumScmConfiguration scmConfiguration = new ContinuumScmConfiguration();
scmConfiguration = ContinuumScmUtils.setSCMCredentialsforSSH( scmConfiguration,
"scm:svn:ssh://svnrepo.com/repos/myproject/trunk",
"dummyuser", "dummypassword" );
assertEquals( "dummyuser", scmConfiguration.getUsername() );
assertEquals( "dummypassword", scmConfiguration.getPassword() );
}
@Test
public void testNotSSHProtocol()
throws Exception
{
ContinuumScmConfiguration scmConfiguration = new ContinuumScmConfiguration();
scmConfiguration = ContinuumScmUtils.setSCMCredentialsforSSH( scmConfiguration,
"scm:git:https://gitrepo.com/myproject.git",
"dummyuser", "dummypassword" );
assertEquals( "dummyuser", scmConfiguration.getUsername() );
assertEquals( "dummypassword", scmConfiguration.getPassword() );
}
}
| 5,270 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.scm.manager.ScmManager;
import org.apache.maven.scm.ScmBranch;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.util.Date;
import static org.mockito.Mockito.*;
public class DefaultContinuumScmTest
{
private ScmManager scmManager;
private ScmRepository scmRepository;
private ScmProviderRepository scmProviderRepository;
private DefaultContinuumScm continuumScm;
private ContinuumScmConfiguration config;
@Before
public void setUp()
throws ScmRepositoryException, NoSuchScmProviderException
{
config = new ContinuumScmConfiguration();
config.setWorkingDirectory( new File( "1" ) );
config.setUrl( "scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-clean-plugin" );
scmManager = mock( ScmManager.class );
scmRepository = mock( ScmRepository.class );
scmProviderRepository = mock( ScmProviderRepository.class );
when( scmManager.makeScmRepository( config.getUrl() ) ).thenReturn( scmRepository );
when( scmRepository.getProviderRepository() ).thenReturn( scmProviderRepository );
continuumScm = new DefaultContinuumScm();
continuumScm.setScmManager( scmManager );
}
@Test
public void testChangeLogWithScmVersion()
throws Exception
{
config.setTag( "1.0-SNAPSHOT" );
continuumScm.changeLog( config );
verify( scmManager ).changeLog( any( ScmRepository.class ), any( ScmFileSet.class ), any( ScmVersion.class ),
any( ScmVersion.class ) );
}
@Test
public void testChangeLogWithNoScmVersion()
throws Exception
{
config.setTag( "" );
continuumScm.changeLog( config );
verify( scmManager ).changeLog( any( ScmRepository.class ), any( ScmFileSet.class ), any( Date.class ),
isNull( Date.class ), eq( 0 ), isNull( ScmBranch.class ),
isNull( String.class ) );
}
} | 5,271 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/ScmSanityTest.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.ChangeSet;
import org.apache.maven.scm.log.DefaultLog;
import org.apache.maven.scm.provider.svn.svnexe.command.changelog.SvnChangeLogConsumer;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import static org.junit.Assert.assertEquals;
/**
* Tests to verify assumptions and avoid regressions in SCM dependencies.
*/
public class ScmSanityTest
{
private InputStream getTestInput( String path )
{
return ScmSanityTest.class.getResourceAsStream( path );
}
/**
* Tests that CONTINUUM-1640 is fixed by updated maven-scm
*/
@Test
public void testSvnLogWithSpaceInAuthorWorks()
throws Exception
{
SvnChangeLogConsumer consumer = new SvnChangeLogConsumer( new DefaultLog(), null );
InputStream input = getTestInput( "svnlog-with-space-in-author.txt" );
BufferedReader r = new BufferedReader( new InputStreamReader( input ) );
String line;
while ( ( line = r.readLine() ) != null )
{
consumer.consumeLine( line );
}
List modifications = consumer.getModifications();
assertEquals( 2, modifications.size() );
ChangeSet firstEntry = (ChangeSet) modifications.get( 0 );
assertEquals( "Immanuel Scheerer", firstEntry.getAuthor() );
ChangeSet secondEntry = (ChangeSet) modifications.get( 1 );
assertEquals( "Immanuel Scheerer", secondEntry.getAuthor() );
}
}
| 5,272 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm | Create_ds/continuum/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java | package org.apache.continuum.scm.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.provider.ScmProvider;
import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
import org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider;
import org.codehaus.plexus.spring.PlexusClassPathXmlApplicationContext;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @todo replace with a spring integration test
*/
public class ScmManagerTest
{
private static final Logger log = LoggerFactory.getLogger( ScmManagerTest.class );
private ScmManager manager;
@Before
public void setUp()
{
ApplicationContext context = new PlexusClassPathXmlApplicationContext(
new String[] { "classpath*:META-INF/spring-context.xml", "classpath*:META-INF/plexus/components.xml",
"classpath*:" + getClass().getName().replace( '.', '/' ) + ".xml" } );
manager = (ScmManager) context.getBean( "scmManager" );
}
@Test
public void testScmProviders()
throws NoSuchScmProviderException
{
Properties backupSysProps = System.getProperties();
try
{
manager.getScmLogger().info( "Hello, World" );
assertNotNull( manager.getProviderByType( "svn" ) );
ScmProvider cvsProvider = manager.getProviderByType( "cvs" );
assertNotNull( cvsProvider );
log.info( "cvs provider class " + cvsProvider.getClass().getName() );
assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
System.setProperty( "maven.scm.provider.cvs.implementation", "cvs_native" );
cvsProvider = manager.getProviderByType( "cvs" );
assertNotNull( cvsProvider );
log.info( "cvs provider class " + cvsProvider.getClass().getName() );
assertEquals( CvsExeScmProvider.class, cvsProvider.getClass() );
System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
cvsProvider = manager.getProviderByType( "cvs" );
assertNotNull( cvsProvider );
log.info( "cvs provider class " + cvsProvider.getClass().getName() );
assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
}
finally
{
System.setProperties( backupSysProps );
System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
}
}
}
| 5,273 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.apache.maven.scm.provider.ScmUrlUtils;
import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
/**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
*/
public class ContinuumScmUtils
{
public static final String GIT_SCM_PROVIDERTYPE = "git";
// CONTINUUM-2628
public static ContinuumScmConfiguration setSCMCredentialsforSSH( ContinuumScmConfiguration config, String scmUrl,
String scmUsername, String scmPassword )
{
String sshScmUsername = "";
String sshScmPassword = "";
String providerType = ScmUrlUtils.getProvider( scmUrl );
String scmSpecificUrl = scmUrl.substring( providerType.length() + 5 );
if ( providerType.contains( GIT_SCM_PROVIDERTYPE ) && scmSpecificUrl.startsWith(
GitScmProviderRepository.PROTOCOL_SSH ) )
{
scmSpecificUrl = scmSpecificUrl.substring( GitScmProviderRepository.PROTOCOL_SSH.length() + 3 );
// extract user information
int indexAt = scmSpecificUrl.indexOf( "@" );
if ( indexAt >= 0 )
{
String userInfo = scmSpecificUrl.substring( 0, indexAt );
sshScmUsername = userInfo;
int indexPwdSep = userInfo.indexOf( ":" );
// password is specified in the url
if ( indexPwdSep < 0 )
{
sshScmUsername = userInfo.substring( indexPwdSep + 1 );
}
else
{
sshScmUsername = userInfo.substring( 0, indexPwdSep );
sshScmPassword = userInfo.substring( indexPwdSep + 1 );
}
}
}
if ( StringUtils.isBlank( sshScmUsername ) )
{
config.setUsername( scmUsername );
config.setPassword( scmPassword );
}
else
{
config.setUsername( sshScmUsername );
if ( !StringUtils.isBlank( sshScmPassword ) )
{
config.setPassword( sshScmPassword );
}
}
return config;
}
}
| 5,274 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.command.update.UpdateScmResult;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.Resource;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @todo consider folding some of this into Maven SCM itself
*/
@Service( "continuumScm" )
public class DefaultContinuumScm
implements ContinuumScm
{
/**
* The Maven SCM manager to use.
*/
@Resource
private ScmManager scmManager;
public CheckOutScmResult checkout( ContinuumScmConfiguration configuration )
throws IOException, ScmException
{
ScmVersion scmVersion = getScmVersion( configuration );
// TODO: probably need to base this from a working directory in the main configuration
File workingDirectory = configuration.getWorkingDirectory();
ScmRepository repository = getScmRepository( configuration );
CheckOutScmResult result;
// TODO: synchronizing *all* checkouts is unnecessary
synchronized ( this )
{
if ( !workingDirectory.exists() )
{
if ( !workingDirectory.mkdirs() )
{
throw new IOException( "Could not make directory: " + workingDirectory.getAbsolutePath() );
}
}
else
{
FileUtils.cleanDirectory( workingDirectory );
}
ScmFileSet fileSet = new ScmFileSet( workingDirectory );
result = scmManager.checkOut( repository, fileSet, scmVersion );
}
return result;
}
private ScmVersion getScmVersion( ContinuumScmConfiguration configuration )
{
String tag = configuration.getTag();
ScmVersion scmVersion = null;
if ( tag != null )
{
// TODO: differentiate between tag and branch? Allow for revision?
scmVersion = new ScmTag( tag );
}
return scmVersion;
}
public UpdateScmResult update( ContinuumScmConfiguration configuration )
throws ScmException
{
ScmVersion scmVersion = getScmVersion( configuration );
File workingDirectory = configuration.getWorkingDirectory();
if ( !workingDirectory.exists() )
{
// TODO: maybe we could check it out - it seems we currently rely on Continuum figuring this out
throw new IllegalStateException(
"The working directory for the project doesn't exist " + "(" + workingDirectory.getAbsolutePath() +
")." );
}
ScmRepository repository = getScmRepository( configuration );
// Some SCM provider requires additional system properties during update
if ( "starteam".equals( repository.getProvider() ) )
{
// TODO: remove the use of system property - need a better way to pass provider specific configuration
// Remove the clientspec name, so it will be recalculated between each command for each project
// instead of use the same for all projects
System.setProperty( "maven.scm.starteam.deleteLocal", "true" );
}
UpdateScmResult result;
ScmFileSet fileSet = new ScmFileSet( workingDirectory );
// TODO: shouldn't need to synchronize this
synchronized ( this )
{
result = scmManager.update( repository, fileSet, scmVersion, configuration.getLatestUpdateDate() );
}
return result;
}
public ChangeLogScmResult changeLog( ContinuumScmConfiguration configuration )
throws ScmException
{
ScmVersion scmVersion = getScmVersion( configuration );
Date startDate = null;
// TODO: probably need to base this from a working directory in the main configuration
File workingDirectory = configuration.getWorkingDirectory();
ScmRepository repository = getScmRepository( configuration );
ChangeLogScmResult result;
ScmFileSet fileSet = new ScmFileSet( workingDirectory );
if ( scmVersion == null || StringUtils.isBlank( scmVersion.getName() ) )
{
// let's get the start date instead
startDate = getScmStartDate( configuration );
result = scmManager.changeLog( repository, fileSet, startDate, null, 0, null, null );
}
else
{
result = scmManager.changeLog( repository, fileSet, scmVersion, scmVersion );
}
return result;
}
/**
* Create a Maven SCM repository for obtaining the checkout from.
*
* @param configuration the configuration for the working copy and SCM
* @return the repository created
* @throws NoSuchScmProviderException
* @throws ScmRepositoryException
*/
private ScmRepository getScmRepository( ContinuumScmConfiguration configuration )
throws ScmRepositoryException, NoSuchScmProviderException
{
ScmRepository repository = scmManager.makeScmRepository( configuration.getUrl() );
// TODO: tie together with the clientspec change below
// This checkout will be retained between uses, so it remains connected to the repository
repository.getProviderRepository().setPersistCheckout( true );
// TODO: should this be svnexe?
if ( !configuration.isUseCredentialsCache() || !"svn".equals( repository.getProvider() ) )
{
if ( !StringUtils.isEmpty( configuration.getUsername() ) )
{
repository.getProviderRepository().setUser( configuration.getUsername() );
if ( !StringUtils.isEmpty( configuration.getPassword() ) )
{
repository.getProviderRepository().setPassword( configuration.getPassword() );
}
else
{
repository.getProviderRepository().setPassword( "" );
}
}
}
if ( "perforce".equals( repository.getProvider() ) )
{
// TODO: remove the use of system property - need a better way to pass provider specific configuration
// Remove the clientspec name, so it will be recalculated between each command for each project
// instead of use the same for all projects
System.setProperty( "maven.scm.perforce.clientspec.name", "" );
}
return repository;
}
private Date getScmStartDate( ContinuumScmConfiguration configuration )
{
Date startDate = configuration.getLatestUpdateDate();
if ( startDate == null )
{
// start date defaults to January 1, 1970
Calendar cal = Calendar.getInstance();
cal.set( 1970, Calendar.JANUARY, 1 );
startDate = cal.getTime();
}
return startDate;
}
public ScmManager getScmManager()
{
return scmManager;
}
public void setScmManager( ScmManager scmManager )
{
this.scmManager = scmManager;
}
// TODO: add a nuke() method
}
| 5,275 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmConfiguration.java | package org.apache.continuum.scm;
import java.io.File;
import java.util.Date;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Configuration for a project's source control.
* @todo JAXB for persistence
*/
public class ContinuumScmConfiguration
{
/**
* The SCM URL, in the format specified by Maven SCM.
*/
private String url;
/**
* The SCM username to use in connecting.
*/
private String username;
/**
* The SCM password to use in connecting.
*
* @todo using some service to obtain this rather than configuring it would be preferable
*/
private String password;
/**
* The tag, branch, or equivalent to check out from.
*/
private String tag;
/**
* The location of the working directory.
*
* @todo is this a File that is absolute, or is it a relative path under the working directories? How will JAXB
* manage? Don't want to store absolute path in the config unless that's what the user configured, so the base
* can be relocated.
*/
private File workingDirectory;
/**
* For SCM clients that support it, use cached credentials on the system to avoid needing to pass them in.
*
* @todo using some service to obtain them rather than configuring it would be preferable
*/
private boolean useCredentialsCache;
/**
* What was the last time this checkout was updated.
*
* @todo we need to improve on the techniques to achieve this
*/
private Date latestUpdateDate;
public String getUsername()
{
return username;
}
public void setUsername( String username )
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword( String password )
{
this.password = password;
}
public String getTag()
{
return tag;
}
public void setTag( String tag )
{
this.tag = tag;
}
public boolean isUseCredentialsCache()
{
return useCredentialsCache;
}
public void setUseCredentialsCache( boolean useCredentialsCache )
{
this.useCredentialsCache = useCredentialsCache;
}
public String getUrl()
{
return url;
}
public void setUrl( String url )
{
this.url = url;
}
public File getWorkingDirectory()
{
return workingDirectory;
}
public void setWorkingDirectory( File workingDirectory )
{
this.workingDirectory = workingDirectory;
}
public Date getLatestUpdateDate()
{
return latestUpdateDate;
}
public void setLatestUpdateDate( Date latestUpdateDate )
{
this.latestUpdateDate = latestUpdateDate;
}
}
| 5,276 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScm.java | package org.apache.continuum.scm;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.command.update.UpdateScmResult;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.repository.ScmRepositoryException;
import java.io.IOException;
/**
* Component that manages SCM interactions and checkouts within Continuum.
*/
public interface ContinuumScm
{
/**
* Check out a working copy for a project.
*
* @param configuration the configuration for the working copy and SCM
* @return the result of the check out
* @throws IOException if there is a problem writing to the working copy location
* @throws NoSuchScmProviderException if there is a problem with the configuration
* @throws ScmRepositoryException if there is a problem with the configuration
* @throws ScmException if there is a problem checking out
*/
CheckOutScmResult checkout( ContinuumScmConfiguration configuration )
throws IOException, ScmRepositoryException, NoSuchScmProviderException, ScmException;
/**
* Update a working copy for a project.
*
* @param config the configuration for the working copy and SCM
* @return the result of the update
* @throws NoSuchScmProviderException if there is a problem with the configuration
* @throws ScmRepositoryException if there is a problem with the configuration
* @throws ScmException if there is a problem updating
*/
UpdateScmResult update( ContinuumScmConfiguration config )
throws ScmRepositoryException, NoSuchScmProviderException, ScmException;
/**
* Get change log for a project
*
* @param config the configuration for the working copy and SCM
* @return the result of the change log
* @throws ScmRepositoryException if there is a problem with the configuration
* @throws NoSuchScmProviderException if there is a problem with the configuration
* @throws ScmException if there is a problem getting the change log
*/
ChangeLogScmResult changeLog( ContinuumScmConfiguration config )
throws ScmRepositoryException, NoSuchScmProviderException, ScmException;
}
| 5,277 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java | package org.apache.continuum.scm.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.log.ScmLogger;
import org.apache.maven.scm.manager.AbstractScmManager;
import java.util.Map;
/**
* Default implementation of the SCM manager.
* @todo move to maven-scm as the default
*/
public class ScmManager
extends AbstractScmManager
{
private ScmLogger scmLogger;
@Override
protected ScmLogger getScmLogger()
{
return scmLogger;
}
@Override
public void setScmProviders( Map providers )
{
super.setScmProviders( providers );
}
public void setScmLogger( ScmLogger scmLogger )
{
this.scmLogger = scmLogger;
}
}
| 5,278 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/Slf4jScmLogger.java | package org.apache.continuum.scm.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.log.ScmLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* SLF4J logger for Maven SCM.
* @todo move to maven-scm?
*/
@Service( "scmLogger" )
public class Slf4jScmLogger
implements ScmLogger
{
private static final Logger logger = LoggerFactory.getLogger( Slf4jScmLogger.class );
public void debug( String arg0 )
{
logger.debug( arg0 );
}
public void debug( Throwable arg0 )
{
logger.debug( "Exception", arg0 );
}
public void debug( String arg0, Throwable arg1 )
{
logger.debug( arg0, arg1 );
}
public void error( String arg0 )
{
logger.error( arg0 );
}
public void error( Throwable arg0 )
{
logger.error( "Exception", arg0 );
}
public void error( String arg0, Throwable arg1 )
{
logger.error( arg0, arg1 );
}
public void info( String arg0 )
{
logger.info( arg0 );
}
public void info( Throwable arg0 )
{
logger.info( "Exception", arg0 );
}
public void info( String arg0, Throwable arg1 )
{
logger.info( arg0, arg1 );
}
public boolean isDebugEnabled()
{
return logger.isDebugEnabled();
}
public boolean isErrorEnabled()
{
return logger.isErrorEnabled();
}
public boolean isInfoEnabled()
{
return logger.isInfoEnabled();
}
public boolean isWarnEnabled()
{
return logger.isWarnEnabled();
}
public void warn( String arg0 )
{
logger.warn( arg0 );
}
public void warn( Throwable arg0 )
{
logger.warn( "Exception", arg0 );
}
public void warn( String arg0, Throwable arg1 )
{
logger.warn( arg0, arg1 );
}
}
| 5,279 |
0 | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager | Create_ds/continuum/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java | package org.apache.continuum.scm.manager.spring;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.scm.provider.ScmProvider;
import org.codehaus.plexus.spring.PlexusToSpringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import java.util.Map;
/**
* <p>
* Factory bean to inject all beans of type {@link ScmProvider}
* </p>
* <p>
* <code><bean id="scmProviders" class="org.apache.continuum.scm.manager.spring.ScmManagerFactoryBean"/>
* </code>
* </p>
*
* @author Carlos Sanchez <carlos@apache.org>
*/
public class ScmProviderFactoryBean
implements FactoryBean, ApplicationContextAware
{
private ApplicationContext applicationContext;
/**
* FIXME : change how we find scm implementations
*
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
public Object getObject()
throws Exception
{
Map<String, ScmProvider> providers;
/*
olamy : comment the pure spring use because we have a duplicate between cvs java and cvs native
Map<String, ScmProvider> beans =
BeanFactoryUtils.beansOfTypeIncludingAncestors( applicationContext, ScmProvider.class );
for ( ScmProvider provider : beans.values() )
{
if ( providers.containsKey( provider.getScmType() ) )
{
throw new BeanInitializationException(
"There are to ScmProvider beans in the appllication context for Scm type " +
provider.getScmType() +
". Probably two conflicting scm implementations are present in the classpath." );
}
if (log.isDebugEnabled())
{
log.debug( "put provider with type " + provider.getScmType() + " and class " + provider.getClass().getName() );
}
providers.put( provider.getScmType(), provider );
}*/
providers = PlexusToSpringUtils.lookupMap( PlexusToSpringUtils.buildSpringId( ScmProvider.class ),
applicationContext );
return providers;
}
public Class getObjectType()
{
return Map.class;
}
public boolean isSingleton()
{
return true;
}
public void setApplicationContext( ApplicationContext applicationContext )
throws BeansException
{
this.applicationContext = applicationContext;
}
}
| 5,280 |
0 | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java | package org.apache.continuum.utils;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectDependency;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
*/
public class ProjectSorterTest
{
/**
* test basic three project tree (really a line in this case)
*/
@Test
public void testBasicNestedProjectStructure()
throws Exception
{
List<Project> list = new ArrayList<Project>();
Project top = getNewProject( "top" );
list.add( top );
Project c1 = getNewProject( "c1" );
c1.setParent( generateProjectDependency( top ) );
list.add( c1 );
Project c2 = getNewProject( "c2" );
c2.setParent( generateProjectDependency( top ) );
c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) ) );
list.add( c2 );
List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
assertNotNull( sortedList );
Project p1 = sortedList.get( 0 );
assertEquals( top.getArtifactId(), p1.getArtifactId() );
Project p2 = sortedList.get( 1 );
assertEquals( c1.getArtifactId(), p2.getArtifactId() );
Project p3 = sortedList.get( 2 );
assertEquals( c2.getArtifactId(), p3.getArtifactId() );
}
public void testNestedProjectStructureWithoutModulesDefinedInParentPom()
throws Exception
{
Project top = getNewProject( "top" );
Project war1 = getNewProject( "war1" );
war1.setParent( generateProjectDependency( top ) );
Project war2 = getNewProject( "war2" );
war2.setParent( generateProjectDependency( top ) );
Project ear1 = getNewProject( "ear1" );
ear1.setParent( generateProjectDependency( top ) );
List<ProjectDependency> deps = new ArrayList<ProjectDependency>();
deps.add( generateProjectDependency( war1 ) );
deps.add( generateProjectDependency( war2 ) );
ear1.setDependencies( deps );
List<Project> list = new ArrayList<Project>();
// We add projects in a random order to really check the project orter
list.add( top );
list.add( ear1 );
list.add( war1 );
list.add( war2 );
List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
assertNotNull( sortedList );
Project p1 = sortedList.get( 0 ); //top project must be the first
assertEquals( top.getArtifactId(), p1.getArtifactId() );
Project p4 = sortedList.get( 3 ); //ear1 project must be the latest
assertEquals( ear1.getArtifactId(), p4.getArtifactId() );
}
/**
* test project build order
* build order: B -> A -> D -> C -> E
*
* @throws Exception
*/
public void testProjectBuildOrder()
throws Exception
{
List<Project> list = new ArrayList<Project>();
Project projectA = getNewProject( "A" );
Project projectB = getNewProject( "B" );
Project projectC = getNewProject( "C" );
Project projectD = getNewProject( "D" );
Project projectE = getNewProject( "E" );
projectA.setParent( generateProjectDependency( projectB ) );
projectE.setParent( generateProjectDependency( projectB ) );
projectC.setParent( generateProjectDependency( projectA ) );
projectC.setDependencies( Collections.singletonList( generateProjectDependency( projectD ) ) );
projectD.setParent( generateProjectDependency( projectA ) );
list.add( projectA );
list.add( projectB );
list.add( projectC );
list.add( projectD );
list.add( projectE );
List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
assertNotNull( sortedList );
List<Project> expectedList = new ArrayList<Project>();
expectedList.add( projectB );
expectedList.add( projectA );
expectedList.add( projectD );
expectedList.add( projectC );
expectedList.add( projectE );
for ( int i = 0; i < sortedList.size(); i++ )
{
Project sorted = sortedList.get( i );
Project expected = expectedList.get( i );
assertEquals( sorted.getArtifactId(), expected.getArtifactId() );
}
}
/**
* test one of the child projects not having the artifactId or groupId empty and working off the
* name instead
*/
public void testIncompleteNestedProjectStructure()
throws Exception
{
List<Project> list = new ArrayList<Project>();
Project top = getNewProject( "top" );
list.add( top );
Project c1 = getIncompleteProject( "c1" );
c1.setParent( generateProjectDependency( top ) );
list.add( c1 );
Project c2 = getNewProject( "c2" );
c2.setParent( generateProjectDependency( top ) );
c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) ) );
list.add( c2 );
List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
assertNotNull( sortedList );
Project p1 = sortedList.get( 0 );
assertEquals( top.getArtifactId(), p1.getArtifactId() );
Project p2 = sortedList.get( 1 );
assertEquals( c1.getArtifactId(), p2.getArtifactId() );
Project p3 = sortedList.get( 2 );
assertEquals( c2.getArtifactId(), p3.getArtifactId() );
}
/**
* project sorter can work with name replacing the artifactid and groupId
*
* @param projectId The project id
* @return The generated Project
*/
private Project getIncompleteProject( String projectId )
{
Project project = new Project();
project.setName( "foo" + projectId );
project.setVersion( "v" + projectId );
project.setProjectGroup( new ProjectGroup() );
return project;
}
private Project getNewProject( String projectId )
{
Project project = new Project();
project.setArtifactId( "a" + projectId );
project.setGroupId( "g" + projectId );
project.setVersion( "v" + projectId );
project.setName( "n" + projectId );
project.setProjectGroup( new ProjectGroup() );
return project;
}
private ProjectDependency generateProjectDependency( Project project )
{
ProjectDependency dep = new ProjectDependency();
dep.setArtifactId( project.getArtifactId() );
dep.setGroupId( project.getGroupId() );
dep.setVersion( project.getVersion() );
return dep;
}
}
| 5,281 |
0 | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils/shell/FileOutputConsumerTest.java | package org.apache.continuum.utils.shell;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.utils.file.DefaultFileSystemManager;
import org.apache.continuum.utils.file.FileSystemManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.*;
/**
* @see org.apache.continuum.utils.shell.FileOutputConsumer
*/
public class FileOutputConsumerTest
{
File outputFile;
FileOutputConsumer consumer;
FileSystemManager fsManager;
@Before
public void setUp()
throws IOException
{
outputFile = File.createTempFile( FileOutputConsumerTest.class.getName(), "output" );
outputFile.delete(); // we want to test whether it is created
assertFalse( "file should not exist", outputFile.exists() );
consumer = new FileOutputConsumer( outputFile );
fsManager = new DefaultFileSystemManager();
}
@After
public void tearDown()
{
outputFile.delete();
consumer = null;
}
@Test
public void noOutputCreatesEmptyFile()
throws IOException
{
consumer.close();
assertFileEmpty();
}
@Test
public void fileExistsAfterClose()
throws IOException
{
String[] lines = { "first", "second", "third" };
writeContent( lines );
consumer.close();
assertFileExists();
assertFileContents( lines );
}
@Test
public void newConsumerTruncatesFile()
throws IOException
{
// Write content to the file
String[] content1 = { "should be overwritten" };
writeContent( content1 );
consumer.close();
assertFileExists();
assertFileContents( content1 );
// New consumer should truncate (overwrite) the previous contents
consumer = new FileOutputConsumer( outputFile );
assertFileExists();
assertFileEmpty();
}
@Test
public void contentsAvailableBeforeClose()
throws IOException
{
String[] content = { "contents", "are not", "critical" };
writeContent( content );
assertFileContents( content );
}
private void writeContent( String... lines )
{
for ( String line : lines )
consumer.consume( line );
}
private void assertFileExists()
{
assertTrue( "file should exist", outputFile.exists() );
}
private void assertFileEmpty()
throws IOException
{
assertEquals( "file should have been empty", "", fsManager.fileContents( outputFile ) );
}
private void assertFileContents( String... contents )
throws IOException
{
StringBuilder finalContents = new StringBuilder();
if ( contents.length >= 1 )
{
for ( String line : contents )
finalContents.append( String.format( "%s%n", line ) );
}
assertEquals( "file did not contain expected contents", finalContents.toString(),
fsManager.fileContents( outputFile ) );
}
}
| 5,282 |
0 | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils/shell/Sleep.java | package org.apache.continuum.utils.shell;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* A portable program that sleeps. Useful for cross platform shell tests.
*/
public class Sleep
{
public static void main( String[] args )
throws InterruptedException
{
if ( args.length != 1 )
{
System.err.printf( "usage: java %s <time-to-sleep-in-seconds>\n", Sleep.class.getName() );
System.exit( 1 );
}
int sleepTimeInMillis = Integer.valueOf( args[0] ) * 1000;
Thread.sleep( sleepTimeInMillis );
}
}
| 5,283 |
0 | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils | Create_ds/continuum/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java | package org.apache.continuum.utils.shell;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @see org.apache.continuum.utils.shell.DefaultShellCommandHelper
*/
public class DefaultShellCommandHelperTest
{
private static final Logger log = LoggerFactory.getLogger( DefaultShellCommandHelper.class );
private DefaultShellCommandHelper helper;
private String javaPath;
private String sleepClasspath;
@Before
public void setUp()
{
helper = new DefaultShellCommandHelper();
List<String> javaPathComponents =
Arrays.asList( new String[] { System.getProperty( "java.home" ), "bin", "java" } );
javaPath = StringUtils.join( javaPathComponents, File.separator );
sleepClasspath = System.getProperty( "sleepClasspath" );
}
@After
public void tearDown()
{
helper = null;
}
/**
* To concurrently check the run status of a process.
*/
private static class RunChecker
implements Runnable
{
ShellCommandHelper shellHelper;
long pid;
boolean wasRunning;
long sleepMillis;
public RunChecker( ShellCommandHelper shellHelper, long pid, long sleepMillis )
{
this.shellHelper = shellHelper;
this.pid = pid;
this.sleepMillis = sleepMillis;
}
public void run()
{
try
{
Thread.sleep( sleepMillis );
this.wasRunning = shellHelper.isRunning( pid );
}
catch ( InterruptedException e )
{
log.error( "run checker interrupted", e );
}
}
}
@Test
public void testIsRunning()
throws Exception
{
long virtualPid = 1, sleepMillis = 100;
RunChecker checker = new RunChecker( helper, virtualPid, sleepMillis );
String[] cmdArgs = { "-cp", sleepClasspath, Sleep.class.getCanonicalName(), "1" };
// Verify process isn't running initially
checker.run();
assertFalse( "Expected that command was not running", checker.wasRunning );
// Verify running status is true when running
Thread checkerThread = new Thread( checker );
checkerThread.start();
helper.executeShellCommand( null, javaPath, cmdArgs, new LogOutputConsumer( log ), virtualPid, null );
checkerThread.join();
assertTrue( "Expected that command was running", checker.wasRunning );
// Verify process isn't running after
checker.run();
assertFalse( "Expected that command was not running", checker.wasRunning );
}
}
| 5,284 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/ContinuumException.java | package org.apache.maven.continuum;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
*/
public class ContinuumException
extends Exception
{
private static final long serialVersionUID = -5566747100823603618L;
public ContinuumException( String message )
{
super( message );
}
public ContinuumException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,285 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java | package org.apache.maven.continuum;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.buildagent.NoBuildAgentException;
import org.apache.continuum.buildagent.NoBuildAgentInGroupException;
import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.model.project.ProjectGroupSummary;
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.continuum.model.release.ContinuumReleaseResult;
import org.apache.continuum.purge.ContinuumPurgeManager;
import org.apache.continuum.purge.PurgeConfigurationService;
import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
import org.apache.continuum.repository.RepositoryService;
import org.apache.continuum.taskqueue.manager.TaskQueueManager;
import org.apache.continuum.utils.build.BuildTrigger;
import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.BuildQueue;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.model.project.Schedule;
import org.apache.maven.continuum.model.scm.ChangeSet;
import org.apache.maven.continuum.profile.ProfileService;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
import org.apache.maven.continuum.release.ContinuumReleaseManager;
import java.io.File;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
*/
public interface Continuum
{
String ROLE = Continuum.class.getName();
// ----------------------------------------------------------------------
// Project Groups
// ----------------------------------------------------------------------
public ProjectGroup getProjectGroup( int projectGroupId )
throws ContinuumException;
public List<ProjectGroup> getAllProjectGroupsWithBuildDetails();
public List<ProjectGroup> getAllProjectGroups();
public ProjectGroup getProjectGroupByProjectId( int projectId )
throws ContinuumException;
public Collection<Project> getProjectsInGroup( int projectGroupId )
throws ContinuumException;
public Collection<Project> getProjectsInGroupWithDependencies( int projectGroupId )
throws ContinuumException;
public void removeProjectGroup( int projectGroupId )
throws ContinuumException;
public void addProjectGroup( ProjectGroup projectGroup )
throws ContinuumException;
public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
throws ContinuumException;
public ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
throws ContinuumException;
public ProjectGroup getProjectGroupByGroupId( String groupId )
throws ContinuumException;
public ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
throws ContinuumException;
public List<ProjectGroup> getAllProjectGroupsWithRepository( int repositoryId );
// ----------------------------------------------------------------------
// Project
// ----------------------------------------------------------------------
void removeProject( int projectId )
throws ContinuumException;
/**
* @param projectId
* @throws ContinuumException
* @deprecated
*/
@Deprecated
void checkoutProject( int projectId )
throws ContinuumException;
Project getProject( int projectId )
throws ContinuumException;
Project getProjectWithBuildDetails( int projectId )
throws ContinuumException;
Collection<Project> getProjects()
throws ContinuumException;
Collection<Project> getProjectsWithDependencies()
throws ContinuumException;
BuildResult getLatestBuildResultForProject( int projectId );
Map<Integer, BuildResult> getLatestBuildResults( int projectGroupId );
Map<Integer, BuildResult> getBuildResultsInSuccess( int projectGroupId );
Map<Integer, ProjectGroupSummary> getProjectsSummaryByGroups();
// ----------------------------------------------------------------------
// Building
// ----------------------------------------------------------------------
/**
* take a collection of projects and sort for order
*
* @param projects
* @return
*/
List<Project> getProjectsInBuildOrder( Collection<Project> projects );
void buildProjects( String username )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProjectsWithBuildDefinition( List<Project> projects, List<BuildDefinition> bds )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProjectsWithBuildDefinition( List<Project> projects, int buildDefinitionId )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProjects( BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProjects( Schedule schedule )
throws ContinuumException;
void buildProject( int projectId, String username )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProject( int projectId, BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
void buildProject( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
public void buildProjectGroup( int projectGroupId, BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
public void buildProjectGroupWithBuildDefinition( int projectGroupId, int buildDefinitionId,
BuildTrigger buildTrigger )
throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
// ----------------------------------------------------------------------
// Build information
// ----------------------------------------------------------------------
BuildResult getBuildResult( int buildId )
throws ContinuumException;
String getBuildOutput( int projectId, int buildId )
throws ContinuumException;
long getNbBuildResultsForProject( int projectId );
Collection<BuildResult> getBuildResultsForProject( int projectId, int offset, int length )
throws ContinuumException;
List<ChangeSet> getChangesSinceLastSuccess( int projectId, int buildResultId )
throws ContinuumException;
void removeBuildResult( int buildId )
throws ContinuumException;
List<BuildResult> getBuildResultsInRange( Collection<Integer> projectGroupId, Date fromDate, Date toDate, int state,
String triggeredBy, int offset, int length );
// ----------------------------------------------------------------------
// Projects
// ----------------------------------------------------------------------
/**
* Add a project to the list of building projects (ant, shell,...)
*
* @param project the project to add
* @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
* @param projectGroupId
* @return id of the project
* @throws ContinuumException
*/
int addProject( Project project, String executorId, int projectGroupId )
throws ContinuumException;
/**
* Add a project to the list of building projects (ant, shell,...)
*
* @param project the project to add
* @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
* @param projectGroupId
* @return id of the project
* @throws ContinuumException
*/
int addProject( Project project, String executorId, int projectGroupId, int buildDefintionTemplateId )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, boolean checkProtocol )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId, boolean checkProtocol )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @param useCredentialsCache whether to use cached scm account credentials or not
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
boolean useCredentialsCache )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @param useCredentialsCache whether to use cached scm account credentials or not
* @param loadRecursiveProjects if multi modules project record all projects (if false only root project added)
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
boolean checkProtocol, boolean useCredentialsCache,
boolean loadRecursiveProjects )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @param useCredentialsCache whether to use cached scm account credentials or not
* @param loadRecursiveProjects if multi modules project record all projects (if false only root project added)
* @param buildDefintionTemplateId buildDefintionTemplateId
* @param checkoutInSingleDirectory TODO
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
boolean checkProtocol, boolean useCredentialsCache,
boolean loadRecursiveProjects,
int buildDefintionTemplateId,
boolean checkoutInSingleDirectory )
throws ContinuumException;
/**
* Add a Maven 1 project to the list of projects.
*
* @param metadataUrl url of the project.xml
* @param projectGroupId id of the project group to use
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId )
throws ContinuumException;
/**
* Add a Maven 1 project to the list of projects.
*
* @param metadataUrl url of the project.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol )
throws ContinuumException;
/**
* Add a Maven 2 project to the list of projects.
*
* @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @param useCredentialsCache whether to use cached scm account credentials or not
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
boolean useCredentialsCache )
throws ContinuumException;
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
boolean useCredentialsCache, int buildDefintionTemplateId )
throws ContinuumException;
void updateProject( Project project )
throws ContinuumException;
void updateProjectGroup( ProjectGroup projectGroup )
throws ContinuumException;
Project getProjectWithCheckoutResult( int projectId )
throws ContinuumException;
Project getProjectWithAllDetails( int projectId )
throws ContinuumException;
Project getProjectWithBuilds( int projectId )
throws ContinuumException;
// ----------------------------------------------------------------------
// Notification
// ----------------------------------------------------------------------
ProjectNotifier getNotifier( int projectId, int notifierId )
throws ContinuumException;
ProjectNotifier updateNotifier( int projectId, ProjectNotifier notifier )
throws ContinuumException;
ProjectNotifier addNotifier( int projectId, ProjectNotifier notifier )
throws ContinuumException;
void removeNotifier( int projectId, int notifierId )
throws ContinuumException;
ProjectNotifier getGroupNotifier( int projectGroupId, int notifierId )
throws ContinuumException;
ProjectNotifier updateGroupNotifier( int projectGroupId, ProjectNotifier notifier )
throws ContinuumException;
ProjectNotifier addGroupNotifier( int projectGroupId, ProjectNotifier notifier )
throws ContinuumException;
void removeGroupNotifier( int projectGroupId, int notifierId )
throws ContinuumException;
// ----------------------------------------------------------------------
// Build Definition
// ----------------------------------------------------------------------
/**
* @deprecated
*/
@Deprecated
List<BuildDefinition> getBuildDefinitions( int projectId )
throws ContinuumException;
/**
* @deprecated
*/
@Deprecated
BuildDefinition getBuildDefinition( int projectId, int buildDefinitionId )
throws ContinuumException;
/**
* @deprecated
*/
@Deprecated
void removeBuildDefinition( int projectId, int buildDefinitionId )
throws ContinuumException;
/**
* returns the build definition from either the project or the project group it is a part of
*
* @param buildDefinitionId
* @return
*/
BuildDefinition getBuildDefinition( int buildDefinitionId )
throws ContinuumException;
/**
* returns the default build definition for the project
* 1) if project has default build definition, return that
* 2) otherwise return default build definition for parent project group
*
* @param projectId
* @return
* @throws ContinuumException
*/
BuildDefinition getDefaultBuildDefinition( int projectId )
throws ContinuumException;
public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
throws ContinuumException;
BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition )
throws ContinuumException;
BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
throws ContinuumException;
List<BuildDefinition> getBuildDefinitionsForProject( int projectId )
throws ContinuumException;
List<BuildDefinition> getBuildDefinitionsForProjectGroup( int projectGroupId )
throws ContinuumException;
void removeBuildDefinitionFromProject( int projectId, int buildDefinitionId )
throws ContinuumException;
void removeBuildDefinitionFromProjectGroup( int projectGroupId, int buildDefinitionId )
throws ContinuumException;
BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition buildDefinition )
throws ContinuumException;
BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
throws ContinuumException;
// ----------------------------------------------------------------------
// Schedule
// ----------------------------------------------------------------------
Schedule getScheduleByName( String scheduleName )
throws ContinuumException;
Schedule getSchedule( int id )
throws ContinuumException;
Collection<Schedule> getSchedules()
throws ContinuumException;
void addSchedule( Schedule schedule )
throws ContinuumException;
void updateSchedule( Schedule schedule )
throws ContinuumException;
void updateSchedule( int scheduleId, Map<String, String> configuration )
throws ContinuumException;
void removeSchedule( int scheduleId )
throws ContinuumException;
void activePurgeSchedule( Schedule schedule );
void activeBuildDefinitionSchedule( Schedule schedule );
// ----------------------------------------------------------------------
// Working copy
// ----------------------------------------------------------------------
File getWorkingDirectory( int projectId )
throws ContinuumException;
String getFileContent( int projectId, String directory, String filename )
throws ContinuumException;
List<File> getFiles( int projectId, String currentDirectory )
throws ContinuumException;
// ----------------------------------------------------------------------
// Configuration
// ----------------------------------------------------------------------
ConfigurationService getConfiguration();
void reloadConfiguration()
throws ContinuumException;
// ----------------------------------------------------------------------
// Continuum Release
// ----------------------------------------------------------------------
ContinuumReleaseManager getReleaseManager();
// ----------------------------------------------------------------------
// Installation
// ----------------------------------------------------------------------
InstallationService getInstallationService();
ProfileService getProfileService();
BuildDefinitionService getBuildDefinitionService();
// ----------------------------------------------------------------------
// Continuum Purge
// ----------------------------------------------------------------------
ContinuumPurgeManager getPurgeManager();
PurgeConfigurationService getPurgeConfigurationService();
// ----------------------------------------------------------------------
// Repository Service
// ----------------------------------------------------------------------
RepositoryService getRepositoryService();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId );
ProjectScmRoot getProjectScmRoot( int projectScmRootId )
throws ContinuumException;
ProjectScmRoot getProjectScmRootByProject( int projectId )
throws ContinuumException;
ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
throws ContinuumException;
// ----------------------------------------------------------------------
// Task Queue Manager
// ----------------------------------------------------------------------
TaskQueueManager getTaskQueueManager();
// ----------------------------------------------------------------------
// Builds Manager
// ----------------------------------------------------------------------
BuildsManager getBuildsManager();
// ----------------------------------------------------------------------
// Build Queue
// ----------------------------------------------------------------------
BuildQueue addBuildQueue( BuildQueue buildQueue )
throws ContinuumException;
BuildQueue getBuildQueue( int buildQueueId )
throws ContinuumException;
BuildQueue getBuildQueueByName( String buildQueueName )
throws ContinuumException;
void removeBuildQueue( BuildQueue buildQueue )
throws ContinuumException;
BuildQueue storeBuildQueue( BuildQueue buildQueue )
throws ContinuumException;
List<BuildQueue> getAllBuildQueues()
throws ContinuumException;
public void startup()
throws ContinuumException;
ContinuumReleaseResult addContinuumReleaseResult( int projectId, String releaseId, String releaseType )
throws ContinuumException;
ContinuumReleaseResult addContinuumReleaseResult( ContinuumReleaseResult releaseResult )
throws ContinuumException;
void removeContinuumReleaseResult( int releaseResultId )
throws ContinuumException;
ContinuumReleaseResult getContinuumReleaseResult( int releaseResultId )
throws ContinuumException;
List<ContinuumReleaseResult> getContinuumReleaseResultsByProjectGroup( int projectGroupId );
List<ContinuumReleaseResult> getAllContinuumReleaseResults();
ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal, long startTime, long endTime )
throws ContinuumException;
String getReleaseOutput( int releaseResultId )
throws ContinuumException;
DistributedBuildManager getDistributedBuildManager();
DistributedReleaseManager getDistributedReleaseManager();
}
| 5,286 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/ContinuumRuntimeException.java | package org.apache.maven.continuum;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Exception thrown as a result of a Continuum programming error so that the user need not deal with it.
*/
public class ContinuumRuntimeException
extends RuntimeException
{
private static final long serialVersionUID = 2345304356025303153L;
public ContinuumRuntimeException( String message, Exception cause )
{
super( message, cause );
}
}
| 5,287 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationException.java | package org.apache.maven.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/
public class ConfigurationException
extends Exception
{
private static final long serialVersionUID = 5598659641431851660L;
public ConfigurationException( String message )
{
super( message );
}
public ConfigurationException( Throwable cause )
{
super( cause );
}
public ConfigurationException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,288 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationLoadingException.java | package org.apache.maven.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/
public class ConfigurationLoadingException
extends Exception
{
private static final long serialVersionUID = -8836376517389252165L;
public ConfigurationLoadingException( String message )
{
super( message );
}
public ConfigurationLoadingException( Throwable cause )
{
super( cause );
}
public ConfigurationLoadingException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,289 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationStoringException.java | package org.apache.maven.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/
public class ConfigurationStoringException
extends Exception
{
private static final long serialVersionUID = -421385426351064628L;
public ConfigurationStoringException( String message )
{
super( message );
}
public ConfigurationStoringException( Throwable cause )
{
super( cause );
}
public ConfigurationStoringException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,290 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java | package org.apache.maven.continuum.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.buildqueue.BuildQueueServiceException;
import org.apache.continuum.configuration.BuildAgentConfiguration;
import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
import org.apache.continuum.configuration.ContinuumConfigurationException;
import org.apache.maven.continuum.model.project.BuildQueue;
import org.apache.maven.continuum.model.project.Schedule;
import org.apache.maven.continuum.store.ContinuumStoreException;
import java.io.File;
import java.util.List;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/
public interface ConfigurationService
{
String ROLE = ConfigurationService.class.getName();
public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
public static final String DEFAULT_BUILD_QUEUE_NAME = "DEFAULT_BUILD_QUEUE";
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
File getApplicationHome();
boolean isInitialized();
void setInitialized( boolean initialized );
String getUrl();
void setUrl( String url );
File getBuildOutputDirectory();
void setBuildOutputDirectory( File buildOutputDirectory );
File getWorkingDirectory();
void setWorkingDirectory( File workingDirectory );
File getDeploymentRepositoryDirectory();
void setDeploymentRepositoryDirectory( File deploymentRepositoryDirectory );
String getBuildOutput( int buildId, int projectId )
throws ConfigurationException;
File getBuildOutputDirectory( int projectId );
File getBuildOutputFile( int buildId, int projectId )
throws ConfigurationException;
File getTestReportsDirectory( int buildId, int projectId )
throws ConfigurationException;
File getReleaseOutputDirectory();
void setReleaseOutputDirectory( File releaseOutputDirectory );
File getReleaseOutputDirectory( int projectGroupId );
File getReleaseOutputFile( int projectGroupId, String releaseName )
throws ConfigurationException;
String getReleaseOutput( int projectGroupId, String releaseName )
throws ConfigurationException;
int getNumberOfBuildsInParallel();
void setNumberOfBuildsInParallel( int num );
BuildQueue getDefaultBuildQueue()
throws BuildQueueServiceException;
List<BuildAgentConfiguration> getBuildAgents();
void addBuildAgent( BuildAgentConfiguration buildAgent )
throws ConfigurationException;
void removeBuildAgent( BuildAgentConfiguration buildAgent );
void updateBuildAgent( BuildAgentConfiguration buildAgent );
boolean isDistributedBuildEnabled();
void setDistributedBuildEnabled( boolean distributedBuildEnabled );
void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
throws ConfigurationException;
void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
throws ConfigurationException;
void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
throws ConfigurationException;
void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
throws ConfigurationException;
void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
throws ConfigurationException;
BuildAgentGroupConfiguration getBuildAgentGroup( String name );
BuildAgentConfiguration getBuildAgent( String url );
List<BuildAgentGroupConfiguration> getBuildAgentGroups();
boolean containsBuildAgentUrl( String buildAgentUrl, BuildAgentGroupConfiguration buildAgentGroup );
void setSharedSecretPassword( String sharedSecretPassword );
String getSharedSecretPassword();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
File getFile( String filename );
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
boolean isLoaded();
void reload()
throws ConfigurationLoadingException, ContinuumConfigurationException;
void store()
throws ConfigurationStoringException, ContinuumConfigurationException;
Schedule getDefaultSchedule()
throws ContinuumStoreException, ConfigurationLoadingException, ContinuumConfigurationException,
BuildQueueServiceException;
}
| 5,291 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java | package org.apache.maven.continuum.notification;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @todo use build result for all of these? need project for those that do?
*/
public interface ContinuumNotificationDispatcher
{
String ROLE = ContinuumNotificationDispatcher.class.getName();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
String MESSAGE_ID_BUILD_STARTED = "BuildStarted";
String MESSAGE_ID_CHECKOUT_STARTED = "CheckoutStarted";
String MESSAGE_ID_CHECKOUT_COMPLETE = "CheckoutComplete";
String MESSAGE_ID_RUNNING_GOALS = "RunningGoals";
String MESSAGE_ID_GOALS_COMPLETED = "GoalsCompleted";
String MESSAGE_ID_BUILD_COMPLETE = "BuildComplete";
String MESSAGE_ID_PREPARE_BUILD_COMPLETE = "PrepareBuildComplete";
String CONTEXT_BUILD = "build";
String CONTEXT_BUILD_OUTPUT = "build-output";
String CONTEXT_PROJECT = "project";
String CONTEXT_BUILD_DEFINITION = "buildDefinition";
String CONTEXT_PROJECT_NOTIFIER = "projectNotifier";
String CONTEXT_BUILD_RESULT = "result";
String CONTEXT_UPDATE_SCM_RESULT = "scmResult";
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
void buildStarted( Project project, BuildDefinition buildDefinition );
void checkoutStarted( Project project, BuildDefinition buildDefinition );
void checkoutComplete( Project project, BuildDefinition buildDefinition );
void runningGoals( Project project, BuildDefinition buildDefinition, BuildResult buildResult );
void goalsCompleted( Project project, BuildDefinition buildDefinition, BuildResult buildResult );
void buildComplete( Project project, BuildDefinition buildDefinition, BuildResult buildResult );
void prepareBuildComplete( ProjectScmRoot projectScmRoot );
}
| 5,292 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/utils/WorkingDirectoryService.java | package org.apache.maven.continuum.utils;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.model.project.Project;
import java.io.File;
import java.util.List;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
*/
public interface WorkingDirectoryService
{
String ROLE = WorkingDirectoryService.class.getName();
File getWorkingDirectory( Project project );
File getWorkingDirectory( Project project, boolean shouldSet );
File getWorkingDirectory( Project project, String projectScmRootUrl, List<Project> projects );
File getWorkingDirectory( Project project, String projectScmRootUrl, List<Project> projects, boolean shouldSet );
}
| 5,293 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManagerListener.java | package org.apache.maven.continuum.release;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.List;
/**
* @author Edwin Punzalan
*/
public interface ContinuumReleaseManagerListener
{
int INITIALIZED = 0, LISTENING = 1, FINISHED = 3;
List<String> getCompletedPhases();
String getInProgress();
String getGoalName();
List<String> getPhases();
String getError();
int getState();
String getUsername();
void setUsername( String username );
}
| 5,294 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java | package org.apache.maven.continuum.release;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.continuum.model.release.ReleaseListenerSummary;
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.shared.release.config.ReleaseDescriptor;
import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
import java.io.File;
import java.util.Map;
import java.util.Properties;
/**
* The Continuum Release Manager is responsible for performing releases based on a release descriptor
* that has been received by the Maven Release Plugin.
*
* @author Jason van Zyl
*/
public interface ContinuumReleaseManager
{
String ROLE = ContinuumReleaseManager.class.getName();
/**
* Prepare a project for release
*
* @param project
* @param releaseProperties
* @param releaseVersions
* @param developmentVersions
* @param listener
* @param workingDirectory
* @return
* @throws ContinuumReleaseException
*/
String prepare( Project project, Properties releaseProperties, Map<String, String> releaseVersions,
Map<String, String> developmentVersions, ContinuumReleaseManagerListener listener,
String workingDirectory )
throws ContinuumReleaseException;
/**
* Prepare a project for release
*
* @param project
* @param releaseProperties
* @param releaseVersions
* @param developmentVersions
* @param listener
* @param workingDirectory
* @param environments
* @param executable
* @return
* @throws ContinuumReleaseException
*/
String prepare( Project project, Properties releaseProperties, Map<String, String> releaseVersions,
Map<String, String> developmentVersions, ContinuumReleaseManagerListener listener,
String workingDirectory, Map<String, String> environments, String executable )
throws ContinuumReleaseException;
/**
* Perform a release based on a given releaseId
*
* @param releaseId
* @param buildDirectory
* @param goals
* @param useReleaseProfile
* @param listener
* @throws ContinuumReleaseException
* @deprecated to remove as not used anymore
*/
void perform( String releaseId, File buildDirectory, String goals, String arguments, boolean useReleaseProfile,
ContinuumReleaseManagerListener listener )
throws ContinuumReleaseException;
/**
* Perform a release based on a release descriptor received by the Maven Release Plugin.
*
* @param releaseId
* @param workingDirectory
* @param buildDirectory
* @param goals
* @param useReleaseProfile
* @param listener
* @throws ContinuumReleaseException
* @deprecated to remove as not used anymore
*/
void perform( String releaseId, String workingDirectory, File buildDirectory, String goals, String arguments,
boolean useReleaseProfile, ContinuumReleaseManagerListener listener )
throws ContinuumReleaseException;
/**
* FIXME use a bean to replace such very huge parameter number (ContinuumReleaseRequest)
*
* @param releaseId
* @param buildDirectory
* @param goals
* @param arguments
* @param useReleaseProfile
* @param listener
* @param repository
* @throws ContinuumReleaseException
*/
void perform( String releaseId, File buildDirectory, String goals, String arguments, boolean useReleaseProfile,
ContinuumReleaseManagerListener listener, LocalRepository repository )
throws ContinuumReleaseException;
/**
* Rollback changes made by a previous release.
*
* @param releaseId
* @param workingDirectory
* @param listener
* @throws ContinuumReleaseException
*/
void rollback( String releaseId, String workingDirectory, ContinuumReleaseManagerListener listener )
throws ContinuumReleaseException;
Map<String, ReleaseDescriptor> getPreparedReleases();
Map<String, String> getPreparedReleasesForProject( String groupId, String artifactId );
Map getReleaseResults();
Map getListeners();
/**
* Clean up the tagname to respect the scm provider policy.
*
* @param scmUrl The scm url
* @param tagName The tag name
* @return The cleaned tag name
*/
String sanitizeTagName( String scmUrl, String tagName )
throws Exception;
/**
* @param releaseId
* @return
*/
ReleaseListenerSummary getListener( String releaseId );
/**
* Determines if there is an ongoing release
*
* @return true if there is an ongoing release; false otherwise
* @throws Exception if unable to determine if release is ongoing
*/
boolean isExecutingRelease()
throws Exception;
/**
* Retrieve the Release TaskQueueExecutor instance
*
* @return Release TaskQueueExecutor instance
* @throws TaskQueueManagerException if unable to retrieve the Release TaskQueueExecutor instance
*/
TaskQueueExecutor getPerformReleaseTaskQueueExecutor()
throws TaskQueueManagerException;
/**
* Retrieve the PrepareRelease TaskQueueExecutor instance
*
* @return PrepareRelease TaskQueueExecutor instance
* @throws TaskQueueManagerException if unable to retrieve the PrepareRelease TaskQueueExecutor instance
*/
TaskQueueExecutor getPrepareReleaseTaskQueueExecutor()
throws TaskQueueManagerException;
/**
* Retrieve the RollbackRelease TaskQueueExecutor instance
*
* @return RollbackRelease TaskQueueExecutor instance
* @throws TaskQueueManagerException if unable to retrieve the RollbackRelease TaskQueueExecutor instance
*/
TaskQueueExecutor getRollbackReleaseTaskQueueExecutor()
throws TaskQueueManagerException;
}
| 5,295 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseException.java | package org.apache.maven.continuum.release;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author Jason van Zyl
*/
public class ContinuumReleaseException
extends Exception
{
private static final long serialVersionUID = 2167029372282426809L;
public ContinuumReleaseException( String id )
{
super( id );
}
public ContinuumReleaseException( String id, Throwable throwable )
{
super( id, throwable );
}
public ContinuumReleaseException( Throwable throwable )
{
super( throwable );
}
}
| 5,296 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationException.java | package org.apache.maven.continuum.installation;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @author <a href="mailto:olamy@codehaus.org">olamy</a>
* @since 13 juin 07
*/
public class InstallationException
extends Exception
{
private static final long serialVersionUID = 5055136446336281496L;
public InstallationException( String message )
{
super( message );
}
public InstallationException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,297 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/installation/InstallationService.java | package org.apache.maven.continuum.installation;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.execution.ExecutorConfigurator;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
import org.apache.maven.continuum.profile.AlreadyExistsProfileException;
import java.util.List;
/**
* @author <a href="mailto:olamy@codehaus.org">olamy</a>
* @since 13 juin 07
*/
public interface InstallationService
{
String ROLE = InstallationService.class.getName();
String JDK_TYPE = "jdk";
String MAVEN2_TYPE = "maven2";
String MAVEN1_TYPE = "maven1";
String ANT_TYPE = "ant";
String ENVVAR_TYPE = "envvar";
public Installation add( Installation installation, boolean automaticProfile )
throws InstallationException, AlreadyExistsProfileException, AlreadyExistsInstallationException;
public Installation add( Installation installation )
throws InstallationException, AlreadyExistsInstallationException;
public void update( Installation installation )
throws InstallationException, AlreadyExistsInstallationException;
public void delete( Installation installation )
throws InstallationException;
public Installation getInstallation( int installationId )
throws InstallationException;
public Installation getInstallation( String installationName )
throws InstallationException;
public List<Installation> getAllInstallations()
throws InstallationException;
public String getEnvVar( String type );
/**
* @param type
* @return ExecutorConfigurator or null if unknown type
*/
public ExecutorConfigurator getExecutorConfigurator( String type );
/**
* @param installation
* @return output of JAVA_HOME/bin/java -version (JAVA_HOME = installation.getVarValue()
* @throws InstallationException
*/
public List<String> getJavaVersionInfo( Installation installation )
throws InstallationException;
/**
* @return output of JAVA_HOME/bin/java -version
* @throws InstallationException
*/
public List<String> getDefaultJavaVersionInfo()
throws InstallationException;
/**
* @param path
* @param executorConfigurator (ec)
* @return the cli output of $path/ec.relativePath.ec.executable ec.versionArgument
* @throws InstallationException
*/
public List<String> getExecutorVersionInfo( String path, ExecutorConfigurator executorConfigurator,
Profile profile )
throws InstallationException;
}
| 5,298 |
0 | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum | Create_ds/continuum/continuum-api/src/main/java/org/apache/maven/continuum/installation/AlreadyExistsInstallationException.java | package org.apache.maven.continuum.installation;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.continuum.ContinuumException;
/**
* @author <a href="mailto:olamy@apache.org">olamy</a>
* @since 1.2
*/
public class AlreadyExistsInstallationException
extends ContinuumException
{
private static final long serialVersionUID = -7673670059441370868L;
/**
* @param message
*/
public AlreadyExistsInstallationException( String message )
{
super( message );
}
/**
* @param message
* @param cause
*/
public AlreadyExistsInstallationException( String message, Throwable cause )
{
super( message, cause );
}
}
| 5,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.