aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.agent.test/src
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2009-09-08 16:13:05 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2009-09-08 16:13:05 +0000
commit69a8f472c5c66ffafc170d4b0981f475da0b44a6 (patch)
treea46785a6a7dd5f9e1eec94f6a023e1e5312879ae /org.jacoco.agent.test/src
parent1a5d9c44d8edaf43d45ee2f168d5df795c192ba6 (diff)
downloadjacoco-69a8f472c5c66ffafc170d4b0981f475da0b44a6.tar.gz
Tests for filtering.
Diffstat (limited to 'org.jacoco.agent.test/src')
-rw-r--r--org.jacoco.agent.test/src/org/jacoco/agent/CoverageTransformerTest.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/org.jacoco.agent.test/src/org/jacoco/agent/CoverageTransformerTest.java b/org.jacoco.agent.test/src/org/jacoco/agent/CoverageTransformerTest.java
new file mode 100644
index 00000000..e3ac6c90
--- /dev/null
+++ b/org.jacoco.agent.test/src/org/jacoco/agent/CoverageTransformerTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ * $Id: $
+ *******************************************************************************/
+package org.jacoco.agent;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.jacoco.core.runtime.AbstractRuntime;
+import org.jacoco.core.runtime.AgentOptions;
+import org.junit.Before;
+import org.junit.Test;
+import org.objectweb.asm.commons.GeneratorAdapter;
+
+/**
+ * Unit tests for {@link CoverageTransformer}.
+ *
+ * @author Marc R. Hoffmann
+ * @version $Revision: $
+ */
+public class CoverageTransformerTest {
+
+ private AgentOptions options;
+
+ @Before
+ public void setup() {
+ options = new AgentOptions();
+ }
+
+ @Test
+ public void testFilterSystemClass() {
+ CoverageTransformer t = createTransformer();
+ assertFalse(t.filter(null));
+ }
+
+ @Test
+ public void testFilterClassLoaderPositive() {
+ options.setExclClassloader("org.jacoco.agent.SomeWhere$*");
+ CoverageTransformer t = createTransformer();
+ assertTrue(t.filter(new ClassLoader(null) {
+ }));
+ }
+
+ @Test
+ public void testFilterClassLoaderNegative() {
+ options
+ .setExclClassloader("org.jacoco.agent.CoverageTransformerTest$*");
+ CoverageTransformer t = createTransformer();
+ assertFalse(t.filter(new ClassLoader(null) {
+ }));
+ }
+
+ private CoverageTransformer createTransformer() {
+ return new CoverageTransformer(new StubRuntime(), options);
+ }
+
+ private static class StubRuntime extends AbstractRuntime {
+ public void generateDataAccessor(long classid, GeneratorAdapter gen) {
+ }
+
+ public void startup() {
+ }
+
+ public void shutdown() {
+ }
+ }
+
+}