类org.junit.internal.matchers.ThrowableMessageMatcher源码实例Demo

下面列出了怎么用org.junit.internal.matchers.ThrowableMessageMatcher的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: obevo   文件: TableChangeParserTest.java
@Test
public void noMetadataContentAllowedAfterFirstLine1() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Instead, found this section in between")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "//// METADATA\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码2 项目: obevo   文件: TableChangeParserTest.java
@Test
public void noMetadataContentAllowedAfterFirstLine3() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Instead, found this section in between")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// METADATA\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "//// METADATA\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码3 项目: beam   文件: ViewTest.java
private void testViewUnbounded(
    Pipeline pipeline,
    PTransform<PCollection<KV<String, Integer>>, ? extends PCollectionView<?>> view) {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Unable to create a side-input view from input");
  thrown.expectCause(
      ThrowableMessageMatcher.hasMessage(Matchers.containsString("non-bounded PCollection")));
  pipeline
      .apply(
          new PTransform<PBegin, PCollection<KV<String, Integer>>>() {
            @Override
            public PCollection<KV<String, Integer>> expand(PBegin input) {
              return PCollection.createPrimitiveOutputInternal(
                  input.getPipeline(),
                  WindowingStrategy.globalDefault(),
                  PCollection.IsBounded.UNBOUNDED,
                  KvCoder.of(StringUtf8Coder.of(), VarIntCoder.of()));
            }
          })
      .apply(view);
}
 
源代码4 项目: beam   文件: DataflowViewTest.java
private void testViewUnbounded(
    Pipeline pipeline,
    PTransform<PCollection<KV<String, Integer>>, ? extends PCollectionView<?>> view) {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Unable to create a side-input view from input");
  thrown.expectCause(
      ThrowableMessageMatcher.hasMessage(Matchers.containsString("non-bounded PCollection")));
  pipeline
      .apply(
          new PTransform<PBegin, PCollection<KV<String, Integer>>>() {
            @Override
            public PCollection<KV<String, Integer>> expand(PBegin input) {
              return PCollection.createPrimitiveOutputInternal(
                  input.getPipeline(),
                  WindowingStrategy.globalDefault(),
                  PCollection.IsBounded.UNBOUNDED,
                  KvCoder.of(StringUtf8Coder.of(), VarIntCoder.of()));
            }
          })
      .apply(view);
}
 
源代码5 项目: beam   文件: DirectRunnerTest.java
@Test
public void transformDisplayDataExceptionShouldFail() {
  DoFn<Integer, Integer> brokenDoFn =
      new DoFn<Integer, Integer>() {
        @ProcessElement
        public void processElement(ProcessContext c) throws Exception {}

        @Override
        public void populateDisplayData(DisplayData.Builder builder) {
          throw new RuntimeException("oh noes!");
        }
      };

  Pipeline p = getPipeline();
  p.apply(Create.of(1, 2, 3)).apply(ParDo.of(brokenDoFn));

  thrown.expectMessage(brokenDoFn.getClass().getName());
  thrown.expectCause(ThrowableMessageMatcher.hasMessage(is("oh noes!")));
  p.run();
}
 
源代码6 项目: obevo   文件: TableChangeParserTest.java
@Test
public void invalidNoContentAllowedInMetadata() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "contentNotAllowedHere\n" +
            "//// METADATA\n" +
            "invalid content\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码7 项目: obevo   文件: TableChangeParserTest.java
@Test
public void invalidNoContentAllowedInPrologue1() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "contentNotAllowedHere\n" +
            "//// METADATA\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码8 项目: obevo   文件: TableChangeParserTest.java
@Test
public void invalidNoContentAllowedInPrologue2() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "contentNotAllowedHere\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码9 项目: obevo   文件: TableChangeParserTest.java
@Test
public void invalidNoContentAllowedInPrologue3() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// CHANGE sections found")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "contentNotAllowedHere\n" +
            "CREATE TABLE;\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码10 项目: obevo   文件: TableChangeParserTest.java
@Test
public void noMetadataContentAllowedAfterFirstLine2() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Instead, found this section in between")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "\n" +
            "//// CHANGE name=chng1\n" +
            "CREATE TABLE;\n" +
            "//// METADATA\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码11 项目: obevo   文件: TableChangeParserTest.java
@Test
public void noContentAtAll1() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections found; at least one is required")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码12 项目: obevo   文件: TableChangeParserTest.java
@Test
public void noContentAtAll2() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections found; at least one is required")));

    TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType);
    String fileContent = "\n" +
            "//// METADATA\n" +
            "";

    parser.value(tableChangeType, null, fileContent, objectName, "schema", null);
}
 
源代码13 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noContentInPrologue() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Improper section ordering: METADATA section must come before the content section")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "prologueContentBeforeSections" +
            "//// METADATA\n" +
            "";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码14 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noChangeSectionAllowed1() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these disallowed sections")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// CHANGE name=abc";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码15 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noChangeSectionAllowed2() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these disallowed sections")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "//// CHANGE name=abc";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码16 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noMultipleMetadataSections1() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [METADATA")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// DROP\n" +
            "//// METADATA\n" +
            "";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码17 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noMultipleMetadataSections2() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [METADATA")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// METADATA\n" +
            "";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码18 项目: obevo   文件: RerunnableChangeParserTest.java
@Test
public void noMultipleDropSections() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [DROP_COMMAND")));

    RerunnableChangeParser parser = new RerunnableChangeParser();
    String fileContent = "\n" +
            "//// METADATA\n" +
            "//// DROP_COMMAND\n" +
            "//// DROP_COMMAND\n" +
            "";

    parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null);
}
 
