linrf 2 years ago
parent 3c26d5ae78
commit 64c230113f

@ -2,11 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>framework</artifactId>
<groupId>com.docus</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.docus</groupId>
<artifactId>docus-soap-api-client</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
@ -24,58 +20,66 @@
<name>docus-soap-api-client</name>
<properties>
<java.version>1.8</java.version>
<spring.version>5.0.2.RELEASE</spring.version>
<spring-ws.version>3.0.10.RELEASE</spring-ws.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>${spring-ws.version}</version>
</dependency>
<dependency>
<groupId>com.docus</groupId>
<artifactId>docus-tool-starter</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,31 @@
package com.docus.soap.api;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import java.io.IOException;
import java.util.Properties;
public class DefaultAppContextInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {
@Override
public void initialize(ConfigurableWebApplicationContext context) {
PropertyLoader propertyLoader = new PropertyLoader();
try {
propertyLoader.setLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:*.properties"));
context.getEnvironment().setIgnoreUnresolvableNestedPlaceholders(true);
context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("properties", propertyLoader.loadProperties()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
static class PropertyLoader extends PropertySourcesPlaceholderConfigurer {
Properties loadProperties() throws IOException {
return mergeProperties();
}
}
}

@ -1,13 +0,0 @@
package com.docus.soap.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DocusSoapApplication {
public static void main(String[] args) {
SpringApplication.run(DocusSoapApplication.class, args);
}
}

@ -7,8 +7,9 @@ public class EnableSoapAPIClientSelector extends AdviceModeImportSelector<Enable
@Override
protected String[] selectImports(AdviceMode adviceMode) {
if (adviceMode != AdviceMode.PROXY)
if (adviceMode != AdviceMode.PROXY) {
throw new IllegalStateException("@EnableSoapAPIClient only support PROXY advice mode.");
}
return new String[]{SoapAPIConfig.class.getName()};
}
}

@ -1,11 +1,11 @@
package com.docus.soap.api.service;
import com.docus.core.util.json.JSON;
import com.docus.soap.api.SoapAPIClient;
import com.docus.soap.api.SoapAPISettings;
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
import com.docus.soap.api.response.complain.ComplaintListResult;
import com.docus.soap.api.response.complain.GetTableByIdDateResponse;
import com.docus.soap.api.util.JSON;
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
public class ComplaintAPIService {

@ -0,0 +1,126 @@
package com.docus.soap.api.util;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public final class Convert {
public static final String DATE_FORMAT_DATE = "MM/dd/yyyy";
public static final String DATE_FORMAT_DATETIME = "MM/dd/yyyy'T'HH:mm:ss";
public static final String DATA_FORMAT_DATETIME_SLASH = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_FORMAT_ISO_WITH_TIMEZONE = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
public static Integer toInt(String text, Integer defaultValue) {
if (!StringUtils.hasText(text)) {
return defaultValue;
}
try {
return Integer.parseInt(text);
} catch (NumberFormatException e) {
return defaultValue;
}
}
public static Long toLong(String text, Long defaultValue) {
if (!StringUtils.hasText(text)) {
return defaultValue;
}
try {
return Long.parseLong(text);
} catch (NumberFormatException e) {
return defaultValue;
}
}
public static Double toDouble(String text, Double defaultValue) {
if (!StringUtils.hasText(text)) {
return defaultValue;
}
try {
return Double.parseDouble(text);
} catch (NumberFormatException e) {
return defaultValue;
}
}
// since DateFormat is not thread safe, we create for each parsing
public static Date toDate(String date, String formatPattern, Date defaultValue) {
if (!StringUtils.hasText(date)) {
return defaultValue;
}
try {
SimpleDateFormat format = new SimpleDateFormat(formatPattern);
return format.parse(date);
} catch (ParseException e) {
return defaultValue;
}
}
public static Date toDate(String date, String formatPattern) {
try {
SimpleDateFormat format = new SimpleDateFormat(formatPattern);
return format.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
public static Date toDate(String date, Date defaultValue) {
return toDate(date, DATE_FORMAT_DATE, defaultValue);
}
public static Date toDateTime(String date, Date defaultValue) {
return toDate(date, DATE_FORMAT_DATETIME, defaultValue);
}
public static Date toISODateTime(String date, Date defaultValue) {
return toDate(date, DATE_FORMAT_ISO_WITH_TIMEZONE, defaultValue);
}
public static String toString(Date date, String format) {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);
}
public static String toString(Date date, String format, TimeZone timeZone) {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setTimeZone(timeZone);
return dateFormat.format(date);
}
public static XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
DatatypeFactory factory;
try {
factory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new IllegalStateException(e);
}
XMLGregorianCalendar result = factory.newXMLGregorianCalendar();
Calendar calendar = DateUtils.calendar(date);
result.setYear(calendar.get(Calendar.YEAR));
result.setMonth(calendar.get(Calendar.MONTH) + 1);
result.setDay(calendar.get(Calendar.DAY_OF_MONTH));
result.setTime(calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
return result;
}
public static <T extends Enum<T>> T toEnum(String value, Class<T> enumClass, T defaultValue) {
if (!StringUtils.hasText(value)) {
return defaultValue;
}
try {
return Enum.valueOf(enumClass, value);
} catch (IllegalArgumentException e) {
return defaultValue;
}
}
private Convert() {
}
}

@ -0,0 +1,117 @@
package com.docus.soap.api.util;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* Date should be considered as immutable object (e.g. String), all methods in
* this util return new instance
*/
public final class DateUtils {
public static Date date(int year, int month, int day) {
return date(year, month, day, 0, 0, 0);
}
public static Date date(int year, int month, int day, int hour, int minute, int second) {
Calendar calendar = Calendar.getInstance();
calendar.setLenient(false);
calendar.set(year, month, day, hour, minute, second);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public static Calendar calendar(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
}
public static Date add(Date date, int field, int value) {
Calendar calendar = calendar(date);
calendar.add(field, value);
return calendar.getTime();
}
public static int get(Date date, int field) {
Calendar calendar = calendar(date);
return calendar.get(field);
}
public static Date withField(Date date, int field, int value) {
Calendar calendar = calendar(date);
calendar.set(field, value);
return calendar.getTime();
}
public static int getYear(Date date) {
return get(date, Calendar.YEAR);
}
public static int getMonth(Date date) {
return get(date, Calendar.MONTH);
}
public static int getDay(Date date) {
return get(date, Calendar.DATE);
}
public static int getHour(Date date) {
return get(date, Calendar.HOUR_OF_DAY);
}
public static int getMinute(Date date) {
return get(date, Calendar.MINUTE);
}
public static Date withHour(Date date, int value) {
return withField(date, Calendar.HOUR_OF_DAY, value);
}
public static Date withMinute(Date date, int value) {
return withField(date, Calendar.MINUTE, value);
}
public static Date toCurrentTimeZone(Date targetDate, TimeZone targetTimeZone) {
Calendar target = calendar(targetDate);
Calendar result = Calendar.getInstance(targetTimeZone);
result.set(Calendar.YEAR, target.get(Calendar.YEAR));
result.set(Calendar.MONTH, target.get(Calendar.MONTH));
result.set(Calendar.DATE, target.get(Calendar.DATE));
result.set(Calendar.HOUR_OF_DAY, target.get(Calendar.HOUR_OF_DAY));
result.set(Calendar.MINUTE, target.get(Calendar.MINUTE));
result.set(Calendar.SECOND, target.get(Calendar.SECOND));
result.set(Calendar.MILLISECOND, target.get(Calendar.MILLISECOND));
return result.getTime();
}
public static boolean isWeekDay(Date targetDate) {
Calendar calendar = calendar(targetDate);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
return dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY;
}
public static boolean isDateValid(int year, int month, int day) {
try {
date(year, month, day);
return true;
} catch (Exception e) {
return false;
}
}
public static Date truncateTime(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
private DateUtils() {
}
}

@ -0,0 +1,68 @@
package com.docus.soap.api.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import java.io.IOException;
public class JSON {
public static String toJSON(Object obj) {
return toJSON(ObjectMapperBuilder.defaultObjectMapper(), obj);
}
public static String toJSON(ObjectMapperBuilder builder, Object obj) {
try {
return builder.get().writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new RuntimeIOException(e);
}
}
public static <T> T fromJSON(String json, Class<T> exceptClass) {
return fromJSON(ObjectMapperBuilder.defaultObjectMapper(), json, exceptClass);
}
public static <T> T fromJSON(ObjectMapperBuilder builder, String json, Class<T> exceptClass) {
try {
return builder.get().readValue(json, exceptClass);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
public static <T> T fromJSONWithGeneric(String json, TypeReference<T> genericType) {
return fromJSONWithGeneric(ObjectMapperBuilder.defaultObjectMapper(), json, genericType);
}
/**
* exampleList<T> jsonList = JSON.fromJSONWithGeneric(JSON.toJSON(list), new TypeReference<List<T>>(){})
*/
public static <T> T fromJSONWithGeneric(ObjectMapperBuilder builder, String json, TypeReference<T> genericType) {
try {
return builder.get().readValue(json, genericType);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
public static <T> T fromJSONWithGeneric(String json, JavaType javaType) {
return fromJSONWithGeneric(ObjectMapperBuilder.defaultObjectMapper(), json, javaType);
}
/**
* @param builder {@see ObjectMapperBuilder}
* @param json value
* @param javaType {@link com.fasterxml.jackson.databind.type.TypeFactory#constructParametricType} or {@link com.fasterxml.jackson.databind.ObjectMapper#constructType}
* @param <T> result Type
* @return result
*/
public static <T> T fromJSONWithGeneric(ObjectMapperBuilder builder, String json, JavaType javaType) {
try {
return builder.get().readValue(json, javaType);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
}

@ -0,0 +1,55 @@
package com.docus.soap.api.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.IOException;
@Deprecated
public final class JSONBinder<T> {
static final ObjectMapper DEFAULT_OBJECT_MAPPER;
static {
DEFAULT_OBJECT_MAPPER = ObjectMapperBuilder.defaultObjectMapper().get();
}
public static <T> JSONBinder<T> binder(Class<T> beanClass) {
return new JSONBinder<>(beanClass);
}
public static ObjectMapper getObjectMapper() {
return DEFAULT_OBJECT_MAPPER;
}
ObjectMapper objectMapper;
private final Class<T> beanClass;
private JSONBinder(Class<T> beanClass) {
this.beanClass = beanClass;
this.objectMapper = DEFAULT_OBJECT_MAPPER;
}
public T fromJSON(String json) {
try {
return objectMapper.readValue(json, beanClass);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String toJSON(T object) {
try {
return objectMapper.writeValueAsString(object);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public JSONBinder<T> indentOutput() {
if (DEFAULT_OBJECT_MAPPER.equals(objectMapper)) {
objectMapper = ObjectMapperBuilder.defaultObjectMapper().rebirth().get();
}
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
return this;
}
}

@ -0,0 +1,82 @@
package com.docus.soap.api.util;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
public class JSONDateFormat extends DateFormat {
private static final long serialVersionUID = 1L;
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
toAppendTo.append(Convert.toString(date, Convert.DATE_FORMAT_ISO_WITH_TIMEZONE));
return toAppendTo;
}
@Override
public Date parse(String source, ParsePosition pos) {
pos.setIndex(source.length());
if (isContainChar(source, '-')) {
if (Convert.DATA_FORMAT_DATETIME_SLASH.length() == source.length()) {
return Convert.toDate(source, Convert.DATA_FORMAT_DATETIME_SLASH);
} else {
return Convert.toDate(source, getISOPattern(source));
}
}
if ("MM/dd/yyyyTHH:mm:ss".length() == source.length()) {
//TODO: remove legacy format
return Convert.toDate(source, Convert.DATE_FORMAT_DATETIME);
}
return Convert.toDate(source, Convert.DATE_FORMAT_DATE);
}
public boolean isContainChar(String source, char character) {
if (!StringUtils.hasText(source)) {
return false;
}
for (char c : source.toCharArray()) {
if (character == c) {
return true;
}
}
return false;
}
public String getISOPattern(String source) {
StringBuilder b = new StringBuilder("yyyy-MM-dd'T'HH:mm:ss");
int precision = 0;
int state = 0;
for (int i = "yyyy-MM-ddTHH:mm:ss".length(); i < source.length(); i++) {
char c = source.charAt(i);
if (c == '.' && state == 0) {
state = 1;
} else if (c == '-' || c == '+' || c == 'Z') {
if (state > 0) {
b.append('.');
//support million seconds
for (int j = 0; j < precision; j++) {
b.append('S');
}
}
b.append("XXX");
break;
} else if (state == 1) {
precision++;
}
}
return b.toString();
}
@Override
public Object clone() {
return this;
}
}

@ -1,6 +1,5 @@
package com.docus.soap.api.util;
import com.docus.core.util.json.ObjectMapperBuilder;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;

@ -0,0 +1,63 @@
package com.docus.soap.api.util;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
public class ObjectMapperBuilder {
static final ObjectMapper DEFAULT_OBJECT_MAPPER;
static {
DEFAULT_OBJECT_MAPPER = createMapper();
}
public static ObjectMapper getObjectMapper() {
return DEFAULT_OBJECT_MAPPER;
}
private static ObjectMapper createMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new JSONDateFormat());
AnnotationIntrospector primary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
return mapper;
}
private boolean changed = false;
private ObjectMapper objectMapper;
public ObjectMapperBuilder() {
this.objectMapper = DEFAULT_OBJECT_MAPPER;
}
public ObjectMapper get() {
return objectMapper;
}
public static ObjectMapperBuilder defaultObjectMapper() {
return new ObjectMapperBuilder();
}
public ObjectMapperBuilder rebirth() {
if (!changed && DEFAULT_OBJECT_MAPPER.equals(objectMapper)) {
objectMapper = createMapper();
}
return this;
}
public ObjectMapperBuilder indent() {
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
changed = true;
return this;
}
}

@ -0,0 +1,8 @@
package com.docus.soap.api.util;
public final class RuntimeIOException extends RuntimeException {
public RuntimeIOException(Throwable cause) {
super(cause);
}
}

@ -1,8 +1,5 @@
package com.docus.soap.api.util;
import com.docus.core.util.Convert;
import com.docus.core.util.StringUtils;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.util.Date;

@ -0,0 +1,69 @@
package com.docus.soap.api.util;
import java.util.regex.Pattern;
public final class StringUtils {
private static final Pattern PATTERN_GUID = Pattern.compile("^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$");
private static final Pattern PATTERN_SAFE_STRING = Pattern.compile("^[.\\-,#&\\p{Alnum}\\p{Space}]*$");
public static boolean isGUID(String input) {
if (!StringUtils.hasText(input)) {
return false;
}
return PATTERN_GUID.matcher(input).matches();
}
public static int compare(String text1, String text2) {
if (text1 == null && text2 == null)
return 0;
if (text1 != null && text2 == null) {
return 1;
}
if (text1 == null) {
return -1;
}
return text1.compareTo(text2);
}
public static boolean hasText(String text) {
if (text == null)
return false;
for (int i = 0; i < text.length(); i++) {
if (!Character.isWhitespace(text.charAt(i)))
return true;
}
return false;
}
public static boolean equals(String text1, String text2) {
if (text1 == null)
return text2 == null;
return text1.equals(text2);
}
public static String truncate(String text, int maxLength) {
if (text == null)
return null;
if (text.length() <= maxLength)
return text;
return text.substring(0, maxLength);
}
public static String trim(String text) {
if (text == null)
return null;
return text.trim();
}
public static boolean isSafeString(String value) {
if (!StringUtils.hasText(value)) {
return true;
}
return PATTERN_SAFE_STRING.matcher(value).matches();
}
private StringUtils() {
}
}

@ -0,0 +1,2 @@
soap.complaint.api.url=http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
soap.complaint.api.action=SOF_GetQRCodeBySys

@ -1,3 +0,0 @@
soap:
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
complaint.api.action: SOF_GetQRCodeBySys

@ -1,29 +1,22 @@
package com.docus.soap.api;
import com.docus.core.util.AssertUtils;
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
import com.docus.soap.api.response.complain.ComplaintListResult;
import com.docus.soap.api.service.ComplaintAPIService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.core.env.Environment;
import javax.inject.Inject;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DocusSoapApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ComplaintAPIServiceTest {
public class ComplaintAPIServiceTest extends SpringTest {
private final Logger logger = LoggerFactory.getLogger(ComplaintAPIServiceTest.class);
@Value("${soap.complaint.api.url}")
public String soapComplaintUrl;
@Value("${soap.complaint.api.action}")
public String soapComplaintAction;
@Inject
private Environment env;
@Inject
private ComplaintAPIService complaintAPIService;
@ -34,13 +27,13 @@ public class ComplaintAPIServiceTest {
GetTableByIdDateRequest request = new GetTableByIdDateRequest();
request.setSys("JSScan");
ComplaintListResult result = complaintAPIService.getTableByIdDate(request, getTableByIdDateSettings());
AssertUtils.assertNotNull(result, "not null");
Assert.assertNotNull("not null", result);
}
private SoapAPISettings getTableByIdDateSettings() {
SoapAPISettings soapAPISettings = new SoapAPISettings();
soapAPISettings.setAction(soapComplaintAction);
soapAPISettings.setUri(soapComplaintUrl);
soapAPISettings.setAction(env.getProperty("soap.complaint.api.action"));
soapAPISettings.setUri(env.getProperty("soap.complaint.api.url"));
return soapAPISettings;
}
}

@ -0,0 +1,17 @@
package com.docus.soap.api;
import org.junit.runner.RunWith;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestEnvironmentConfig.class}, initializers = DefaultAppContextInitializer.class)
@TransactionConfiguration
@ActiveProfiles("test")
@WebAppConfiguration
public abstract class SpringTest {
}

@ -0,0 +1,12 @@
package com.docus.soap.api;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
@Profile("test")
@Configuration
@Import(SoapAPIConfig.class)
public class TestEnvironmentConfig {
}

@ -0,0 +1,2 @@
soap.complaint.api.url=http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
soap.complaint.api.action=SOF_GetQRCodeBySys

@ -1,3 +0,0 @@
soap:
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
complaint.api.action: SOF_GetQRCodeBySys
Loading…
Cancel
Save