KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > model > converter > V3PomRewriterTest


1 package org.apache.maven.model.converter;
2
3 /*
4  * Copyright 2005-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.codehaus.plexus.PlexusTestCase;
20 import org.codehaus.plexus.util.xml.Xpp3Dom;
21 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
22
23 import java.io.StringReader JavaDoc;
24 import java.io.StringWriter JavaDoc;
25 import java.io.Writer JavaDoc;
26
27 /**
28  * Test rewriter.
29  *
30  * @author <a HREF="mailto:brett@apache.org">Brett Porter</a>
31  * @version $Id: V3PomRewriterTest.java 349340 2005-11-28 01:34:44Z brett $
32  */

33 public class V3PomRewriterTest
34     extends PlexusTestCase
35 {
36     private V3PomRewriter rewriter;
37
38     protected void setUp()
39         throws Exception JavaDoc
40     {
41         super.setUp();
42
43         rewriter = (V3PomRewriter) lookup( V3PomRewriter.ROLE );
44     }
45
46     public void testCurrentVersionExpressionConversion()
47         throws Exception JavaDoc
48     {
49         String JavaDoc pom =
50             "<project><dependencies><dependency><groupId>g</groupId><artifactId>a</artifactId><version>${pom.currentVersion}</version></dependency></dependencies></project>";
51
52         Writer JavaDoc to = new StringWriter JavaDoc();
53         rewriter.rewrite( new StringReader JavaDoc( pom ), to, false, null, null, null, null );
54
55         Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader JavaDoc( to.toString() ) );
56         String JavaDoc version = dom.getChild( "dependencies" ).getChild( "dependency" ).getChild( "version" ).getValue();
57         assertEquals( "check new version expression", "${project.version}", version );
58     }
59
60 }
61
Popular Tags