mirror of https://github.com/apache/archiva.git
Boilerplate unit testing with hsqldb for other devs ...
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@521303 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2087d187e7
commit
3e1c7a3ad2
|
@ -25,6 +25,8 @@ import org.apache.maven.archiva.model.ArchivaRepositoryModel;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.jdo.JDOHelper;
|
||||
|
||||
/**
|
||||
* JdoArchivaDAOTest
|
||||
*
|
||||
|
@ -35,33 +37,54 @@ public class JdoArchivaDAOTest extends AbstractArchivaDatabaseTestCase
|
|||
{
|
||||
public void testRepositoryCRUD() throws ArchivaDatabaseException
|
||||
{
|
||||
// Create it
|
||||
ArchivaRepositoryModel repo = dao.createRepository( "testRepo", "http://localhost:8080/repository/foo" );
|
||||
|
||||
assertNotNull( repo );
|
||||
|
||||
repo.setName( "The Test Repostitory." );
|
||||
// Set some mandatory values
|
||||
repo.setName( "The Test Repository." );
|
||||
repo.setCreationSource( "Test Case" );
|
||||
repo.setLayoutName( "default" );
|
||||
|
||||
// Save it.
|
||||
ArchivaRepositoryModel repoSaved = dao.saveRepository( repo );
|
||||
assertNotNull( repoSaved );
|
||||
assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved ).toString() );
|
||||
|
||||
// Test that something has been saved.
|
||||
List repos = dao.getRepositories();
|
||||
assertNotNull( repos );
|
||||
assertEquals( 1, repos.size() );
|
||||
|
||||
|
||||
// Test that retreived object is what we expect.
|
||||
ArchivaRepositoryModel firstRepo = (ArchivaRepositoryModel) repos.get( 0 );
|
||||
assertNotNull( firstRepo );
|
||||
assertEquals( "testRepo", repo.getId() );
|
||||
assertEquals( "The Test Repository.", repo.getName() );
|
||||
assertEquals( "Test Case", repo.getCreationSource() );
|
||||
assertEquals( "default", repo.getLayoutName() );
|
||||
|
||||
// Change value and save.
|
||||
repoSaved.setName( "Saved Again" );
|
||||
dao.saveRepository( repoSaved );
|
||||
|
||||
|
||||
// Test that only 1 object is saved.
|
||||
assertEquals( 1, dao.getRepositories().size() );
|
||||
|
||||
// Get the specific repo.
|
||||
ArchivaRepositoryModel actualRepo = dao.getRepository( "testRepo" );
|
||||
assertNotNull( actualRepo );
|
||||
|
||||
// Test expected values.
|
||||
assertEquals( "testRepo", actualRepo.getId() );
|
||||
assertEquals( "http://localhost:8080/repository/foo", actualRepo.getUrl() );
|
||||
assertEquals( "Saved Again", actualRepo.getName() );
|
||||
|
||||
|
||||
// Test that only 1 object is saved.
|
||||
assertEquals( 1, dao.getRepositories().size() );
|
||||
|
||||
|
||||
// Delete object.
|
||||
dao.deleteRepository( actualRepo );
|
||||
assertEquals( 0, dao.getRepositories().size() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,20 +76,12 @@
|
|||
<goals>
|
||||
<goal>java</goal>
|
||||
<goal>xsd</goal>
|
||||
<goal>jpox-jdo-mapping</goal>
|
||||
<goal>jpox-metadata-class</goal>
|
||||
<goal>xpp3-writer</goal>
|
||||
<goal>xpp3-reader</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jdo</id>
|
||||
<goals>
|
||||
<goal>jpox-jdo-mapping</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/target/classes/org/apache/maven/archiva/model</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" ?>
|
||||
<model jpox.table-prefix="ARCHIVA_"
|
||||
<model jpox.mapping-in-package="true"
|
||||
jpox.table-prefix="ARCHIVA_"
|
||||
xsd.namespace="http://maven.apache.org/archiva/MODEL-1.0.0"
|
||||
xsd.target-namespace="http://maven.apache.org/archiva/MODEL-1.0.0">
|
||||
<id>archiva-base-model</id>
|
||||
|
@ -93,11 +94,13 @@
|
|||
-->
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.table="REPOSITORIES">
|
||||
jpox.table="REPOSITORIES"
|
||||
jpox.not-persisted-fields="modelEncoding">
|
||||
<name>ArchivaRepositoryModel</name>
|
||||
<version>1.0.0+</version>
|
||||
<fields>
|
||||
<field>
|
||||
<field jpox.primary-key="true"
|
||||
jpox.value-strategy="off">
|
||||
<name>id</name>
|
||||
<identity>true</identity>
|
||||
<version>1.0.0+</version>
|
||||
|
@ -148,26 +151,29 @@
|
|||
The layout of the repository.
|
||||
(Either 'default', or 'legacy')
|
||||
</description>
|
||||
<defaultValue>default</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>releasePolicy</name>
|
||||
<identity>false</identity>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<type>boolean</type>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The releases policy of the repository.
|
||||
</description>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<identity>false</identity>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<type>boolean</type>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The snapshot policy of the repository.
|
||||
</description>
|
||||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
|
Loading…
Reference in New Issue