Java Code Examples for junit.framework.Assert.assertEquals()

The following are Jave code examples for showing how to use assertEquals() of the junit.framework.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: redirector   File: CaseSensitiveAttributeTest.java   View Source Code Vote up 6 votes
@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());
}
 
Example 2
Project: oscm   File: UserGroupServiceLocalBeanIT.java   View Source Code Vote up 6 votes
@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());
}
 
Example 3
Project: TITAN   File: ExpressionTest.java   View Source Code Vote up 6 votes
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));
}
 
Example 4
Project: dubbox-hystrix   File: RegistryDirectoryTest.java   View Source Code Vote up 6 votes
/**
 * 测试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"));
}
 
Example 5
Project: GameResourceBot   File: OcrTestEnglish.java   View Source Code Vote up 6 votes
@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));
}
 
Example 6
Project: flume-release-1.7.0   File: TestKafkaSource.java   View Source Code Vote up 6 votes
@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));
}
 
Example 7
Project: dubbo2   File: RegistryDirectoryTest.java   View Source Code Vote up 6 votes
/**
 * 测试同时推送清除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"));
}
 
Example 8
Project: dubbo2   File: ExchangeCodecTest.java   View Source Code Vote up 6 votes
@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());
}
 
Example 9
Project: dubbox-hystrix   File: RegistryDirectoryTest.java   View Source Code Vote up 5 votes
@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());
}
 
Example 10
Project: mycat-src-1.6.1-RELEASE   File: ServerParseTest.java   View Source Code Vote up 5 votes
@Test
public void testKillQuery() {
	String sql = "kill query 1102 ";
	int result = ServerParse.parse(sql);
	int sqlType = result & 0xff;
	Assert.assertEquals(ServerParse.KILL_QUERY, sqlType);
}
 
Example 11
Project: EatDubbo   File: ExchangeCodecTest.java   View Source Code Vote up 5 votes
@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());
}
 
Example 12
Project: parabuild-ci   File: LongExtraTypeTest.java   View Source Code Vote up 5 votes
public void testEquals() {
	LongExtraType otherLongExtra = new LongExtraType();
	BottomType bottom = new BottomType();

	Assert.assertEquals(longExtraType, otherLongExtra);
	Assert.assertFalse(longExtraType.equals(bottom));
}
 
Example 13
Project: incubator-netbeans   File: SvnClientInvocationHandlerTest.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 14
Project: dubbocloud   File: DubboMonitorTest.java   View Source Code Vote up 5 votes
@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();
    }
}
 
Example 15
Project: github-test   File: RegistryDirectoryTest.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 16
Project: flume-release-1.7.0   File: TestJMSSource.java   View Source Code Vote up 5 votes
@Test
public void testProcessPartialBatch() throws Exception {
  when(messageConsumer.receiveNoWait()).thenReturn(message, (Message)null);
  source.configure(context);
  source.start();
  Assert.assertEquals(Status.READY, source.process());
  Assert.assertEquals(2, events.size());
  assertBodyIsExpected(events);
  verify(consumer).commit();
}
 
Example 17
Project: EatDubbo   File: AbstractRegistryFactoryTest.java   View Source Code Vote up 4 votes
@Test
public void testRegistryFactoryIpCache() throws Exception {
    Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233"));
    Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233"));
    Assert.assertEquals(registry1, registry2);
}
 
Example 18
Project: redirector   File: StacksServiceTest.java   View Source Code Vote up 4 votes
private void verifyPathItem(String name, int nodes, int nodesWhitelisted, PathItem item) {
    Assert.assertEquals(name, item.getValue());
    Assert.assertEquals(nodes, item.getActiveNodesCount());
    Assert.assertEquals(nodesWhitelisted, item.getWhitelistedNodesCount());
}
 
Example 19
Project: cuttlefish   File: TestWeightedKCore.java   View Source Code Vote up 4 votes
/**
 * This test validates the Weighted KCore algorithm against the simple KCore
 * algorithm. The Weighted KCore algorithm should return exactly the same
 * core assignment as the simple KCore, if all edge weights are set to 1.
 * The test creates a random network, runs both algorithms for unit edge
 * weights and compares the result.
 * 
 * The test is successful if the two core assignments returned by the two
 * algorithms are identical.
 */
@Test
public void testCompareWithKCore() {
	if (!TEST_COMPARE_WITH_KCORE) {
		return;
	}

	boolean saveToFile = false;

	log("Test: Weighted KCore Layout (comparison with KCore)");

	RandomNetworkGenerator rng = new RandomNetworkGenerator();
	rng.directedEdges(false);
	rng.setAllEdgesWeight(1.0);
	rng.allowLoopEdges(false);

	BrowsableNetwork net = rng.generateNetwork();
	Layout<Vertex, Edge> layout = new ARF2Layout<Vertex, Edge>(net, true,
			Integer.MAX_VALUE);
	Set<Integer> indices = new HashSet<Integer>();
	Map<Vertex, Integer> kcoreness, wcoreness;

	KCoreLayout<Vertex, Edge> kcore = new KCoreLayout<Vertex, Edge>(
			layout.getGraph(), layout);
	kcoreness = kcore.getCoreness();

	WeightedKCoreLayout<Vertex, Edge> kcoreWeighted = new WeightedKCoreLayout<Vertex, Edge>(
			layout.getGraph(), layout, 1, 1);
	wcoreness = kcoreWeighted.getCoreness();

	if (saveToFile) {
		try {
			String fname = rng.saveAsCxf(net, kcoreWeighted);
			log("   Weighted KCore layout saved as \"" + fname + "\".");
		} catch (IOException e1) {
			log("   Could not save layout.");
			e1.printStackTrace();
		}
	}

	log("   Validating the match of layouts with unit weights...");
	for (Vertex v : kcoreness.keySet()) {
		Assert.assertTrue(wcoreness.containsKey(v));
		Assert.assertEquals(kcoreness.get(v), wcoreness.get(v));
		indices.add(wcoreness.get(v));
	}

	int max = Collections.max(indices);
	int min = Collections.min(indices);
	Set<Integer> sequence = new HashSet<Integer>();
	for (int i = min; i <= max; ++i) {
		sequence.add(i);
	}

	Assert.assertEquals(sequence, indices);
	log("   Completed successfully!\n");
}
 
Example 20
Project: MobileAppForPatient   File: HealthDataBeanTest.java   View Source Code Vote up 4 votes
@Test
public void testsetEntry_created(){
    String entry_created = "entry_created";
    healthDataBean.setEntry_created(entry_created);
    Assert.assertEquals("service name is not same",entry_created,healthDataBean.getEntry_created());
}