-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
802e1d9
commit d39ad95
Showing
19 changed files
with
479 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 0 additions & 124 deletions
124
sandbox-core/src/test/java/test/com/alibaba/jvm/sandbox/core/enhance/BaseTestCase.java
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
sandbox-core/src/test/java/test/com/alibaba/jvm/sandbox/core/enhance/Computer.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...jvm/sandbox/module/mgr/ControlModule.java → ...jvm/sandbox/module/mgr/ControlModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ba/jvm/sandbox/module/mgr/InfoModule.java → ...ba/jvm/sandbox/module/mgr/InfoModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/sandbox/module/mgr/ModuleMgrModule.java → ...m/sandbox/module/mgr/ModuleMgrModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
sandbox-mgr-module/src/main/resources/META-INF/services/com.alibaba.jvm.sandbox.api.Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
com.albaba.jvm.sandbox.module.mgr.ModuleMgrModule | ||
com.albaba.jvm.sandbox.module.mgr.InfoModule | ||
com.albaba.jvm.sandbox.module.mgr.ControlModule | ||
com.alibaba.jvm.sandbox.module.mgr.ModuleMgrModule | ||
com.alibaba.jvm.sandbox.module.mgr.InfoModule | ||
com.alibaba.jvm.sandbox.module.mgr.ControlModule |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.alibaba.jvm.sandbox</groupId> | ||
<artifactId>sandbox</artifactId> | ||
<version>1.0.16</version> | ||
</parent> | ||
<groupId>com.alibaba.jvm.sandbox</groupId> | ||
<artifactId>sandbox-qatest</artifactId> | ||
<name>sandbox-qatest</name> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<forkMode>pertest</forkMode> | ||
<argLine>-Xbootclasspath/p:./lib/sandbox-spy-1.0.16-for-qatest.jar</argLine> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.9</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.jvm.sandbox</groupId> | ||
<artifactId>sandbox-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
75 changes: 75 additions & 0 deletions
75
...-qatest/src/test/java/com/alibaba/jvm/sandbox/qatest/core/enhance/CalculatorTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.alibaba.jvm.sandbox.qatest.core.enhance; | ||
|
||
import com.alibaba.jvm.sandbox.api.event.BeforeEvent; | ||
import com.alibaba.jvm.sandbox.api.event.Event; | ||
import com.alibaba.jvm.sandbox.api.event.ThrowsEvent; | ||
import com.alibaba.jvm.sandbox.api.filter.Filter; | ||
import com.alibaba.jvm.sandbox.api.filter.NameRegexFilter; | ||
import com.alibaba.jvm.sandbox.api.listener.EventListener; | ||
import com.alibaba.jvm.sandbox.core.util.SandboxReflectUtils; | ||
import com.alibaba.jvm.sandbox.core.util.UnCaughtException; | ||
import com.alibaba.jvm.sandbox.qatest.core.enhance.target.Calculator; | ||
import junit.framework.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
import static com.alibaba.jvm.sandbox.core.util.SandboxReflectUtils.unCaughtGetClassDeclaredJavaMethod; | ||
import static com.alibaba.jvm.sandbox.core.util.SandboxReflectUtils.unCaughtInvokeMethod; | ||
|
||
public class CalculatorTestCase extends CoreEnhanceBaseTestCase { | ||
|
||
protected int calculatorSum(final Object calculatorObject, int... numArray) { | ||
return unCaughtInvokeMethod( | ||
unCaughtGetClassDeclaredJavaMethod(calculatorObject.getClass(), "sum", int[].class), | ||
calculatorObject, | ||
numArray | ||
); | ||
} | ||
|
||
protected int calculatorErrorSum(final Object calculatorObject, int... numArray) throws Throwable { | ||
try { | ||
return unCaughtInvokeMethod( | ||
unCaughtGetClassDeclaredJavaMethod(calculatorObject.getClass(), "errorSum", int[].class), | ||
calculatorObject, | ||
numArray | ||
); | ||
} catch (Throwable cause) { | ||
if(cause instanceof UnCaughtException | ||
&& (cause.getCause() instanceof InvocationTargetException)) { | ||
throw ((InvocationTargetException)cause.getCause()).getTargetException(); | ||
} | ||
throw cause; | ||
} | ||
} | ||
|
||
@Test | ||
public void test_sum() throws IllegalAccessException, IOException, InvocationTargetException, InstantiationException { | ||
final Class<?> computerClass = watching( | ||
Calculator.class, | ||
new NameRegexFilter(".*", "sum"), | ||
new InterruptedEventListener() { | ||
@Override | ||
public void onEvent(Event event) throws Throwable { | ||
final BeforeEvent beforeEvent = (BeforeEvent) event; | ||
final int[] numberArray = (int[]) beforeEvent.argumentArray[0]; | ||
numberArray[0] = 40; | ||
numberArray[1] = 60; | ||
} | ||
}, | ||
Event.Type.BEFORE | ||
); | ||
|
||
Assert.assertEquals( | ||
100, | ||
calculatorSum( | ||
computerClass.newInstance(), | ||
1, 1 | ||
) | ||
); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.