Commit d8a19e3d authored by Liang Ding's avatar Liang Ding

💚 修复单元测试

parent 4159beb0
...@@ -456,7 +456,10 @@ public class PreferenceConsole { ...@@ -456,7 +456,10 @@ public class PreferenceConsole {
renderer.setJSONObject(ret); renderer.setJSONObject(ret);
try { try {
final JSONObject requestJSONObject = context.requestJSON(); 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 accessKey = requestJSONObject.optString("ossAccessKey").trim();
final String secretKey = requestJSONObject.optString("ossSecretKey").trim(); final String secretKey = requestJSONObject.optString("ossSecretKey").trim();
String domain = requestJSONObject.optString("ossDomain").trim(); String domain = requestJSONObject.optString("ossDomain").trim();
......
...@@ -33,7 +33,7 @@ import java.io.StringReader; ...@@ -33,7 +33,7 @@ import java.io.StringReader;
* {@link PreferenceConsole} test case. * {@link PreferenceConsole} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 2.9.8
*/ */
@Test(suiteName = "processor") @Test(suiteName = "processor")
...@@ -159,20 +159,21 @@ public class PreferenceConsoleTestCase extends AbstractTestCase { ...@@ -159,20 +159,21 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
} }
/** /**
* updateQiniu. * updateOss.
* *
* @throws Exception exception * @throws Exception exception
*/ */
@Test(dependsOnMethods = "init") @Test(dependsOnMethods = "init")
public void updateQiniu() throws Exception { public void updateOss() throws Exception {
final JSONObject p = new JSONObject(); 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_ACCESS_KEY, "1");
p.put(Option.ID_C_QINIU_SECRET_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_DOMAIN, "1");
p.put(Option.ID_C_QINIU_BUCKET, "1"); p.put(Option.ID_C_QINIU_BUCKET, "1");
final MockHttpServletRequest request = mockRequest(); final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/preference/qiniu"); request.setRequestURI("/console/preference/oss");
request.setMethod("PUT"); request.setMethod("PUT");
final BufferedReader reader = new BufferedReader(new StringReader(p.toString())); final BufferedReader reader = new BufferedReader(new StringReader(p.toString()));
request.setReader(reader); request.setReader(reader);
...@@ -187,15 +188,15 @@ public class PreferenceConsoleTestCase extends AbstractTestCase { ...@@ -187,15 +188,15 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
} }
/** /**
* getQiniuPreference. * getOssPreference.
* *
* @throws Exception exception * @throws Exception exception
*/ */
@Test(dependsOnMethods = "updateQiniu") @Test(dependsOnMethods = "updateOss")
public void getQiniuPreference() throws Exception { public void getOssPreference() throws Exception {
final MockHttpServletRequest request = mockRequest(); 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); mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse(); final MockHttpServletResponse response = mockResponse();
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
</div> </div>
</li> </li>
<li> <li>
<div id="tabPreference_qiniu"> <div id="tabPreference_oss">
<a href="#toos/preference/qiniu">${qiniuLabel}</a> <a href="#toos/preference/oss">${ossServerLabel}</a>
</div> </div>
</li> </li>
<li> <li>
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
</select> </select>
<label for="timeZoneId">${timeZoneId1Label}</label> <label for="timeZoneId">${timeZoneId1Label}</label>
<select id="timeZoneId"> <select id="timeZoneId">
${timeZoneIdOptions} ${timeZoneIdOptions}
</select> </select>
<label for="articleListDisplay">${articleListDisplay1Label}</label> <label for="articleListDisplay">${articleListDisplay1Label}</label>
<select id="articleListDisplay"> <select id="articleListDisplay">
...@@ -172,21 +172,25 @@ ...@@ -172,21 +172,25 @@
<button onclick="admin.preference.update()" class="right">${updateLabel}</button> <button onclick="admin.preference.update()" class="right">${updateLabel}</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div id="tabPreferencePanel_qiniu" class="none form"> <div id="tabPreferencePanel_oss" class="none form">
<span class="right"> <span class="right">
<a href="https://hacpai.com/article/1442418791213" target="_blank">${howConfigLabel}</a> <a href="https://hacpai.com/article/1442418791213" target="_blank">${howConfigLabel}</a>
&nbsp; &nbsp;
<button onclick="admin.preference.updateQiniu()">${updateLabel}</button> <button onclick="admin.preference.updateOss()">${updateLabel}</button>
</span> </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> <div class="clear"></div>
<label for="qiniuAccessKey">${accessKey1Label}</label> <label for="osSAccessKey">${accessKey1Label}</label>
<input id="qiniuAccessKey" type="text"/> <input id="ossAccessKey" type="text"/>
<label for="qiniuSecretKey">${secretKey1Label}</label> <label for="ossSecretKey">${secretKey1Label}</label>
<input id="qiniuSecretKey" type="text"/> <input id="ossSecretKey" type="text"/>
<label for="qiniuDomain">${domain1Label}</label> <label for="ossDomain">${domain1Label}</label>
<input id="qiniuDomain" type="text"/> <input id="ossDomain" type="text"/>
<label for="qiniuBucket">${bucket1Label}</label> <label for="ossBucket">${bucket1Label}</label>
<input id="qiniuBucket" type="text"/> <input id="ossBucket" type="text"/>
</div> </div>
</div> </div>
${plugins} ${plugins}
\ No newline at end of file
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