• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TestUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.holonplatform.core.internal.utils.TestUtils的典型用法代码示例。如果您正苦于以下问题:Java TestUtils类的具体用法?Java TestUtils怎么用?Java TestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestUtils类属于com.holonplatform.core.internal.utils包,在下文中一共展示了TestUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testUtils

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testUtils() {

	ORMPlatform ptf = ORMPlatform.resolve(entityManager);
	assertNotNull(ptf);
	assertEquals(ORMPlatform.HIBERNATE, ptf);

	TestUtils.expectedException(IllegalArgumentException.class, new Runnable() {

		@Override
		public void run() {
			ORMPlatform.resolve(null);
		}
	});

}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:17,代码来源:TestBase.java


示例2: testRealmContext

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testRealmContext() {

	TestUtils.expectedException(IllegalStateException.class, new Runnable() {

		@Override
		public void run() {
			Realm.require();
		}
	});

	String name = Context.get().executeThreadBound(Realm.CONTEXT_KEY,
			Realm.builder().name("rlm").withDefaultAuthorizer().build(), () -> {
				return Realm.getCurrent().orElseThrow(() -> new IllegalStateException("Missing Realm")).getName()
						.orElse(null);
			});

	assertEquals("rlm", name);

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:21,代码来源:TestRealm.java


示例3: testNotEmpty

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testNotEmpty() {
	Validator.notEmpty().validate("a");
	TestUtils.expectedException(ValidationException.class, () -> Validator.notEmpty().validate(null));
	TestUtils.expectedException(ValidationException.class, () -> Validator.notEmpty().validate(""));

	Validator.notEmpty().validate(Collections.singleton(1));
	TestUtils.expectedException(ValidationException.class,
			() -> Validator.notEmpty().validate(Collections.emptySet()));

	Validator.notEmpty().validate(Collections.singletonMap("a", 1));
	TestUtils.expectedException(ValidationException.class,
			() -> Validator.notEmpty().validate(Collections.emptyMap()));

	Validator.notEmpty().validate(new String[] { "a" });
	TestUtils.expectedException(ValidationException.class, () -> Validator.notEmpty().validate(new String[0]));

	TestUtils.expectedException(UnsupportedValidationTypeException.class, () -> Validator.notEmpty().validate(1));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:20,代码来源:TestValidators.java


示例4: testMin

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testMin() {
	Validator.min(1).validate(null);
	Validator.min(1).validate("a");
	Validator.min(1).validate("ab");
	Validator.min(1).validate(1);
	Validator.min(1).validate(2);
	Validator.min(1).validate(1d);
	Validator.min(1).validate(1.1d);
	Validator.min(1).validate(1L);
	Validator.min(1).validate(BigDecimal.valueOf(1));
	Validator.min(1).validate(BigInteger.valueOf(1));
	Validator.min(1).validate(Collections.singleton(1));
	Validator.min(1).validate(Collections.singletonMap("a", 1));
	Validator.min(1).validate(new String[] { "a" });

	TestUtils.expectedException(ValidationException.class, () -> Validator.min(1).validate(""));
	TestUtils.expectedException(ValidationException.class, () -> Validator.min(1).validate(0));
	TestUtils.expectedException(ValidationException.class, () -> Validator.min(2).validate(1.5d));
	TestUtils.expectedException(ValidationException.class, () -> Validator.min(1).validate(Collections.emptySet()));
	TestUtils.expectedException(ValidationException.class, () -> Validator.min(1).validate(Collections.emptyMap()));
	TestUtils.expectedException(ValidationException.class, () -> Validator.min(1).validate(new String[0]));

	TestUtils.expectedException(UnsupportedValidationTypeException.class,
			() -> Validator.min(1).validate(new Date()));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:27,代码来源:TestValidators.java


示例5: testBase

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testBase() {

	TestUtils.checkEnum(TemporalType.class);
	TestUtils.checkEnum(TemporalFormat.class);
	TestUtils.checkEnum(NumberFormatFeature.class);

	Localization lc = Localization.builder(Locale.ITALY).defaultDecimalPositions(2)
			.defaultDateTemporalFormat(TemporalFormat.MEDIUM).defaultTimeTemporalFormat(TemporalFormat.SHORT)
			.build();

	assertEquals(Locale.ITALY, lc.getLocale());
	assertEquals(new Integer(2), lc.getDefaultDecimalPositions().get());
	assertEquals(TemporalFormat.MEDIUM, lc.getDefaultDateTemporalFormat().get());
	assertEquals(TemporalFormat.SHORT, lc.getDefaultTimeTemporalFormat().get());

	DefaultLocalization l2 = new DefaultLocalization(Locale.US);

	Localization lp = Localization.builder(Locale.ITALY).parent(l2).build();
	assertEquals(l2, lp.getParent().get());

	assertNotEquals(lc, l2);
	assertNotEquals(lc, null);
	assertEquals(lc, lc);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:26,代码来源:TestI18n.java


示例6: testContainerUtils

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testContainerUtils() {
	assertNotNull(ContainerUtils.getQueryExpression(TestData.ID, CFG));

	assertNull(ContainerUtils.getQueryExpression(null, CFG));

	TestUtils.expectedException(InvalidExpressionException.class, new Callable<Void>() {

		@Override
		public Void call() throws InvalidExpressionException {
			ContainerUtils.getQueryExpression("invalid", CFG);
			return null;
		}
	});
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:16,代码来源:TestItems.java


示例7: testErrors

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testErrors() {
	final RestClient client = JaxrsRestClient.create(getClient()).defaultTarget(getBaseUri());

	ResponseEntity<?> rsp = client.request().path("test").path("data/save")
			.put(RequestEntity.json(new TestData(-1, "testErr")));

	assertNotNull(rsp);
	assertEquals(HttpStatus.BAD_REQUEST, rsp.getStatus());

	ApiError error = rsp.as(ApiError.class).orElse(null);
	assertNotNull(error);
	assertEquals("ERR000", error.getCode());

	ResponseEntity<TestData> r2 = client.request().path("test").path("data2/{id}").resolve("id", -1)
			.get(TestData.class);
	assertNotNull(r2);
	assertEquals(HttpStatus.BAD_REQUEST, r2.getStatus());

	error = r2.as(ApiError.class).orElse(null);
	assertNotNull(error);
	assertEquals("ERR000", error.getCode());

	TestUtils.expectedException(UnsuccessfulResponseException.class, () -> {
		client.request().path("test").path("data2/{id}").resolve("id", -1).getForEntity(TestData.class)
				.orElse(null);
	});

	try {
		client.request().path("test").path("data2/{id}").resolve("id", -1).getForEntity(TestData.class)
				.orElse(null);
	} catch (UnsuccessfulResponseException e) {
		assertEquals(HttpStatus.BAD_REQUEST, e.getStatus().orElse(null));
		assertNotNull(e.getResponse());

		ApiError err = e.getResponse().as(ApiError.class).orElse(null);
		assertNotNull(err);
		assertEquals("ERR000", err.getCode());
	}
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:41,代码来源:TestJaxrsClient.java


示例8: testHttp

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testHttp() throws URISyntaxException {

	TestUtils.checkUtilityClass(HttpUtils.class);

	assertFalse(HttpUtils.isSecure(null));
	assertTrue(HttpUtils.isSecure(new URI("https://example.com/test")));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:9,代码来源:TestHttp.java


示例9: testCredentialsEncoder

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testCredentialsEncoder() throws UnsupportedEncodingException {

	TestUtils.expectedException(IllegalStateException.class, new Runnable() {

		@Override
		public void run() {
			Credentials.encoder().build();
		}
	});

	final String secret = "test";
	final byte[] secretBytes = ConversionUtils.toBytes(secret);

	byte[] bytes = Credentials.encoder().secret(secret).build();
	assertTrue(Arrays.equals(secretBytes, bytes));

	String sb = Credentials.encoder().secret(secret).buildAndEncodeBase64();
	assertEquals(Base64.getEncoder().encodeToString(secret.getBytes("UTF-8")), sb);

	bytes = Credentials.encoder().secret(secret).hashMD5().build();
	assertNotNull(bytes);
	bytes = Credentials.encoder().secret(secret).hashSHA1().build();
	assertNotNull(bytes);
	bytes = Credentials.encoder().secret(secret).hashSHA256().build();
	assertNotNull(bytes);
	bytes = Credentials.encoder().secret(secret).hashSHA384().build();
	assertNotNull(bytes);
	bytes = Credentials.encoder().secret(secret).hashSHA512().charset("UTF-8").build();
	assertNotNull(bytes);

	TestUtils.expectedException(RuntimeException.class, new Runnable() {

		@Override
		public void run() {
			Credentials.encoder().secret("test").hashAlgorithm("xxx").build();
		}
	});

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:41,代码来源:TestCredentials.java


示例10: testAuthContextResource

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testAuthContextResource() {

	TestUtils.expectedException(IllegalStateException.class, new Runnable() {

		@Override
		public void run() {
			AuthContext.require();
		}
	});

	boolean ia = Context.get().executeThreadBound(AuthContext.CONTEXT_KEY,
			AuthContext.create(Realm.builder().withDefaultAuthorizer().build()), () -> {
				return AuthContext.getCurrent().orElseThrow(() -> new IllegalStateException("Missing AuthContext"))
						.isAuthenticated();
			});

	assertFalse(ia);

	ia = Context.get().executeThreadBound(AuthContext.CONTEXT_KEY,
			AuthContext.create(Realm.builder().withDefaultAuthorizer().build()), () -> {
				return AuthContext.require().isAuthenticated();
			});

	assertFalse(ia);

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:28,代码来源:TestAuthContext.java


示例11: testNotBlank

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testNotBlank() {
	Validator.notBlank().validate("a");

	TestUtils.expectedException(ValidationException.class, () -> Validator.notBlank().validate(null));
	TestUtils.expectedException(ValidationException.class, () -> Validator.notBlank().validate(""));
	TestUtils.expectedException(ValidationException.class, () -> Validator.notBlank().validate(" "));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:9,代码来源:TestValidators.java


示例12: testMax

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testMax() {
	Validator.max(1).validate(null);
	Validator.max(2).validate("ab");
	Validator.max(1).validate(1);
	Validator.max(1).validate(0);
	Validator.max(1).validate(1d);
	Validator.max(5).validate(4.9d);
	Validator.max(3).validate(2L);
	Validator.max(2).validate(BigDecimal.valueOf(1));
	Validator.max(1).validate(BigInteger.valueOf(1));
	Validator.max(2).validate(Collections.singleton(1));
	Validator.max(1).validate(Collections.singletonMap("a", 1));
	Validator.max(3).validate(new String[] { "a", "b" });

	TestUtils.expectedException(ValidationException.class, () -> Validator.max(1).validate("ab"));
	TestUtils.expectedException(ValidationException.class, () -> Validator.max(1).validate(2));
	TestUtils.expectedException(ValidationException.class, () -> Validator.max(2).validate(2.1d));
	TestUtils.expectedException(ValidationException.class,
			() -> Validator.max(0).validate(Collections.singleton(1)));
	TestUtils.expectedException(ValidationException.class,
			() -> Validator.max(0).validate(Collections.singletonMap("a", 1)));
	TestUtils.expectedException(ValidationException.class,
			() -> Validator.max(1).validate(new String[] { "a", "b" }));

	TestUtils.expectedException(UnsupportedValidationTypeException.class,
			() -> Validator.max(1).validate(new Date()));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:29,代码来源:TestValidators.java


示例13: testPattern

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testPattern() {
	Validator.pattern("a").validate(null);

	Validator.pattern("\\d+").validate("012");

	TestUtils.expectedException(ValidationException.class, () -> Validator.pattern("\\d+").validate("a1"));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:9,代码来源:TestValidators.java


示例14: testIn

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testIn() {
	Validator.in(1, 2).validate(2);

	TestUtils.expectedException(ValidationException.class, () -> Validator.in(1, 2).validate(null));
	TestUtils.expectedException(ValidationException.class, () -> Validator.in(1, 2).validate(3));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:8,代码来源:TestValidators.java


示例15: testNotIn

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testNotIn() {
	Validator.notIn(1, 2).validate(3);
	Validator.notIn(1, 2).validate(null);

	TestUtils.expectedException(ValidationException.class, () -> Validator.notIn(1, 2).validate(1));
	TestUtils.expectedException(ValidationException.class, () -> Validator.notIn(1, 2).validate(2));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:9,代码来源:TestValidators.java


示例16: testNotNegative

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testNotNegative() {
	Validator.notNegative().validate(null);
	Validator.notNegative().validate(0);
	Validator.notNegative().validate(2);
	Validator.notNegative().validate(2.7d);
	Validator.notNegative().validate(BigDecimal.valueOf(0.1));

	TestUtils.expectedException(ValidationException.class, () -> Validator.notNegative().validate(-1));
	TestUtils.expectedException(ValidationException.class, () -> Validator.notNegative().validate(-0.67d));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:12,代码来源:TestValidators.java


示例17: testDigits

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testDigits() {
	Validator.digits(3, 2).validate(123.56);
	Validator.digits(3, 2).validate(23.56);
	Validator.digits(3, 2).validate(1);
	Validator.digits(3, 2).validate(0);
	Validator.digits(3, 0).validate(200);

	TestUtils.expectedException(ValidationException.class, () -> Validator.digits(3, 2).validate(2.567d));
	TestUtils.expectedException(ValidationException.class, () -> Validator.digits(3, 2).validate(4000.6));
	TestUtils.expectedException(ValidationException.class, () -> Validator.digits(3, 2).validate(4000));
	TestUtils.expectedException(ValidationException.class, () -> Validator.digits(3, 0).validate(0.4));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:14,代码来源:TestValidators.java


示例18: testLess

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testLess() {
	Validator.lessThan(3).validate(2);
	TestUtils.expectedException(ValidationException.class, () -> Validator.lessThan(3).validate(3));
	TestUtils.expectedException(ValidationException.class, () -> Validator.lessThan(3).validate(4));

	Validator.lessOrEqual(3).validate(2);
	Validator.lessOrEqual(3).validate(3);
	TestUtils.expectedException(ValidationException.class, () -> Validator.lessOrEqual(3).validate(4));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:11,代码来源:TestValidators.java


示例19: testGreater

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testGreater() {
	Validator.greaterThan(3).validate(4);
	TestUtils.expectedException(ValidationException.class, () -> Validator.greaterThan(3).validate(3));
	TestUtils.expectedException(ValidationException.class, () -> Validator.greaterThan(3).validate(2));

	Validator.greaterOrEqual(3).validate(4);
	Validator.greaterOrEqual(3).validate(3);
	TestUtils.expectedException(ValidationException.class, () -> Validator.greaterOrEqual(3).validate(2));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:11,代码来源:TestValidators.java


示例20: testWellDefined

import com.holonplatform.core.internal.utils.TestUtils; //导入依赖的package包/类
@Test
public void testWellDefined() {
	TestUtils.checkUtilityClass(TestUtils.class);
	TestUtils.checkUtilityClass(AnnotationUtils.class);
	TestUtils.checkUtilityClass(ClassUtils.class);
	TestUtils.checkUtilityClass(ConversionUtils.class);
	TestUtils.checkUtilityClass(FormatUtils.class);
	TestUtils.checkUtilityClass(TypeUtils.class);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:10,代码来源:TestUtilities.java



注:本文中的com.holonplatform.core.internal.utils.TestUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerSimulator类代码示例发布时间:2022-05-23
下一篇:
Java WarnStatus类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap