-
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple, map based binary locator for a caching type pool.
- Loading branch information
Showing
3 changed files
with
100 additions
and
80 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
80 changes: 0 additions & 80 deletions
80
...a/net/bytebuddy/agent/builder/AgentBuilderBinaryLocatorWithTypePoolCacheProviderTest.java
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
...ava/net/bytebuddy/agent/builder/AgentBuilderBinaryLocatorWithTypePoolCacheSimpleTest.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,43 @@ | ||
package net.bytebuddy.agent.builder; | ||
|
||
import net.bytebuddy.dynamic.ClassFileLocator; | ||
import net.bytebuddy.pool.TypePool; | ||
import net.bytebuddy.test.utility.MockitoRule; | ||
import net.bytebuddy.test.utility.ObjectPropertyAssertion; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestRule; | ||
import org.mockito.Mock; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
|
||
public class AgentBuilderBinaryLocatorWithTypePoolCacheSimpleTest { | ||
|
||
@Rule | ||
public TestRule mockitoRule = new MockitoRule(this); | ||
|
||
@Mock | ||
private ClassFileLocator classFileLocator; | ||
|
||
@Mock | ||
private ClassLoader first, second; | ||
|
||
@Test | ||
public void testSimpleImplementation() throws Exception { | ||
ConcurrentMap<ClassLoader, TypePool.CacheProvider> cacheProviders = new ConcurrentHashMap<ClassLoader, TypePool.CacheProvider>(); | ||
AgentBuilder.BinaryLocator binaryLocator = new AgentBuilder.BinaryLocator.WithTypePoolCache.Simple(TypePool.Default.ReaderMode.FAST, cacheProviders); | ||
assertThat(binaryLocator.typePool(classFileLocator, first), is(binaryLocator.typePool(classFileLocator, first))); | ||
assertThat(binaryLocator.typePool(classFileLocator, first), not(binaryLocator.typePool(classFileLocator, second))); | ||
} | ||
|
||
@Test | ||
public void testObjectProperties() throws Exception { | ||
ObjectPropertyAssertion.of(AgentBuilder.BinaryLocator.WithTypePoolCache.Simple.class).apply(); | ||
} | ||
} |