源代码19 项目: beam   文件: ViewTest.java
@Test
@Category(NeedsRunner.class)
public void testMapSideInputWithNullValuesCatchesDuplicates() {

  final PCollectionView<Map<String, Integer>> view =
      pipeline
          .apply(
              "CreateSideInput",
              Create.of(KV.of("a", (Integer) null), KV.of("a", (Integer) null))
                  .withCoder(
                      KvCoder.of(StringUtf8Coder.of(), NullableCoder.of(VarIntCoder.of()))))
          .apply(View.asMap());

  PCollection<KV<String, Integer>> output =
      pipeline
          .apply("CreateMainInput", Create.of("apple", "banana", "blackberry"))
          .apply(
              "OutputSideInputs",
              ParDo.of(
                      new DoFn<String, KV<String, Integer>>() {
                        @ProcessElement
                        public void processElement(ProcessContext c) {
                          c.output(
                              KV.of(
                                  c.element(),
                                  c.sideInput(view)
                                      .getOrDefault(c.element().substring(0, 1), 0)));
                        }
                      })
                  .withSideInputs(view));

  PAssert.that(output)
      .containsInAnyOrder(KV.of("apple", 1), KV.of("banana", 3), KV.of("blackberry", 3));

  // PipelineExecutionException is thrown with cause having a message stating that a
  // duplicate is not allowed.
  thrown.expectCause(
      ThrowableMessageMatcher.hasMessage(Matchers.containsString("Duplicate values for a")));
  pipeline.run();
}
 
源代码20 项目: beam   文件: ViewTest.java
private void testViewNonmerging(
    Pipeline pipeline,
    PTransform<PCollection<KV<String, Integer>>, ? extends PCollectionView<?>> view) {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Unable to create a side-input view from input");
  thrown.expectCause(
      ThrowableMessageMatcher.hasMessage(Matchers.containsString("Consumed by GroupByKey")));
  pipeline
      .apply(Create.of(KV.of("hello", 5)))
      .apply(
          Window.into(
              new InvalidWindows<>(
                  "Consumed by GroupByKey", FixedWindows.of(Duration.standardHours(1)))))
      .apply(view);
}
 
源代码21 项目: beam   文件: DataflowViewTest.java
private void testViewNonmerging(
    Pipeline pipeline,
    PTransform<PCollection<KV<String, Integer>>, ? extends PCollectionView<?>> view) {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Unable to create a side-input view from input");
  thrown.expectCause(
      ThrowableMessageMatcher.hasMessage(Matchers.containsString("Consumed by GroupByKey")));
  pipeline
      .apply(Create.of(KV.of("hello", 5)))
      .apply(
          Window.into(
              new InvalidWindows<>(
                  "Consumed by GroupByKey", FixedWindows.of(Duration.standardHours(1)))))
      .apply(view);
}
 
源代码22 项目: java-client-api   文件: BulkInputCallerTest.java
@Test
public void bulkInputEndpointInterruptTest() throws Exception {
    String apiName = "bulkInputCallerImpl.api";

    String endpointState = "{\"next\":"+startValue+"}";
    String workUnit      = "{\"max\":"+workMax+"}";
    ObjectNode apiObj     = IOTestUtil.readApi(apiName);
    String     scriptPath = IOTestUtil.getScriptPath(apiObj);
    String     apiPath    = IOTestUtil.getApiPath(scriptPath);
    IOTestUtil.load(apiName, apiObj, scriptPath, apiPath);
    InputEndpoint loadEndpt = InputEndpoint.on(IOTestUtil.db, new JacksonHandle(apiObj));

    InputEndpoint.BulkInputCaller loader = loadEndpt.bulkCaller();
    loader.setEndpointState(new ByteArrayInputStream(endpointState.getBytes()));
    loader.setWorkUnit(new ByteArrayInputStream(workUnit.getBytes()));

    Stream<InputStream> input         = Stream.of(
            IOTestUtil.asInputStream("{\"docNum\":1, \"docName\":\"doc1\"}"),
            IOTestUtil.asInputStream("{\"docNum\":2, \"docName\":\"doc2\"}"),
            IOTestUtil.asInputStream("{\"docNum\":3, \"docName\":\"doc3\"}")
    );

    Stream<InputStream> input2         = Stream.of(
            IOTestUtil.asInputStream("{\"docNum\":4, \"docName\":\"doc4\"}"),
            IOTestUtil.asInputStream("{\"docNum\":5, \"docName\":\"doc5\"}"),
            IOTestUtil.asInputStream("{\"docNum\":6, \"docName\":\"doc6\"}"));

    input.forEach(loader::accept);
    loader.interrupt();

    expectedException.expect(IllegalStateException.class);
    expectedException.expect(new ThrowableMessageMatcher(new StringContains("cannot accept more input as current phase is  INTERRUPTING")));
    input2.forEach(loader::accept);
}
 
源代码23 项目: java-client-api   文件: BulkOutputCallerTest.java
@Test
public void bulkOutputCallerWithNullConsumer() {
    OutputEndpoint loadEndpt = OutputEndpoint.on(IOTestUtil.db, new JacksonHandle(apiObj));
    OutputEndpoint.BulkOutputCaller loader = loadEndpt.bulkCaller();

    expectedException.expect(IllegalStateException.class);
    expectedException.expect(new ThrowableMessageMatcher(new StringContains("Output consumer is null")));
    loader.awaitCompletion();
}
 
@Test
public void nonWritableBasedir() throws IOException {
	String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
	this.expected.expectCause(ThrowableMessageMatcher
			.hasMessage(containsString("Cannot write parent")));
	this.context = new SpringApplicationBuilder(TestConfiguration.class)
			.web(WebApplicationType.NONE)
			.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri,
					"spring.cloud.config.server.git.basedir:/tmp")
			.run();
}
 
 类所在包
 同包方法