You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/12/20 00:30:06 UTC

[shardingsphere] branch master updated: Fix AgentTransformerTest (#22981)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ebebf9de6b Fix AgentTransformerTest (#22981)
8ebebf9de6b is described below

commit 8ebebf9de6b88aa0058250fac69933dac08006b9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Dec 20 08:29:49 2022 +0800

    Fix AgentTransformerTest (#22981)
    
    * Fix AgentTransformerTest
    
    * Fix AgentTransformerTest
    
    * Fix AgentTransformerTest
    
    * Fix AgentTransformerTest
---
 .../core/transformer/AgentTransformerTest.java     | 94 +++++++++++-----------
 .../{FooStaticMethodAdvice.java => BarAdvice.java} | 41 +++++++---
 .../fixture/advice/BarInstanceMethodAdvice.java    | 47 -----------
 ...FooInstanceMethodAdvice.java => FooAdvice.java} | 50 +++++++-----
 .../fixture/advice/FooConstructorAdvice.java       | 32 --------
 .../fixture/targeted/BarTargetObjectFixture.java   | 34 --------
 ...ObjectFixture.java => TargetObjectFixture.java} | 43 ++++++----
 7 files changed, 136 insertions(+), 205 deletions(-)

diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformerTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformerTest.java
index bff7c41c27a..67027aa5c1d 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformerTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformerTest.java
@@ -27,45 +27,35 @@ import org.apache.shardingsphere.agent.config.advisor.AdvisorConfiguration;
 import org.apache.shardingsphere.agent.config.advisor.MethodAdvisorConfiguration;
 import org.apache.shardingsphere.agent.core.classloader.AgentClassLoader;
 import org.apache.shardingsphere.agent.core.logging.LoggingListener;
-import org.apache.shardingsphere.agent.core.transformer.fixture.advice.FooConstructorAdvice;
-import org.apache.shardingsphere.agent.core.transformer.fixture.advice.FooInstanceMethodAdvice;
-import org.apache.shardingsphere.agent.core.transformer.fixture.advice.BarInstanceMethodAdvice;
-import org.apache.shardingsphere.agent.core.transformer.fixture.advice.FooStaticMethodAdvice;
-import org.apache.shardingsphere.agent.core.transformer.fixture.targeted.FooTargetObjectFixture;
-import org.apache.shardingsphere.agent.core.transformer.fixture.targeted.BarTargetObjectFixture;
-import org.junit.After;
+import org.apache.shardingsphere.agent.core.transformer.fixture.advice.BarAdvice;
+import org.apache.shardingsphere.agent.core.transformer.fixture.advice.FooAdvice;
+import org.apache.shardingsphere.agent.core.transformer.fixture.targeted.TargetObjectFixture;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
 
 public final class AgentTransformerTest {
     
     private static ResettableClassFileTransformer byteBuddyAgent;
     
-    private final List<String> queue = new LinkedList<>();
-    
     @BeforeClass
     public static void setup() throws ReflectiveOperationException {
         ByteBuddyAgent.install();
         AgentClassLoader.init(Collections.emptyList());
-        Map<String, AdvisorConfiguration> advisorConfigs = new HashMap<>(2, 1);
         AdvisorConfiguration advisorConfig = createAdvisorConfiguration();
-        advisorConfigs.put(advisorConfig.getTargetClassName(), advisorConfig);
-        AdvisorConfiguration advisorConfigInTwice = createAdvisorConfigurationInTwice();
-        advisorConfigs.put(advisorConfigInTwice.getTargetClassName(), advisorConfigInTwice);
+        Map<String, AdvisorConfiguration> advisorConfigs = Collections.singletonMap(advisorConfig.getTargetClassName(), advisorConfig);
         byteBuddyAgent = new AgentBuilder.Default().with(new ByteBuddy().with(TypeValidation.ENABLED))
                 .ignore(ElementMatchers.isSynthetic()).or(ElementMatchers.nameStartsWith("org.apache.shardingsphere.agent.")
-                        .and(ElementMatchers.not(ElementMatchers.nameStartsWith("org.apache.shardingsphere.agent.core.fixture"))))
+                        .and(ElementMatchers.not(ElementMatchers.nameStartsWith("org.apache.shardingsphere.agent.core.transformer.fixture"))))
                 .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
                 .with(new LoggingListener())
                 .type(new AgentJunction(advisorConfigs))
@@ -75,51 +65,65 @@ public final class AgentTransformerTest {
     }
     
     private static AdvisorConfiguration createAdvisorConfiguration() {
-        AdvisorConfiguration result = new AdvisorConfiguration("org.apache.shardingsphere.agent.core.fixture.targeted.FooTargetObjectFixture");
-        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.isConstructor().and(ElementMatchers.takesArguments(1)), FooConstructorAdvice.class.getTypeName()));
-        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("mock"), FooInstanceMethodAdvice.class.getTypeName()));
-        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("staticMock"), FooStaticMethodAdvice.class.getTypeName()));
+        AdvisorConfiguration result = new AdvisorConfiguration("org.apache.shardingsphere.agent.core.transformer.fixture.targeted.TargetObjectFixture");
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.isConstructor().and(ElementMatchers.takesArguments(1)), FooAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.isConstructor().and(ElementMatchers.takesArguments(1)), BarAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callInstanceMethod"), FooAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callInstanceMethod"), BarAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callInstanceMethodWhenExceptionThrown"), FooAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callInstanceMethodWhenExceptionThrown"), BarAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callStaticMethod"), FooAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callStaticMethod"), BarAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callStaticMethodWhenExceptionThrown"), FooAdvice.class.getName()));
+        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("callStaticMethodWhenExceptionThrown"), BarAdvice.class.getName()));
         return result;
     }
     
