diff --git a/gradle.properties b/gradle.properties index aa1b6ad2f..0f1b32306 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8 systemProp.file.encoding=UTF-8 org.gradle.daemon=true org.gradle.workers.max=8 -idea_version=2017.3.5 +idea_version=2019.1.4 kotlin_version=1.4.31 junit_version=5.7.1 descriptionFile=parts/pluginDescription.html diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/config/CachedResourceResolver.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/config/CachedResourceResolver.kt index 74d748799..e12876850 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/config/CachedResourceResolver.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/config/CachedResourceResolver.kt @@ -92,4 +92,4 @@ open class CachedResourceResolver : DefaultResourceResolver() { } private const val URL_CACHE_EXPIRE = "url.cache.expire" -private val LOG = org.apache.log4j.Logger.getLogger(CachedResourceResolver::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(CachedResourceResolver::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/DataEventCollector.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/DataEventCollector.kt index d1ecd9ce2..6138f5506 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/DataEventCollector.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/DataEventCollector.kt @@ -20,10 +20,7 @@ class DataEventCollector : DataContext { this.anActionEvent = anActionEvent } - override fun getData(dataId: String?): Any? { - if (dataId == null) { - return null - } + override fun getData(dataId: String): Any? { if (cache.containsKey(dataId)) { return cache[dataId] } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt index 56175532f..a10356e9b 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt @@ -1689,4 +1689,4 @@ fun LazyAction.disposable(): DisposableLazyAction { return DisposableLazyAction(this) } -private val LOG = org.apache.log4j.Logger.getLogger(DefaultMethodInferHelper::class.java) +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(DefaultMethodInferHelper::class.java) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt index a88db00b3..0a41d1e2a 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt @@ -442,4 +442,4 @@ open class DefaultPostmanApiHelper : PostmanApiHelper { } -private val LOG = org.apache.log4j.Logger.getLogger(DefaultPostmanApiHelper::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(DefaultPostmanApiHelper::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt index f89ff430f..7b04131a2 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt @@ -215,4 +215,4 @@ class PostmanApiExporter { } } -private val LOG = org.apache.log4j.Logger.getLogger(PostmanApiExporter::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(PostmanApiExporter::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanCachedApiHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanCachedApiHelper.kt index f0d357218..7103ef34d 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanCachedApiHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanCachedApiHelper.kt @@ -342,4 +342,4 @@ class PostmanCachedApiHelper : DefaultPostmanApiHelper(), CacheSwitcher { } } -private val LOG = org.apache.log4j.Logger.getLogger(PostmanCachedApiHelper::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(PostmanCachedApiHelper::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/configurable/AbstractEasyApiConfigurable.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/configurable/AbstractEasyApiConfigurable.kt index 27c1734a9..f899564d5 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/configurable/AbstractEasyApiConfigurable.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/configurable/AbstractEasyApiConfigurable.kt @@ -95,4 +95,4 @@ abstract class AbstractEasyApiConfigurable(private var myProject: Project?) : Se } } -private val LOG = org.apache.log4j.Logger.getLogger(EasyApiConfigurable::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(EasyApiConfigurable::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/AbstractApiDashboardDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/AbstractApiDashboardDialog.kt index 2bb4d6d99..c5f02ef26 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/AbstractApiDashboardDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/AbstractApiDashboardDialog.kt @@ -667,4 +667,4 @@ abstract class AbstractApiDashboardDialog : JDialog() { } } -private val LOG = org.apache.log4j.Logger.getLogger(AbstractApiDashboardDialog::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(AbstractApiDashboardDialog::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiDashboardDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiDashboardDialog.kt index bfba774a6..6c6ee9633 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiDashboardDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiDashboardDialog.kt @@ -1040,4 +1040,4 @@ class ApiDashboardDialog : AbstractApiDashboardDialog() { } -private val LOG = org.apache.log4j.Logger.getLogger(ApiDashboardDialog::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(ApiDashboardDialog::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt index c254f4ee6..fce6cac78 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt @@ -620,4 +620,4 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() { } } -private val LOG = org.apache.log4j.Logger.getLogger(YapiDashboardDialog::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(YapiDashboardDialog::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ScriptExecutorDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ScriptExecutorDialog.kt index 258fc2880..87bde6f55 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ScriptExecutorDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ScriptExecutorDialog.kt @@ -362,7 +362,7 @@ class ScriptExecutorDialog : JDialog() { this.editor = editor val debugDialog = this document.addDocumentListener(object : com.intellij.openapi.editor.event.DocumentListener { - override fun documentChanged(event: com.intellij.openapi.editor.event.DocumentEvent?) { + override fun documentChanged(event: com.intellij.openapi.editor.event.DocumentEvent) { autoComputer.value(debugDialog::scriptText, document.text) super.documentChanged(event) } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/YapiDashboardDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/YapiDashboardDialog.kt index 35027db6d..c68528380 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/YapiDashboardDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/YapiDashboardDialog.kt @@ -827,4 +827,4 @@ class YapiDashboardDialog : AbstractApiDashboardDialog() { } -private val LOG = org.apache.log4j.Logger.getLogger(YapiDashboardDialog::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(YapiDashboardDialog::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/render/AdaptiveMarkdownRender.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/render/AdaptiveMarkdownRender.kt index f860ff81c..d952be92a 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/render/AdaptiveMarkdownRender.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/render/AdaptiveMarkdownRender.kt @@ -87,4 +87,4 @@ class AdaptiveMarkdownRender : MarkdownRender { } } -private val LOG = org.apache.log4j.Logger.getLogger(AdaptiveMarkdownRender::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(AdaptiveMarkdownRender::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/Settings.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/Settings.kt index 8db3f1fab..e3fd21580 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/Settings.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/Settings.kt @@ -190,6 +190,10 @@ class Settings : ProjectSettingsSupport, ApplicationSettingsSupport { return result } + override fun toString(): String { + return "Settings(methodDocEnable=$methodDocEnable, genericEnable=$genericEnable, feignEnable=$feignEnable, quarkusEnable=$quarkusEnable, pullNewestDataBefore=$pullNewestDataBefore, postmanToken=$postmanToken, postmanWorkspace=$postmanWorkspace, postmanExportMode=$postmanExportMode, postmanCollections=$postmanCollections, wrapCollection=$wrapCollection, autoMergeScript=$autoMergeScript, postmanJson5FormatType='$postmanJson5FormatType', queryExpanded=$queryExpanded, formExpanded=$formExpanded, readGetter=$readGetter, readSetter=$readSetter, inferEnable=$inferEnable, inferMaxDeep=$inferMaxDeep, yapiServer=$yapiServer, yapiTokens=$yapiTokens, enableUrlTemplating=$enableUrlTemplating, switchNotice=$switchNotice, loginMode=$loginMode, yapiReqBodyJson5=$yapiReqBodyJson5, yapiResBodyJson5=$yapiResBodyJson5, httpTimeOut=$httpTimeOut, trustHosts=${trustHosts.contentToString()}, useRecommendConfig=$useRecommendConfig, recommendConfigs='$recommendConfigs', logLevel=$logLevel, logCharset='$logCharset', outputDemo=$outputDemo, outputCharset='$outputCharset', markdownFormatType='$markdownFormatType', builtInConfig=$builtInConfig)" + } + companion object { const val DEFAULT_INFER_MAX_DEEP = 4 diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinder.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinder.kt index 6a0dd21b4..c345f5137 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinder.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinder.kt @@ -27,8 +27,8 @@ class XmlSettingBinder : SettingBinder { override fun save(t: Settings?) { if (t == null) { - projectSettingsComponent?.loadState(null) - applicationSettingsComponent.loadState(null) + projectSettingsComponent?.loadState(ProjectSettings()) + applicationSettingsComponent.loadState(ApplicationSettings()) return } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettings.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettings.kt index 2c44fc2b0..35bce6f73 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettings.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettings.kt @@ -2,6 +2,7 @@ package com.itangcent.idea.plugin.settings.xml import com.itangcent.idea.plugin.settings.MarkdownFormatType import com.itangcent.idea.plugin.settings.PostmanJson5FormatType +import com.itangcent.idea.plugin.settings.Settings import com.itangcent.idea.plugin.settings.helper.RecommendConfigLoader import com.itangcent.idea.utils.Charsets @@ -113,7 +114,7 @@ class ApplicationSettings : ApplicationSettingsSupport { override var inferEnable: Boolean = false - override var inferMaxDeep: Int = 0 + override var inferMaxDeep: Int = Settings.DEFAULT_INFER_MAX_DEEP //endregion @@ -138,7 +139,7 @@ class ApplicationSettings : ApplicationSettingsSupport { //unit:s override var httpTimeOut: Int = 5 - override var trustHosts: Array = emptyArray() + override var trustHosts: Array = Settings.DEFAULT_TRUST_HOSTS //endregion diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettingsComponent.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettingsComponent.kt index 0ce5293a8..0a31bf038 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettingsComponent.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/xml/ApplicationSettingsComponent.kt @@ -17,7 +17,7 @@ class ApplicationSettingsComponent : PersistentStateComponent { return projectSettings?.copy() } - override fun loadState(state: ProjectSettings?) { + override fun loadState(state: ProjectSettings) { this.projectSettings = state } } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/sqlite/SqliteDataResourceHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/sqlite/SqliteDataResourceHelper.kt index 79b784c5b..0fa475515 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/sqlite/SqliteDataResourceHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/sqlite/SqliteDataResourceHelper.kt @@ -320,4 +320,4 @@ fun SqliteDataResourceHelper.ExpiredBeanDAO.delete(str: String) { this.delete(str.toByteArray(Charsets.UTF_8)) } -private val LOG = org.apache.log4j.Logger.getLogger(SqliteDataResourceHelper::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(SqliteDataResourceHelper::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/Charsets.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/Charsets.kt index 7554e350b..9adadded9 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/Charsets.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/Charsets.kt @@ -57,8 +57,9 @@ abstract class Charsets { * Returns a charset object for the named charset. */ fun forName(charset: String): Charsets? { - return SUPPORTED_CHARSETS.firstOrNull { it.displayName() == charset } - ?: tryLoadCharset(charset) + return SUPPORTED_CHARSETS.firstOrNull { + it.displayName() == charset || it.charset().name() == charset + } ?: tryLoadCharset(charset) } /** diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt index e83c8b2de..86f70211c 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt @@ -71,7 +71,7 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { val obj = try { GsonExUtils.fromJson(valueText) } catch (e: Exception) { - LOG.error("failed parse json:\n$valueText\n", e) + LOG.warn("failed parse json:\n$valueText\n", e) return } if (isOriginal(obj)) { @@ -132,4 +132,4 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { } } -private val LOG = org.apache.log4j.Logger.getLogger(CustomizedPsiClassHelper::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(CustomizedPsiClassHelper::class.java) \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/JacksonUtils.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/JacksonUtils.kt index fe7566979..db438344a 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/JacksonUtils.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/JacksonUtils.kt @@ -14,7 +14,7 @@ object JacksonUtils { init { objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY) - objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL) + objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL) objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } @@ -48,4 +48,4 @@ object JacksonUtils { } } -private val LOG = org.apache.log4j.Logger.getLogger(JacksonUtils::class.java) +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(JacksonUtils::class.java) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/spi/SpiCompositeLoader.kt b/idea-plugin/src/main/kotlin/com/itangcent/spi/SpiCompositeLoader.kt index 906c2663e..68c0f83cc 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/spi/SpiCompositeLoader.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/spi/SpiCompositeLoader.kt @@ -66,5 +66,5 @@ object SpiCompositeLoader { return exclusions } - val LOG = org.apache.log4j.Logger.getLogger(SpiCompositeLoader::class.java)!! + val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(SpiCompositeLoader::class.java)!! } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/task/Task.kt b/idea-plugin/src/main/kotlin/com/itangcent/task/Task.kt index c932b6b77..8fd7ccb97 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/task/Task.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/task/Task.kt @@ -165,7 +165,7 @@ abstract class BaseTask( } Thread.sleep(100) } - LOG.error("wait task $this done timeout") + LOG.warn("wait task $this done timeout") } override fun disposed(): Boolean { @@ -237,4 +237,4 @@ abstract class AsyncTask(actionContext: ActionContext, taskManager: TaskManager) return ret } } -private val LOG = org.apache.log4j.Logger.getLogger(Task::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(Task::class.java) \ No newline at end of file diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/render/RemoteMarkdownRenderTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/render/RemoteMarkdownRenderTest.kt index 2e1d8f0e2..c2c908a43 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/render/RemoteMarkdownRenderTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/render/RemoteMarkdownRenderTest.kt @@ -10,6 +10,7 @@ import org.apache.http.entity.ContentType import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test import java.util.concurrent.CountDownLatch +import java.util.concurrent.CyclicBarrier import java.util.concurrent.atomic.AtomicInteger import kotlin.test.assertEquals import kotlin.test.assertNull @@ -37,9 +38,9 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .response(content = "

Header

", - contentType = ContentType.TEXT_PLAIN).build()) + .url("http://www.itangcent.com/render") + .response(content = "

Header

", + contentType = ContentType.TEXT_PLAIN).build()) } } @@ -65,9 +66,9 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .response(content = "

Header

", - contentType = ContentType.TEXT_PLAIN).build()) + .url("http://www.itangcent.com/render") + .response(content = "

Header

", + contentType = ContentType.TEXT_PLAIN).build()) } } @@ -80,7 +81,7 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { val md = "# Header" val html = markdownRender.render(md) assertEquals( - "

Header

", html + "

Header

", html ) } } @@ -91,8 +92,8 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .response(responseCode = 404).build()) + .url("http://www.itangcent.com/render") + .response(responseCode = 404).build()) } } @@ -113,9 +114,9 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .failed(IllegalArgumentException()) - .build() + .url("http://www.itangcent.com/render") + .failed(IllegalArgumentException()) + .build() ) } } @@ -137,12 +138,12 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .response(content = "

Header

", - contentType = ContentType.TEXT_PLAIN, - elapse = 3000) - .currentTotalLimit(4, IllegalArgumentException("limited!")) - .build()) + .url("http://www.itangcent.com/render") + .response(content = "

Header

", + contentType = ContentType.TEXT_PLAIN, + elapse = 3000) + .currentTotalLimit(4, IllegalArgumentException("limited!")) + .build()) } } @@ -151,19 +152,22 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { assertNull(markdownRender.render("")) assertNull(markdownRender.render("\t")) - val countDownLatch = CountDownLatch(6) + val countDownLatch = CountDownLatch(7) + val cyclicBarrier = CyclicBarrier(7) val failed = AtomicInteger() - for (i in 0..6) { + + @Language("Markdown") + val md = "# Header" + for (i in 1..7) { Thread { try { - @Language("Markdown") - val md = "# Header" + cyclicBarrier.await() val html = markdownRender.render(md) if (html == null) { failed.incrementAndGet() } else { assertEquals( - "

Header

", html + "

Header

", html ) } } finally { @@ -182,12 +186,12 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { super.bind(builder) builder.bind(HttpClientProvider::class) { it.toInstance(HttpClientProviderMockBuilder.builder() - .url("http://www.itangcent.com/render") - .response(content = "

Header

", - contentType = ContentType.TEXT_PLAIN, - elapse = 3000) - .currentTotalLimit(7, IllegalArgumentException("limited!")) - .build()) + .url("http://www.itangcent.com/render") + .response(content = "

Header

", + contentType = ContentType.TEXT_PLAIN, + elapse = 3000) + .currentTotalLimit(7, IllegalArgumentException("limited!")) + .build()) } } @@ -204,7 +208,7 @@ internal open class RemoteMarkdownRenderTest : AdvancedContextTest() { val md = "# Header" val html = markdownRender.render(md) assertEquals( - "

Header

", html + "

Header

", html ) } finally { countDownLatch.countDown() diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/DefaultSettingBinderTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/DefaultSettingBinderTest.kt index 75b25dded..445aa7073 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/DefaultSettingBinderTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/DefaultSettingBinderTest.kt @@ -22,7 +22,10 @@ internal class DefaultSettingBinderTest : PluginContextLightCodeInsightFixtureTe fun testReadAndSave() { - assertNull(settingBinder.tryRead()) + settingBinder.save(null) + settingBinder.tryRead().let { + assertTrue(it == null || it == Settings()) + } val settings = settingBinder.read() assertEquals(Settings(), settings) diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinderTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinderTest.kt index f98e25c7c..95002dc0a 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinderTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/XmlSettingBinderTest.kt @@ -1,9 +1,6 @@ package com.itangcent.idea.plugin.settings import com.google.inject.Inject -import com.intellij.openapi.components.ServiceManager -import com.itangcent.idea.plugin.settings.xml.ApplicationSettingsComponent -import com.itangcent.idea.plugin.settings.xml.ProjectSettingsComponent import com.itangcent.intellij.context.ActionContext import com.itangcent.intellij.extend.guice.with import com.itangcent.testFramework.PluginContextLightCodeInsightFixtureTestCase @@ -24,7 +21,10 @@ internal class XmlSettingBinderTest : PluginContextLightCodeInsightFixtureTestCa fun testReadAndSave() { - assertNull(settingBinder.tryRead()) + settingBinder.save(null) + settingBinder.tryRead().let { + assertTrue(it == null || it == Settings()) + } val settings = settingBinder.read() assertEquals(Settings(), settings) @@ -39,7 +39,7 @@ internal class XmlSettingBinderTest : PluginContextLightCodeInsightFixtureTestCa assertEquals(settings, settingBinder.tryRead()) settingBinder.save(null) - assertNull(settingBinder.tryRead()) + assertEquals(Settings(), settingBinder.tryRead()) } } \ No newline at end of file diff --git a/idea-plugin/src/test/kotlin/com/itangcent/task/AsyncTaskTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/task/AsyncTaskTest.kt index 963a5f983..261550de1 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/task/AsyncTaskTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/task/AsyncTaskTest.kt @@ -146,4 +146,4 @@ internal class AsyncTaskTest : BaseContextTest() { } } -private val LOG = org.apache.log4j.Logger.getLogger(AsyncTaskTest::class.java) \ No newline at end of file +private val LOG = com.intellij.openapi.diagnostic.Logger.getInstance(AsyncTaskTest::class.java) \ No newline at end of file diff --git a/idea-plugin/src/test/kotlin/com/itangcent/test/HttpClientProviderMockBuilder.kt b/idea-plugin/src/test/kotlin/com/itangcent/test/HttpClientProviderMockBuilder.kt index a381db808..1d82ac42a 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/test/HttpClientProviderMockBuilder.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/test/HttpClientProviderMockBuilder.kt @@ -88,8 +88,10 @@ class HttpClientProviderMockBuilder : RequestStub { throw error } } - afterCall { _, _, _ -> - cnt.decrementAndGet() + afterCall { _, _, e -> + if (e != null) { + cnt.decrementAndGet() + } } return this; } @@ -115,7 +117,7 @@ class HttpClientProviderMockBuilder : RequestStub { class RequestHandle( val requestMatcher: (HttpUriRequest) -> Boolean, - val response: () -> HttpResponse, priority: Int? + val response: () -> HttpResponse, priority: Int?, ) { val priority: Int @@ -131,7 +133,7 @@ class RequestHandle( class MockHttpClient( private val handles: List, private val before: ((HttpUriRequest) -> Unit)?, - private val after: ((HttpUriRequest, HttpResponse?, Throwable?) -> Unit)? + private val after: ((HttpUriRequest, HttpResponse?, Throwable?) -> Unit)?, ) : HttpClient { private val delegate: HttpClient by lazy { @@ -189,7 +191,7 @@ class MockHttpClient( override fun execute( request: HttpUriRequest?, responseHandler: ResponseHandler?, - context: HttpContext? + context: HttpContext?, ): T? { return responseHandler?.handleResponse(request?.let { handleRequest(it) }) } @@ -197,7 +199,7 @@ class MockHttpClient( override fun execute( target: HttpHost?, request: HttpRequest?, - responseHandler: ResponseHandler? + responseHandler: ResponseHandler?, ): T { TODO("Not yet implemented") } @@ -206,7 +208,7 @@ class MockHttpClient( target: HttpHost?, request: HttpRequest?, responseHandler: ResponseHandler?, - context: HttpContext? + context: HttpContext?, ): T { TODO("Not yet implemented") } @@ -259,7 +261,7 @@ interface ResponseStub { responseCode: Int = 200, contentType: ContentType = ContentType.APPLICATION_JSON, headers: Array>? = null, - elapse: Long? = null + elapse: Long? = null, ): HttpClientProviderMockBuilder fun failed(e: Throwable, elapse: Long? = null): HttpClientProviderMockBuilder @@ -284,7 +286,7 @@ class CallStub : RequestStub, ResponseStub { internal constructor( builder: HttpClientProviderMockBuilder, requestMatcher: (HttpUriRequest) -> Boolean, - priority: Int + priority: Int, ) { this.builder = builder this.requestMatcher = requestMatcher @@ -319,7 +321,7 @@ class CallStub : RequestStub, ResponseStub { override fun failed( e: Throwable, - elapse: Long? + elapse: Long?, ): HttpClientProviderMockBuilder { builder.addHandle(RequestHandle(this.requestMatcher, { elapse?.let { Thread.sleep(elapse) } @@ -334,7 +336,7 @@ class CallStub : RequestStub, ResponseStub { responseCode: Int, contentType: ContentType, headers: Array>?, - elapse: Long? + elapse: Long?, ): HttpClientProviderMockBuilder { builder.addHandle(RequestHandle(this.requestMatcher, { elapse?.let { Thread.sleep(elapse) } @@ -348,7 +350,7 @@ class CallStub : RequestStub, ResponseStub { contentByte: ByteArray?, responseCode: Int, headers: Array>?, - contentType: ContentType + contentType: ContentType, ): BasicHttpResponse { //build response val httpEntity = BasicHttpEntity() diff --git a/idea-plugin/src/test/kotlin/com/itangcent/test/SelectWorkDirOrFileKt.kt b/idea-plugin/src/test/kotlin/com/itangcent/test/SelectWorkDirOrFileKt.kt index 5fd43ca19..3b2a4ad0c 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/test/SelectWorkDirOrFileKt.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/test/SelectWorkDirOrFileKt.kt @@ -26,19 +26,19 @@ fun ActionContextBuilder.workAt(vararg psiDirectory: PsiDirectory) { } private class WorkAtFile(private val psiFile: PsiFile) : DataContext { - override fun getData(dataId: String?): Any? { + override fun getData(dataId: String): Any? { return if (CommonDataKeys.PSI_FILE.name == dataId) psiFile else null } } private class WorkAtDirectory(private val psiDirectory: PsiDirectory) : DataContext { - override fun getData(dataId: String?): Any? { + override fun getData(dataId: String): Any? { return if (CommonDataKeys.NAVIGATABLE.name == dataId) psiDirectory else null } } private class WorkAtDirectoryArray(private val psiDirectory: Array) : DataContext { - override fun getData(dataId: String?): Any? { + override fun getData(dataId: String): Any? { return if (CommonDataKeys.NAVIGATABLE_ARRAY.name == dataId) psiDirectory else null } } \ No newline at end of file