1 package org.apache.maven.archiva.scheduled.tasks;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
25
26 public class TaskCreatorTest
27 extends PlexusInSpringTestCase
28 {
29 private static final String REPO_ID = "test-repo";
30
31 public void testCreateRepositoryTask()
32 throws Exception
33 {
34 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID );
35
36 assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() );
37 }
38
39 public void testCreateRepositoryTaskWithTaskNameSuffix()
40 throws Exception
41 {
42 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID );
43
44 assertBasicTaskDetails( task );
45 }
46
47 public void testCreateRepositoryTaskScanAllArtifacts()
48 throws Exception
49 {
50 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, true );
51
52 assertBasicTaskDetails( task );
53 assertTrue( task.isScanAll() );
54 }
55
56 public void testCreateRepositoryTaskDoNotScanAllArtifacts()
57 throws Exception
58 {
59 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, false );
60
61 assertBasicTaskDetails( task );
62 assertFalse( task.isScanAll() );
63 }
64
65 public void testCreateRepositoryTaskForArtifactUpdateAllRelated()
66 throws Exception
67 {
68 File resource = new File( getBasedir(), "target/test-classes/test.jar" );
69 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, true );
70
71 assertBasicTaskDetails( task );
72 assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() );
73 assertTrue( task.isUpdateRelatedArtifacts() );
74 }
75
76 public void testCreateRepositoryTaskForArtifactDoNotUpdateAllRelated()
77 throws Exception
78 {
79 File resource = new File( getBasedir(), "target/test-classes/test.jar" );
80 RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, false );
81
82 assertBasicTaskDetails( task );
83 assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() );
84 assertFalse( task.isUpdateRelatedArtifacts() );
85 }
86
87 private void assertBasicTaskDetails( RepositoryTask task )
88 {
89 assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() );
90 }
91
92 }