diff options
Diffstat (limited to 'test/cuchaz/enigma/TestJarIndexConstructorReferences.java')
| -rw-r--r-- | test/cuchaz/enigma/TestJarIndexConstructorReferences.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java index 38882a0..c069188 100644 --- a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -18,10 +18,13 @@ import static org.hamcrest.Matchers.containsInAnyOrder; | |||
| 18 | import static org.hamcrest.Matchers.empty; | 18 | import static org.hamcrest.Matchers.empty; |
| 19 | import static org.hamcrest.Matchers.is; | 19 | import static org.hamcrest.Matchers.is; |
| 20 | 20 | ||
| 21 | import java.io.File; | ||
| 22 | import java.util.Collection; | ||
| 21 | import java.util.jar.JarFile; | 23 | import java.util.jar.JarFile; |
| 22 | 24 | ||
| 23 | import org.junit.Test; | 25 | import org.junit.Test; |
| 24 | 26 | ||
| 27 | import cuchaz.enigma.analysis.EntryReference; | ||
| 25 | import cuchaz.enigma.analysis.JarIndex; | 28 | import cuchaz.enigma.analysis.JarIndex; |
| 26 | import cuchaz.enigma.mapping.BehaviorEntry; | 29 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 27 | import cuchaz.enigma.mapping.ClassEntry; | 30 | import cuchaz.enigma.mapping.ClassEntry; |
| @@ -30,17 +33,19 @@ import cuchaz.enigma.mapping.ConstructorEntry; | |||
| 30 | public class TestJarIndexConstructorReferences | 33 | public class TestJarIndexConstructorReferences |
| 31 | { | 34 | { |
| 32 | private JarIndex m_index; | 35 | private JarIndex m_index; |
| 33 | 36 | ||
| 34 | private ClassEntry m_baseClass = new ClassEntry( "none/a" ); | 37 | private ClassEntry m_baseClass = new ClassEntry( "none/a" ); |
| 35 | private ClassEntry m_subClass = new ClassEntry( "none/c" ); | 38 | private ClassEntry m_subClass = new ClassEntry( "none/d" ); |
| 36 | private ClassEntry m_subsubClass = new ClassEntry( "none/d" ); | 39 | private ClassEntry m_subsubClass = new ClassEntry( "none/e" ); |
| 40 | private ClassEntry m_defaultClass = new ClassEntry( "none/c" ); | ||
| 37 | private ClassEntry m_callerClass = new ClassEntry( "none/b" ); | 41 | private ClassEntry m_callerClass = new ClassEntry( "none/b" ); |
| 38 | 42 | ||
| 39 | public TestJarIndexConstructorReferences( ) | 43 | public TestJarIndexConstructorReferences( ) |
| 40 | throws Exception | 44 | throws Exception |
| 41 | { | 45 | { |
| 46 | File jarFile = new File( "build/libs/testConstructors.obf.jar" ); | ||
| 42 | m_index = new JarIndex(); | 47 | m_index = new JarIndex(); |
| 43 | m_index.indexJar( new JarFile( "build/libs/testConstructors.obf.jar" ), false ); | 48 | m_index.indexJar( new JarFile( jarFile ), false ); |
| 44 | } | 49 | } |
| 45 | 50 | ||
| 46 | @Test | 51 | @Test |
| @@ -51,6 +56,7 @@ public class TestJarIndexConstructorReferences | |||
| 51 | m_baseClass, | 56 | m_baseClass, |
| 52 | m_subClass, | 57 | m_subClass, |
| 53 | m_subsubClass, | 58 | m_subsubClass, |
| 59 | m_defaultClass, | ||
| 54 | m_callerClass | 60 | m_callerClass |
| 55 | ) ); | 61 | ) ); |
| 56 | } | 62 | } |
| @@ -60,7 +66,8 @@ public class TestJarIndexConstructorReferences | |||
| 60 | public void baseDefault( ) | 66 | public void baseDefault( ) |
| 61 | { | 67 | { |
| 62 | BehaviorEntry source = new ConstructorEntry( m_baseClass, "()V" ); | 68 | BehaviorEntry source = new ConstructorEntry( m_baseClass, "()V" ); |
| 63 | assertThat( m_index.getBehaviorReferences( source ), containsInAnyOrder( | 69 | Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = m_index.getBehaviorReferences( source ); |
| 70 | assertThat( references, containsInAnyOrder( | ||
| 64 | newBehaviorReferenceByMethod( source, m_callerClass.getName(), "a", "()V" ), | 71 | newBehaviorReferenceByMethod( source, m_callerClass.getName(), "a", "()V" ), |
| 65 | newBehaviorReferenceByConstructor( source, m_subClass.getName(), "()V" ), | 72 | newBehaviorReferenceByConstructor( source, m_subClass.getName(), "()V" ), |
| 66 | newBehaviorReferenceByConstructor( source, m_subClass.getName(), "(III)V" ) | 73 | newBehaviorReferenceByConstructor( source, m_subClass.getName(), "(III)V" ) |
| @@ -126,4 +133,14 @@ public class TestJarIndexConstructorReferences | |||
| 126 | newBehaviorReferenceByMethod( source, m_callerClass.getName(), "f", "()V" ) | 133 | newBehaviorReferenceByMethod( source, m_callerClass.getName(), "f", "()V" ) |
| 127 | ) ); | 134 | ) ); |
| 128 | } | 135 | } |
| 136 | |||
| 137 | @Test | ||
| 138 | @SuppressWarnings( "unchecked" ) | ||
| 139 | public void defaultConstructable( ) | ||
| 140 | { | ||
| 141 | BehaviorEntry source = new ConstructorEntry( m_defaultClass, "()V" ); | ||
| 142 | assertThat( m_index.getBehaviorReferences( source ), containsInAnyOrder( | ||
| 143 | newBehaviorReferenceByMethod( source, m_callerClass.getName(), "g", "()V" ) | ||
| 144 | ) ); | ||
| 145 | } | ||
| 129 | } | 146 | } |