1 package org.apache.maven.rtinfo.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.rtinfo.RuntimeInformation;
23 import org.codehaus.plexus.PlexusTestCase;
24
25 public class DefaultRuntimeInformationTest
26 extends PlexusTestCase
27 {
28
29 public void testGetMavenVersion()
30 throws Exception
31 {
32 RuntimeInformation rtInfo = lookup( RuntimeInformation.class );
33
34 String mavenVersion = rtInfo.getMavenVersion();
35 assertNotNull( mavenVersion );
36 assertTrue( mavenVersion.length() > 0 );
37 }
38
39 public void testIsMavenVersion()
40 throws Exception
41 {
42 RuntimeInformation rtInfo = lookup( RuntimeInformation.class );
43
44 assertTrue( rtInfo.isMavenVersion( "2.0" ) );
45 assertFalse( rtInfo.isMavenVersion( "9.9" ) );
46
47 assertTrue( rtInfo.isMavenVersion( "[2.0.11,2.1.0),[3.0,)" ) );
48 assertFalse( rtInfo.isMavenVersion( "[9.0,)" ) );
49
50 try
51 {
52 rtInfo.isMavenVersion( "[3.0," );
53 fail( "Bad version range wasn't rejected" );
54 }
55 catch ( IllegalArgumentException e )
56 {
57 assertTrue( true );
58 }
59
60 try
61 {
62 rtInfo.isMavenVersion( "" );
63 fail( "Bad version range wasn't rejected" );
64 }
65 catch ( IllegalArgumentException e )
66 {
67 assertTrue( true );
68 }
69
70 try
71 {
72 rtInfo.isMavenVersion( null );
73 fail( "Bad version range wasn't rejected" );
74 }
75 catch ( NullPointerException e )
76 {
77 assertTrue( true );
78 }
79 }
80
81 }