[jboss-svn-commits] JBoss Common SVN: r4771 - in arquillian/trunk/frameworks: cobertura and 25 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Jul 18 10:54:52 EDT 2010
Author: aslak
Date: 2010-07-18 10:54:51 -0400 (Sun, 18 Jul 2010)
New Revision: 4771
Added:
arquillian/trunk/frameworks/cobertura/
arquillian/trunk/frameworks/cobertura/pom.xml
arquillian/trunk/frameworks/cobertura/src/
arquillian/trunk/frameworks/cobertura/src/main/
arquillian/trunk/frameworks/cobertura/src/main/java/
arquillian/trunk/frameworks/cobertura/src/main/java/net/
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/TouchCollector.java
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenter.java
arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenterExposer.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ClientSuiteContextAppender.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaApplicationArchiveInstrumenter.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaAuxiliaryArchiveAppender.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaWrapperAsset.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ContainerClassContextAppender.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoverageReportGenerator.java
arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/WriteOutCoverageData.java
arquillian/trunk/frameworks/cobertura/src/main/resources/
arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/
arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/
arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ApplicationArchiveProcessor
arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.SuiteContextAppender
arquillian/trunk/frameworks/cobertura/src/test/
arquillian/trunk/frameworks/cobertura/src/test/java/
arquillian/trunk/frameworks/cobertura/src/test/java/org/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/CoberturaIntegrationTestCase.java
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/test/
arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/test/RepositoryManager.java
arquillian/trunk/frameworks/cobertura/src/test/resources/
arquillian/trunk/frameworks/cobertura/src/test/resources/jndi.properties
Log:
ARQ-163 Initial attempt at auto code coverage. Contains Cobertura patchs that should be pushed upstream, Instrument based on Field, not adding a interface and do not register a ShutdownHook to write out the file. This test hardcodes output location etc, needs Arquillian Client / Container communication framework to operate.
Added: arquillian/trunk/frameworks/cobertura/pom.xml
===================================================================
--- arquillian/trunk/frameworks/cobertura/pom.xml (rev 0)
+++ arquillian/trunk/frameworks/cobertura/pom.xml 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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 -->
+ <parent>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.arquillian.framework</groupId>
+ <artifactId>arquillian-framework-cobertura</artifactId>
+ <name>Arquillian Framework Cobertura</name>
+ <description>Cobertura code coverage integration for the Arquillian project</description>
+
+
+ <!-- Properties -->
+ <properties>
+
+ <version.cobertura>1.9.4.1</version.cobertura>
+ <version.jboss_6>6.0.0.20100429-M3</version.jboss_6>
+
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!--
+ org.jboss.arquillian
+ -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-spi</artifactId>
+ </dependency>
+
+ <!--
+ org.jboss.jsfunit
+ -->
+
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${version.cobertura}</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>log4j</artifactId>
+ <groupId>log4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!--
+ External Projects
+ -->
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${version.jboss_6}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0-SP1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Surefire -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Skip Tests in main build due to bug in JSFUnit -->
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
Added: arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/TouchCollector.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/TouchCollector.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/TouchCollector.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,222 @@
+/*
+ * Cobertura - http://cobertura.sourceforge.net/
+ *
+ * Copyright (C) 2010 Piotr Tabor
+ *
+ * Note: This file is dual licensed under the GPL and the Apache
+ * Source License (so that it can be used from both the main
+ * Cobertura classes and the ant tasks).
+ *
+ * Cobertura is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Cobertura 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cobertura; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+package net.sourceforge.cobertura.coveragedata;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import net.sourceforge.cobertura.coveragedata.countermaps.AtomicCounterMap;
+import net.sourceforge.cobertura.coveragedata.countermaps.CounterMap;
+
+public class TouchCollector implements HasBeenInstrumented{
+
+ private static final CounterMap<LineTouchData> touchedLines=new AtomicCounterMap<LineTouchData>();
+ private static final CounterMap<SwitchTouchData> switchTouchData=new AtomicCounterMap<SwitchTouchData>();
+ private static final CounterMap<JumpTouchData> jumpTouchData=new AtomicCounterMap<JumpTouchData>();
+
+ private static AtomicInteger lastClassId=new AtomicInteger(1);
+ private static final Map<String,Integer> class2classId=new ConcurrentHashMap<String, Integer>();
+ private static final Map<Integer,String> classId2class=new ConcurrentHashMap<Integer,String>();
+
+// We can handle dumping of data manually. No ShutDownHook required
+// static{
+// ProjectData.initialize();
+// }
+
+ private static final int registerClassData(String name){
+ Integer res=class2classId.get(name);
+ if (res==null){
+ int new_id=lastClassId.incrementAndGet();
+ class2classId.put(name, new_id);
+ classId2class.put(new_id, name);
+ return new_id;
+ }
+ return res;
+ }
+
+ /**
+ * This method is only called by code that has been instrumented. It
+ * is not called by any of the Cobertura code or ant tasks.
+ */
+ public static final void touchSwitch(String classId,int lineNumber, int switchNumber, int branch) {
+ switchTouchData.incrementValue(new SwitchTouchData(registerClassData(classId),lineNumber, switchNumber, branch));
+ }
+
+ /**
+ * This method is only called by code that has been instrumented. It
+ * is not called by any of the Cobertura code or ant tasks.
+ */
+ public static final void touch(String classId,int lineNumber) {
+ touchedLines.incrementValue(new LineTouchData(registerClassData(classId), lineNumber));
+ }
+
+ /**
+ * This method is only called by code that has been instrumented. It
+ * is not called by any of the Cobertura code or ant tasks.
+ */
+ public static final void touchJump(String classId,int lineNumber, int branchNumber, boolean branch) {
+ jumpTouchData.incrementValue(new JumpTouchData(registerClassData(classId),lineNumber, branchNumber, branch));
+ }
+
+ private static class LineTouchData implements HasBeenInstrumented{
+ int classId,lineNumber;
+ public LineTouchData(int classId,int lineNumber) {
+ this.classId=classId;
+ this.lineNumber=lineNumber;
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + classId;
+ result = prime * result + lineNumber;
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LineTouchData other = (LineTouchData) obj;
+ if (classId != other.classId)
+ return false;
+ if (lineNumber != other.lineNumber)
+ return false;
+ return true;
+ }
+ }
+
+ private static class SwitchTouchData extends LineTouchData implements HasBeenInstrumented{
+ int switchNumber, branch;
+
+ public SwitchTouchData(int classId,int lineNumber, int switchNumber, int branch) {
+ super(classId,lineNumber);
+ this.switchNumber=switchNumber;
+ this.branch=branch;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + branch;
+ result = prime * result + switchNumber;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SwitchTouchData other = (SwitchTouchData) obj;
+ if (branch != other.branch)
+ return false;
+ if (switchNumber != other.switchNumber)
+ return false;
+ return true;
+ }
+ }
+
+ private static class JumpTouchData extends LineTouchData implements HasBeenInstrumented{
+ int branchNumber;
+ boolean branch;
+ public JumpTouchData(int classId,int lineNumber, int branchNumber, boolean branch) {
+ super(classId, lineNumber);
+ this.branchNumber=branchNumber;
+ this.branch=branch;
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + (branch ? 1231 : 1237);
+ result = prime * result + branchNumber;
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ JumpTouchData other = (JumpTouchData) obj;
+ if (branch != other.branch)
+ return false;
+ if (branchNumber != other.branchNumber)
+ return false;
+ return true;
+ }
+ }
+
+
+ public static synchronized void applyTouchesOnProjectData(ProjectData projectData){
+ //System.out.println("Flushing results...");
+ Map<LineTouchData,Integer> touches=touchedLines.getFinalStateAndCleanIt();
+ for(Entry<LineTouchData, Integer> touch:touches.entrySet()){
+ if(touch.getValue()>0){
+ getClassFor(touch.getKey(),projectData).touch(touch.getKey().lineNumber,touch.getValue());
+ }
+ }
+
+ Map<SwitchTouchData,Integer> switchTouches=switchTouchData.getFinalStateAndCleanIt();
+ for(Entry<SwitchTouchData, Integer> touch:switchTouches.entrySet()){
+ if(touch.getValue()>0){
+ getClassFor(touch.getKey(),projectData).touchSwitch(
+ touch.getKey().lineNumber,
+ touch.getKey().switchNumber,
+ touch.getKey().branch,touch.getValue());
+ }
+ }
+
+ Map<JumpTouchData,Integer> jumpTouches=jumpTouchData.getFinalStateAndCleanIt();
+ for(Entry<JumpTouchData, Integer> touch:jumpTouches.entrySet()){
+ if(touch.getValue()>0){
+ getClassFor(touch.getKey(),projectData).touchJump(
+ touch.getKey().lineNumber,
+ touch.getKey().branchNumber,
+ touch.getKey().branch,touch.getValue());
+ }
+ }
+ //System.out.println("Flushing results done");
+ }
+
+ private static ClassData getClassFor(LineTouchData key,ProjectData projectData) {
+// System.out.println("\nLooking for:"+key.classId+"\n");
+ return projectData.getOrCreateClassData(classId2class.get(key.classId));
+ }
+
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenter.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenter.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenter.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,170 @@
+/*
+ * Cobertura - http://cobertura.sourceforge.net/
+ *
+ * Copyright (C) 2005 Mark Doliner
+ * Copyright (C) 2006 Jiri Mares
+ *
+ * Cobertura is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Cobertura 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cobertura; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+package net.sourceforge.cobertura.instrument;
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import net.sourceforge.cobertura.coveragedata.ClassData;
+import net.sourceforge.cobertura.coveragedata.ProjectData;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+public class ClassInstrumenter extends ClassAdapter
+{
+
+ private static final Logger logger = Logger.getLogger(ClassInstrumenter.class.getName());
+
+ private final static String hasBeenInstrumented = "net/sourceforge/cobertura/coveragedata/HasBeenInstrumented";
+
+ private final static String HAS_BEEN_INSTRUMENTED_FIELD_NAME = "___COBERTURA_INSTRUMENTED";
+
+ private Collection ignoreRegexs;
+
+ private Collection ignoreBranchesRegexs;
+
+ private ProjectData projectData;
+
+ private ClassData classData;
+
+ private String myName;
+
+ private boolean instrument = false;
+
+ public String getClassName()
+ {
+ return this.myName;
+ }
+
+ public boolean isInstrumented()
+ {
+ return instrument;
+ }
+
+ public ClassInstrumenter(ProjectData projectData, final ClassVisitor cv, final Collection ignoreRegexs,
+ final Collection ignoreBranchesRegexes)
+ {
+ super(cv);
+ this.projectData = projectData;
+ this.ignoreRegexs = ignoreRegexs;
+ this.ignoreBranchesRegexs = ignoreBranchesRegexes;
+ }
+
+ private boolean arrayContains(Object[] array, Object key)
+ {
+ for (int i = 0; i < array.length; i++)
+ {
+ if (array[i].equals(key))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param name In the format
+ * "net/sourceforge/cobertura/coverage/ClassInstrumenter"
+ */
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
+ {
+ this.myName = name.replace('/', '.');
+ this.classData = this.projectData.getOrCreateClassData(this.myName);
+ this.classData.setContainsInstrumentationInfo();
+
+ // Do not attempt to instrument interfaces or classes that
+ // have already been instrumented
+
+
+
+ if (((access & Opcodes.ACC_INTERFACE) != 0) || arrayContains(interfaces, hasBeenInstrumented))
+ {
+ super.visit(version, access, name, signature, superName, interfaces);
+ }
+ else
+ {
+ instrument = true;
+
+// // Flag this class as having been instrumented
+// String[] newInterfaces = new String[interfaces.length + 1];
+// System.arraycopy(interfaces, 0, newInterfaces, 0, interfaces.length);
+// newInterfaces[newInterfaces.length - 1] = hasBeenInstrumented;
+
+ super.visit(version, access, name, signature, superName, interfaces);
+ }
+ }
+
+ /**
+ * @param source In the format "ClassInstrumenter.java"
+ */
+ public void visitSource(String source, String debug)
+ {
+ super.visitSource(source, debug);
+ classData.setSourceFileName(source);
+ }
+
+ @Override
+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
+ {
+ if(HAS_BEEN_INSTRUMENTED_FIELD_NAME.equals(name))
+ {
+ instrument = false;
+ }
+ return super.visitField(access, name, desc, signature, value);
+ }
+
+ public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
+ final String[] exceptions)
+ {
+ MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
+
+ if (!instrument)
+ return mv;
+
+ return mv == null ? null : new FirstPassMethodInstrumenter(classData, mv, this.myName, access, name, desc,
+ signature, exceptions, ignoreRegexs, ignoreBranchesRegexs);
+ }
+
+ public void visitEnd()
+ {
+ if(instrument)
+ {
+ FieldVisitor visitor = super.visitField(
+ Opcodes.ACC_PRIVATE & Opcodes.ACC_STATIC & Opcodes.ACC_FINAL,
+ HAS_BEEN_INSTRUMENTED_FIELD_NAME,
+ Type.BOOLEAN_TYPE.toString(),
+ null,
+ true);
+ visitor.visitEnd();
+ }
+
+ if (instrument && classData.getNumberOfValidLines() == 0)
+ logger.warning("No line number information found for class " + this.myName
+ + ". Perhaps you need to compile with debug=true?");
+ }
+
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenterExposer.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenterExposer.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/net/sourceforge/cobertura/instrument/ClassInstrumenterExposer.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package net.sourceforge.cobertura.instrument;
+
+import java.util.Collection;
+import java.util.regex.Pattern;
+
+import net.sourceforge.cobertura.coveragedata.ProjectData;
+
+import org.objectweb.asm.ClassVisitor;
+
+/**
+ * Hack to expose package private ClassInstrumenter from Cobertura package.
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ClassInstrumenterExposer
+{
+ public static ClassInstrumenter getInstrumenter(ProjectData projectData, final ClassVisitor cv,
+ final Collection<Pattern> ignoreRegexs, final Collection<Pattern> ignoreBranchesRegexes)
+ {
+ return new ClassInstrumenter(projectData, cv, ignoreRegexs, ignoreBranchesRegexes);
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ClientSuiteContextAppender.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ClientSuiteContextAppender.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ClientSuiteContextAppender.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.SuiteContextAppender;
+import org.jboss.arquillian.spi.event.suite.AfterSuite;
+
+/**
+ * ClientSuiteContextAppender
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ClientSuiteContextAppender implements SuiteContextAppender
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.SuiteContextAppender#append(org.jboss.arquillian.spi.Context)
+ */
+ public void append(Context context)
+ {
+ context.register(AfterSuite.class, new CoverageReportGenerator());
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaApplicationArchiveInstrumenter.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaApplicationArchiveInstrumenter.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaApplicationArchiveInstrumenter.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.arquillian.spi.ApplicationArchiveProcessor;
+import org.jboss.arquillian.spi.TestClass;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.Filters;
+import org.jboss.shrinkwrap.api.Node;
+
+/**
+ * CoberturaApplicationArchiveInstrumenter
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class CoberturaApplicationArchiveInstrumenter implements ApplicationArchiveProcessor
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.ApplicationArchiveProcessor#process(org.jboss.shrinkwrap.api.Archive, org.jboss.arquillian.spi.TestClass)
+ */
+ public void process(Archive<?> applicationArchive, TestClass testClass)
+ {
+
+ Map<ArchivePath, Node> classes = applicationArchive.getContent(Filters.include(".*\\.class"));
+ for(Entry<ArchivePath, Node> entry : classes.entrySet())
+ {
+ applicationArchive.add(
+ new CoberturaWrapperAsset(
+ entry.getValue().getAsset()),
+ entry.getKey());
+ }
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaAuxiliaryArchiveAppender.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaAuxiliaryArchiveAppender.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaAuxiliaryArchiveAppender.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import net.sourceforge.cobertura.coveragedata.TouchCollector;
+import net.sourceforge.cobertura.instrument.ClassInstrumenter;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.ClassContextAppender;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * CoperturaAuxiliaryArchiveAppender
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class CoberturaAuxiliaryArchiveAppender implements AuxiliaryArchiveAppender
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.AuxiliaryArchiveAppender#createAuxiliaryArchive()
+ */
+ public Archive<?> createAuxiliaryArchive()
+ {
+ return ShrinkWrap.create(JavaArchive.class, "arquillian-cobertura.jar")
+ .addPackages(
+ true,
+ net.sourceforge.cobertura.instrument.Main.class.getPackage(),
+ net.sourceforge.cobertura.coveragedata.CoverageData.class.getPackage(),
+ net.sourceforge.cobertura.reporting.Main.class.getPackage(),
+ net.sourceforge.cobertura.util.StringUtil.class.getPackage(),
+ net.sourceforge.cobertura.util.StringUtil.class.getPackage(),
+ org.objectweb.asm.ClassWriter.class.getPackage())
+ .addServiceProvider(ClassContextAppender.class, ContainerClassContextAppender.class)
+ .addClasses(
+ ContainerClassContextAppender.class,
+ WriteOutCoverageData.class,
+ TouchCollector.class,
+ ClassInstrumenter.class);
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaWrapperAsset.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaWrapperAsset.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoberturaWrapperAsset.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import net.sourceforge.cobertura.coveragedata.ProjectData;
+import net.sourceforge.cobertura.instrument.ClassInstrumenter;
+
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.impl.base.Validate;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+
+/**
+ * CoberturaAsset
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class CoberturaWrapperAsset implements Asset
+{
+ public static final List<ProjectData> PROJECT_DATA = new ArrayList<ProjectData>();
+
+ private Asset asset;
+
+ public CoberturaWrapperAsset(Asset asset)
+ {
+ Validate.notNull(asset, "Asset must be specified");
+ this.asset = asset;
+ }
+
+ public InputStream openStream()
+ {
+ ProjectData projectData = new ProjectData();
+ PROJECT_DATA.add(projectData);
+ try
+ {
+ InputStream inputStream = asset.openStream();
+ ClassReader cr = new ClassReader(inputStream);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ cr.accept(
+ new ClassInstrumenter(projectData, cw, new ArrayList<Pattern>(), new ArrayList<Pattern>()),
+ 0);
+
+ return new ByteArrayInputStream(cw.toByteArray());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not instrument Asset " + asset, e);
+ }
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ContainerClassContextAppender.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ContainerClassContextAppender.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/ContainerClassContextAppender.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import org.jboss.arquillian.spi.ClassContextAppender;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.event.suite.AfterClass;
+
+/**
+ * CoberturaClassContextAppender
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ContainerClassContextAppender implements ClassContextAppender
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.ClassContextAppender#append(org.jboss.arquillian.spi.Context)
+ */
+ public void append(Context context)
+ {
+ context.register(AfterClass.class, new WriteOutCoverageData());
+ }
+
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoverageReportGenerator.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoverageReportGenerator.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/CoverageReportGenerator.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import java.io.File;
+
+import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler;
+import net.sourceforge.cobertura.coveragedata.ProjectData;
+import net.sourceforge.cobertura.coveragedata.TouchCollector;
+import net.sourceforge.cobertura.reporting.ComplexityCalculator;
+import net.sourceforge.cobertura.reporting.html.HTMLReport;
+import net.sourceforge.cobertura.util.FileFinder;
+
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.event.Event;
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+
+/**
+ * CoverageReportGenerator
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class CoverageReportGenerator implements EventHandler<Event>
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.event.suite.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
+ */
+ public void callback(Context context, Event event) throws Exception
+ {
+ // TODO: Need communication between Client and Server, https://jira.jboss.org/browse/ARQ-216
+ ProjectData projectData = mergeCoverageFiles(new File(
+ "/home/aslak/dev/source/testing/arquillian/frameworks/cobertura/target/report/"));
+
+ synchronized (CoberturaWrapperAsset.PROJECT_DATA)
+ {
+ for(ProjectData assetData : CoberturaWrapperAsset.PROJECT_DATA)
+ {
+ projectData.merge(assetData);
+ }
+ CoberturaWrapperAsset.PROJECT_DATA.clear();
+ }
+ TouchCollector.applyTouchesOnProjectData(projectData);
+
+ FileFinder finder = new FileFinder();
+ // TODO: Need to be able to load configuration data, https://jira.jboss.org/browse/ARQ-215
+ finder.addSourceDirectory("src/main/java");
+ finder.addSourceDirectory("src/test/java");
+
+ ComplexityCalculator complexity = new ComplexityCalculator(finder);
+
+ // TODO: Need to be able to load configuration data, https://jira.jboss.org/browse/ARQ-215
+ new HTMLReport(projectData, new File("target/coverage-report-html"), finder, complexity, "UTF-8");
+ }
+
+ private ProjectData mergeCoverageFiles(File outputDirectory)
+ {
+ ProjectData data = new ProjectData();
+ File[] coverageFiles = outputDirectory.listFiles();
+ for(File coverageFile : coverageFiles)
+ {
+ coverageFile.deleteOnExit();
+ ProjectData snippet = CoverageDataFileHandler.loadCoverageData(coverageFile);
+ data.merge(snippet);
+ }
+ return data;
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/WriteOutCoverageData.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/WriteOutCoverageData.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/java/org/jboss/arquillian/framework/cobertura/WriteOutCoverageData.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+import java.util.UUID;
+
+import net.sourceforge.cobertura.coveragedata.ProjectData;
+import net.sourceforge.cobertura.coveragedata.TouchCollector;
+
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.event.suite.ClassEvent;
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+
+/**
+ * DumpCoverageData
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class WriteOutCoverageData implements EventHandler<ClassEvent>
+{
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.event.suite.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
+ */
+ public void callback(Context context, ClassEvent event) throws Exception
+ {
+ ProjectData projectData = new ProjectData();
+ TouchCollector.applyTouchesOnProjectData(projectData);
+
+ // TODO: https://jira.jboss.org/browse/ARQ-216
+ //context.get(ClientCommunicator.class).send(CoberturaClient.class, projectData);
+
+ write(projectData);
+ }
+
+ private void write(ProjectData projectData)
+ {
+ ObjectOutputStream stream = null;
+ try
+ {
+ // TODO: create a communication service for messaging between Container and client, https://jira.jboss.org/browse/ARQ-216
+ stream = new ObjectOutputStream(
+ new FileOutputStream(
+ "/home/aslak/dev/source/testing/arquillian/frameworks/cobertura/target/report/" +
+ UUID.randomUUID().toString()));
+ stream.writeObject(projectData);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not write out coverage data", e);
+ }
+ finally
+ {
+ if(stream != null)
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not close coverage stream", e);
+ }
+ }
+ }
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ApplicationArchiveProcessor
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ApplicationArchiveProcessor (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ApplicationArchiveProcessor 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1 @@
+org.jboss.arquillian.framework.cobertura.CoberturaApplicationArchiveInstrumenter
\ No newline at end of file
Added: arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1 @@
+org.jboss.arquillian.framework.cobertura.CoberturaAuxiliaryArchiveAppender
\ No newline at end of file
Added: arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.SuiteContextAppender
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.SuiteContextAppender (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/main/resources/META-INF/services/org.jboss.arquillian.spi.SuiteContextAppender 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1 @@
+org.jboss.arquillian.framework.cobertura.ClientSuiteContextAppender
\ No newline at end of file
Added: arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/CoberturaIntegrationTestCase.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/CoberturaIntegrationTestCase.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/CoberturaIntegrationTestCase.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura;
+
+import javax.ejb.EJB;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.framework.cobertura.test.RepositoryManager;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * CoperturaIntegrationTestCase
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class CoberturaIntegrationTestCase
+{
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ return ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClass(RepositoryManager.class);
+ }
+
+ @EJB
+ private RepositoryManager manager;
+
+ @Test
+ public void shouldBeAbleToAdd() throws Exception
+ {
+ Assert.assertNotNull(manager);
+
+ manager.add();
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/test/RepositoryManager.java
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/test/RepositoryManager.java (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/test/java/org/jboss/arquillian/framework/cobertura/test/RepositoryManager.java 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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,
+ * 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.
+ */
+package org.jboss.arquillian.framework.cobertura.test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import javax.ejb.Stateless;
+
+/**
+ * RepositoyManager
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Stateless
+public class RepositoryManager
+{
+ /**
+ * Some random code lines just to make something to coverage.
+ */
+ public void add()
+ {
+ if(true)
+ {
+ String test = "test";
+ if(test.equals("ba"))
+ {
+ test = "ba";
+
+ }
+ if(System.currentTimeMillis() > 0)
+ {
+ test = "da da";
+ }
+ }
+ for(int i = 0; i < 10; i++)
+ {
+ System.currentTimeMillis();
+ }
+
+ try
+ {
+ Field[] fields = this.getClass().getDeclaredFields();
+ for(Field field: fields)
+ {
+ System.out.println("Field: " + field.getName() + " " + field.getType() + " " + Modifier.toString(field.getModifiers()));
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: arquillian/trunk/frameworks/cobertura/src/test/resources/jndi.properties
===================================================================
--- arquillian/trunk/frameworks/cobertura/src/test/resources/jndi.properties (rev 0)
+++ arquillian/trunk/frameworks/cobertura/src/test/resources/jndi.properties 2010-07-18 14:54:51 UTC (rev 4771)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming\:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
\ No newline at end of file
More information about the jboss-svn-commits
mailing list