Vanilla Jhispter:无法运行测试(SocketTimeOut Exception)

时间:2017-04-10 14:59:44

标签: jhipster

我使用带有gradle和mongoDB选项的JHipster生成了一个新的应用程序。 Gradle汇编得很好:

brew reinstall xz --universal

当我希望进行单一测试时,问题就出现了:

    c:\webs\workspace-jhipster\jpoc>gradle clean compileJava compileTestJava
:clean
:cleanResources UP-TO-DATE
:bootBuildInfo
:nodeSetup SKIPPED
:npmSetup SKIPPED
:webpackBuildDev SKIPPED
:processResources
:compileJava
:classes
:compileTestJava

BUILD SUCCESSFUL

Total time: 6.704 secs

输出:

gradle test --tests com.jpoc.service.UserServiceIntTest

我很确定这是一个配置错误的问题,但我不知道哪一个。

我使用最新的jhipster 4.2.0

谢谢。

1 个答案:

答案 0 :(得分:0)

要使用spring boot在测试套件中设置mongoDB代理,我举了例如:

 @BeforeClass
    public static void setup_mongo() throws UnknownHostException, IOException{

        String proxyHost = "proxy.priv.atos.fr";
        String proxyPort = "3128";

        String proxy = System.getenv("http_proxy");
        System.out.println("Proxy URL : " + proxy);
        if(proxy != null){
            if(proxyHost == null && proxyPort == null){
                URL proxyurl = new URL(proxy);
               proxyHost = proxyurl.getHost();
               proxyPort = String.valueOf(proxyurl.getPort());
            }  
        }

        MongodStarter starter ;

        System.out.println("Proxy Host : " + proxyHost);
        System.out.println("Proxy Port : " + proxyPort);
        if (proxyHost != null && proxyPort != null) {
            IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(Command.MongoD)
                    .artifactStore(
                            new ArtifactStoreBuilder().defaults(Command.MongoD)
                                    .download(
                                            new DownloadConfigBuilder()
                                                    .defaultsForCommand(Command.MongoD)
                                                    .proxyFactory(
                                                            new HttpProxyFactory(
                                                                    proxyHost,
                                                                    Integer.parseInt(proxyPort)))
                                                    .build()).build()).build();
             starter = MongodStarter.getInstance(runtimeConfig);
        } else {
             starter = MongodStarter.getDefaultInstance();
        }


        IMongodConfig mongodConfig = new MongodConfigBuilder()
                .version(Version.Main.PRODUCTION)
                .net(new Net(0, Network.localhostIsIPv6())).build();

        MongodExecutable mongodExecutable = null;

        mongodExecutable = starter.prepare(mongodConfig);
         mongodExecutable.start();

    }

像这样,它下载mongoDB服务器并尝试运行它。下一个问题是我没有权限在JVM中运行此可执行文件。