diff options
| author | 2014-09-21 00:32:03 -0400 | |
|---|---|---|
| committer | 2014-09-21 00:32:03 -0400 | |
| commit | 8409dea980fa03c06b180969c5e0696f7cb5474b (patch) | |
| tree | eb0cdfad4bc2cee6df8a311e62fc2f60d0360970 /test/cuchaz | |
| parent | removed workaround for procyon bug (diff) | |
| download | enigma-8409dea980fa03c06b180969c5e0696f7cb5474b.tar.gz enigma-8409dea980fa03c06b180969c5e0696f7cb5474b.tar.xz enigma-8409dea980fa03c06b180969c5e0696f7cb5474b.zip | |
started unit testing for inner/anonymous class detection
Diffstat (limited to 'test/cuchaz')
| -rw-r--r-- | test/cuchaz/enigma/TestDeobfuscator.java | 2 | ||||
| -rw-r--r-- | test/cuchaz/enigma/TestInnerClasses.java | 64 | ||||
| -rw-r--r-- | test/cuchaz/enigma/TestJarIndexConstructorReferences.java | 10 | ||||
| -rw-r--r-- | test/cuchaz/enigma/TestJarIndexInheritanceTree.java | 14 | ||||
| -rw-r--r-- | test/cuchaz/enigma/TestJarIndexLoneClass.java | 14 | ||||
| -rw-r--r-- | test/cuchaz/enigma/inputs/innerClasses/Anonymous.java | 17 | ||||
| -rw-r--r-- | test/cuchaz/enigma/inputs/innerClasses/ConstructorArgs.java | 22 | ||||
| -rw-r--r-- | test/cuchaz/enigma/inputs/innerClasses/Simple.java | 9 |
8 files changed, 122 insertions, 30 deletions
diff --git a/test/cuchaz/enigma/TestDeobfuscator.java b/test/cuchaz/enigma/TestDeobfuscator.java index 3bb0c480..71de24ae 100644 --- a/test/cuchaz/enigma/TestDeobfuscator.java +++ b/test/cuchaz/enigma/TestDeobfuscator.java | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | ******************************************************************************/ | 11 | ******************************************************************************/ |
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import static org.junit.Assert.assertEquals; | 14 | import static org.junit.Assert.*; |
| 15 | 15 | ||
| 16 | import java.io.File; | 16 | import java.io.File; |
| 17 | import java.io.IOException; | 17 | import java.io.IOException; |
diff --git a/test/cuchaz/enigma/TestInnerClasses.java b/test/cuchaz/enigma/TestInnerClasses.java new file mode 100644 index 00000000..c6b1b5fb --- /dev/null +++ b/test/cuchaz/enigma/TestInnerClasses.java | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * | ||
| 4 | * All rights reserved. This program and the accompanying materials | ||
| 5 | * are made available under the terms of the GNU Public License v3.0 | ||
| 6 | * which accompanies this distribution, and is available at | ||
| 7 | * http://www.gnu.org/licenses/gpl.html | ||
| 8 | * | ||
| 9 | * Contributors: | ||
| 10 | * Jeff Martin - initial API and implementation | ||
| 11 | ******************************************************************************/ | ||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import static org.hamcrest.MatcherAssert.*; | ||
| 15 | import static org.hamcrest.Matchers.*; | ||
| 16 | |||
| 17 | import java.util.jar.JarFile; | ||
| 18 | |||
| 19 | import org.junit.Test; | ||
| 20 | |||
| 21 | import cuchaz.enigma.analysis.JarIndex; | ||
| 22 | |||
| 23 | public class TestInnerClasses | ||
| 24 | { | ||
| 25 | private JarIndex m_index; | ||
| 26 | |||
| 27 | private static final String AnonymousOuter = "none/a"; | ||
| 28 | private static final String AnonymousInner = "none/b"; | ||
| 29 | private static final String SimpleOuter = "none/e"; | ||
| 30 | private static final String SimpleInner = "none/f"; | ||
| 31 | private static final String ConstructorArgsOuter = "none/c"; | ||
| 32 | private static final String ConstructorArgsInner = "none/d"; | ||
| 33 | |||
| 34 | public TestInnerClasses( ) | ||
| 35 | throws Exception | ||
| 36 | { | ||
| 37 | m_index = new JarIndex(); | ||
| 38 | m_index.indexJar( new JarFile( "build/libs/testInnerClasses.obf.jar" ), true ); | ||
| 39 | } | ||
| 40 | |||
| 41 | @Test | ||
| 42 | public void simple( ) | ||
| 43 | { | ||
| 44 | assertThat( m_index.getOuterClass( SimpleInner ), is( SimpleOuter ) ); | ||
| 45 | assertThat( m_index.getInnerClasses( SimpleOuter ), containsInAnyOrder( SimpleInner ) ); | ||
| 46 | assertThat( m_index.isAnonymousClass( SimpleInner ), is( false ) ); | ||
| 47 | } | ||
| 48 | |||
| 49 | @Test | ||
| 50 | public void anonymous( ) | ||
| 51 | { | ||
| 52 | assertThat( m_index.getOuterClass( AnonymousInner ), is( AnonymousOuter ) ); | ||
| 53 | assertThat( m_index.getInnerClasses( AnonymousOuter ), containsInAnyOrder( AnonymousInner ) ); | ||
| 54 | assertThat( m_index.isAnonymousClass( AnonymousInner ), is( true ) ); | ||
| 55 | } | ||
| 56 | |||
| 57 | @Test | ||
| 58 | public void constructorArgs( ) | ||
| 59 | { | ||
| 60 | assertThat( m_index.getOuterClass( ConstructorArgsInner ), is( ConstructorArgsOuter ) ); | ||
| 61 | assertThat( m_index.getInnerClasses( ConstructorArgsOuter ), containsInAnyOrder( ConstructorArgsInner ) ); | ||
| 62 | assertThat( m_index.isAnonymousClass( ConstructorArgsInner ), is( false ) ); | ||
| 63 | } | ||
| 64 | } | ||
diff --git a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java index c0691888..02381718 100644 --- a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -10,13 +10,9 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma; | 11 | package cuchaz.enigma; |
| 12 | 12 | ||
| 13 | import static cuchaz.enigma.EntryFactory.newBehaviorReferenceByConstructor; | 13 | import static cuchaz.enigma.EntryFactory.*; |
| 14 | import static cuchaz.enigma.EntryFactory.newBehaviorReferenceByMethod; | 14 | import static org.hamcrest.MatcherAssert.*; |
| 15 | import static cuchaz.enigma.EntryFactory.newClass; | 15 | import static org.hamcrest.Matchers.*; |
| 16 | import static org.hamcrest.MatcherAssert.assertThat; | ||
| 17 | import static org.hamcrest.Matchers.containsInAnyOrder; | ||
| 18 | import static org.hamcrest.Matchers.empty; | ||
| 19 | import static org.hamcrest.Matchers.is; | ||
| 20 | 16 | ||
| 21 | import java.io.File; | 17 | import java.io.File; |
| 22 | import java.util.Collection; | 18 | import java.util.Collection; |
diff --git a/test/cuchaz/enigma/TestJarIndexInheritanceTree.java b/test/cuchaz/enigma/TestJarIndexInheritanceTree.java index 3d488ee4..317a6bc4 100644 --- a/test/cuchaz/enigma/TestJarIndexInheritanceTree.java +++ b/test/cuchaz/enigma/TestJarIndexInheritanceTree.java | |||
| @@ -10,17 +10,9 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma; | 11 | package cuchaz.enigma; |
| 12 | 12 | ||
| 13 | import static cuchaz.enigma.EntryFactory.newBehaviorReferenceByConstructor; | 13 | import static cuchaz.enigma.EntryFactory.*; |
| 14 | import static cuchaz.enigma.EntryFactory.newBehaviorReferenceByMethod; | 14 | import static org.hamcrest.MatcherAssert.*; |
| 15 | import static cuchaz.enigma.EntryFactory.newClass; | 15 | import static org.hamcrest.Matchers.*; |
| 16 | import static cuchaz.enigma.EntryFactory.newFieldReferenceByConstructor; | ||
| 17 | import static cuchaz.enigma.EntryFactory.newFieldReferenceByMethod; | ||
| 18 | import static org.hamcrest.MatcherAssert.assertThat; | ||
| 19 | import static org.hamcrest.Matchers.contains; | ||
| 20 | import static org.hamcrest.Matchers.containsInAnyOrder; | ||
| 21 | import static org.hamcrest.Matchers.empty; | ||
| 22 | import static org.hamcrest.Matchers.is; | ||
| 23 | import static org.hamcrest.Matchers.nullValue; | ||
| 24 | 16 | ||
| 25 | import java.util.Collection; | 17 | import java.util.Collection; |
| 26 | import java.util.Set; | 18 | import java.util.Set; |
diff --git a/test/cuchaz/enigma/TestJarIndexLoneClass.java b/test/cuchaz/enigma/TestJarIndexLoneClass.java index 9236d0c1..4c32b703 100644 --- a/test/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/test/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -11,17 +11,9 @@ | |||
| 11 | ******************************************************************************/ | 11 | ******************************************************************************/ |
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import static cuchaz.enigma.EntryFactory.newClass; | 14 | import static cuchaz.enigma.EntryFactory.*; |
| 15 | import static cuchaz.enigma.EntryFactory.newField; | 15 | import static org.hamcrest.MatcherAssert.*; |
| 16 | import static cuchaz.enigma.EntryFactory.newFieldReferenceByConstructor; | 16 | import static org.hamcrest.Matchers.*; |
| 17 | import static cuchaz.enigma.EntryFactory.newFieldReferenceByMethod; | ||
| 18 | import static cuchaz.enigma.EntryFactory.newMethod; | ||
| 19 | import static org.hamcrest.MatcherAssert.assertThat; | ||
| 20 | import static org.hamcrest.Matchers.containsInAnyOrder; | ||
| 21 | import static org.hamcrest.Matchers.empty; | ||
| 22 | import static org.hamcrest.Matchers.is; | ||
| 23 | import static org.hamcrest.Matchers.not; | ||
| 24 | import static org.hamcrest.Matchers.nullValue; | ||
| 25 | 17 | ||
| 26 | import java.util.Collection; | 18 | import java.util.Collection; |
| 27 | import java.util.Set; | 19 | import java.util.Set; |
diff --git a/test/cuchaz/enigma/inputs/innerClasses/Anonymous.java b/test/cuchaz/enigma/inputs/innerClasses/Anonymous.java new file mode 100644 index 00000000..dbff5238 --- /dev/null +++ b/test/cuchaz/enigma/inputs/innerClasses/Anonymous.java | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | package cuchaz.enigma.inputs.innerClasses; | ||
| 2 | |||
| 3 | public class Anonymous // a | ||
| 4 | { | ||
| 5 | public void foo( ) | ||
| 6 | { | ||
| 7 | Runnable runnable = new Runnable( ) // b | ||
| 8 | { | ||
| 9 | @Override | ||
| 10 | public void run( ) | ||
| 11 | { | ||
| 12 | // don't care | ||
| 13 | } | ||
| 14 | }; | ||
| 15 | runnable.run(); | ||
| 16 | } | ||
| 17 | } | ||
diff --git a/test/cuchaz/enigma/inputs/innerClasses/ConstructorArgs.java b/test/cuchaz/enigma/inputs/innerClasses/ConstructorArgs.java new file mode 100644 index 00000000..d12d9cf7 --- /dev/null +++ b/test/cuchaz/enigma/inputs/innerClasses/ConstructorArgs.java | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | package cuchaz.enigma.inputs.innerClasses; | ||
| 2 | |||
| 3 | @SuppressWarnings( "unused" ) | ||
| 4 | public class ConstructorArgs // c | ||
| 5 | { | ||
| 6 | class Inner // d | ||
| 7 | { | ||
| 8 | private int a; | ||
| 9 | |||
| 10 | public Inner( int a ) | ||
| 11 | { | ||
| 12 | this.a = a; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | Inner i; | ||
| 17 | |||
| 18 | public void foo( ) | ||
| 19 | { | ||
| 20 | i = new Inner( 5 ); | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/test/cuchaz/enigma/inputs/innerClasses/Simple.java b/test/cuchaz/enigma/inputs/innerClasses/Simple.java new file mode 100644 index 00000000..f2c08a73 --- /dev/null +++ b/test/cuchaz/enigma/inputs/innerClasses/Simple.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | package cuchaz.enigma.inputs.innerClasses; | ||
| 2 | |||
| 3 | public class Simple // e | ||
| 4 | { | ||
| 5 | class Inner // f | ||
| 6 | { | ||
| 7 | // nothing to do | ||
| 8 | } | ||
| 9 | } | ||