Skip to content
Browse files

ARQ-989 Format source code following JBoss convention

* Format Java and XML files

* Add checkstyle maven plugin
  • Loading branch information...
1 parent d4a8df6 commit 5bc36b314cad45b45d3544b2fcb6bbc10b0fd139 @DavideD DavideD committed Jun 6, 2012
Showing with 836 additions and 784 deletions.
  1. +28 −0 build-config/pom.xml
  2. +53 −0 build-config/src/main/resources/checkstyle.xml
  3. +10 −1 plugin/pom.xml
  4. +266 −299 plugin/src/main/java/org/jboss/arquillian/maven/BaseCommand.java
  5. +33 −32 plugin/src/main/java/org/jboss/arquillian/maven/Deploy.java
  6. +34 −34 plugin/src/main/java/org/jboss/arquillian/maven/DeployRemote.java
  7. +49 −56 plugin/src/main/java/org/jboss/arquillian/maven/Run.java
  8. +33 −31 plugin/src/main/java/org/jboss/arquillian/maven/Start.java
  9. +39 −41 plugin/src/main/java/org/jboss/arquillian/maven/Stop.java
  10. +31 −29 plugin/src/main/java/org/jboss/arquillian/maven/Undeploy.java
  11. +35 −35 plugin/src/main/java/org/jboss/arquillian/maven/UndeployRemote.java
  12. +44 −60 plugin/src/main/java/org/jboss/arquillian/maven/Utils.java
  13. +26 −32 plugin/src/test/java/org/jboss/arquillian/maven/BaseCommandTestBase.java
  14. +5 −7 plugin/src/test/java/org/jboss/arquillian/maven/DeployTestCase.java
  15. +5 −7 plugin/src/test/java/org/jboss/arquillian/maven/RunTestCase.java
  16. +5 −7 plugin/src/test/java/org/jboss/arquillian/maven/StartTestCase.java
  17. +5 −7 plugin/src/test/java/org/jboss/arquillian/maven/StopTestCase.java
  18. +5 −7 plugin/src/test/java/org/jboss/arquillian/maven/UndeployTestCase.java
  19. +42 −6 pom.xml
  20. +6 −1 test/pom.xml
  21. +11 −11 test/src/main/java/org/jboss/arquillian/maven/test/MySimpleServlet.java
  22. +12 −15 test/src/test/java/org/jboss/arquillian/maven/test/MySimpleServletITCase.java
  23. +26 −29 test/src/test/java/org/jboss/arquillian/maven/test/MySimpleServletTestCase.java
  24. +25 −27 test/src/test/java/org/jboss/arquillian/maven/test/Utils.java
  25. +1 −2 test/src/test/resources/jbossas7/arquillian.xml
  26. +7 −8 test/src/test/resources/jetty7/arquillian.xml
