小编Ala*_*Dea的帖子

如何使用SBT运行JUnit 4.11测试用例?

我在build.sbt中有以下内容:

libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"

libraryDependencies += "junit" % "junit" % "4.11" % "test"
Run Code Online (Sandbox Code Playgroud)

我注意到junit-interface 0.10依赖于junit-dep 4.10.这使得无法编译使用junit 4.11中引入的assertNotEquals的测试.

如何使用SBT运行JUnit 4.11测试用例?

junit sbt

9
推荐指数
2
解决办法
5870
查看次数

如何设置IDEA以自动配置Scala facet用于混合Scala/Java Maven项目?

如何让IntelliJ在具有混合Scala和Java源代码的Maven项目中自动配置Scala方面?

我正在使用Scala Plugin Nightly for Maia Build 2099.

mvn compilemvn test都可以从命令提示符和IntelliJ中的Maven Projects面板进行操作.但是,如果我尝试直接在IntelliJ中运行ScalaSpec,则会出现错误对话框无法使用内容编译Scala文件请在Scala facet中指定编译器.

项目目录结构:

MixedJavaScala
?   MixedScalaJava.iml
?   pom.xml
?
????src
    ????main
    ?   ????java
    ?   ?       HelloJava.java
    ?   ?
    ?   ????scala
    ?           HelloScala.scala
    ?
    ????test
        ????java
        ?       TestJava.java
        ?
        ????scala
                ScalaSpec.scala
Run Code Online (Sandbox Code Playgroud)

HelloJava.java列表:

public class HelloJava {}
Run Code Online (Sandbox Code Playgroud)

HelloScala.scala列表:

class HelloScala
Run Code Online (Sandbox Code Playgroud)

TestJava.java列表:

public class TestJava
{
    @org.junit.Test public void example() {}
}
Run Code Online (Sandbox Code Playgroud)

ScalaSpec.scala列表:

