-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8af42bb
commit 8cd1b10
Showing
15 changed files
with
700 additions
and
523 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
22 changes: 19 additions & 3 deletions
22
spring-boot-starter-fastjson/src/main/java/com/ruijc/fastjson/FastJsonProperties.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 |
---|---|---|
@@ -1,19 +1,35 @@ | ||
package com.ruijc.fastjson; | ||
|
||
import com.alibaba.fastjson.serializer.SerializerFeature; | ||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | ||
import com.ruijc.fastjson.converter.MyFastJsonHttpMessageConverter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.util.List; | ||
|
||
@ConfigurationProperties("spring.http.converters.fastjson") | ||
public class FastJsonProperties { | ||
|
||
private List<String> features; | ||
private List<SerializerFeature> features; | ||
private Class<? extends FastJsonHttpMessageConverter> converter; | ||
|
||
public List<String> getFeatures() { | ||
public FastJsonProperties() { | ||
converter = MyFastJsonHttpMessageConverter.class; | ||
} | ||
|
||
public List<SerializerFeature> getFeatures() { | ||
return features; | ||
} | ||
|
||
public void setFeatures(List<String> features) { | ||
public void setFeatures(List<SerializerFeature> features) { | ||
this.features = features; | ||
} | ||
|
||
public Class<? extends FastJsonHttpMessageConverter> getConverter() { | ||
return converter; | ||
} | ||
|
||
public void setConverter(Class<? extends FastJsonHttpMessageConverter> converter) { | ||
this.converter = converter; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
spring-boot-starter-fastjson/src/test/java/com/ruijc/fastjson/Config.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,14 @@ | ||
package com.ruijc.fastjson; | ||
|
||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class Config { | ||
|
||
@Bean | ||
public FastJsonHttpMessageConverter converter() { | ||
return new TestFastjsonHttpMessageConverter(); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
spring-boot-starter-fastjson/src/test/java/com/ruijc/fastjson/FastjsonApplication.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
spring-boot-starter-fastjson/src/test/java/com/ruijc/fastjson/FastjsonTest.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,47 @@ | ||
package com.ruijc.fastjson; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.mock.web.MockServletContext; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MockServletContext.class) | ||
@SpringBootApplication | ||
public class FastjsonTest { | ||
|
||
private MockMvc mvc; | ||
@Autowired | ||
protected WebApplicationContext wac; | ||
|
||
@Before | ||
public void setup() { | ||
mvc = MockMvcBuilders.webAppContextSetup(wac).build(); | ||
} | ||
|
||
@Test | ||
public void testJsonp() throws Exception { | ||
mvc.perform(get("/user/jsonp")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(equalTo("user({\"id\":1})"))); | ||
} | ||
|
||
@Test | ||
public void testRest() throws Exception { | ||
mvc.perform(get("/user/rest")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(equalTo("{\"id\":1}"))); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
spring-boot-starter-fastjson/src/test/java/com/ruijc/fastjson/FastjsonTests.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...t-starter-fastjson/src/test/java/com/ruijc/fastjson/TestFastjsonHttpMessageConverter.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,12 @@ | ||
package com.ruijc.fastjson; | ||
|
||
import com.ruijc.fastjson.converter.MyFastJsonHttpMessageConverter; | ||
|
||
public class TestFastjsonHttpMessageConverter extends MyFastJsonHttpMessageConverter { | ||
|
||
@Override | ||
protected String getResult(String old) { | ||
System.err.println("--->TestFastjsonHttpMessageConverter"); | ||
return super.getResult(old); | ||
} | ||
} |
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