当前位置: 首页>>代码示例>>Java>>正文


Java ExpectedException.none方法代码示例

本文整理汇总了Java中org.junit.rules.ExpectedException.none方法的典型用法代码示例。如果您正苦于以下问题:Java ExpectedException.none方法的具体用法?Java ExpectedException.none怎么用?Java ExpectedException.none使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.rules.ExpectedException的用法示例。


在下文中一共展示了ExpectedException.none方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: noValueForSize

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void noValueForSize() throws IOException {
    thrown = ExpectedException.none();
    // Basic division by zero.
    final Token token = def("a", div(con(1), con(0)));
    assertFalse(token.parse(env(stream(1))).isPresent());
    // Try to negate division by zero.
    final Token token2 = def("a", neg(div(con(1), con(0))));
    assertFalse(token2.parse(env(stream(1))).isPresent());
    // Add one to division by zero.
    final Token token3 = def("a", add(div(con(1), con(0)), con(1)));
    assertFalse(token3.parse(env(stream(1))).isPresent());
    // Add division by zero to one.
    final Token token4 = def("a", add(con(1), div(con(1), con(0))));
    assertFalse(token4.parse(env(stream(1))).isPresent());
}
 
开发者ID:parsingdata,项目名称:metal,代码行数:17,代码来源:ErrorsTest.java

示例2: testExceptionThrownWhenMisConfigured

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void testExceptionThrownWhenMisConfigured() throws Exception {
  Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
  conf.set("hbase.thrift.security.qop", "privacy");
  conf.setBoolean("hbase.thrift.ssl.enabled", false);

  ThriftServerRunner runner = null;
  ExpectedException thrown = ExpectedException.none();
  try {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Thrift HTTP Server's QoP is privacy, " +
        "but hbase.thrift.ssl.enabled is false");
    runner = new ThriftServerRunner(conf);
    fail("Thrift HTTP Server starts up even with wrong security configurations.");
  } catch (Exception e) {
  }

  assertNull(runner);
}
 
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:TestThriftHttpServer.java

示例3: testAnnotationBasedParser

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void testAnnotationBasedParser() {
    expectedEx = ExpectedException.none();

    MyMapper mapper = new MyMapper();

    TestRecord record = new TestRecord("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " +
        "Chrome/48.0.2564.82 Safari/537.36");

    record = mapper.enrich(record);

    assertEquals("Desktop", record.deviceClass);
    assertEquals("Chrome 48.0.2564.82", record.agentNameVersion);
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:15,代码来源:TestAnnotationSystem.java

示例4: tearDown

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
    //单个测试案例执行完之后,引用置空,防止数据污染
    tEmployee = null;
    tEmployeeExample = null;
    expectedException = ExpectedException.none();
}
 
开发者ID:xmomen,项目名称:easy-mybatis,代码行数:8,代码来源:MybatisDaoTest.java

示例5: testMakeFromUrlAndPath

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void testMakeFromUrlAndPath() throws Exception {
    if (expectedResult == null) {
        expectedException.expect(IllegalArgumentException.class);
    } else {
        expectedException = ExpectedException.none();
    }

    assertThat(UrlHelper.makeFromUrlAndPath(url, path)).isEqualTo(expectedResult);
}
 
开发者ID:jakriz,项目名称:derrick,代码行数:11,代码来源:UrlHelperTest.java