class ScalaSpec extends org.specs.Specification { …
Run Code Online (Sandbox Code Playgroud)

java maven-2 scala intellij-idea maven

8
推荐指数
1
解决办法
5409
查看次数

如何将Class <?>与Hamcrest匹配器中的特定Class实例进行匹配?

我希望能够断言注释值与期望的类匹配:

import org.junit.Test;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;

public final class AnnotatedClassTest {
    @Test
    public void someAnnotationIsString() {
        assertThat(
            AnnotatedClass.class.getAnnotation(SomeAnnotation.class).value(),
            is(equalTo(String.class));
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,这是一个类型错误:

AnnotatedClassTest.java:9: error: no suitable method found for assertThat(Class<CAP#1>,Matcher<Class<String>>)
        assertThat(
        ^
    method MatcherAssert.<T#1>assertThat(T#1,Matcher<? super T#1>) is not applicable
      (actual argument Matcher<Class<String>> cannot be converted to Matcher<? super Class<CAP#1>> by method invocation conversion)
    method MatcherAssert.<T#2>assertThat(String,T#2,Matcher<? super T#2>) is not applicable
      (cannot instantiate from arguments because actual and formal argument lists differ in length)
    method MatcherAssert.assertThat(String,boolean) is not …
Run Code Online (Sandbox Code Playgroud)

java generics junit hamcrest junit4

8
推荐指数
1
解决办法
6132
查看次数

我是否可以获得仅限访问单个组织的Github访问令牌?

我需要通过github api访问组织中的私有存储库.

我使用我的个人访问令牌,但它提供了我不希望它拥有的私人仓库的访问权限.

是否可以创建只访问一个组织的访问令牌,而不是所有私有存储库?

github-api

8
推荐指数
1
解决办法
2285
查看次数

使用依赖存储桶名称的模板设置 S3 存储桶策略时如何避免循环错误?

我有一个terraform运行时失败的文件,terraform plan我收到错误消息:

Error: Cycle: module.hosting.data.template_file.bucket_policy, module.hosting.aws_s3_bucket.website
Run Code Online (Sandbox Code Playgroud)

这是有道理的,因为存储桶指的是策略,反之亦然:

data "template_file" "bucket_policy" {
  template = file("${path.module}/policy.json")
  vars = {
    bucket = aws_s3_bucket.website.arn
  }
}

resource "aws_s3_bucket" "website" {
  bucket = "xxx-website"

  website {
    index_document = "index.html"
  }

  policy = data.template_file.bucket_policy.rendered
}
Run Code Online (Sandbox Code Playgroud)

如何避免这种双向引用?

amazon-web-services terraform terraform-template-file terraform-provider-aws

8
推荐指数
2
解决办法
715
查看次数

如何使用HTTP客户端传递客户端证书?

我想在服务A和B之间使用相互SSL身份验证.我目前正在实现从Java中的服务A传递客户端证书.我正在使用Apache DefaultHttpClient来执行我的请求.我能够从内部凭据管理器检索我的服务A的客户端证书,并将其保存为字节数组.

DefaultHttpClient client = new DefaultHttpClient();
byte [] certificate = localCertManager.retrieveCert();
Run Code Online (Sandbox Code Playgroud)

我在这方面的经验很少,我很感激你的帮助!

我想也许它应该以某种方式通过HTTP客户端或可能在标头中的参数传递.

如何使用HTTP客户端传递客户端证书?

apache ssl https ssl-certificate apache-commons-httpclient

6
推荐指数
2
解决办法
2万
查看次数

在Java中进行对数螺旋

import java.io.*;
import java.awt.*;

// Logarithmic spiral example
public class Spiral extends Frame
{// The spiral consists of n line segments. Line segment 1
// has starting point (hc, vc). Line segment k, for 1<=k<=n,
// has length k*d. Each line segment makes an angle of turn
// degrees with the previous line segment. The colors of the
// lines alternate between red, blue, and green.

final static int hc= 500;   // Center of spiral is (hc,vc)
final static int …
Run Code Online (Sandbox Code Playgroud)

java spiral

6
推荐指数
1
解决办法
1239
查看次数

随机提供者的守护者映射解决了什么问题?

我试图了解terraform random 提供者的keeper功能的用例。我阅读了文档,但它不适合我。具体示例是什么,使用 keeper 地图的情况以及原因。下面复制的文档示例。

resource "random_id" "server" {
  keepers = {
    # Generate a new id each time we switch to a new AMI id
    ami_id = "${var.ami_id}"
  }

  byte_length = 8
}

resource "aws_instance" "server" {
  tags = {
    Name = "web-server ${random_id.server.hex}"
  }

  # Read the AMI id "through" the random_id resource to ensure that
  # both will change together.
  ami = "${random_id.server.keepers.ami_id}"

  # ... (other aws_instance arguments) ...
}
Run Code Online (Sandbox Code Playgroud)

terraform

6
推荐指数
1
解决办法
5381
查看次数

你如何阻止Guice注入一个没有绑定在模块中的类?

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;

public class GuiceDemo
{
    public static void main(String[] args)
    {
        new GuiceDemo().run();
    }

    public void run()
    {
        Injector injector = Guice.createInjector(new EmptyModule());
        DemoInstance demoInstance = injector.getInstance(DemoInstance.class);
        assert(demoInstance.demoUnbound == null);
    }

    public static class EmptyModule extends AbstractModule
    {
        @Override
        protected void configure()
        {
        }
    }

    public static class DemoInstance
    {
        public final DemoUnbound demoUnbound;

        @Inject
        public DemoInstance(DemoUnbound demoUnbound)
        {
            this.demoUnbound = demoUnbound;
        }
    }

    public static class DemoUnbound
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以阻止Guice向DemoInstance的构造函数提供DemoUnbound实例吗?

本质上,我正在寻找一种在完全显式的绑定模式下运行Guice的方法,其中注入未绑定的类是一个错误. …

java guice

5
推荐指数
2
解决办法
3148
查看次数

如何检测 HttpServletRequest 的 TLS 版本?

我正在逐步停止对 Web 应用程序的 TLS 1.0 和 TLS 1.1 的支持。

我想根据他们与我的服务器建立的连接来检测这将影响的用户。

我正在运行 Tomcat 7 和 Java 8。

如何检测 HttpServletRequest 的 TLS 版本?

java tomcat servlets

5
推荐指数
1
解决办法
2808
查看次数