-    private static AdvisorConfiguration createAdvisorConfigurationInTwice() {
-        AdvisorConfiguration result = new AdvisorConfiguration("org.apache.shardingsphere.agent.core.fixture.targeted.BarTargetObjectFixture");
-        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("mock"), FooInstanceMethodAdvice.class.getTypeName()));
-        result.getAdvisors().add(new MethodAdvisorConfiguration(ElementMatchers.named("mock"), BarInstanceMethodAdvice.class.getTypeName()));
-        return result;
+    @AfterClass
+    public static void destroy() {
+        byteBuddyAgent.reset(ByteBuddyAgent.getInstrumentation(), AgentBuilder.RedefinitionStrategy.RETRANSFORMATION);
     }
     
     @Test
-    public void assertInstanceMethod() {
-        assertThat(new FooTargetObjectFixture().mock(queue), is("invocation"));
-        assertArrayEquals(new String[]{"before", "on", "after"}, queue.toArray());
+    public void assertAdviceConstructor() {
+        List<String> queue = new LinkedList<>();
+        new TargetObjectFixture(queue);
+        assertThat(queue, is(Arrays.asList("on constructor", "foo constructor", "bar constructor")));
     }
     
     @Test
-    public void assertInstanceMethodInRepeatedAdvice() {
-        assertThat(new BarTargetObjectFixture().mock(queue), is("invocation"));
-        assertArrayEquals(new String[]{"before", "twice_before", "on", "after", "twice_after"}, queue.toArray());
+    public void assertAdviceInstanceMethod() {
+        List<String> queue = new LinkedList<>();
+        new TargetObjectFixture(new LinkedList<>()).callInstanceMethod(queue);
+        assertThat(queue, is(Arrays.asList("foo before instance method", "bar before instance method", "on instance method", "foo after instance method", "bar after instance method")));
     }
     
     @Test
-    public void assertStaticMethod() {
-        assertThat(FooTargetObjectFixture.staticMock(queue), is("static invocation"));
-        assertArrayEquals(new String[]{"before", "on", "after"}, queue.toArray());
+    public void assertAdviceInstanceMethodWhenExceptionThrown() {
+        List<String> queue = new LinkedList<>();
+        try {
+            new TargetObjectFixture(new LinkedList<>()).callInstanceMethodWhenExceptionThrown(queue);
+        } catch (final UnsupportedOperationException ignored) {
+        }
+        assertThat(queue, is(Arrays.asList("foo before instance method", "bar before instance method",
+                "foo throw instance method exception", "bar throw instance method exception", "foo after instance method", "bar after instance method")));
     }
     
     @Test
-    public void assertConstructor() {
-        new FooTargetObjectFixture(queue);
-        assertArrayEquals(new String[]{"constructor", "advice constructor"}, queue.toArray());
+    public void assertAdviceStaticMethod() {
+        List<String> queue = new LinkedList<>();
+        TargetObjectFixture.callStaticMethod(queue);
+        assertThat(queue, is(Arrays.asList("foo before static method", "bar before static method", "on static method", "foo after static method", "bar after static method")));
     }
     
-    @After
-    public void cleanup() {
-        queue.clear();
-    }
-    
-    @AfterClass
-    public static void destroy() {
-        byteBuddyAgent.reset(ByteBuddyAgent.getInstrumentation(), AgentBuilder.RedefinitionStrategy.RETRANSFORMATION);
+    @Test
+    public void assertAdviceStaticMethodWhenExceptionThrown() {
+        List<String> queue = new LinkedList<>();
+        try {
+            TargetObjectFixture.callStaticMethodWhenExceptionThrown(queue);
+        } catch (final UnsupportedOperationException ignored) {
+        }
+        assertThat(queue, is(Arrays.asList("foo before static method", "bar before static method",
+                "foo throw static method exception", "bar throw static method exception", "foo after static method", "bar after static method")));
     }
 }
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooStaticMethodAdvice.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarAdvice.java
similarity index 54%
rename from agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooStaticMethodAdvice.java
rename to agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarAdvice.java
index 08aecd2506f..934b1b6fca5 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooStaticMethodAdvice.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarAdvice.java
@@ -17,41 +17,56 @@
 
 package org.apache.shardingsphere.agent.core.transformer.fixture.advice;
 
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.advice.type.StaticMethodAdvice;
 import org.apache.shardingsphere.agent.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
+import org.apache.shardingsphere.agent.advice.type.ConstructorAdvice;
+import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice;
+import org.apache.shardingsphere.agent.advice.type.StaticMethodAdvice;
 
 import java.lang.reflect.Method;
 import java.util.List;
 
-@RequiredArgsConstructor
 @SuppressWarnings("unchecked")
-public final class FooStaticMethodAdvice implements StaticMethodAdvice {
+public final class BarAdvice implements ConstructorAdvice, InstanceMethodAdvice, StaticMethodAdvice {
     
-    private final boolean rebase;
+    @Override
+    public void onConstructor(final TargetAdviceObject target, final Object[] args) {
+        ((List<String>) args[0]).add("bar constructor");
+    }
     
-    public FooStaticMethodAdvice() {
-        this(false);
+    @Override
+    public void beforeMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("bar before instance method");
     }
     
     @Override
     public void beforeMethod(final Class<?> clazz, final Method method, final Object[] args, final MethodInvocationResult result) {
         List<String> queue = (List<String>) args[0];
-        queue.add("before");
-        if (rebase) {
-            result.rebase("rebase static invocation method");
-        }
+        queue.add("bar before static method");
+    }
+    
+    @Override
+    public void afterMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("bar after instance method");
     }
     
     @Override
     public void afterMethod(final Class<?> clazz, final Method method, final Object[] args, final MethodInvocationResult result) {
         List<String> queue = (List<String>) args[0];
-        queue.add("after");
+        queue.add("bar after static method");
+    }
+    
+    @Override
+    public void onThrowing(final TargetAdviceObject target, final Method method, final Object[] args, final Throwable throwable) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("bar throw instance method exception");
     }
     
     @Override
     public void onThrowing(final Class<?> clazz, final Method method, final Object[] args, final Throwable throwable) {
         List<String> queue = (List<String>) args[0];
-        queue.add("exception");
+        queue.add("bar throw static method exception");
     }
 }
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarInstanceMethodAdvice.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarInstanceMethodAdvice.java
deleted file mode 100644
index 902f613edfd..00000000000
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/BarInstanceMethodAdvice.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.shardingsphere.agent.core.transformer.fixture.advice;
-
-import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice;
-import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
-import org.apache.shardingsphere.agent.advice.MethodInvocationResult;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-@SuppressWarnings("unchecked")
-public final class BarInstanceMethodAdvice implements InstanceMethodAdvice {
-    
-    @Override
-    public void beforeMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("twice_before");
-    }
-    
-    @Override
-    public void afterMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("twice_after");
-    }
-    
-    @Override
-    public void onThrowing(final TargetAdviceObject target, final Method method, final Object[] args, final Throwable throwable) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("twice_exception");
-    }
-}
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooInstanceMethodAdvice.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooAdvice.java
similarity index 53%
rename from agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooInstanceMethodAdvice.java
rename to agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooAdvice.java
index 051a990bdf5..9be98306280 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooInstanceMethodAdvice.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooAdvice.java
@@ -17,42 +17,56 @@
 
 package org.apache.shardingsphere.agent.core.transformer.fixture.advice;
 
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice;
-import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
 import org.apache.shardingsphere.agent.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