示例6: nsdManagementOnboardTest

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void nsdManagementOnboardTest()
    throws NotFoundException, BadFormatException, NetworkServiceIntegrityException,
        CyclicDependenciesException, EntityInUseException, BadRequestException, IOException,
        AlreadyExistingException, PluginException, IncompatibleVNFPackage, VimException,
        InterruptedException, EntityUnreachableException {

  NetworkServiceDescriptor nsd_exp = createNetworkServiceDescriptor();

  when(vnfmManagerEndpointRepository.findAll())
      .thenReturn(
          new ArrayList<VnfmManagerEndpoint>() {
            {
              VnfmManagerEndpoint vnfmManagerEndpoint = new VnfmManagerEndpoint();
              vnfmManagerEndpoint.setEndpoint("test");
              vnfmManagerEndpoint.setType("test");
              vnfmManagerEndpoint.setActive(true);
              vnfmManagerEndpoint.setEnabled(true);
              add(vnfmManagerEndpoint);
            }
          });

  when(nsdRepository.save(nsd_exp)).thenReturn(nsd_exp);
  exception = ExpectedException.none();
  nsdManagement.onboard(nsd_exp, projectId);
  assertEqualsNSD(nsd_exp);
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:28,代码来源:NetworkServiceDescriptorManagementClassSuiteTest.java

示例7: testHTTPError

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void testHTTPError() {
	ExpectedException exception = ExpectedException.none();
	try {
		exception.expect(CandybeanException.class);
		response = WS.request(WS.OP.POST, uri + "/get", headers, "", ContentType.DEFAULT_TEXT);
		Assert.fail();
	} catch (CandybeanException e) {
		Assert.assertEquals("HTTP request received HTTP code: 405",
				e.getMessage().split("\n")[0]);
	}
}
 
开发者ID:sugarcrm,项目名称:candybean,代码行数:13,代码来源:WSSystemTest.java

示例8: testResponseError

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
@Ignore("This test should pass, but takes a full minute to do so because it" +
		"waits for the response to time out.")
public void testResponseError() {
	ExpectedException exception = ExpectedException.none();
	try {
		exception.expect(CandybeanException.class);
		// Send to an IP address that does not exist
		response = WS.request(WS.OP.POST, "http://240.0.0.0", headers, "", ContentType.DEFAULT_TEXT);
		Assert.fail();
	} catch (CandybeanException e) {
		Assert.assertEquals("Connect to 240.0.0.0:80 [/240.0.0.0] failed: Operation timed out", e.getMessage());
	}
}
 
开发者ID:sugarcrm,项目名称:candybean,代码行数:15,代码来源:WSSystemTest.java

示例9: outputIsIdentical

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Test
public void outputIsIdentical() throws IOException, InterruptedException, ExecutionException {
  if (!ToolHelper.artSupported()) {
    return;
  }

  String original = getOriginalDexFile().toString();

  File generated;
  // Collect the generated dex files.
  File[] outputFiles =
      temp.getRoot().listFiles((File file) -> file.getName().endsWith(".dex"));
  if (outputFiles.length == 1) {
    // Just run Art on classes.dex.
    generated = outputFiles[0];
  } else {
    // Run Art on JAR file with multiple dex files.
    generated = temp.getRoot().toPath().resolve(pkg + ".jar").toFile();
    JarBuilder.buildJar(outputFiles, generated);
  }

  ToolHelper.ProcessResult javaResult =
      ToolHelper.runJava(ImmutableList.of(getOriginalJarFile().toString()), mainClass);
  if (javaResult.exitCode != 0) {
    fail("JVM failed for: " + mainClass);
  }

  // TODO(ager): Once we have a bot running using dalvik (version 4.4.4) we should remove
  // this explicit loop to get rid of repeated testing on the buildbots.
  for (DexVm version : artVersions) {
    TestCondition condition = failingRun.get(mainClass);
    if (condition != null && condition.test(tool, compiler, version, mode)) {
      thrown.expect(Throwable.class);
    } else {
      thrown = ExpectedException.none();
    }

    // Check output against Art output on original dex file.
    String output =
        ToolHelper.checkArtOutputIdentical(original, generated.toString(), mainClass, version);

    // Check output against JVM output.
    if (shouldMatchJVMOutput(version)) {
      String javaOutput = javaResult.stdout;
      assertEquals(
          "JVM and Art output differ:\n" + "JVM:\n" + javaOutput + "\nArt:\n" + output,
          output,
          javaOutput);
    }
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:52,代码来源:R8RunExamplesTest.java

示例10: ExpectedTimeoutRule

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
private ExpectedTimeoutRule() {
  this.delegate = ExpectedException.none();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:4,代码来源:ExpectedTimeoutRule.java

示例11: tearDown

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
    types = null;
    parserFactory = null;
    exception = ExpectedException.none();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:7,代码来源:JsonReaderTestCase.java

示例12: setUp

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    expectedException = ExpectedException.none();
    // makes Curator fail faster, otherwise it takes 15 seconds to trigger a retry
    System.setProperty("curator-default-connection-timeout", "0");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:7,代码来源:ZookeeperConfigAutoConfigurationTests.java

示例13: testInvalidFind

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
public void testInvalidFind(InvalidDocumentTestResult<T> result) {
	rule = ExpectedException.none();
	rule.expect(result.getExceptionClass());
	T document = service.findOne(result.getDocument().getId());
}
 
开发者ID:jeffsegal,项目名称:mongo-rest,代码行数:6,代码来源:DocumentValidationTest.java

示例14: testInvalidSave

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
public void testInvalidSave(InvalidDocumentTestResult<T> result) throws Exception {
	rule = ExpectedException.none();
	rule.expect(result.getExceptionClass());
	service.create((T) result.getDocument());
}
 
开发者ID:jeffsegal,项目名称:mongo-rest,代码行数:6,代码来源:DocumentValidationTest.java

示例15: GoogleAnalyticsApiFacadeTest

import org.junit.rules.ExpectedException; //导入方法依赖的package包/类
public GoogleAnalyticsApiFacadeTest( String path, Class<Exception> expectedExceptionClass ) {
  this.path = path;

  this.expectedException = ExpectedException.none();
  this.expectedException.expect( expectedExceptionClass );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:7,代码来源:GoogleAnalyticsApiFacadeTest.java


注:本文中的org.junit.rules.ExpectedException.none方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。