[jboss-cvs] JBossAS SVN: r87564 - in projects/assistme/trunk: assistme and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 20 05:53:51 EDT 2009
Author: wolfc
Date: 2009-04-20 05:53:51 -0400 (Mon, 20 Apr 2009)
New Revision: 87564
Added:
projects/assistme/trunk/assistme/
projects/assistme/trunk/assistme/.classpath
projects/assistme/trunk/assistme/.project
projects/assistme/trunk/assistme/.settings/
projects/assistme/trunk/assistme/.settings/org.eclipse.jdt.core.prefs
projects/assistme/trunk/assistme/.settings/org.maven.ide.eclipse.prefs
projects/assistme/trunk/assistme/pom.xml
projects/assistme/trunk/assistme/src/
projects/assistme/trunk/assistme/src/main/
projects/assistme/trunk/assistme/src/main/java/
projects/assistme/trunk/assistme/src/main/java/org/
projects/assistme/trunk/assistme/src/main/java/org/jboss/
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/Main.java
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/HostnameCheck.java
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/MulticastCheck.java
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/IgnoreIf.java
projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/TextListener.java
projects/assistme/trunk/assistme/src/test/
projects/assistme/trunk/assistme/src/test/java/
Log:
JBAS-6806: initial commit on assistme
Property changes on: projects/assistme/trunk/assistme
___________________________________________________________________
Name: svn:ignore
+ eclipse-target
target
Added: projects/assistme/trunk/assistme/.classpath
===================================================================
--- projects/assistme/trunk/assistme/.classpath (rev 0)
+++ projects/assistme/trunk/assistme/.classpath 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry including="**/*.java" kind="src" output="eclipse-target/tests-classes" path="src/test/java"/>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+</classpath>
Added: projects/assistme/trunk/assistme/.project
===================================================================
--- projects/assistme/trunk/assistme/.project (rev 0)
+++ projects/assistme/trunk/assistme/.project 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,17 @@
+<projectDescription>
+ <name>jboss-assistme</name>
+ <comment>JBoss Assist Me helps diagnosing network configuration problems.</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/assistme/trunk/assistme/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/assistme/trunk/assistme/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/assistme/trunk/assistme/.settings/org.eclipse.jdt.core.prefs 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,5 @@
+#Wed Apr 15 12:34:02 CEST 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/assistme/trunk/assistme/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/assistme/trunk/assistme/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/assistme/trunk/assistme/.settings/org.maven.ide.eclipse.prefs 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,8 @@
+#Wed Apr 15 12:44:37 CEST 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=false
+resourceFilterGoals=process-resources resources\:testResources
+version=1
Added: projects/assistme/trunk/assistme/pom.xml
===================================================================
--- projects/assistme/trunk/assistme/pom.xml (rev 0)
+++ projects/assistme/trunk/assistme/pom.xml 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,110 @@
+<!--
+ vi:ts=2:sw=2:expandtab
+-->
+<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/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.assistme</groupId>
+ <artifactId>jboss-assistme</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JBoss Assist Me</name>
+ <url>http://labs.jboss.com/jbossejb3</url>
+ <description>
+ JBoss Assist Me helps diagnosing network configuration problems.
+ </description>
+
+ <!-- EJB3 Developers -->
+ <developers>
+ <developer>
+ <name>Carlo de Wolf</name>
+ <email>carlo.dewolf at jboss.com</email>
+ <organization>JBoss, a division of Red Hat, Inc.</organization>
+ <organizationUrl>http://www.jboss.com</organizationUrl>
+ <roles>
+ <role>Project Lead</role>
+ </roles>
+ <timezone>+1</timezone>
+ </developer>
+ </developers>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/assistme/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/assistme/trunk</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/jbossas/projects/assistme/trunk</url>
+ </scm>
+
+ <!-- TODO: configure
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.jboss.com/jira/browse/TODO</url>
+ </issueManagement>
+ -->
+
+ <build>
+ <outputDirectory>${outputDirectory}</outputDirectory>
+ <testOutputDirectory>${testOutputDirectory}</testOutputDirectory>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ <property>
+ <name>activate-default</name>
+ </property>
+ </activation>
+ <properties>
+ <outputDirectory>target/classes</outputDirectory>
+ <testOutputDirectory>target/tests-classes</testOutputDirectory>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>process-test-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>eclipse</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <buildOutputDirectory>${outputDirectory}</buildOutputDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <outputDirectory>eclipse-target/classes</outputDirectory>
+ <testOutputDirectory>eclipse-target/tests-classes</testOutputDirectory>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Added: projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/Main.java
===================================================================
--- projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/Main.java (rev 0)
+++ projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/Main.java 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.assistme;
+
+import org.jboss.assistme.ipv4.HostnameCheck;
+import org.jboss.assistme.ipv4.MulticastCheck;
+import org.jboss.assistme.junit.TextListener;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.notification.Failure;
+
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Main
+{
+ private static class TerseTextListener extends TextListener
+ {
+ @Override
+ protected void printFailure(Failure failure, int count)
+ {
+ getWriter().println(count + ") " + failure.getTestHeader() + ": " + failure.getException().getLocalizedMessage());
+ }
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ JUnitCore junit = new JUnitCore();
+ // Don't use experimental PrintableResult, this is non-buffered
+ if(args.length > 0 && args[0].equals("-v"))
+ junit.addListener(new TextListener());
+ else
+ junit.addListener(new TerseTextListener());
+
+ // TODO: not hardcoded
+ Class<?> classes[] = { HostnameCheck.class, MulticastCheck.class };
+ junit.run(classes);
+ }
+}
Added: projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/HostnameCheck.java
===================================================================
--- projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/HostnameCheck.java (rev 0)
+++ projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/HostnameCheck.java 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.assistme.ipv4;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.InetAddress;
+
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class HostnameCheck
+{
+ @Test
+ public void check() throws Exception
+ {
+ // TODO: on windows it's COMPUTERNAME
+ String host = System.getenv("HOSTNAME");
+ assertNotNull("Environment variable HOSTNAME is not set", host);
+
+ InetAddress address = InetAddress.getByName(host);
+ String hostAddress = address.getHostAddress();
+ assertFalse("host " + host + " must not resolve to 127.0.0.1", hostAddress.equals("127.0.0.1"));
+ }
+}
Added: projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/MulticastCheck.java
===================================================================
--- projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/MulticastCheck.java (rev 0)
+++ projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/ipv4/MulticastCheck.java 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.assistme.ipv4;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.SocketAddress;
+import java.util.Date;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MulticastCheck
+{
+ @Test
+ public void checkIpForward() throws IOException
+ {
+ assumeTrue(isLinux());
+
+ BufferedReader reader = new BufferedReader(new FileReader("/proc/sys/net/ipv4/ip_forward"));
+ String s = reader.readLine();
+ assertEquals("Linux Adv-Routing-HOWTO: Chapter 8. Multicast routing: /proc/sys/net/ipv4/ip_forward must be set to 1", "1", s);
+ }
+
+ /*
+ * HostnameCheck should be passing.
+ */
+ @Test
+ public void checkMulticast() throws Exception
+ {
+ InetAddress mcastaddr = Inet4Address.getByName("224.1.1.1");
+
+ //final MulticastSocket socket = socket(new InetSocketAddress(Inet4Address.getByName("localhost"), 5454), mcastaddr);
+ final MulticastSocket socket = socket(5454, mcastaddr);
+ //final MulticastSocket socket2 = socket(new InetSocketAddress(Inet4Address.getByName("192.168.1.18"), 5454), mcastaddr);
+
+ Callable<DatagramPacket> callable = new Callable<DatagramPacket>() {
+ public DatagramPacket call() throws Exception
+ {
+ byte buf[] = new byte[4096];
+ DatagramPacket p = new DatagramPacket(buf, buf.length);
+ socket.receive(p);
+ return p;
+ }
+ };
+ FutureTask<DatagramPacket> task = new FutureTask<DatagramPacket>(callable);
+ Thread thread = new Thread(task);
+ thread.start();
+
+ String s = "Hello world " + new Date();
+ byte buf[] = s.getBytes();
+ DatagramPacket p = new DatagramPacket(buf, buf.length);
+ p.setAddress(mcastaddr);
+ p.setPort(5454);
+ socket.send(p);
+
+ try
+ {
+ p = task.get();
+ }
+ catch(ExecutionException e)
+ {
+ throw exception(e);
+ }
+
+ String actual = new String(p.getData(), 0, p.getLength());
+ assertEquals(s, actual);
+ }
+
+ @Test
+ @Ignore
+ public void checkMulticastRemote()
+ {
+ // FIXME: implement
+ }
+
+ @Test
+ @Ignore
+ public void checkRoute()
+ {
+ // FIXME: how to easily check for a route
+ // Linux Adv-Routing-HOWTO: Chapter 8. Multicast routing: route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
+ // or dev eth0
+ }
+
+ private static Exception exception(Throwable t)
+ {
+ if(t instanceof Error)
+ throw (Error) t;
+ if(t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ return (Exception) t;
+ }
+
+ private static boolean isLinux()
+ {
+ // TODO: well, maybe...
+ return true;
+ }
+
+ private static MulticastSocket socket(int port, InetAddress mcastaddr) throws IOException
+ {
+ MulticastSocket socket = new MulticastSocket(port);
+ assertTrue(socket.isBound());
+ socket.setSoTimeout(5000);
+ socket.joinGroup(mcastaddr);
+ return socket;
+ }
+
+ private static MulticastSocket socket(SocketAddress bindaddr, InetAddress mcastaddr) throws IOException
+ {
+ MulticastSocket socket = new MulticastSocket(bindaddr);
+ assertTrue(socket.isBound());
+ socket.setSoTimeout(5000);
+ socket.joinGroup(mcastaddr);
+ return socket;
+ }
+}
Added: projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/IgnoreIf.java
===================================================================
--- projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/IgnoreIf.java (rev 0)
+++ projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/IgnoreIf.java 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.assistme.junit;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Retention(RUNTIME)
+ at Target({METHOD, TYPE})
+public @interface IgnoreIf {
+ boolean value();
+}
Added: projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/TextListener.java
===================================================================
--- projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/TextListener.java (rev 0)
+++ projects/assistme/trunk/assistme/src/main/java/org/jboss/assistme/junit/TextListener.java 2009-04-20 09:53:51 UTC (rev 87564)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.assistme.junit;
+
+/**
+ * A copy of org.junit.internal.TextListener.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+import java.io.PrintStream;
+import java.text.NumberFormat;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+public class TextListener extends RunListener {
+
+ private final PrintStream fWriter;
+
+ public TextListener() {
+ this(System.out);
+ }
+
+ public TextListener(PrintStream writer) {
+ this.fWriter= writer;
+ }
+
+ @Override
+ public void testRunFinished(Result result) {
+ printHeader(result.getRunTime());
+ printFailures(result);
+ printFooter(result);
+ }
+
+ @Override
+ public void testStarted(Description description) {
+ fWriter.append('.');
+ }
+
+ @Override
+ public void testFailure(Failure failure) {
+ fWriter.append('E');
+ }
+
+ @Override
+ public void testIgnored(Description description) {
+ fWriter.append('I');
+ }
+
+ /*
+ * Internal methods
+ */
+
+ protected PrintStream getWriter() {
+ return fWriter;
+ }
+
+ protected void printHeader(long runTime) {
+ getWriter().println();
+ getWriter().println("Time: " + elapsedTimeAsString(runTime));
+ }
+
+ protected void printFailures(Result result) {
+ if (result.getFailureCount() == 0)
+ return;
+ if (result.getFailureCount() == 1)
+ getWriter().println("There was " + result.getFailureCount() + " failure:");
+ else
+ getWriter().println("There were " + result.getFailureCount() + " failures:");
+ int i= 1;
+ for (Failure each : result.getFailures())
+ printFailure(each, i++);
+ }
+
+ protected void printFailure(Failure failure, int count) {
+ printFailureHeader(failure, count);
+ printFailureTrace(failure);
+ }
+
+ protected void printFailureHeader(Failure failure, int count) {
+ getWriter().println(count + ") " + failure.getTestHeader());
+ }
+
+ protected void printFailureTrace(Failure failure) {
+ getWriter().print(failure.getTrace());
+ }
+
+ protected void printFooter(Result result) {
+ if (result.wasSuccessful()) {
+ getWriter().println();
+ getWriter().print("OK");
+ getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")");
+
+ } else {
+ getWriter().println();
+ getWriter().println("FAILURES!!!");
+ getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount());
+ }
+ getWriter().println();
+ }
+
+ /**
+ * Returns the formatted string of the elapsed time. Duplicated from
+ * BaseTestRunner. Fix it.
+ */
+ protected String elapsedTimeAsString(long runTime) {
+ return NumberFormat.getInstance().format((double) runTime / 1000);
+ }
+}
More information about the jboss-cvs-commits
mailing list