Source Code Cross Referenced for TranslationLibraryTestMojo.java in  » UML » AndroMDA-3.2 » org » andromda » maven » plugin » bootstrap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » AndroMDA 3.2 » org.andromda.maven.plugin.bootstrap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.maven.plugin.bootstrap;
002:
003:        import java.io.File;
004:
005:        import java.net.URL;
006:
007:        import java.util.List;
008:
009:        import junit.framework.TestResult;
010:
011:        import org.andromda.core.common.ExceptionUtils;
012:        import org.andromda.core.common.ResourceUtils;
013:        import org.andromda.maven.plugin.configuration.AbstractConfigurationMojo;
014:        import org.andromda.translation.ocl.testsuite.TranslationTestProcessor;
015:        import org.apache.maven.artifact.factory.ArtifactFactory;
016:        import org.apache.maven.artifact.repository.ArtifactRepository;
017:        import org.apache.maven.plugin.MojoExecutionException;
018:        import org.apache.maven.plugin.MojoFailureException;
019:        import org.apache.maven.project.MavenProject;
020:        import org.apache.maven.settings.Settings;
021:
022:        /**
023:         * The bootstrap version of the translation-library test.
024:         *
025:         * @phase test
026:         * @goal test-translation-library
027:         * @requiresDependencyResolution test
028:         * @description runs AndroMDA Translation-Library tests
029:         * @author Chad Brandon
030:         */
031:        public class TranslationLibraryTestMojo extends
032:                AbstractConfigurationMojo {
033:            /**
034:             * Base directory to which the cartridge test report is written
035:             *
036:             * @parameter expression="${project.build.directory}/translation-library-test/reports"
037:             */
038:            private String reportDirectory;
039:
040:            /**
041:             * Whether or not the expression shall be 'traced' (i.e. the TraceTranslator will run instead of the specified translator).
042:             * This is helpful, in allowing us to see which expressions are being parsed in what order, etc.
043:             *
044:             * @parameter expression="${trace.expression}"
045:             */
046:            protected boolean traceExpression;
047:
048:            /**
049:             * When specified, only this translation will be tested (If more than one TestTranslation-* file is found).
050:             *
051:             * @parameter expression="${translation.name}"
052:             */
053:            protected String translationName;
054:
055:            /**
056:             * The directory containing the test source.
057:             *
058:             * @parameter expression="${basedir}"
059:             * @required
060:             * @readonly
061:             */
062:            protected String testSourceDirectory;
063:
064:            /**
065:             * Set this to 'true' to bypass translation-library tests entirely. Its use is NOT RECOMMENDED, but quite convenient on occasion.
066:             *
067:             * @parameter expression="${maven.test.skip}"
068:             */
069:            protected boolean skip;
070:
071:            /**
072:             * This is the URI to the AndroMDA configuration file.
073:             *
074:             * @parameter expression="file:${basedir}/conf/test/andromda.xml"
075:             * @required
076:             */
077:            protected String configurationUri;
078:
079:            /**
080:             * @parameter expression="${project}"
081:             * @required
082:             * @readonly
083:             */
084:            private MavenProject project;
085:
086:            /**
087:             * @parameter expression="${project.build.filters}"
088:             */
089:            private List propertyFiles;
090:
091:            /**
092:             * The current user system settings for use in Maven. (allows us to pass the user
093:             * settings to the AndroMDA configuration).
094:             *
095:             * @parameter expression="${settings}"
096:             * @required
097:             * @readonly
098:             */
099:            private Settings settings;
100:
101:            /**
102:             * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
103:             * @required
104:             * @readonly
105:             */
106:            private ArtifactFactory factory;
107:
108:            /**
109:             * The registered plugin implementations.
110:             *
111:             * @parameter expression="${project.build.plugins}"
112:             * @required
113:             * @readonlya
114:             */
115:            protected List plugins;
116:
117:            /**
118:             * @parameter expression="${localRepository}"
119:             * @required
120:             * @readonly
121:             */
122:            protected ArtifactRepository localRepository;
123:
124:            /**
125:             * @see org.apache.maven.plugin.Mojo#execute()
126:             */
127:            public void execute() throws MojoExecutionException,
128:                    MojoFailureException {
129:                if (!this .skip) {
130:                    try {
131:                        this 
132:                                .getLog()
133:                                .info(
134:                                        "--------------------------------------------------------------------------------");
135:                        this 
136:                                .getLog()
137:                                .info(
138:                                        "  A n d r o M D A   T r a n s l a t i o n - L i b r a r y  T e s t   S u i t e  ");
139:                        this 
140:                                .getLog()
141:                                .info(
142:                                        "--------------------------------------------------------------------------------");
143:
144:                        this 
145:                                .initializeClasspathFromClassPathElements(this .project
146:                                        .getTestClasspathElements());
147:
148:                        final TranslationTestProcessor processor = TranslationTestProcessor
149:                                .instance();
150:                        processor.setTranslationName(this .translationName);
151:                        processor.setUseTraceTranslator(this .traceExpression);
152:                        processor
153:                                .setTestSourceDirectory(this .testSourceDirectory);
154:                        final URL configurationUri = ResourceUtils
155:                                .toURL(this .configurationUri);
156:                        if (configurationUri == null) {
157:                            throw new MojoExecutionException(
158:                                    "No configuration could be loaded from --> '"
159:                                            + this .configurationUri + "'");
160:                        }
161:                        processor.setConfiguration(this 
162:                                .getConfiguration(configurationUri));
163:
164:                        final TranslationLibraryTestFormatter formatter = new TranslationLibraryTestFormatter();
165:
166:                        // - set the report location
167:                        final File report = new File(this .reportDirectory, this 
168:                                .getProject().getArtifactId()
169:                                + ".txt");
170:                        formatter.setReportFile(report);
171:                        final TestResult result = new TestResult();
172:                        formatter.startTestSuite(this .getProject().getName());
173:                        result.addListener(formatter);
174:                        processor.setResult(result);
175:                        processor.runSuite();
176:                        this .getLog().info("");
177:                        this .getLog().info("Results:");
178:                        this .getLog().info(formatter.endTestSuite());
179:                        if (result.failureCount() > 0
180:                                || result.errorCount() > 0) {
181:                            throw new MojoExecutionException(
182:                                    "Test are some test failures");
183:                        }
184:                        processor.shutdown();
185:                    } catch (final Throwable throwable) {
186:                        if (throwable instanceof  MojoExecutionException) {
187:                            throw (MojoExecutionException) throwable;
188:                        }
189:                        throw new MojoExecutionException(
190:                                "An error occured while testing translation-library",
191:                                ExceptionUtils.getRootCause(throwable));
192:                    }
193:                } else {
194:                    this .getLog().info("Skipping translation-library tests");
195:                }
196:            }
197:
198:            /**
199:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getProject()
200:             */
201:            protected MavenProject getProject() {
202:                return this .project;
203:            }
204:
205:            /**
206:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getPropertyFiles()
207:             */
208:            protected List getPropertyFiles() {
209:                return this .propertyFiles;
210:            }
211:
212:            /**
213:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getSettings()
214:             */
215:            protected Settings getSettings() {
216:                return this .settings;
217:            }
218:
219:            /**
220:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getFactory()
221:             */
222:            protected ArtifactFactory getFactory() {
223:                return this .factory;
224:            }
225:
226:            /**
227:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getPlugins()
228:             */
229:            protected List getPlugins() {
230:                return this .plugins;
231:            }
232:
233:            /**
234:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getLocalRepository()
235:             */
236:            protected ArtifactRepository getLocalRepository() {
237:                return this.localRepository;
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.