Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding missing javadoc and tests for the new module-related API.
- Loading branch information
Showing
8 changed files
with
435 additions
and
27 deletions.
There are no files selected for viewing
223 changes: 204 additions & 19 deletions
223
byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/AgentBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
65 changes: 65 additions & 0 deletions
65
byte-buddy-dep/src/test/java/net/bytebuddy/utility/JavaModuleTest.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,65 @@ | ||
package net.bytebuddy.utility; | ||
|
||
import net.bytebuddy.test.utility.ObjectPropertyAssertion; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
|
||
import static org.hamcrest.CoreMatchers.nullValue; | ||
import static org.hamcrest.CoreMatchers.sameInstance; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class JavaModuleTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testExtractModule() throws Exception { | ||
JavaModule.of(mock(Object.class)); | ||
} | ||
|
||
@Test | ||
public void testUnwrap() throws Exception { | ||
Object object = new Object(); | ||
JavaModule module = new JavaModule(object); | ||
assertThat(module.unwrap(), sameInstance(object)); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testIsNamedDisabledThrowException() throws Exception { | ||
JavaModule.Dispatcher.Disabled.INSTANCE.isNamed(mock(Object.class)); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testGetNameDisabledThrowException() throws Exception { | ||
JavaModule.Dispatcher.Disabled.INSTANCE.getName(mock(Object.class)); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testGetClassLoaderDisabledThrowException() throws Exception { | ||
JavaModule.Dispatcher.Disabled.INSTANCE.getClassLoader(mock(Object.class)); | ||
} | ||
|
||
@Test | ||
public void testDisabledModuleIsNull() throws Exception { | ||
assertThat(JavaModule.Dispatcher.Disabled.INSTANCE.moduleOf(Object.class), nullValue(JavaModule.class)); | ||
} | ||
|
||
@Test | ||
public void testObjectProperties() throws Exception { | ||
ObjectPropertyAssertion.of(JavaModule.class).skipToString().apply(); | ||
Object object = new Object(); | ||
assertThat(new JavaModule(object).hashCode(), is(object.hashCode())); | ||
assertThat(new JavaModule(object).toString(), is(object.toString())); | ||
final Iterator<Method> iterator = Arrays.asList(Object.class.getDeclaredMethods()).iterator(); | ||
ObjectPropertyAssertion.of(JavaModule.Dispatcher.Enabled.class).create(new ObjectPropertyAssertion.Creator<Method>() { | ||
@Override | ||
public Method create() { | ||
return iterator.next(); | ||
} | ||
}).apply(); | ||
ObjectPropertyAssertion.of(JavaModule.Dispatcher.Disabled.class).apply(); | ||
} | ||
} |
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