Commit d8a19e3d authored by Liang Ding's avatar Liang Ding

💚 修复单元测试

parent 4159beb0
......@@ -456,7 +456,10 @@ public class PreferenceConsole {
renderer.setJSONObject(ret);
try {
final JSONObject requestJSONObject = context.requestJSON();
final String ossServer = requestJSONObject.optString(ID_C_CLOUD_STORAGE_KEY).trim();
String ossServer = requestJSONObject.optString(ID_C_CLOUD_STORAGE_KEY).trim();
if (StringUtils.isBlank(ossServer)) {
ossServer = CATEGORY_C_QINIU;
}
final String accessKey = requestJSONObject.optString("ossAccessKey").trim();
final String secretKey = requestJSONObject.optString("ossSecretKey").trim();
String domain = requestJSONObject.optString("ossDomain").trim();
......
......@@ -33,7 +33,7 @@ import java.io.StringReader;
* {@link PreferenceConsole} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Dec 11, 2018
* @version 1.0.0.1, Dec 23, 2018
* @since 2.9.8
*/
@Test(suiteName = "processor")
......@@ -159,20 +159,21 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
}
/**
* updateQiniu.
* updateOss.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void updateQiniu() throws Exception {
public void updateOss() throws Exception {
final JSONObject p = new JSONObject();
p.put(Option.ID_C_CLOUD_STORAGE_KEY, Option.CATEGORY_C_QINIU);
p.put(Option.ID_C_QINIU_ACCESS_KEY, "1");
p.put(Option.ID_C_QINIU_SECRET_KEY, "1");
p.put(Option.ID_C_QINIU_DOMAIN, "1");
p.put(Option.ID_C_QINIU_BUCKET, "1");
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/preference/qiniu");
request.setRequestURI("/console/preference/oss");
request.setMethod("PUT");
final BufferedReader reader = new BufferedReader(new StringReader(p.toString()));
request.setReader(reader);
......@@ -187,15 +188,15 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
}
/**
* getQiniuPreference.
* getOssPreference.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "updateQiniu")
public void getQiniuPreference() throws Exception {
@Test(dependsOnMethods = "updateOss")
public void getOssPreference() throws Exception {
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/preference/qiniu");
request.setRequestURI("/console/preference/oss");
request.putParameter(Option.ID_C_CLOUD_STORAGE_KEY, Option.CATEGORY_C_QINIU);
mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse();
......
......@@ -40,8 +40,8 @@
</div>
</li>
<li>
<div id="tabPreference_qiniu">
<a href="#toos/preference/qiniu">${qiniuLabel}</a>
<div id="tabPreference_oss">
<a href="#toos/preference/oss">${ossServerLabel}</a>
</div>
</li>
<li>
......@@ -89,7 +89,7 @@
</select>
<label for="timeZoneId">${timeZoneId1Label}</label>
<select id="timeZoneId">
${timeZoneIdOptions}
${timeZoneIdOptions}
</select>
<label for="articleListDisplay">${articleListDisplay1Label}</label>
<select id="articleListDisplay">
......@@ -172,21 +172,25 @@
<button onclick="admin.preference.update()" class="right">${updateLabel}</button>
<div class="clear"></div>
</div>
<div id="tabPreferencePanel_qiniu" class="none form">
<span class="right">
<div id="tabPreferencePanel_oss" class="none form">
<span class="right">
<a href="https://hacpai.com/article/1442418791213" target="_blank">${howConfigLabel}</a>
&nbsp;
<button onclick="admin.preference.updateQiniu()">${updateLabel}</button>
<button onclick="admin.preference.updateOss()">${updateLabel}</button>
</span>
${qiniuOssLabel}
<input name="ossServer" id= "qiniuOss" type="radio" value="qiniu" onclick="admin.preference.ossServerChange()"/>
${aliyunOssLabel}
<input name="ossServer" id= "aliyunOss" type="radio" value="aliyun" onclick="admin.preference.ossServerChange()"/>
<div class="clear"></div>
<label for="qiniuAccessKey">${accessKey1Label}</label>
<input id="qiniuAccessKey" type="text"/>
<label for="qiniuSecretKey">${secretKey1Label}</label>
<input id="qiniuSecretKey" type="text"/>
<label for="qiniuDomain">${domain1Label}</label>
<input id="qiniuDomain" type="text"/>
<label for="qiniuBucket">${bucket1Label}</label>
<input id="qiniuBucket" type="text"/>
<label for="osSAccessKey">${accessKey1Label}</label>
<input id="ossAccessKey" type="text"/>
<label for="ossSecretKey">${secretKey1Label}</label>
<input id="ossSecretKey" type="text"/>
<label for="ossDomain">${domain1Label}</label>
<input id="ossDomain" type="text"/>
<label for="ossBucket">${bucket1Label}</label>
<input id="ossBucket" type="text"/>
</div>
</div>
${plugins}
\ No newline at end of file
${plugins}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment