本文整理汇总了Java中junit.framework.Assert.assertEquals方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertEquals方法的具体用法?Java Assert.assertEquals怎么用?Java Assert.assertEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.Assert
的用法示例。
在下文中一共展示了Assert.assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCaseSensitive
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testCaseSensitive() throws RuleEngineInitException {
String xml = buildEqualsExpression("true");
Model model = new Model(fromString(xml), namespacedListsHolder);
Map<String, String> params = new HashMap<String, String>();
params.put("platform", "linux");
Assert.assertEquals("first", ((Server)model.execute(params)).getName());
params.put("platform", "LiNuX");
Assert.assertEquals("second", ((Server)model.execute(params)).getName());
xml = buildContainsExpression("true");
model = new Model(fromString(xml), namespacedListsHolder);
params.put("mac", "ih-jk-56");
Assert.assertEquals("first", ((Server)model.execute(params)).getName());
params.put("mac", "Ih-jK-56");
Assert.assertEquals("second", ((Server)model.execute(params)).getName());
}
示例2: getOrganizationalUnits
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void getOrganizationalUnits()
throws Exception {
// given
container.login(userKey);
List<UserGroup> createdGroups = createGroups(10);
// when
List<UserGroup> groups = runTX(new Callable<List<UserGroup>>() {
@Override
public List<UserGroup> call() throws Exception {
return localService.getOrganizationalUnits(null);
}
});
// then
Assert.assertEquals(createdGroups.size(), groups.size());
}
示例3: testA
import junit.framework.Assert; //导入方法依赖的package包/类
public @Test void testA() {
AbstractExpression headerExpression = new HeaderExpression();
AbstractExpression paramExpression = new ParamExpression();
ParamContext context = new ParamContext();
context.setParams(
"?fullcoudivonId=115&shodivId=123&adivdivCont=0&isNewVersion=1%%%{'header':{'Cookie':'ticket_123','testHeader':'test_321'}}");
Assert.assertEquals("?fullcoudivonId=115&shodivId=123&adivdivCont=0&isNewVersion=1",
paramExpression.get(context));
Assert.assertEquals("{'header':{'Cookie':'ticket_123','testHeader':'test_321'}}",
headerExpression.get(context));
context.setParams("?fullcoudivonId=115&shodivId=123&adivdivCont=0&isNewVersion=1");
Assert.assertEquals("?fullcoudivonId=115&shodivId=123&adivdivCont=0&isNewVersion=1",
paramExpression.get(context));
Assert.assertEquals(null, headerExpression.get(context));
context.setParams("{'header':{'Cookie':'ticket_123','testHeader':'test_321'}}");
Assert.assertEquals(null, paramExpression.get(context));
Assert.assertEquals("{'header':{'Cookie':'ticket_123','testHeader':'test_321'}}",
headerExpression.get(context));
context.setParams(null);
Assert.assertEquals(null, paramExpression.get(context));
Assert.assertEquals(null, headerExpression.get(context));
}
示例4: testNotifyoverrideUrls_withInvoker
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* 测试override规则是否优先
* 场景:与invoker 一起推override规则
*/
@Test
public void testNotifyoverrideUrls_withInvoker(){
RegistryDirectory registryDirectory = getRegistryDirectory();
List<URL> durls = new ArrayList<URL>();
durls.add(SERVICEURL.addParameter("timeout", "1000"));
durls.add(SERVICEURL2.addParameter("timeout", "1000").addParameter("connections", "10"));
durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
registryDirectory.notify(durls);
Assert.assertEquals(true, registryDirectory.isAvailable());
//开始验证参数值
invocation = new RpcInvocation();
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Assert.assertEquals(2, invokers.size());
Assert.assertEquals("override rute must be first priority", "1", invokers.get(0).getUrl().getParameter("timeout"));
Assert.assertEquals("override rute must be first priority", "5", invokers.get(0).getUrl().getParameter("connections"));
}
示例5: test_screens_fire_c2
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void test_screens_fire_c2() throws Exception {
InputStream stream = OcrTestEnglish.class.getClassLoader().getResourceAsStream("720_en_c2.png");
Map<String, Long> stocks = OCR.getInstance().convertToStocks(stream, Locale.ENGLISH, Device.ANDROID);
Assert.assertEquals(9,stocks.keySet().size());
Assert.assertEquals(Long.valueOf(13277), stocks.get(GLASS));
Assert.assertEquals(Long.valueOf(1437), stocks.get(OXYGEN));
Assert.assertEquals(Long.valueOf(181), stocks.get(CLEAN_WATER));
Assert.assertEquals(Long.valueOf(125), stocks.get(SULFURIC_ACID));
Assert.assertEquals(Long.valueOf(4864), stocks.get(RUBBER));
Assert.assertEquals(Long.valueOf(115), stocks.get(REFINED_OIL));
Assert.assertEquals(Long.valueOf(341), stocks.get(DIETHYL_ETHER));
Assert.assertTrue(stocks.keySet().contains(URANIUM_ROD));
Assert.assertEquals(Long.valueOf(610), stocks.get(URANIUM_ROD));
Assert.assertEquals(Long.valueOf(26), stocks.get(PLASTIC));
}
示例6: testTwoBatchesWithAutocommit
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testTwoBatchesWithAutocommit() throws InterruptedException, EventDeliveryException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE,"1");
context.put(BATCH_DURATION_MS,"30000");
context.put(KAFKA_CONSUMER_PREFIX + "enable.auto.commit", "true");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, "", "event 1");
Thread.sleep(500L);
kafkaSource.process();
Assert.assertEquals("event 1", new String(events.get(0).getBody(), Charsets.UTF_8));
events.clear();
kafkaServer.produce(topic0, "", "event 2");
Thread.sleep(500L);
kafkaSource.process();
Assert.assertEquals("event 2", new String(events.get(0).getBody(), Charsets.UTF_8));
}
示例7: testNofityOverrideUrls_CleanNOverride
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* 测试同时推送清除override和针对某个provider的override
* 看override是否能够生效
*/
@Test
public void testNofityOverrideUrls_CleanNOverride(){
RegistryDirectory registryDirectory = getRegistryDirectory();
invocation = new RpcInvocation();
List<URL> durls = new ArrayList<URL>();
durls.add(SERVICEURL.setHost("10.20.30.140").addParameter("timeout", "1"));
registryDirectory.notify(durls);
durls = new ArrayList<URL>();
durls.add(URL.valueOf("override://0.0.0.0?timeout=3"));
durls.add(URL.valueOf("override://0.0.0.0"));
durls.add(URL.valueOf("override://10.20.30.140:9091?timeout=4"));
registryDirectory.notify(durls);
List<Invoker<?>> invokers = registryDirectory.list(invocation);
Invoker<?> aInvoker = invokers.get(0);
Assert.assertEquals("4",aInvoker.getUrl().getParameter("timeout"));
}
示例8: test_Encode_Request
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void test_Encode_Request() throws IOException{
ChannelBuffer encodeBuffer = ChannelBuffers.dynamicBuffer(2014);
Channel channel = getCliendSideChannel(url);
Request request = new Request();
Person person = new Person();
request.setData(person);
codec.encode(channel, encodeBuffer, request);
//encode resault check need decode
byte[] data = new byte[encodeBuffer.writerIndex()];
encodeBuffer.readBytes(data);
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
Request obj = (Request)codec.decode(channel, decodeBuffer);
Assert.assertEquals(request.isBroken(), obj.isBroken());
Assert.assertEquals(request.isHeartbeat(), obj.isHeartbeat());
Assert.assertEquals(request.isTwoWay(), obj.isTwoWay());
Assert.assertEquals(person, obj.getData());
}
示例9: testNotified_WithError
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testNotified_WithError() {
RegistryDirectory registryDirectory = getRegistryDirectory();
List<URL> serviceUrls = new ArrayList<URL>();
// ignore error log
URL badurl = URL.valueOf("notsupported://127.0.0.1/" + service);
serviceUrls.add(badurl);
serviceUrls.add(SERVICEURL);
registryDirectory.notify(serviceUrls);
Assert.assertEquals(true, registryDirectory.isAvailable());
List invokers = registryDirectory.list(invocation);
Assert.assertEquals(1, invokers.size());
}
示例10: testKillQuery
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testKillQuery() {
String sql = "kill query 1102 ";
int result = ServerParse.parse(sql);
int sqlType = result & 0xff;
Assert.assertEquals(ServerParse.KILL_QUERY, sqlType);
}
示例11: test_Decode_Error_Response_Object
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void test_Decode_Error_Response_Object() throws IOException{
//00000010-response/oneway/hearbeat=true |20-stats=ok|id=0|length=0
byte[] header = new byte[] { MAGIC_HIGH, MAGIC_LOW, 0x20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Person person = new Person();
byte[] request = getRequestBytes(person, header);
//bad object
byte[] badbytes = new byte[]{-1,-2,-3,-4,-3,-4,-3,-4,-3,-4,-3,-4};
System.arraycopy(badbytes, 0, request, 21, badbytes.length);
Response obj = (Response)decode(request);
Assert.assertEquals(90, obj.getStatus());
}
示例12: testEquals
import junit.framework.Assert; //导入方法依赖的package包/类
public void testEquals() {
LongExtraType otherLongExtra = new LongExtraType();
BottomType bottom = new BottomType();
Assert.assertEquals(longExtraType, otherLongExtra);
Assert.assertFalse(longExtraType.equals(bottom));
}
示例13: testClientMethods
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* Tests all ISVNClientAdapter methods available. All WC read-only methods
* must be picked and inserted into SvnClientInvocationHandler's
* READ_ONLY_METHODS to ensure the methods are called under read-lock.
*/
@Test
public void testClientMethods () {
Set<String> newMethods = new HashSet<>();
for (Method m : ISVNClientAdapter.class.getDeclaredMethods()) {
if (!METHODS.contains(m.getName())) {
newMethods.add(m.getName());
}
}
List<String> methodArray = new ArrayList<>(newMethods);
Collections.sort(methodArray);
Assert.assertEquals("New methods ISVNClientAdapter." + methodArray
+ ". Is there a read-only method?", 0, methodArray.size());
}
示例14: testMonitorFactory
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testMonitorFactory() throws Exception {
MockMonitorService monitorService = new MockMonitorService();
URL statistics = new URL("dubbo", "10.20.153.10", 0)
.addParameter(MonitorService.APPLICATION, "morgan")
.addParameter(MonitorService.INTERFACE, "MemberService")
.addParameter(MonitorService.METHOD, "findPerson")
.addParameter(MonitorService.CONSUMER, "10.20.153.11")
.addParameter(MonitorService.SUCCESS, 1)
.addParameter(MonitorService.FAILURE, 0)
.addParameter(MonitorService.ELAPSED, 3)
.addParameter(MonitorService.MAX_ELAPSED, 3)
.addParameter(MonitorService.CONCURRENT, 1)
.addParameter(MonitorService.MAX_CONCURRENT, 1);
Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
MonitorFactory monitorFactory = ExtensionLoader.getExtensionLoader(MonitorFactory.class).getAdaptiveExtension();
Exporter<MonitorService> exporter = protocol.export(proxyFactory.getInvoker(monitorService, MonitorService.class, URL.valueOf("dubbo://127.0.0.1:17979/" + MonitorService.class.getName())));
try {
Monitor monitor = monitorFactory.getMonitor(URL.valueOf("dubbo://127.0.0.1:17979?interval=10"));
try {
monitor.collect(statistics);
int i = 0;
while(monitorService.getStatistics() == null && i < 200) {
i ++;
Thread.sleep(10);
}
URL result = monitorService.getStatistics();
Assert.assertEquals(1, result.getParameter(MonitorService.SUCCESS, 0));
Assert.assertEquals(3, result.getParameter(MonitorService.ELAPSED, 0));
} finally {
monitor.destroy();
}
} finally {
exporter.unexport();
}
}
示例15: testNotifyRouterUrls
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* 1. notify twice, the second time notified router rules should completely replace the former one. 2. notify with
* no router url, do nothing to current routers 3. notify with only one router url, with router=clean, clear all
* current routers
*/
@Test
public void testNotifyRouterUrls() {
if (isScriptUnsupported) return;
RegistryDirectory registryDirectory = getRegistryDirectory();
URL routerurl = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9096/");
URL routerurl2 = URL.valueOf(Constants.ROUTE_PROTOCOL + "://127.0.0.1:9097/");
List<URL> serviceUrls = new ArrayList<URL>();
// without ROUTER_KEY, the first router should not be created.
serviceUrls.add(routerurl.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
"notsupported").addParameter(Constants.RULE_KEY,
"function test1(){}"));
serviceUrls.add(routerurl2.addParameter(Constants.CATEGORY_KEY, Constants.ROUTERS_CATEGORY).addParameter(Constants.TYPE_KEY, "javascript").addParameter(Constants.ROUTER_KEY,
ScriptRouterFactory.NAME).addParameter(Constants.RULE_KEY,
"function test1(){}"));
registryDirectory.notify(serviceUrls);
List<Router> routers = registryDirectory.getRouters();
//default invocation selector
Assert.assertEquals(1 + 1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
registryDirectory.notify(new ArrayList<URL>());
routers = registryDirectory.getRouters();
Assert.assertEquals(1 + 1, routers.size());
Assert.assertTrue(ScriptRouter.class == routers.get(1).getClass() || ScriptRouter.class == routers.get(0).getClass());
serviceUrls.clear();
serviceUrls.add(routerurl.addParameter(Constants.ROUTER_KEY, Constants.ROUTER_TYPE_CLEAR));
registryDirectory.notify(serviceUrls);
routers = registryDirectory.getRouters();
Assert.assertEquals(0 + 1, routers.size());
}