gpt4 book ai didi

grails - 测试在Amazon和Codeship上失败

转载 作者:行者123 更新时间:2023-12-02 16:02:29 25 4
gpt4 key购买 nike

在Groovy中使用Dropbox和Google Drive构建应用程序,测试运行良好。

码:

 def "It instantiates and configures the googleAuthorizationCodeFlowBuilder component"() {
given:
def ctx = grailsApplication.mainContext
GoogleAuthorizationCodeFlow.Builder builder = ctx.googleAuthorizationCodeFlowBuilder

expect:
}

但是,在Codeship和Amazon上运行时,测试失败:

Message: Error creating bean with name 'googleAuthorizationCodeFlowBuilder': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder]: Constructor threw exception; nested exception is java.lang.NullPointerException

Line | Method ->> 285 | autowireConstructor in org.springframework.beans.factory.support.ConstructorResolver

| 1075 | autowireConstructor in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory

/* stuff */

org.apache.catalina.core.ContainerBase$StartChild | 1549 | call in '' | 262 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread

Caused by BeanInstantiationException: Could not instantiate bean class [com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder]: Constructor threw exception; nested exception is java.lang.NullPointerException ->> 163 | instantiateClass in org.springframework.beans.BeanUtils

| 121 | instantiate in org.springframework.beans.factory.support.SimpleInstantiationStrategy | 277 | autowireConstructor . . . . . . in org.springframework.beans.factory.support.ConstructorResolver | 1075 | autowireConstructor in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory | 979 | createBeanInstance . . . . . . in '' | 487 | doCreateBean in '' | 123 | doCreateBean . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor

/* more stacktrace */

| 615 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread



googleAuthorizationflowBuilder Bean仅创建一个GoogleAuthorizationCodeFlow.Builder(我使用Google Java API)。

编辑1:我通过修改doWithSpring重现了我的机器上的错误:
def doWithSpring = {
def config = application.config
String googleSecret = getConfigValue(config, 'storage.google.secret')
String googleAppId = null//getConfigValue(config, 'storage.google.appId')
String appName = getConfigValue(config, 'storage.appName')

if (!ConfigUtils.optional(config,'storage.google.disabled')) {
googleNetHttpTransport(NetHttpTransport)
googleJsonFactory(JacksonFactory)
googleCredentialsBuilder(GoogleCredential.Builder) {
transport = googleNetHttpTransport
jsonFactory = googleJsonFactory
}
googleAuthorizationCodeFlowBuilder(GoogleAuthorizationCodeFlow.Builder, ref('googleNetHttpTransport'), ref('googleJsonFactory'),
googleAppId, googleSecret, [DRIVE])
}
}

编辑2:似乎错误专门发生在AppId为null时...问题是为什么它在云上而不是在我的机器上为null ...

最佳答案

好的,似乎未在Codebase项目上设置用于初始化Config.groovy的值的环境变量,从而导致上述错误。

缺少的环境变量已在Codeship上初始化,并且现在一切正常。

关于grails - 测试在Amazon和Codeship上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29142381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com