View
28 build-config/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>arquillian-maven-plugin-parent</artifactId>
+ <groupId>org.jboss.arquillian.maven</groupId>
+ <version>1.0.0.Final-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>arquillian-maven-build-config</artifactId>
+ <name>Arquillian Maven Build Configuration</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
53 build-config/src/main/resources/checkstyle.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+ <module name="FileTabCharacter">
+ <property name="eachLine" value="true"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <!-- \s matches whitespace character, $ matches end of line. -->
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+
+ <module name="TreeWalker">
+
+ <property name="cacheFile" value="${checkstyle.cache.file}"/>
+
+ <!-- Checks for imports -->
+ <module name="AvoidStarImport"/>
+ <module name="RedundantImport"/>
+ <!-- Disabled until checkstyle can recognize imports which are used only by javadoc -->
+ <!--<module name="UnusedImports"/>-->
+
+ <!-- Modifier Checks -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <module name="LeftCurly"/>
+
+ <!-- Checks for common coding problems -->
+ <!-- Disabled until http://sourceforge.net/tracker/?func=detail&aid=2843447&group_id=29721&atid=397078 is fixed-->
+ <!--<module name="DoubleCheckedLocking"/>-->
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <module name="IllegalInstantiation"/>
+ <module name="RedundantThrows">
+ <property name="allowUnchecked" value="true"/>
+ </module>
+
+ <!-- Miscellaneous other checks. -->
+ <module name="UpperEll"/>
+ <module name="PackageAnnotation"/>
+ <module name="CovariantEquals"/>
+ <module name="ArrayTypeStyle"/>
+
+ </module>
+
+</module>
+
View
11 plugin/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -48,4 +49,12 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
View
565 plugin/src/main/java/org/jboss/arquillian/maven/BaseCommand.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -41,307 +41,274 @@
/**
* BaseCommand
- *
+ *
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @author Davide D'Alto
* @version $Revision: $
- *
+ *
* @requiresDependencyResolution test
*/
-abstract class BaseCommand extends AbstractMojo
-{
- private static final String ARQUILLIAN_XML_SYS_PROP = "arquillian.xml";
-
- private static final String LOADABLE_EXTESION_LOADER_CLASS = "org.jboss.arquillian.core.impl.loadable.LoadableExtensionLoader";
-
- public enum ClassLoadingStrategy
- {
- COMPILE,
- TEST,
- PLUGIN
- }
-
- /**
- * The maven project.
- *
- * @parameter expression="${project}"
- */
- private MavenProject project;
-
- /**
- * The ClassLoading strategy to use: TEST, COMPILE or PLUGIN.
- *
- * @parameter property="classloading"
- */
- private ClassLoadingStrategy classLoadingStrategy = ClassLoadingStrategy.TEST;
-
- /**
- * @param classLoadingStrategy the classLoadingStrategy to set
- */
- public void setClassloading(String classloading)
- {
- this.classLoadingStrategy = ClassLoadingStrategy.valueOf(classloading.toUpperCase());
- }
-
- /**
- * The target directory the application to be deployed is located.
- *
- * @parameter expression="${echo.target}" default-value="${project.build.directory}/"
- */
- private File targetDir;
-
- /**
- * The file name of the application to be deployed.
- *
- * @parameter expression="${echo.filename}" default-value="${project.build.finalName}.${project.packaging}"
- */
- private String filename;
-
- /**
- * Location of the arquillian configuration file. It can be set either as location on the file system (Ex: ${basedir}/test/arquillian4test.xml)
- * or as a resource in the classpath (Ex: /arquillian4test.xml).
- *
- * @parameter expression="${arquillian.xml}"
- */
- private String arquillianXml;
-
- /**
- * The target directory the archive is located. The default is {@code project.build.directory}.
- *
- * @return the target directory the archive is located.
- */
- public final File targetDirectory()
- {
- return targetDir;
- }
-
- /**
- * The file name of the archive not including the directory. The default is
- * {@code project.build.finalName + . + project.packaging}
- *
- * @return the file name of the archive.
- */
- public final String filename()
- {
- return filename;
- }
-
- /**
- * The archive file.
- *
- * @return the archive file.
- */
- public final File file()
- {
- return new File(targetDir, filename);
- }
-
- /**
- * Return the value of the arquillianXml configuration property.
- */
- public final String arquillianXml()
- {
- return arquillianXml;
- }
-
- /**
- * The goal of the deployment.
- *
- * @return the goal of the deployment.
- */
- public abstract String goal();
-
- /**
- * Perform the defined goal, e.g. deploy / run / undeploy
- *
- * @param container The chosen container to operate on
- * @throws LifecycleException
- * @throws DeploymentException
- */
- public abstract void perform(Manager manager, Container container) throws DeploymentException, LifecycleException;
-
- /* (non-Javadoc)
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException
- {
- validateInput();
- initArquillianXml();
-
- getLog().info("Using configuration: " + System.getProperty(ARQUILLIAN_XML_SYS_PROP));
- getLog().info(goal() + " file: " + file().getAbsoluteFile());
-
- ClassLoader previousCL = Thread.currentThread().getContextClassLoader();
- try
- {
- ClassLoader cl = getClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
-
- Class<?> extension = cl.loadClass(LOADABLE_EXTESION_LOADER_CLASS);
-
- loadContainer(extension);
- }
- catch (Exception e)
- {
- throw new MojoExecutionException("Could not perform goal: " + goal() + " on file " + file(), e);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(previousCL);
- }
- }
-
- void initArquillianXml()
- {
- if (arquillianXml() != null) {
- System.setProperty(ARQUILLIAN_XML_SYS_PROP, arquillianXml());
- }
- }
-
- void validateInput()
- {
- File deploymentFile = file();
- if (!deploymentFile.exists())
- {
- throw new IllegalArgumentException("Specified file does not exist:" + deploymentFile
- + ". Verify 'target' and 'filename' configuration.");
- }
-
- if( (classLoadingStrategy == ClassLoadingStrategy.TEST || classLoadingStrategy == ClassLoadingStrategy.COMPILE) && project == null)
- {
- throw new IllegalArgumentException("Can not use 'classloading' strategy " + classLoadingStrategy + " outside a project");
- }
- }
-
- private void loadContainer(Class<?>... extensions) throws Exception
- {
- Manager manager = startManager(extensions);
- try
- {
- perform(manager, selectContainer(manager));
- }
- catch (Exception e)
- {
- manager.shutdown();
- throw e;
- }
- }
-
- private Manager startManager(Class<?>... extensions)
- {
- Manager manager = getFromContext(Manager.class);
- if (isStarted(manager))
- return manager;
-
- manager = startNewManager(extensions);
- putInContext(Manager.class, manager);
- return manager;
- }
-
- private boolean isStarted(Manager manager)
- {
- return manager != null;
- }
-
- Manager startNewManager(Class<?>... extensions)
- {
- Manager manager = ManagerBuilder.from().extensions(extensions).create();
- manager.start();
- return manager;
- }
-
- private Container selectContainer(Manager manager)
- {
- // TODO: Add support for multi configuration
- Container container = createRegistry(manager).getContainer(TargetDescription.DEFAULT);
- getLog().info("to container: " + container.getName());
- return container;
- }
-
- Archive<?> createDeployment()
- {
- getLog().info(goal() + " file: " + file().getAbsoluteFile());
-
- File deploymentFile = file();
- Archive<?> deployment = ShrinkWrap.create(ZipImporter.class, deploymentFile.getName())
- .importFrom(deploymentFile).as(GenericArchive.class);
- return deployment;
- }
-
- private ContainerRegistry createRegistry(Manager manager)
- {
- ContainerRegistry registry = getFromContext(ContainerRegistry.class);
- if (registry != null)
- return registry;
-
- registry = manager.resolve(ContainerRegistry.class);
- validateRegistry(registry);
- putInContext(ContainerRegistry.class, registry);
- return registry;
- }
-
- private void validateRegistry(ContainerRegistry registry)
- {
- if (registry == null)
- {
- throw new IllegalStateException(
- "No ContainerRegistry found in Context. Something is wrong with the classpath.....");
- }
-
- if (registry.getContainers().size() == 0)
- {
- throw new IllegalStateException(
- "No Containers in registry. You need to add the Container Adaptor dependencies to the plugin dependency section");
- }
- }
-
- protected ClassLoader getClassLoader() throws Exception
- {
- ClassLoader classLoader = getFromContext(ClassLoader.class);
- if (classLoader != null)
- return classLoader;
-
- synchronized (BaseCommand.class)
- {
- List<URL> urls = new ArrayList<URL>();
- List<String> classPathElements;
-
- switch (classLoadingStrategy)
- {
- case COMPILE :
- classPathElements = project.getCompileClasspathElements();
- break;
- case TEST :
- classPathElements = project.getTestClasspathElements();
- break;
- case PLUGIN :
- classPathElements = new ArrayList<String>();
- break;
-
- default :
- classPathElements = new ArrayList<String>();
- break;
- }
-
- for (String object : classPathElements)
- {
- String path = (String) object;
- urls.add(new File(path).toURI().toURL());
- }
- URLClassLoader urlClassLoader = new URLClassLoader(urls.toArray(new URL[]{}), BaseCommand.class.getClassLoader());
- putInContext(ClassLoader.class, urlClassLoader);
- return urlClassLoader;
- }
- }
-
- @SuppressWarnings("unchecked")
- <T> T getFromContext(Class<T> key) {
- return (T) getPluginContext().get(key);
- }
-
- @SuppressWarnings("unchecked")
- <T> T putInContext(Class<T> key, T value) {
- return (T) getPluginContext().put(key, value);
- }
+abstract class BaseCommand extends AbstractMojo {
+ private static final String ARQUILLIAN_XML_SYS_PROP = "arquillian.xml";
+
+ private static final String LOADABLE_EXTESION_LOADER_CLASS = "org.jboss.arquillian.core.impl.loadable.LoadableExtensionLoader";
+
+ public enum ClassLoadingStrategy {
+ COMPILE, TEST, PLUGIN
+ }
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ */
+ private MavenProject project;
+
+ /**
+ * The ClassLoading strategy to use: TEST, COMPILE or PLUGIN.
+ *
+ * @parameter property="classloading"
+ */
+ private ClassLoadingStrategy classLoadingStrategy = ClassLoadingStrategy.TEST;
+
+ /**
+ * @param classLoadingStrategy the classLoadingStrategy to set
+ */
+ public void setClassloading(String classloading) {
+ this.classLoadingStrategy = ClassLoadingStrategy.valueOf(classloading.toUpperCase());
+ }
+
+ /**
+ * The target directory the application to be deployed is located.
+ *
+ * @parameter expression="${echo.target}" default-value="${project.build.directory}/"
+ */
+ private File targetDir;
+
+ /**
+ * The file name of the application to be deployed.
+ *
+ * @parameter expression="${echo.filename}" default-value="${project.build.finalName}.${project.packaging}"
+ */
+ private String filename;
+
+ /**
+ * Location of the arquillian configuration file. It can be set either as location on the file system (Ex:
+ * ${basedir}/test/arquillian4test.xml) or as a resource in the classpath (Ex: /arquillian4test.xml).
+ *
+ * @parameter expression="${arquillian.xml}"
+ */
+ private String arquillianXml;
+
+ /**
+ * The target directory the archive is located. The default is {@code project.build.directory}.
+ *
+ * @return the target directory the archive is located.
+ */
+ public final File targetDirectory() {
+ return targetDir;
+ }
+
+ /**
+ * The file name of the archive not including the directory. The default is
+ * {@code project.build.finalName + . + project.packaging}
+ *
+ * @return the file name of the archive.
+ */
+ public final String filename() {
+ return filename;
+ }
+
+ /**
+ * The archive file.
+ *
+ * @return the archive file.
+ */
+ public final File file() {
+ return new File(targetDir, filename);
+ }
+
+ /**
+ * Return the value of the arquillianXml configuration property.
+ */
+ public final String arquillianXml() {
+ return arquillianXml;
+ }
+
+ /**
+ * The goal of the deployment.
+ *
+ * @return the goal of the deployment.
+ */
+ public abstract String goal();
+
+ /**
+ * Perform the defined goal, e.g. deploy / run / undeploy
+ *
+ * @param container The chosen container to operate on
+ * @throws LifecycleException
+ * @throws DeploymentException
+ */
+ public abstract void perform(Manager manager, Container container) throws DeploymentException, LifecycleException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ validateInput();
+ initArquillianXml();
+
+ getLog().info("Using configuration: " + System.getProperty(ARQUILLIAN_XML_SYS_PROP));
+ getLog().info(goal() + " file: " + file().getAbsoluteFile());
+
+ ClassLoader previousCL = Thread.currentThread().getContextClassLoader();
+ try {
+ ClassLoader cl = getClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+
+ Class<?> extension = cl.loadClass(LOADABLE_EXTESION_LOADER_CLASS);
+
+ loadContainer(extension);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Could not perform goal: " + goal() + " on file " + file(), e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(previousCL);
+ }
+ }
+
+ void initArquillianXml() {
+ if (arquillianXml() != null) {
+ System.setProperty(ARQUILLIAN_XML_SYS_PROP, arquillianXml());
+ }
+ }
+
+ void validateInput() {
+ File deploymentFile = file();
+ if (!deploymentFile.exists()) {
+ throw new IllegalArgumentException("Specified file does not exist:" + deploymentFile
+ + ". Verify 'target' and 'filename' configuration.");
+ }
+
+ if ((classLoadingStrategy == ClassLoadingStrategy.TEST || classLoadingStrategy == ClassLoadingStrategy.COMPILE)
+ && project == null) {
+ throw new IllegalArgumentException("Can not use 'classloading' strategy " + classLoadingStrategy
+ + " outside a project");
+ }
+ }
+
+ private void loadContainer(Class<?>... extensions) throws Exception {
+ Manager manager = startManager(extensions);
+ try {
+ perform(manager, selectContainer(manager));
+ } catch (Exception e) {
+ manager.shutdown();
+ throw e;
+ }
+ }
+
+ private Manager startManager(Class<?>... extensions) {
+ Manager manager = getFromContext(Manager.class);
+ if (isStarted(manager))
+ return manager;
+
+ manager = startNewManager(extensions);
+ putInContext(Manager.class, manager);
+ return manager;
+ }
+
+ private boolean isStarted(Manager manager) {
+ return manager != null;
+ }
+
+ Manager startNewManager(Class<?>... extensions) {
+ Manager manager = ManagerBuilder.from().extensions(extensions).create();
+ manager.start();
+ return manager;
+ }
+
+ private Container selectContainer(Manager manager) {
+ // TODO: Add support for multi configuration
+ Container container = createRegistry(manager).getContainer(TargetDescription.DEFAULT);
+ getLog().info("to container: " + container.getName());
+ return container;
+ }
+
+ Archive<?> createDeployment() {
+ getLog().info(goal() + " file: " + file().getAbsoluteFile());
+
+ File deploymentFile = file();
+ Archive<?> deployment = ShrinkWrap.create(ZipImporter.class, deploymentFile.getName()).importFrom(deploymentFile)
+ .as(GenericArchive.class);
+ return deployment;
+ }
+
+ private ContainerRegistry createRegistry(Manager manager) {
+ ContainerRegistry registry = getFromContext(ContainerRegistry.class);
+ if (registry != null)
+ return registry;
+
+ registry = manager.resolve(ContainerRegistry.class);
+ validateRegistry(registry);
+ putInContext(ContainerRegistry.class, registry);
+ return registry;
+ }
+
+ private void validateRegistry(ContainerRegistry registry) {
+ if (registry == null) {
+ throw new IllegalStateException("No ContainerRegistry found in Context. Something is wrong with the classpath.....");
+ }
+
+ if (registry.getContainers().size() == 0) {
+ throw new IllegalStateException(
+ "No Containers in registry. You need to add the Container Adaptor dependencies to the plugin dependency section");
+ }
+ }
+
+ protected ClassLoader getClassLoader() throws Exception {
+ ClassLoader classLoader = getFromContext(ClassLoader.class);
+ if (classLoader != null)
+ return classLoader;
+
+ synchronized (BaseCommand.class) {
+ List<URL> urls = new ArrayList<URL>();
+ List<String> classPathElements;
+
+ switch (classLoadingStrategy) {
+ case COMPILE:
+ classPathElements = project.getCompileClasspathElements();
+ break;
+ case TEST:
+ classPathElements = project.getTestClasspathElements();
+ break;
+ case PLUGIN:
+ classPathElements = new ArrayList<String>();
+ break;
+
+ default:
+ classPathElements = new ArrayList<String>();
+ break;
+ }
+
+ for (String object : classPathElements) {
+ String path = (String) object;
+ urls.add(new File(path).toURI().toURL());
+ }
+ URLClassLoader urlClassLoader = new URLClassLoader(urls.toArray(new URL[] {}), BaseCommand.class.getClassLoader());
+ putInContext(ClassLoader.class, urlClassLoader);
+ return urlClassLoader;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ <T> T getFromContext(Class<T> key) {
+ return (T) getPluginContext().get(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ <T> T putInContext(Class<T> key, T value) {
+ return (T) getPluginContext().put(key, value);
+ }
}
View
65 plugin/src/main/java/org/jboss/arquillian/maven/Deploy.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -27,41 +27,42 @@
* Deploy to a Container
*
* @goal deploy
- *
+ *
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
- *
+ *
*/
-public final class Deploy extends BaseCommand
-{
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "deploy";
- }
+public final class Deploy extends BaseCommand {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "deploy";
+ }
- @Override
- Manager startNewManager(Class<?>... extensions)
- {
- throw new RuntimeException("Container not started. The container must be started before deploy. If the container is remote sue \"arquillian:deployRemote\"");
- }
+ @Override
+ Manager startNewManager(Class<?>... extensions) {
+ throw new RuntimeException(
+ "Container not started. The container must be started before deploy. If the container is remote sue \"arquillian:deployRemote\"");
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
- */
- @Override
- public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException
- {
- Archive<?> deployment = createDeployment();
- getLog().info("Perform deploy on " + container.getName() + " of deployment " + deployment.getName());
- execute(manager, container, deployment);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException {
+ Archive<?> deployment = createDeployment();
+ getLog().info("Perform deploy on " + container.getName() + " of deployment " + deployment.getName());
+ execute(manager, container, deployment);
+ }
- static void execute(Manager manager, Container container, Archive<?> deployment) throws DeploymentException
- {
- Utils.deploy(manager, container, deployment);
- }
+ static void execute(Manager manager, Container container, Archive<?> deployment) throws DeploymentException {
+ Utils.deploy(manager, container, deployment);
+ }
}
View
68 plugin/src/main/java/org/jboss/arquillian/maven/DeployRemote.java
@@ -32,44 +32,44 @@
* @version $Revision: $
*
*/
-public final class DeployRemote extends BaseCommand
-{
- private boolean managerStartedByMe = false;
+public final class DeployRemote extends BaseCommand {
+ private boolean managerStartedByMe = false;
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "deployRemote";
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "deployRemote";
+ }
- @Override
- Manager startNewManager(Class<?>... extensions)
- {
- managerStartedByMe = true;
- return super.startNewManager(extensions);
- }
+ @Override
+ Manager startNewManager(Class<?>... extensions) {
+ managerStartedByMe = true;
+ return super.startNewManager(extensions);
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
- */
- @Override
- public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException
- {
- if (managerStartedByMe)
- Start.execute(manager, container);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException {
+ if (managerStartedByMe)
+ Start.execute(manager, container);
- deploy(manager, container);
+ deploy(manager, container);
- Stop.execute( manager, container );
- }
+ Stop.execute(manager, container);
+ }
- private void deploy(Manager manager, Container container) throws DeploymentException
- {
- Archive<?> deployment = createDeployment();
- getLog().info("Perform deploy on " + container.getName() + " of deployment " + deployment.getName());
- Deploy.execute( manager, container, deployment );
- }
+ private void deploy(Manager manager, Container container) throws DeploymentException {
+ Archive<?> deployment = createDeployment();
+ getLog().info("Perform deploy on " + container.getName() + " of deployment " + deployment.getName());
+ Deploy.execute(manager, container, deployment);
+ }
}
View
105 plugin/src/main/java/org/jboss/arquillian/maven/Run.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -28,69 +28,62 @@
* Deploy to a Container
*
* @goal run
- *
+ *
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
- *
+ *
*/
-public final class Run extends BaseCommand
-{
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "run";
- }
+public final class Run extends BaseCommand {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "run";
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
- */
- @Override
- public void perform(final Manager manager, final Container container) throws LifecycleException, DeploymentException
- {
- Start.execute(manager, container);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void perform(final Manager manager, final Container container) throws LifecycleException, DeploymentException {
+ Start.execute(manager, container);
- final Archive<?> deployment = deploy(manager, container);
+ final Archive<?> deployment = deploy(manager, container);
- Runtime.getRuntime().addShutdownHook(new Thread()
- {
- @Override
- public void run()
- {
- // ThreadLocals are not auto transfered / reactivated on new Threads, activate the ApplicationContext
- manager.getContext(ApplicationContext.class).activate();
- try
- {
- Undeploy.execute(manager, container, deployment);
- Stop.execute(manager, container);
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ // ThreadLocals are not auto transfered / reactivated on new Threads, activate the ApplicationContext
+ manager.getContext(ApplicationContext.class).activate();
+ try {
+ Undeploy.execute(manager, container, deployment);
+ Stop.execute(manager, container);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- catch (Exception e)
- {
- e.printStackTrace();
+ });
+ try {
+ while (true) {
+ Thread.sleep(10000);
}
- }
- });
- try
- {
- while(true)
- {
- Thread.sleep(10000);
- }
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(e);
- }
- }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
- private Archive<?> deploy(final Manager manager, final Container container) throws DeploymentException
- {
- final Archive<?> deployment = createDeployment();
- getLog().info("Perform run on " + container.getName() + " of deployment " + deployment.getName());
+ private Archive<?> deploy(final Manager manager, final Container container) throws DeploymentException {
+ final Archive<?> deployment = createDeployment();
+ getLog().info("Perform run on " + container.getName() + " of deployment " + deployment.getName());
- Deploy.execute(manager, container, deployment);
- return deployment;
- }
+ Deploy.execute(manager, container, deployment);
+ return deployment;
+ }
}
View
64 plugin/src/main/java/org/jboss/arquillian/maven/Start.java
@@ -30,39 +30,41 @@
* @version $Revision: $
*
*/
-public final class Start extends BaseCommand
-{
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "start";
- }
+public final class Start extends BaseCommand {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "start";
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#validateInput()
- */
- @Override
- void validateInput()
- {
- // No need to validate when starting
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#validateInput()
+ */
+ @Override
+ void validateInput() {
+ // No need to validate when starting
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container)
- */
- @Override
- public void perform(Manager manager, Container container) throws LifecycleException
- {
- execute(manager, container);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container)
+ */
+ @Override
+ public void perform(Manager manager, Container container) throws LifecycleException {
+ execute(manager, container);
+ }
- static void execute(Manager manager, Container container) throws LifecycleException
- {
- Utils.setup(manager, container);
- Utils.start(manager, container);
- }
+ static void execute(Manager manager, Container container) throws LifecycleException {
+ Utils.setup(manager, container);
+ Utils.start(manager, container);
+ }
}
View
80 plugin/src/main/java/org/jboss/arquillian/maven/Stop.java
@@ -29,48 +29,46 @@
* @version $Revision: $
*
*/
-public final class Stop extends BaseCommand
-{
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "stop";
- }
+public final class Stop extends BaseCommand {
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#validateInput()
- */
- @Override
- void validateInput()
- {
- // No need to validate when stopping
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "stop";
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container)
- */
- @Override
- public void perform(Manager manager, Container container)
- {
- execute(manager, container);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#validateInput()
+ */
+ @Override
+ void validateInput() {
+ // No need to validate when stopping
+ }
- static void execute(Manager manager, Container container)
- {
- try
- {
- Utils.stop(manager, container);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- manager.shutdown();
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container)
+ */
+ @Override
+ public void perform(Manager manager, Container container) {
+ execute(manager, container);
+ }
+
+ static void execute(Manager manager, Container container) {
+ try {
+ Utils.stop(manager, container);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ manager.shutdown();
+ }
+ }
}
View
60 plugin/src/main/java/org/jboss/arquillian/maven/Undeploy.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -32,35 +32,37 @@
* @version $Revision: $
*
*/
-public final class Undeploy extends BaseCommand
-{
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "undeploy";
- }
+public final class Undeploy extends BaseCommand {
- Manager startNewManager(Class<?>... extensions)
- {
- throw new RuntimeException("Container not started. The container must be started before undeploy. If the container is remote sue \"arquillian:undeployRemote\"");
- };
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "undeploy";
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
- */
- @Override
- public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException
- {
- final Archive<?> deployment = createDeployment();
- getLog().info("Perform undeploy on " + container.getName() + " of deployment " + deployment.getName());
- execute(manager, container, deployment);
- }
+ Manager startNewManager(Class<?>... extensions) {
+ throw new RuntimeException(
+ "Container not started. The container must be started before undeploy. If the container is remote sue \"arquillian:undeployRemote\"");
+ };
- static void execute(Manager manager, Container container, final Archive<?> deployment) throws DeploymentException
- {
- Utils.undeploy(manager, container, deployment);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException {
+ final Archive<?> deployment = createDeployment();
+ getLog().info("Perform undeploy on " + container.getName() + " of deployment " + deployment.getName());
+ execute(manager, container, deployment);
+ }
+
+ static void execute(Manager manager, Container container, final Archive<?> deployment) throws DeploymentException {
+ Utils.undeploy(manager, container, deployment);
+ }
}
View
70 plugin/src/main/java/org/jboss/arquillian/maven/UndeployRemote.java
@@ -24,52 +24,52 @@
import org.jboss.shrinkwrap.api.Archive;
/**
- * UnDeploy to a remote container.
- * Start and stop the container before and after the undeploy.
+ * UnDeploy to a remote container. Start and stop the container before and after the undeploy.
*
* @goal undeployRemote
*
* @author Davide D'Alto
* @version $Revision: $
*
*/
-public final class UndeployRemote extends BaseCommand
-{
- private boolean managerStartedByMe = false;
+public final class UndeployRemote extends BaseCommand {
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#goal()
- */
- @Override
- public String goal()
- {
- return "undeployRemote";
- }
+ private boolean managerStartedByMe = false;
- Manager startNewManager(Class<?>... extensions)
- {
- managerStartedByMe = true;
- return super.startNewManager(extensions);
- };
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#goal()
+ */
+ @Override
+ public String goal() {
+ return "undeployRemote";
+ }
- /* (non-Javadoc)
- * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager, org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
- */
- @Override
- public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException
- {
- if (managerStartedByMe)
- Start.execute(manager, container);
+ Manager startNewManager(Class<?>... extensions) {
+ managerStartedByMe = true;
+ return super.startNewManager(extensions);
+ };
- undeploy(manager, container);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.arquillian.maven.BaseCommand#perform(org.jboss.arquillian.core.spi.Manager,
+ * org.jboss.arquillian.container.spi.Container, org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void perform(final Manager manager, final Container container) throws DeploymentException, LifecycleException {
+ if (managerStartedByMe)
+ Start.execute(manager, container);
- Stop.execute(manager, container);
- }
+ undeploy(manager, container);
- private void undeploy(Manager manager, Container container) throws DeploymentException
- {
- final Archive<?> deployment = createDeployment();
- getLog().info("Perform undeploy on " + container.getName() + " of deployment " + deployment.getName());
- Undeploy.execute( manager, container, deployment );
- }
+ Stop.execute(manager, container);
+ }
+
+ private void undeploy(Manager manager, Container container) throws DeploymentException {
+ final Archive<?> deployment = createDeployment();
+ getLog().info("Perform undeploy on " + container.getName() + " of deployment " + deployment.getName());
+ Undeploy.execute(manager, container, deployment);
+ }
}
View
104 plugin/src/main/java/org/jboss/arquillian/maven/Utils.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -43,69 +43,53 @@
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
*/
-final class Utils
-{
- private static Map<Archive<?>, Deployment> contextMap = new HashMap<Archive<?>, Deployment>();
-
- private Utils() { }
-
- public static void setup(Manager manager, Container container) throws LifecycleException
- {
- manager.fire(new SetupContainer(container));
- }
-
- public static void start(Manager manager, Container container) throws LifecycleException
- {
- manager.fire(new StartContainer(container));
- }
+final class Utils {
- public static void stop(Manager manager, Container container) throws LifecycleException
- {
- manager.fire(new StopContainer(container));
- }
+ private static Map<Archive<?>, Deployment> contextMap = new HashMap<Archive<?>, Deployment>();
- public static void deploy(Manager manager, Container container, Archive<?> deployment) throws DeploymentException
- {
- manager.fire(new DeployDeployment(
- container,
- getOrCreateDeployment(deployment)),
- new NonManagedObserver<DeployDeployment>()
- {
- @Inject
- private Instance<ProtocolMetaData> metadataInst;
+ private Utils() {
+ }
- @Override
- public void fired(DeployDeployment event)
- {
- ProtocolMetaData metadata = metadataInst.get();
- if(metadata != null)
- {
- System.out.println(metadata);
- }
- }
- });
- }
+ public static void setup(Manager manager, Container container) throws LifecycleException {
+ manager.fire(new SetupContainer(container));
+ }
- public static void undeploy(Manager manager, Container container, Archive<?> deployment) throws DeploymentException
- {
- manager.fire(new UnDeployDeployment(
- container,
- getOrCreateDeployment(deployment)));
- }
+ public static void start(Manager manager, Container container) throws LifecycleException {
+ manager.fire(new StartContainer(container));
+ }
- private static Deployment getOrCreateDeployment(Archive<?> archive)
- {
- if(contextMap.containsKey(archive))
- {
- return contextMap.remove(archive);
- }
- else
- {
- Deployment deployment = new Deployment(
- new DeploymentDescription("NO-NAME", archive));
- contextMap.put(archive, deployment);
+ public static void stop(Manager manager, Container container) throws LifecycleException {
+ manager.fire(new StopContainer(container));
+ }
- return deployment;
- }
- }
+ public static void deploy(Manager manager, Container container, Archive<?> deployment) throws DeploymentException {
+ manager.fire(new DeployDeployment(container, getOrCreateDeployment(deployment)),
+ new NonManagedObserver<DeployDeployment>() {
+ @Inject
+ private Instance<ProtocolMetaData> metadataInst;
+
+ @Override
+ public void fired(DeployDeployment event) {
+ ProtocolMetaData metadata = metadataInst.get();
+ if (metadata != null) {
+ System.out.println(metadata);
+ }
+ }
+ });
+ }
+
+ public static void undeploy(Manager manager, Container container, Archive<?> deployment) throws DeploymentException {
+ manager.fire(new UnDeployDeployment(container, getOrCreateDeployment(deployment)));
+ }
+
+ private static Deployment getOrCreateDeployment(Archive<?> archive) {
+ if (contextMap.containsKey(archive)) {
+ return contextMap.remove(archive);
+ } else {
+ Deployment deployment = new Deployment(new DeploymentDescription("NO-NAME", archive));
+ contextMap.put(archive, deployment);
+
+ return deployment;
+ }
+ }
}
View
58 plugin/src/test/java/org/jboss/arquillian/maven/BaseCommandTestBase.java
@@ -24,46 +24,40 @@
/**
* @author Davide D'Alto
*/
-abstract class BaseCommandTestBase extends AbstractMojoTestCase
-{
+abstract class BaseCommandTestBase extends AbstractMojoTestCase {
- private static final String ARQUILLIAN_XML_SYS_PROP = "arquillian.xml";
+ private static final String ARQUILLIAN_XML_SYS_PROP = "arquillian.xml";
- public void testArquillianXmlIsNullWhenNotSet() throws Exception
- {
- BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("empty-configuration-pom.xml"));
- assertNull(baseCommand.arquillianXml());
- }
+ public void testArquillianXmlIsNullWhenNotSet() throws Exception {
+ BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("empty-configuration-pom.xml"));
+ assertNull(baseCommand.arquillianXml());
+ }
- public void testArquillianXmlWhenIsSet() throws Exception
- {
- String savedValue = System.getProperty(ARQUILLIAN_XML_SYS_PROP);
+ public void testArquillianXmlWhenIsSet() throws Exception {
+ String savedValue = System.getProperty(ARQUILLIAN_XML_SYS_PROP);
- BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("arquillianXml4test-pom.xml"));
- assertNotNull(baseCommand.arquillianXml());
- assertEquals("Unexpected value for arquillian.xml system property",
- "arquillianXml4test.xml",
- System.getProperty(ARQUILLIAN_XML_SYS_PROP));
+ BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("arquillianXml4test-pom.xml"));
+ assertNotNull(baseCommand.arquillianXml());
+ assertEquals("Unexpected value for arquillian.xml system property", "arquillianXml4test.xml",
+ System.getProperty(ARQUILLIAN_XML_SYS_PROP));
- System.setProperty(ARQUILLIAN_XML_SYS_PROP, savedValue);
- }
+ System.setProperty(ARQUILLIAN_XML_SYS_PROP, savedValue);
+ }
- public void testArquillianXmlInitialization() throws Exception
- {
- BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("arquillianXml4test-pom.xml"));
- baseCommand.initArquillianXml();
+ public void testArquillianXmlInitialization() throws Exception {
+ BaseCommand baseCommand = (BaseCommand) lookupMojo(goal(), pomFile("arquillianXml4test-pom.xml"));
+ baseCommand.initArquillianXml();
- assertEquals("Unexpected value for arquillianXml property", "arquillianXml4test.xml", baseCommand.arquillianXml());
- }
+ assertEquals("Unexpected value for arquillianXml property", "arquillianXml4test.xml", baseCommand.arquillianXml());
+ }
- private File pomFile(String pomFileName)
- {
- File pom = getTestFile("src/test/resources/" + pomFileName);
- assertNotNull(pom);
- assertTrue(pom.exists());
- return pom;
- }
+ private File pomFile(String pomFileName) {
+ File pom = getTestFile("src/test/resources/" + pomFileName);
+ assertNotNull(pom);
+ assertTrue(pom.exists());
+ return pom;
+ }
- abstract String goal();
+ abstract String goal();
}
View
12 plugin/src/test/java/org/jboss/arquillian/maven/DeployTestCase.java
@@ -20,13 +20,11 @@
/**
* @author Davide D'Alto
*/
-public final class DeployTestCase extends BaseCommandTestBase
-{
+public final class DeployTestCase extends BaseCommandTestBase {
- @Override
- public String goal()
- {
- return "deploy";
- }
+ @Override
+ public String goal() {
+ return "deploy";
+ }
}
View
12 plugin/src/test/java/org/jboss/arquillian/maven/RunTestCase.java
@@ -20,13 +20,11 @@
/**
* @author Davide D'Alto
*/
-public final class RunTestCase extends BaseCommandTestBase
-{
+public final class RunTestCase extends BaseCommandTestBase {
- @Override
- public String goal()
- {
- return "run";
- }
+ @Override
+ public String goal() {
+ return "run";
+ }
}
View
12 plugin/src/test/java/org/jboss/arquillian/maven/StartTestCase.java
@@ -20,13 +20,11 @@
/**
* @author Davide D'Alto
*/
-public final class StartTestCase extends BaseCommandTestBase
-{
+public final class StartTestCase extends BaseCommandTestBase {
- @Override
- public String goal()
- {
- return "start";
- }
+ @Override
+ public String goal() {
+ return "start";
+ }
}
View
12 plugin/src/test/java/org/jboss/arquillian/maven/StopTestCase.java
@@ -20,13 +20,11 @@
/**
* @author Davide D'Alto
*/
-public final class StopTestCase extends BaseCommandTestBase
-{
+public final class StopTestCase extends BaseCommandTestBase {
- @Override
- public String goal()
- {
- return "stop";
- }
+ @Override
+ public String goal() {
+ return "stop";
+ }
}
View
12 plugin/src/test/java/org/jboss/arquillian/maven/UndeployTestCase.java
@@ -20,13 +20,11 @@
/**
* @author Davide D'Alto
*/
-public final class UndeployTestCase extends BaseCommandTestBase
-{
+public final class UndeployTestCase extends BaseCommandTestBase {
- @Override
- public String goal()
- {
- return "undeploy";
- }
+ @Override
+ public String goal() {
+ return "undeploy";
+ }
}
View
48 pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -75,20 +76,55 @@
</dependencyManagement>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <configLocation>checkstyle.xml</configLocation>
+ <logViolationsToConsole>true</logViolationsToConsole>
+ <failsOnError>true</failsOnError>
+ <violationSeverity>error</violationSeverity>
+ </configuration>
+ <executions>
+ <execution>
+ <id>check-style</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>checkstyle</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.maven</groupId>
+ <artifactId>arquillian-maven-build-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ <pushChanges>false</pushChanges>
+ <localCheckout>true</localCheckout>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
- <configuration>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <pushChanges>false</pushChanges>
- <localCheckout>true</localCheckout>
- </configuration>
</plugin>
</plugins>
</build>
<modules>
<module>plugin</module>
<module>test</module>
+ <module>build-config</module>
</modules>
</project>
View
7 test/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -133,6 +134,10 @@
<groupId>org.jboss.arquillian.maven</groupId>
<artifactId>arquillian-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
</plugins>
</build>
View
22 test/src/main/java/org/jboss/arquillian/maven/test/MySimpleServlet.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -32,15 +32,15 @@
* @version $Revision: $
*/
@WebServlet(name = "MySimpleServlet", urlPatterns = { "/*" })
-public class MySimpleServlet extends HttpServlet
-{
- public static final String WELCOME_MSG = "Welcome to the Arquillian Maven Plugin!";
-
- private static final long serialVersionUID = 1L;
+public class MySimpleServlet extends HttpServlet {
+
+ public static final String WELCOME_MSG = "Welcome to the Arquillian Maven Plugin!";
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.getWriter().write(WELCOME_MSG);
+ }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- resp.getWriter().write(WELCOME_MSG);
- }
}
View
27 test/src/test/java/org/jboss/arquillian/maven/test/MySimpleServletITCase.java
@@ -33,20 +33,17 @@
* @author Davide D'Alto
* @version $Revision: $
*/
-public class MySimpleServletITCase
-{
- @Test
- public void shouldBeAbleToCallServlet() throws Exception
- {
- String url = "http://127.0.0.1:" + servletPort() + "/arquillian-maven/hello";
- String result = read(new URL(url));
- Assert.assertEquals(MySimpleServlet.WELCOME_MSG, result);
- }
+public class MySimpleServletITCase {
+ @Test
+ public void shouldBeAbleToCallServlet() throws Exception {
+ String url = "http://127.0.0.1:" + servletPort() + "/arquillian-maven/hello";
+ String result = read(new URL(url));
+ Assert.assertEquals(MySimpleServlet.WELCOME_MSG, result);
+ }
- private String servletPort() throws IOException
- {
- Properties properties = new Properties();
- properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("test.properties"));
- return properties.getProperty("servlet.port");
- }
+ private String servletPort() throws IOException {
+ Properties properties = new Properties();
+ properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("test.properties"));
+ return properties.getProperty("servlet.port");
+ }
}
View
55 test/src/test/java/org/jboss/arquillian/maven/test/MySimpleServletTestCase.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -40,32 +40,29 @@
* @version $Revision: $
*/
@RunWith(Arquillian.class)
-public class MySimpleServletTestCase
-{
- @Deployment(testable = false)
- public static WebArchive createDeployment()
- {
- String servletName = MySimpleServlet.class.getSimpleName();
- return ShrinkWrap.create(WebArchive.class)
- .addClass(MySimpleServlet.class)
- .setWebXML(new StringAsset(
- Descriptors.create(WebAppDescriptor.class)
- .createServlet()
- .servletName(servletName)
- .servletClass(MySimpleServlet.class.getName())
- .up()
- .createServletMapping()
- .servletName(servletName)
- .urlPattern("/*")
- .up()
- .exportAsString()
- ));
- }
-
- @Test
- public void shouldBeAbleToCallServlet(@ArquillianResource(MySimpleServlet.class) URL baseURL) throws Exception
- {
- String result = read(new URL(baseURL + "Test"));
- Assert.assertEquals(MySimpleServlet.WELCOME_MSG, result);
- }
+public class MySimpleServletTestCase {
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ String servletName = MySimpleServlet.class.getSimpleName();
+ return ShrinkWrap.create(WebArchive.class)
+ .addClass(MySimpleServlet.class)
+ .setWebXML(new StringAsset(
+ Descriptors.create(WebAppDescriptor.class)
+ .createServlet()
+ .servletName(servletName)
+ .servletClass(MySimpleServlet.class.getName())
+ .up()
+ .createServletMapping()
+ .servletName(servletName)
+ .urlPattern("/*")
+ .up()
+ .exportAsString()
+ ));
+ }
+
+ @Test
+ public void shouldBeAbleToCallServlet(@ArquillianResource(MySimpleServlet.class) URL baseURL) throws Exception {
+ String result = read(new URL(baseURL + "Test"));
+ Assert.assertEquals(MySimpleServlet.WELCOME_MSG, result);
+ }
}
View
52 test/src/test/java/org/jboss/arquillian/maven/test/Utils.java
@@ -10,7 +10,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -27,30 +27,28 @@
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
*/
-public class Utils
-{
- private Utils() {}
-
- static String read(URL url) throws Exception
- {
- return read(url.openStream());
- }
-
- static String read(InputStream is) throws Exception
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try
- {
- int read;
- while( (read = is.read()) != -1)
- {
- out.write(read);
- }
- }
- finally
- {
- try { is.close(); } catch (Exception e) { }
- }
- return out.toString();
- }
+public class Utils {
+
+ private Utils() {
+ }
+
+ static String read(URL url) throws Exception {
+ return read(url.openStream());
+ }
+
+ static String read(InputStream is) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try {
+ int read;
+ while ((read = is.read()) != -1) {
+ out.write(read);
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (Exception e) {
+ }
+ }
+ return out.toString();
+ }
}
View
3 test/src/test/resources/jbossas7/arquillian.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://jboss.org/schema/arquillian"
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="jboss7" default="true">
View
15 test/src/test/resources/jetty7/arquillian.xml
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://jboss.org/schema/arquillian"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
- <container qualifier="jetty" default="true">
- <configuration>
- <property name="bindHttpPort">9595</property>
- </configuration>
- </container>
+ <container qualifier="jetty" default="true">
+ <configuration>
+ <property name="bindHttpPort">9595</property>
+ </configuration>
+ </container>
</arquillian>

0 comments on commit 5bc36b3

Please sign in to comment.
Something went wrong with that request. Please try again.