+import org.apache.shardingsphere.agent.advice.type.ConstructorAdvice;
+import org.apache.shardingsphere.agent.advice.type.InstanceMethodAdvice;
+import org.apache.shardingsphere.agent.advice.type.StaticMethodAdvice;
 
 import java.lang.reflect.Method;
 import java.util.List;
 
-@RequiredArgsConstructor
 @SuppressWarnings("unchecked")
-public final class FooInstanceMethodAdvice implements InstanceMethodAdvice {
+public final class FooAdvice implements ConstructorAdvice, InstanceMethodAdvice, StaticMethodAdvice {
     
-    private final boolean rebase;
-    
-    public FooInstanceMethodAdvice() {
-        this(false);
+    @Override
+    public void onConstructor(final TargetAdviceObject target, final Object[] args) {
+        ((List<String>) args[0]).add("foo constructor");
     }
     
     @Override
     public void beforeMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("before");
-        if (rebase) {
-            invocationResult.rebase("rebase invocation method");
-        }
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo before instance method");
+    }
+    
+    @Override
+    public void beforeMethod(final Class<?> clazz, final Method method, final Object[] args, final MethodInvocationResult result) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo before static method");
     }
     
     @Override
     public void afterMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("after");
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo after instance method");
+    }
+    
+    @Override
+    public void afterMethod(final Class<?> clazz, final Method method, final Object[] args, final MethodInvocationResult result) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo after static method");
     }
     
     @Override
     public void onThrowing(final TargetAdviceObject target, final Method method, final Object[] args, final Throwable throwable) {
-        List<String> queues = (List<String>) args[0];
-        queues.add("exception");
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo throw instance method exception");
+    }
+    
+    @Override
+    public void onThrowing(final Class<?> clazz, final Method method, final Object[] args, final Throwable throwable) {
+        List<String> queue = (List<String>) args[0];
+        queue.add("foo throw static method exception");
     }
 }
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooConstructorAdvice.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooConstructorAdvice.java
deleted file mode 100644
index a0bb33feea7..00000000000
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/advice/FooConstructorAdvice.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.shardingsphere.agent.core.transformer.fixture.advice;
-
-import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
-import org.apache.shardingsphere.agent.advice.type.ConstructorAdvice;
-
-import java.util.List;
-
-public final class FooConstructorAdvice implements ConstructorAdvice {
-    
-    @Override
-    @SuppressWarnings("unchecked")
-    public void onConstructor(final TargetAdviceObject target, final Object[] args) {
-        ((List<String>) args[0]).add("advice constructor");
-    }
-}
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/BarTargetObjectFixture.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/BarTargetObjectFixture.java
deleted file mode 100644
index f5c3c5d752f..00000000000
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/BarTargetObjectFixture.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.shardingsphere.agent.core.transformer.fixture.targeted;
-
-import java.util.List;
-
-public final class BarTargetObjectFixture {
-    
-    /**
-     * Mock method for testing.
-     *
-     * @param queue queue
-     * @return result
-     */
-    public String mock(final List<String> queue) {
-        queue.add("on");
-        return "invocation";
-    }
-}
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/FooTargetObjectFixture.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/TargetObjectFixture.java
similarity index 53%
rename from agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/FooTargetObjectFixture.java
rename to agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/TargetObjectFixture.java
index d82f03fdf29..54a7e3b2b40 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/FooTargetObjectFixture.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/transformer/fixture/targeted/TargetObjectFixture.java
@@ -17,36 +17,47 @@
 
 package org.apache.shardingsphere.agent.core.transformer.fixture.targeted;
 
