-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
142 additions
and
20 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
90 changes: 90 additions & 0 deletions
90
...test/java/rocks/inspectit/gepard/agent/internal/instrumentation/InstrumentedTypeTest.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,90 @@ | ||
package rocks.inspectit.gepard.agent.internal.instrumentation; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class InstrumentedTypeTest { | ||
|
||
private static final Class<?> TEST_CLASS = InstrumentedTypeTest.class; | ||
|
||
@Test | ||
void typeIsEqualToClass() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
InstrumentedType type = new InstrumentedType(typeName, typeClassLoader); | ||
|
||
assertTrue(type.isEqualTo(TEST_CLASS)); | ||
} | ||
|
||
@Test | ||
void typeWithDifferentNameIsNotEqualToClass() { | ||
String typeName = TEST_CLASS.getSimpleName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
InstrumentedType type = new InstrumentedType(typeName, typeClassLoader); | ||
|
||
assertFalse(type.isEqualTo(TEST_CLASS)); | ||
} | ||
|
||
@Test | ||
void typeWithDifferentClassLoaderIsNotEqualToClass() { | ||
String typeName = TEST_CLASS.getName(); | ||
InstrumentedType type = new InstrumentedType(typeName, null); | ||
|
||
assertFalse(type.isEqualTo(TEST_CLASS)); | ||
} | ||
|
||
@Test | ||
void typeEqualsOtherType() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
|
||
InstrumentedType type1 = new InstrumentedType(typeName, typeClassLoader); | ||
InstrumentedType type2 = new InstrumentedType(typeName, typeClassLoader); | ||
|
||
assertEquals(type2, type1); | ||
} | ||
|
||
@Test | ||
void typeDoesNotEqualOtherType() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
|
||
InstrumentedType type1 = new InstrumentedType(typeName, typeClassLoader); | ||
InstrumentedType type2 = new InstrumentedType(typeName, null); | ||
|
||
assertNotEquals(type2, type1); | ||
} | ||
|
||
@Test | ||
void typeDoesNotEqualNull() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
|
||
InstrumentedType type1 = new InstrumentedType(typeName, typeClassLoader); | ||
|
||
assertNotEquals(null, type1); | ||
} | ||
|
||
@Test | ||
void typesHaveSameHashCode() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
|
||
InstrumentedType type1 = new InstrumentedType(typeName, typeClassLoader); | ||
InstrumentedType type2 = new InstrumentedType(typeName, typeClassLoader); | ||
|
||
assertEquals(type2.hashCode(), type1.hashCode()); | ||
} | ||
|
||
@Test | ||
void typesHaveDifferentHashCode() { | ||
String typeName = TEST_CLASS.getName(); | ||
ClassLoader typeClassLoader = TEST_CLASS.getClassLoader(); | ||
|
||
InstrumentedType type1 = new InstrumentedType(typeName, typeClassLoader); | ||
InstrumentedType type2 = new InstrumentedType(typeName, null); | ||
|
||
assertNotEquals(type2.hashCode(), type1.hashCode()); | ||
} | ||
} |