#525 目录调整

This commit is contained in:
calvin1978
2017-01-22 01:50:47 +08:00
parent 72e1e8f75a
commit 11966020b6
12 changed files with 35 additions and 29 deletions

View File

@@ -20,7 +20,7 @@ import org.springside.examples.bootapi.service.BookAdminService;
import org.springside.examples.bootapi.service.BookBorrowService; import org.springside.examples.bootapi.service.BookBorrowService;
import org.springside.examples.bootapi.service.exception.ErrorCode; import org.springside.examples.bootapi.service.exception.ErrorCode;
import org.springside.examples.bootapi.service.exception.ServiceException; import org.springside.examples.bootapi.service.exception.ServiceException;
import org.springside.modules.utils.reflect.BeanMapper; import org.springside.modules.utils.mapper.BeanMapper;
import org.springside.modules.web.MediaTypes; import org.springside.modules.web.MediaTypes;
// Spring Restful MVC Controller的标识, 直接输出内容不调用template引擎. // Spring Restful MVC Controller的标识, 直接输出内容不调用template引擎.

View File

@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.springside.examples.bootapi.service.exception.ServiceException; import org.springside.examples.bootapi.service.exception.ServiceException;
import org.springside.modules.utils.text.JsonMapper; import org.springside.modules.utils.mapper.JsonMapper;
import org.springside.modules.web.MediaTypes; import org.springside.modules.web.MediaTypes;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

View File

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springside.modules.utils.text.JsonMapper; import org.springside.modules.utils.mapper.JsonMapper;
import org.springside.modules.web.MediaTypes; import org.springside.modules.web.MediaTypes;
/** /**

View File

@@ -33,7 +33,7 @@ import org.springside.examples.bootapi.dto.BookDto;
import org.springside.examples.bootapi.repository.BookDao; import org.springside.examples.bootapi.repository.BookDao;
import org.springside.examples.bootapi.service.exception.ErrorCode; import org.springside.examples.bootapi.service.exception.ErrorCode;
import org.springside.modules.test.data.RandomData; import org.springside.modules.test.data.RandomData;
import org.springside.modules.utils.text.JsonMapper; import org.springside.modules.utils.mapper.JsonMapper;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

View File

@@ -94,18 +94,6 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
<scope>test</scope>
</dependency>
<!-- TEST end --> <!-- TEST end -->
</dependencies> </dependencies>

View File

@@ -118,6 +118,22 @@
<version>${logback.version}</version> <version>${logback.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- only for XMLMapper test -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
<scope>test</scope>
</dependency>
<!-- TEST end --> <!-- TEST end -->
</dependencies> </dependencies>

View File

@@ -3,7 +3,7 @@
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/ *******************************************************************************/
package org.springside.modules.utils.reflect; package org.springside.modules.utils.mapper;
import java.util.List; import java.util.List;

View File

@@ -3,7 +3,7 @@
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/ *******************************************************************************/
package org.springside.modules.utils.text; package org.springside.modules.utils.mapper;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;

View File

@@ -3,7 +3,7 @@
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/ *******************************************************************************/
package org.springside.modules.web; package org.springside.modules.utils.mapper;
import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
@@ -32,7 +32,7 @@ import org.springside.modules.utils.reflect.ClassUtil;
* *
* @author calvin * @author calvin
*/ */
public class JaxbMapper { public class XmlMapper {
private static ConcurrentMap<Class, JAXBContext> jaxbContexts = new ConcurrentHashMap<Class, JAXBContext>(); private static ConcurrentMap<Class, JAXBContext> jaxbContexts = new ConcurrentHashMap<Class, JAXBContext>();

View File

@@ -1,4 +1,4 @@
package org.springside.modules.utils.reflect; package org.springside.modules.utils.mapper;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@@ -6,6 +6,7 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.springside.modules.utils.collection.ListUtil; import org.springside.modules.utils.collection.ListUtil;
import org.springside.modules.utils.mapper.BeanMapper;
import ma.glasnost.orika.metadata.Type; import ma.glasnost.orika.metadata.Type;

View File

@@ -3,7 +3,7 @@
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/ *******************************************************************************/
package org.springside.modules.utils.text; package org.springside.modules.utils.mapper;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@@ -14,6 +14,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.junit.Test; import org.junit.Test;
import org.springside.modules.utils.mapper.JsonMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -172,7 +173,7 @@ public class JsonMapperTest {
public void update() { public void update() {
TestBean bean = new TestBean("A"); TestBean bean = new TestBean("A");
bean.setDefaultValue("lalala"); bean.setDefaultValue("lalala");
JsonMapper.INSTANCE.update("{\"name\":\"B\"", bean); JsonMapper.INSTANCE.update("{\"name\":\"B\"}", bean);
assertThat(bean.getName()).isEqualTo("B"); assertThat(bean.getName()).isEqualTo("B");
assertThat(bean.getDefaultValue()).isEqualTo("lalala"); assertThat(bean.getDefaultValue()).isEqualTo("lalala");
} }

View File

@@ -3,7 +3,7 @@
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/ *******************************************************************************/
package org.springside.modules.mapper; package org.springside.modules.utils.mapper;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@@ -22,7 +22,7 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.junit.Test; import org.junit.Test;
import org.springside.modules.web.JaxbMapper; import org.springside.modules.utils.mapper.XmlMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -42,7 +42,7 @@ import com.google.common.collect.Lists;
* </user> * </user>
* </pre> * </pre>
*/ */
public class JaxbMapperTest { public class XmlMapperTest {
@Test @Test
public void objectToXml() { public void objectToXml() {
@@ -53,7 +53,7 @@ public class JaxbMapperTest {
user.getInterests().add("movie"); user.getInterests().add("movie");
user.getInterests().add("sports"); user.getInterests().add("sports");
String xml = JaxbMapper.toXml(user, "UTF-8"); String xml = XmlMapper.toXml(user, "UTF-8");
System.out.println("Jaxb Object to Xml result:\n" + xml); System.out.println("Jaxb Object to Xml result:\n" + xml);
assertXmlByDom4j(xml); assertXmlByDom4j(xml);
} }
@@ -61,7 +61,7 @@ public class JaxbMapperTest {
@Test @Test
public void xmlToObject() { public void xmlToObject() {
String xml = generateXmlByDom4j(); String xml = generateXmlByDom4j();
User user = JaxbMapper.fromXml(xml, User.class); User user = XmlMapper.fromXml(xml, User.class);
System.out.println("Jaxb Xml to Object result:\n" + user); System.out.println("Jaxb Xml to Object result:\n" + user);
@@ -84,7 +84,7 @@ public class JaxbMapperTest {
List<User> userList = Lists.newArrayList(user1, user2); List<User> userList = Lists.newArrayList(user1, user2);
String xml = JaxbMapper.toXml(userList, "userList", User.class, "UTF-8"); String xml = XmlMapper.toXml(userList, "userList", User.class, "UTF-8");
System.out.println("Jaxb Object List to Xml result:\n" + xml); System.out.println("Jaxb Object List to Xml result:\n" + xml);
} }