-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #995 from clairton/master
Fix Get Adapters in Proxy Class
- Loading branch information
Showing
3 changed files
with
71 additions
and
14 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
56 changes: 56 additions & 0 deletions
56
...r-core/src/test/java/br/com/caelum/vraptor/serialization/gson/GsonBuilderWrapperTest.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,56 @@ | ||
package br.com.caelum.vraptor.serialization.gson; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonSerializationContext; | ||
import com.google.gson.JsonSerializer; | ||
|
||
import br.com.caelum.vraptor.WeldJunitRunner; | ||
|
||
@RunWith(WeldJunitRunner.class) | ||
public class GsonBuilderWrapperTest { | ||
private @Inject GsonBuilderWrapper builder; | ||
private Gson gson; | ||
|
||
@Before | ||
public void init(){ | ||
gson = builder.create(); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
String json = gson.toJson(new Bean()); | ||
assertEquals("{\"test123\":{}}", json); | ||
} | ||
} | ||
|
||
class Bean{ | ||
|
||
} | ||
|
||
|
||
@RegisterStrategy(RegisterType.SINGLE) | ||
@RequestScoped | ||
class BeanSerializer implements JsonSerializer<Bean> { | ||
private static final JsonObject element = new JsonObject(); | ||
static{ | ||
element.add("test123", new JsonObject()); | ||
} | ||
|
||
@Override | ||
public JsonElement serialize(Bean src, Type typeOfSrc, JsonSerializationContext context) { | ||
return element; | ||
} | ||
} |
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