Created
March 22, 2019 17:14
-
-
Save ganadist/de6176eef9e3011c53656b29dc559669 to your computer and use it in GitHub Desktop.
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
package com.google.gson.functional; | |
import com.google.gson.Gson; | |
import com.google.gson.annotations.SerializedName; | |
import junit.framework.TestCase; | |
public class EnumWithObfuscatedTest extends TestCase { | |
private Gson gson; | |
@Override | |
protected void setUp() throws Exception { | |
super.setUp(); | |
gson = new Gson(); | |
} | |
public enum Gender { | |
@SerializedName("MAIL") | |
MALE, | |
@SerializedName("FEMAIL") | |
FEMALE | |
} | |
public void testEnumClassWithObfuscated() { | |
assertEquals(Gender.MALE, gson.fromJson("\"MAIL\"", Gender.class)); | |
assertEquals("\"MAIL\"", gson.toJson(Gender.MALE, Gender.class)); | |
} | |
} |
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
+ <plugin> | |
+ <groupId>com.github.wvengen</groupId> | |
+ <artifactId>proguard-maven-plugin</artifactId> | |
+ <executions> | |
+ <execution> | |
+ <phase>process-test-classes</phase> | |
+ <goals><goal>proguard</goal></goals> | |
+ </execution> | |
+ </executions> | |
+ <configuration> | |
+ <injar>test-classes</injar> | |
+ <outjar>test-classes</outjar> | |
+ <inFilter>com/google/gson/functional/EnumWithObfuscatedTest$Gender</inFilter> | |
+ <!-- options from Android Gradle Plugins --> | |
+ <options> | |
+ <option>-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*</option > | |
+ <option>-optimizationpasses 1</option> | |
+ <option>-allowaccessmodification</option> | |
+ <option>-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod</option> | |
+ <option>-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }</opt ion> | |
+ </options> | |
+ <libs> | |
+ <lib>${java.home}/lib/rt.jar</lib> | |
+ </libs> | |
+ </configuration> | |
+ </plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment