diff options
Diffstat (limited to 'test/cuchaz/enigma/TestJarIndexLoneClass.java')
| -rw-r--r-- | test/cuchaz/enigma/TestJarIndexLoneClass.java | 168 |
1 files changed, 75 insertions, 93 deletions
diff --git a/test/cuchaz/enigma/TestJarIndexLoneClass.java b/test/cuchaz/enigma/TestJarIndexLoneClass.java index e2a87d0..0575eec 100644 --- a/test/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/test/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -33,154 +33,136 @@ import cuchaz.enigma.mapping.FieldEntry; | |||
| 33 | import cuchaz.enigma.mapping.MethodEntry; | 33 | import cuchaz.enigma.mapping.MethodEntry; |
| 34 | import cuchaz.enigma.mapping.Translator; | 34 | import cuchaz.enigma.mapping.Translator; |
| 35 | 35 | ||
| 36 | public class TestJarIndexLoneClass | 36 | public class TestJarIndexLoneClass { |
| 37 | { | 37 | |
| 38 | private JarIndex m_index; | 38 | private JarIndex m_index; |
| 39 | 39 | ||
| 40 | public TestJarIndexLoneClass( ) | 40 | public TestJarIndexLoneClass() throws Exception { |
| 41 | throws Exception | ||
| 42 | { | ||
| 43 | m_index = new JarIndex(); | 41 | m_index = new JarIndex(); |
| 44 | m_index.indexJar( new JarFile( "build/libs/testLoneClass.obf.jar" ), false ); | 42 | m_index.indexJar(new JarFile("build/libs/testLoneClass.obf.jar"), false); |
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | @Test | 45 | @Test |
| 48 | public void obfEntries( ) | 46 | public void obfEntries() { |
| 49 | { | 47 | assertThat(m_index.getObfClassEntries(), containsInAnyOrder( |
| 50 | assertThat( m_index.getObfClassEntries(), containsInAnyOrder( | 48 | newClass("cuchaz/enigma/inputs/Keep"), |
| 51 | newClass( "cuchaz/enigma/inputs/Keep" ), | 49 | newClass("none/a") |
| 52 | newClass( "none/a" ) | 50 | )); |
| 53 | ) ); | ||
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | @Test | 53 | @Test |
| 57 | public void translationIndex( ) | 54 | public void translationIndex() { |
| 58 | { | 55 | assertThat(m_index.getTranslationIndex().getSuperclassName("none/a"), is(nullValue())); |
| 59 | assertThat( m_index.getTranslationIndex().getSuperclassName( "none/a" ), is( nullValue() ) ); | 56 | assertThat(m_index.getTranslationIndex().getSuperclassName("cuchaz/enigma/inputs/Keep"), is(nullValue())); |
| 60 | assertThat( m_index.getTranslationIndex().getSuperclassName( "cuchaz/enigma/inputs/Keep" ), is( nullValue() ) ); | 57 | assertThat(m_index.getTranslationIndex().getAncestry("none/a"), is(empty())); |
| 61 | assertThat( m_index.getTranslationIndex().getAncestry( "none/a" ), is( empty() ) ); | 58 | assertThat(m_index.getTranslationIndex().getAncestry("cuchaz/enigma/inputs/Keep"), is(empty())); |
| 62 | assertThat( m_index.getTranslationIndex().getAncestry( "cuchaz/enigma/inputs/Keep" ), is( empty() ) ); | 59 | assertThat(m_index.getTranslationIndex().getSubclassNames("none/a"), is(empty())); |
| 63 | assertThat( m_index.getTranslationIndex().getSubclassNames( "none/a" ), is( empty() ) ); | 60 | assertThat(m_index.getTranslationIndex().getSubclassNames("cuchaz/enigma/inputs/Keep"), is(empty())); |
| 64 | assertThat( m_index.getTranslationIndex().getSubclassNames( "cuchaz/enigma/inputs/Keep" ), is( empty() ) ); | ||
| 65 | } | 61 | } |
| 66 | 62 | ||
| 67 | @Test | 63 | @Test |
| 68 | public void access( ) | 64 | public void access() { |
| 69 | { | 65 | assertThat(m_index.getAccess(newField("none/a", "a")), is(Access.Private)); |
| 70 | assertThat( m_index.getAccess( newField( "none/a", "a" ) ), is( Access.Private ) ); | 66 | assertThat(m_index.getAccess(newMethod("none/a", "a", "()Ljava/lang/String;")), is(Access.Public)); |
| 71 | assertThat( m_index.getAccess( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ), is( Access.Public ) ); | 67 | assertThat(m_index.getAccess(newField("none/a", "b")), is(nullValue())); |
| 72 | assertThat( m_index.getAccess( newField( "none/a", "b" ) ), is( nullValue() ) ); | ||
| 73 | } | 68 | } |
| 74 | 69 | ||
| 75 | @Test | 70 | @Test |
| 76 | public void classInheritance( ) | 71 | public void classInheritance() { |
| 77 | { | 72 | ClassInheritanceTreeNode node = m_index.getClassInheritance(new Translator(), newClass("none/a")); |
| 78 | ClassInheritanceTreeNode node = m_index.getClassInheritance( new Translator(), newClass( "none/a" ) ); | 73 | assertThat(node, is(not(nullValue()))); |
| 79 | assertThat( node, is( not( nullValue() ) ) ); | 74 | assertThat(node.getObfClassName(), is("none/a")); |
| 80 | assertThat( node.getObfClassName(), is( "none/a" ) ); | 75 | assertThat(node.getChildCount(), is(0)); |
| 81 | assertThat( node.getChildCount(), is( 0 ) ); | ||
| 82 | } | 76 | } |
| 83 | 77 | ||
| 84 | @Test | 78 | @Test |
| 85 | public void methodInheritance( ) | 79 | public void methodInheritance() { |
| 86 | { | 80 | MethodEntry source = newMethod("none/a", "a", "()Ljava/lang/String;"); |
| 87 | MethodEntry source = newMethod( "none/a", "a", "()Ljava/lang/String;" ); | 81 | MethodInheritanceTreeNode node = m_index.getMethodInheritance(new Translator(), source); |
| 88 | MethodInheritanceTreeNode node = m_index.getMethodInheritance( new Translator(), source ); | 82 | assertThat(node, is(not(nullValue()))); |
| 89 | assertThat( node, is( not( nullValue() ) ) ); | 83 | assertThat(node.getMethodEntry(), is(source)); |
| 90 | assertThat( node.getMethodEntry(), is( source ) ); | 84 | assertThat(node.getChildCount(), is(0)); |
| 91 | assertThat( node.getChildCount(), is( 0 ) ); | ||
| 92 | } | 85 | } |
| 93 | 86 | ||
| 94 | @Test | 87 | @Test |
| 95 | public void classImplementations( ) | 88 | public void classImplementations() { |
| 96 | { | 89 | ClassImplementationsTreeNode node = m_index.getClassImplementations(new Translator(), newClass("none/a")); |
| 97 | ClassImplementationsTreeNode node = m_index.getClassImplementations( new Translator(), newClass( "none/a" ) ); | 90 | assertThat(node, is(nullValue())); |
| 98 | assertThat( node, is( nullValue() ) ); | ||
| 99 | } | 91 | } |
| 100 | 92 | ||
| 101 | @Test | 93 | @Test |
| 102 | public void methodImplementations( ) | 94 | public void methodImplementations() { |
| 103 | { | 95 | MethodEntry source = newMethod("none/a", "a", "()Ljava/lang/String;"); |
| 104 | MethodEntry source = newMethod( "none/a", "a", "()Ljava/lang/String;" ); | 96 | MethodImplementationsTreeNode node = m_index.getMethodImplementations(new Translator(), source); |
| 105 | MethodImplementationsTreeNode node = m_index.getMethodImplementations( new Translator(), source ); | 97 | assertThat(node, is(nullValue())); |
| 106 | assertThat( node, is( nullValue() ) ); | ||
| 107 | } | 98 | } |
| 108 | 99 | ||
| 109 | @Test | 100 | @Test |
| 110 | public void relatedMethodImplementations( ) | 101 | public void relatedMethodImplementations() { |
| 111 | { | 102 | Set<MethodEntry> entries = m_index.getRelatedMethodImplementations(newMethod("none/a", "a", "()Ljava/lang/String;")); |
| 112 | Set<MethodEntry> entries = m_index.getRelatedMethodImplementations( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ); | 103 | assertThat(entries, containsInAnyOrder( |
| 113 | assertThat( entries, containsInAnyOrder( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ) ); | 104 | newMethod("none/a", "a", "()Ljava/lang/String;") |
| 105 | )); | ||
| 114 | } | 106 | } |
| 115 | 107 | ||
| 116 | @Test | 108 | @Test |
| 117 | @SuppressWarnings( "unchecked" ) | 109 | @SuppressWarnings("unchecked") |
| 118 | public void fieldReferences( ) | 110 | public void fieldReferences() { |
| 119 | { | 111 | FieldEntry source = newField("none/a", "a"); |
| 120 | FieldEntry source = newField( "none/a", "a" ); | 112 | Collection<EntryReference<FieldEntry,BehaviorEntry>> references = m_index.getFieldReferences(source); |
| 121 | Collection<EntryReference<FieldEntry,BehaviorEntry>> references = m_index.getFieldReferences( source ); | 113 | assertThat(references, containsInAnyOrder( |
| 122 | assertThat( references, containsInAnyOrder( | 114 | newFieldReferenceByConstructor(source, "none/a", "(Ljava/lang/String;)V"), |
| 123 | newFieldReferenceByConstructor( source, "none/a", "(Ljava/lang/String;)V" ), | 115 | newFieldReferenceByMethod(source, "none/a", "a", "()Ljava/lang/String;") |
| 124 | newFieldReferenceByMethod( source, "none/a", "a", "()Ljava/lang/String;" ) | 116 | )); |
| 125 | ) ); | ||
| 126 | } | 117 | } |
| 127 | 118 | ||
| 128 | @Test | 119 | @Test |
| 129 | public void behaviorReferences( ) | 120 | public void behaviorReferences() { |
| 130 | { | 121 | assertThat(m_index.getBehaviorReferences(newMethod("none/a", "a", "()Ljava/lang/String;")), is(empty())); |
| 131 | assertThat( m_index.getBehaviorReferences( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ), is( empty() ) ); | ||
| 132 | } | 122 | } |
| 133 | 123 | ||
| 134 | @Test | 124 | @Test |
| 135 | public void innerClasses( ) | 125 | public void innerClasses() { |
| 136 | { | 126 | assertThat(m_index.getInnerClasses("none/a"), is(empty())); |
| 137 | assertThat( m_index.getInnerClasses( "none/a" ), is( empty() ) ); | ||
| 138 | } | 127 | } |
| 139 | 128 | ||
| 140 | @Test | 129 | @Test |
| 141 | public void outerClass( ) | 130 | public void outerClass() { |
| 142 | { | 131 | assertThat(m_index.getOuterClass("a"), is(nullValue())); |
| 143 | assertThat( m_index.getOuterClass( "a" ), is( nullValue() ) ); | ||
| 144 | } | 132 | } |
| 145 | 133 | ||
| 146 | @Test | 134 | @Test |
| 147 | public void isAnonymousClass( ) | 135 | public void isAnonymousClass() { |
| 148 | { | 136 | assertThat(m_index.isAnonymousClass("none/a"), is(false)); |
| 149 | assertThat( m_index.isAnonymousClass( "none/a" ), is( false ) ); | ||
| 150 | } | 137 | } |
| 151 | 138 | ||
| 152 | @Test | 139 | @Test |
| 153 | public void interfaces( ) | 140 | public void interfaces() { |
| 154 | { | 141 | assertThat(m_index.getInterfaces("none/a"), is(empty())); |
| 155 | assertThat( m_index.getInterfaces( "none/a" ), is( empty() ) ); | ||
| 156 | } | 142 | } |
| 157 | 143 | ||
| 158 | @Test | 144 | @Test |
| 159 | public void implementingClasses( ) | 145 | public void implementingClasses() { |
| 160 | { | 146 | assertThat(m_index.getImplementingClasses("none/a"), is(empty())); |
| 161 | assertThat( m_index.getImplementingClasses( "none/a" ), is( empty() ) ); | ||
| 162 | } | 147 | } |
| 163 | 148 | ||
| 164 | @Test | 149 | @Test |
| 165 | public void isInterface( ) | 150 | public void isInterface() { |
| 166 | { | 151 | assertThat(m_index.isInterface("none/a"), is(false)); |
| 167 | assertThat( m_index.isInterface( "none/a" ), is( false ) ); | ||
| 168 | } | 152 | } |
| 169 | 153 | ||
| 170 | @Test | 154 | @Test |
| 171 | public void bridgeMethods( ) | 155 | public void bridgeMethods() { |
| 172 | { | 156 | assertThat(m_index.getBridgeMethod(newMethod("none/a", "a", "()Ljava/lang/String;")), is(nullValue())); |
| 173 | assertThat( m_index.getBridgeMethod( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ), is( nullValue() ) ); | ||
| 174 | } | 157 | } |
| 175 | 158 | ||
| 176 | @Test | 159 | @Test |
| 177 | public void contains( ) | 160 | public void contains() { |
| 178 | { | 161 | assertThat(m_index.containsObfClass(newClass("none/a")), is(true)); |
| 179 | assertThat( m_index.containsObfClass( newClass( "none/a" ) ), is( true ) ); | 162 | assertThat(m_index.containsObfClass(newClass("none/b")), is(false)); |
| 180 | assertThat( m_index.containsObfClass( newClass( "none/b" ) ), is( false ) ); | 163 | assertThat(m_index.containsObfField(newField("none/a", "a")), is(true)); |
| 181 | assertThat( m_index.containsObfField( newField( "none/a", "a" ) ), is( true ) ); | 164 | assertThat(m_index.containsObfField(newField("none/a", "b")), is(false)); |
| 182 | assertThat( m_index.containsObfField( newField( "none/a", "b" ) ), is( false ) ); | 165 | assertThat(m_index.containsObfBehavior(newMethod("none/a", "a", "()Ljava/lang/String;")), is(true)); |
| 183 | assertThat( m_index.containsObfBehavior( newMethod( "none/a", "a", "()Ljava/lang/String;" ) ), is( true ) ); | 166 | assertThat(m_index.containsObfBehavior(newMethod("none/a", "b", "()Ljava/lang/String;")), is(false)); |
| 184 | assertThat( m_index.containsObfBehavior( newMethod( "none/a", "b", "()Ljava/lang/String;" ) ), is( false ) ); | ||
| 185 | } | 167 | } |
| 186 | } | 168 | } |