-import lombok.NoArgsConstructor;
-
 import java.util.List;
 
-@NoArgsConstructor
-public final class FooTargetObjectFixture {
+public final class TargetObjectFixture {
+    
+    public TargetObjectFixture(final List<String> queue) {
+        queue.add("on constructor");
+    }
     
-    public FooTargetObjectFixture(final List<String> queue) {
-        queue.add("constructor");
+    /**
+     * Call instance method.
+     *
+     * @param queue queue
+     */
+    public void callInstanceMethod(final List<String> queue) {
+        queue.add("on instance method");
+    }
+    
+    /**
+     * Call instance method when exception thrown.
+     *
+     * @param queue queue
+     */
+    public void callInstanceMethodWhenExceptionThrown(final List<String> queue) {
+        throw new UnsupportedOperationException();
     }
     
     /**
-     * Mock method for testing.
+     * Call static method.
      *
      * @param queue queue
-     * @return result
      */
-    public String mock(final List<String> queue) {
-        queue.add("on");
-        return "invocation";
+    public static void callStaticMethod(final List<String> queue) {
+        queue.add("on static method");
     }
     
     /**
-     * Mock static method for testing.
+     * Call static method when exception thrown.
      *
      * @param queue queue
-     * @return result
      */
-    public static String staticMock(final List<String> queue) {
-        queue.add("on");
-        return "static invocation";
+    public static void callStaticMethodWhenExceptionThrown(final List<String> queue) {
+        throw new UnsupportedOperationException();
     }
 }