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

The following examples show how to use junit.framework.Assert#assertEquals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerProfilingTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testLayerProfiling() throws Exception {
	ObjectName mbean = new ObjectName("bean:name=org.geomajas.profiling.layers");

	mBeanServer.invoke(mbean, "clear", new Object[]{}, new String[]{});

	SearchAttributesRequest request = new SearchAttributesRequest();
	request.setLayerId(LAYER_ID);
	request.setAttributePath("manyToOneAttr");
	SearchAttributesResponse response = (SearchAttributesResponse) dispatcher.execute(
			SearchAttributesRequest.COMMAND, request, null, "en");
	org.junit.Assert.assertFalse(response.isError());
	List<Attribute<?>> attributes = response.getAttributes();
	org.junit.Assert.assertNotNull(attributes);
	org.junit.Assert.assertEquals(2, attributes.size());

	System.out.println("" + mBeanServer.getAttribute(mbean, "Total"));
	Assert.assertEquals(1, ((OneContainer) mBeanServer.getAttribute(mbean, "Total")).getInvocationCount());
	System.out.println("" + mBeanServer.getAttribute(mbean, "GroupData"));

	//Thread.sleep(1000000000); // use this to test whether you can connect using JConsole
}
 
Example 2
Source File: TestSQLPersonsDeps02.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
public void test02() throws Exception { //FD Multi column
        String scenarioName = "persons-deps-02";
        Scenario scenario = UtilityTest.loadScenarioFromResources(References.persons_deps_02_dbms, true);
        setConfigurationForTest(scenario);
        scenario.getConfiguration().setRemoveDuplicates(true);
        DeltaChaseStep result = ChaserFactoryMC.getChaser(scenario).doChase(scenario);
        if (logger.isDebugEnabled()) logger.debug("Scenario " + scenarioName);
        if (logger.isDebugEnabled()) logger.debug(result.toStringWithSort());
        if (logger.isDebugEnabled()) logger.debug("Number of solutions: " + resultSizer.getPotentialSolutions(result));
        if (logger.isDebugEnabled()) logger.debug("Number of duplicate solutions: " + resultSizer.getDuplicates(result));
        Assert.assertEquals(11, resultSizer.getPotentialSolutions(result));
        Assert.assertEquals(0, resultSizer.getDuplicates(result));
        checkSolutions(result);
//        exportResults("/Temp/expected-" + scenarioName, result);
        checkExpectedSolutions("expected-" + scenarioName, result);
    }
 
Example 3
Source File: MemoryGroupByNewAggregateTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Test
@Ignore
public void testNewAggregate() throws HopException {
  Object[] r = new Object[ 16 ];
  Arrays.fill( r, null );

  Aggregate agg = new Aggregate();

  transform.newAggregate( r, agg );

  Assert.assertEquals( "All possible aggregation cases considered", 16, agg.agg.length );

  // all aggregations types is int values, filled in ascending order in perconditions
  for ( int i = 0; i < agg.agg.length; i++ ) {
    int type = i + 1;
    if ( strings.contains( type ) ) {
      Assert.assertTrue( "This is appendable type, type=" + type, agg.agg[ i ] instanceof Appendable );
    } else if ( statistics.contains( type ) ) {
      Assert.assertTrue( "This is collection, type=" + type, agg.agg[ i ] instanceof Collection );
    } else {
      Assert.assertNull( "Aggregation initialized with null, type=" + type, agg.agg[ i ] );
    }
  }
}
 
Example 4
Source File: AnnotationHelperTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void extractEntityTypeNameViaNavigation() throws Exception {
  Field field = NavigationAnnotated.class.getDeclaredField("navigationPropertySimpleEntity");
  EdmNavigationProperty enp = field.getAnnotation(EdmNavigationProperty.class);

  String name = annotationHelper.extractEntityTypeName(enp, SimpleEntity.class);

  Assert.assertEquals("SimpleEntity", name);
}
 
Example 5
Source File: MockClusterInvokerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试mock策略是否正常-fail-mock
 */
@Test
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("mock","true")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getSomething");
       Result ret = cluster.invoke(invocation);
       Assert.assertEquals("somethingmock", ret.getValue());
}
 
Example 6
Source File: MycatSchemaStatVisitorTest.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 从注解中解析 mycat schema
 */
@Test
public void test4() {
	String sql = "/*!mycat:schema = helper1 */update adm_task a set a.remark = 'test' where id=1";
	Assert.assertEquals(getSchema(sql), "helper1.");
	sql = "/*!mycat:schema=helper1*/update adm_task a set a.remark = 'test' where id=1";
	Assert.assertEquals(getSchema(sql), "helper1.");
	sql = "/*!mycat:schema=  helper1*/update adm_task a set a.remark = 'test' where id=1";
	Assert.assertEquals(getSchema(sql), "helper1.");
	System.out.println(getSchema(sql));
}
 
Example 7
Source File: Step3.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public void execute(PipelineContext context, StringAttribute response) throws GeomajasException {
	context.put("Step3", id);
	Assert.assertEquals("bla", context.get("test", String.class));
	Assert.assertNotNull(context.get("Step1"));
	if ("s3".equals(id)) {
		Assert.assertNotNull(context.get("Step2"));
	}
	Assert.assertNotNull(context.get("Step3"));
	response.setValue(response.getValue() + id);
}
 
Example 8
Source File: TypeInstanceContainerBackendTest.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Test
public void createTypeInstanceTest7() throws CouldntSaveDataException, CouldntLoadDataException {
  final TypeInstance typeInstance =
      typeInstancContainerBackend.createTypeInstance(" TYPE INSTANCE ",
          " TYPE INSTANCE COMMENT ", baseType, section, 0);
  Assert.assertEquals(typeInstance.getName(), " TYPE INSTANCE ");
  Assert.assertEquals(typeInstance.getBaseType(), baseType);
  Assert.assertEquals(typeInstance.getSection(), section);
  Assert.assertEquals(typeInstance.getAddress().getOffset(), 0);
}
 
Example 9
Source File: TestMonitoredCounterGroup.java    From mt-flume with Apache License 2.0 5 votes vote down vote up
private void assertSkCounterState(ObjectName on, long connCreated,
    long connClosed, long connFailed, long batchEmpty, long batchUnderflow,
    long batchComplete, long eventDrainAttempt, long eventDrainSuccess)
      throws Exception {
  Assert.assertEquals("SkConnCreated",
      getSkConnectionCreated(on),
      connCreated);
  Assert.assertEquals("SkConnClosed",
      getSkConnectionClosed(on),
      connClosed);
  Assert.assertEquals("SkConnFailed",
      getSkConnectionFailed(on),
      connFailed);
  Assert.assertEquals("SkBatchEmpty",
      getSkBatchEmpty(on),
      batchEmpty);
  Assert.assertEquals("SkBatchUnderflow",
      getSkBatchUnderflow(on),
      batchUnderflow);
  Assert.assertEquals("SkBatchComplete",
      getSkBatchComplete(on),
      batchComplete);
  Assert.assertEquals("SkEventDrainAttempt",
      getSkEventDrainAttempt(on),
      eventDrainAttempt);
  Assert.assertEquals("SkEventDrainSuccess",
      getSkEventDrainSuccess(on),
      eventDrainSuccess);
}
 
Example 10
Source File: TestDeleteL3BasicNetwork.java    From zstack with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    ZoneInventory zone = api.createZones(1).get(0);
    L2NetworkInventory linv = api.createNoVlanL2Network(zone.getUuid(), "eth0");
    L3NetworkInventory l3inv = api.createL3BasicNetwork(linv.getUuid());
    api.deleteL3Network(l3inv.getUuid());
    L3NetworkVO vo = dbf.findByUuid(l3inv.getUuid(), L3NetworkVO.class);
    Assert.assertEquals(null, vo);
}
 
Example 11
Source File: TestDeletePrimaryStorage.java    From zstack with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    SimulatorPrimaryStorageDetails sp = new SimulatorPrimaryStorageDetails();
    sp.setTotalCapacity(SizeUnit.TERABYTE.toByte(10));
    sp.setAvailableCapacity(sp.getTotalCapacity());
    sp.setUrl("nfs://simulator/primary/");
    ZoneInventory zone = api.createZones(1).get(0);
    sp.setZoneUuid(zone.getUuid());
    PrimaryStorageInventory inv = api.createSimulatoPrimaryStorage(1, sp).get(0);
    PrimaryStorageVO vo = dbf.findByUuid(inv.getUuid(), PrimaryStorageVO.class);
    Assert.assertNotNull(vo);
    api.deletePrimaryStorage(vo.getUuid());
    vo = dbf.findByUuid(inv.getUuid(), PrimaryStorageVO.class);
    Assert.assertEquals(null, vo);
}
 
Example 12
Source File: TestCreateDataVolume.java    From zstack with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws ApiSenderException {
    DiskOfferingInventory dinv = new DiskOfferingInventory();
    dinv.setDiskSize(SizeUnit.GIGABYTE.toByte(10));
    dinv.setName("Test");
    dinv.setDescription("Test");
    dinv = api.addDiskOffering(dinv);

    VolumeInventory vinv = api.createDataVolume("TestData", dinv.getUuid());
    Assert.assertEquals(VolumeStatus.NotInstantiated.toString(), vinv.getStatus());
    Assert.assertEquals(VolumeType.Data.toString(), vinv.getType());
    Assert.assertFalse(vinv.isAttached());
}
 
Example 13
Source File: MediaTypesTest.java    From cougar with Apache License 2.0 5 votes vote down vote up
public void testGetResponseMediaTypeSimple() {
	Assert.assertEquals("image/gif",
               MediaTypeUtils.getResponseMediaType(
                       MediaTypeUtils.parseMediaTypes("image/gif"),
                       MediaTypeUtils.parseMediaTypes("image/gif"))
                       .toString());
}
 
Example 14
Source File: TestSecurityGroupOnMultipleNetworks5.java    From zstack with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws ApiSenderException, InterruptedException {
    SecurityGroupInventory scinv = deployer.securityGroups.get("test");
    VmInstanceInventory vm1 = deployer.vms.get("TestVm");
    L3NetworkInventory l3nw1 = deployer.l3Networks.get("TestL3Network1");
    L3NetworkInventory l3nw2 = deployer.l3Networks.get("TestL3Network2");
    VmNicInventory vm1Nic1 = SecurityGroupTestValidator.getVmNicOnSpecificL3Network(vm1.getVmNics(), l3nw1.getUuid());
    VmNicInventory vm1Nic2 = SecurityGroupTestValidator.getVmNicOnSpecificL3Network(vm1.getVmNics(), l3nw2.getUuid());

    VmInstanceInventory vm2 = deployer.vms.get("TestVm1");
    VmNicInventory vm2Nic1 = SecurityGroupTestValidator.getVmNicOnSpecificL3Network(vm2.getVmNics(), l3nw1.getUuid());

    api.addVmNicToSecurityGroup(scinv.getUuid(), vm1Nic1.getUuid());
    api.addVmNicToSecurityGroup(scinv.getUuid(), vm1Nic2.getUuid());
    api.addVmNicToSecurityGroup(scinv.getUuid(), vm2Nic1.getUuid());

    TimeUnit.MILLISECONDS.sleep(500);
    api.stopVmInstance(vm2.getUuid());
    TimeUnit.MILLISECONDS.sleep(500);

    SecurityGroupRuleTO vm1Nic1TO = sbkd.getRulesOnHost(vm1.getHostUuid(), vm1Nic1.getInternalName());
    SecurityGroupTestValidator.validateInternalIpIn(vm1Nic1TO, vm2Nic1.getIp(), scinv.getRules());
    SecurityGroupRuleTO vm1Nic2TO = sbkd.getRulesOnHost(vm1.getHostUuid(), vm1Nic2.getInternalName());
    SecurityGroupTestValidator.validate(vm1Nic2TO, scinv.getRules());
    SecurityGroupRuleTO vm2Nic1TO = sbkd.getRulesOnHost(vm2.getHostUuid(), vm2Nic1.getInternalName());
    Assert.assertEquals(0, vm2Nic1TO.getRules().size());
}
 
Example 15
Source File: Checks.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * 3.3.2.4 Consistency Condition 4 
 * Entries in the ORDER and ORDER-LINE
 * tables must satisfy the relationship: sum(O_OL_CNT) = [number of rows in
 * the ORDER-LINE table for this district] for each district defined by
 * (O_W_ID = OL_W_ID) and (O_D_ID = OL_D_ID).
 */
public void testCondition4() throws SQLException {
    
    Statement s = createStatement();
    ResultSet rs = s.executeQuery("SELECT " +
                    "T1.SUM_OL_CNT,T2.NUM_OL_ROWS, T1.O_W_ID," +
                    "T1.O_D_ID FROM " +
                    "(SELECT O.O_W_ID, O.O_D_ID, " +
                    "SUM(CAST(O.O_OL_CNT AS BIGINT)) AS " +
                    "SUM_OL_CNT FROM ORDERS " +
                    "O GROUP BY O.O_W_ID,O.O_D_ID) T1 ," +
                    "(SELECT OL_W_ID,OL_D_ID,COUNT(*) AS " +
                    "NUM_OL_ROWS FROM ORDERLINE " +
                    "OL GROUP BY OL.OL_W_ID,OL.OL_D_ID) T2" +
                    " WHERE (T1.O_W_ID = T2.OL_W_ID) AND" +
                    " (T1.O_D_ID = T2.OL_D_ID)");    
    while(rs.next())
    {
        println("Sum of ol_cnt"+ rs.getLong(1) 
                +" Num_rows_OL="+rs.getInt(1));
        Assert.assertEquals("Condition#4 sum(O_OL_CNT) = [number of rows"
                +" in the ORDER-LINE table for this district]not satisfied"
                +"for O_W_ID="+rs.getShort(3)+",O_D_ID="+rs.getShort(4),
                rs.getLong(1),rs.getLong(2));
    }
    commit();
    rs.close();
    s.close();

}
 
Example 16
Source File: NetCastTVServiceTest.java    From Connect-SDK-Android-Core with Apache License 2.0 4 votes vote down vote up
@Test
public void testDecToHexWithNullArgument() {
    Assert.assertEquals(null, service.decToHex(null));
}
 
Example 17
Source File: ThreeWayMNBTrainerTest.java    From weka-mnb-sentiment-analysis-template-project with Apache License 2.0 4 votes vote down vote up
@org.junit.Test
public void testArbitraryTextMixed() throws Exception {
    threeWayMnbTrainer.loadModel(modelFile);
    Assert.assertEquals(SentimentClass.ThreeWayClazz.NEUTRAL, threeWayMnbTrainer.classify("I really don't know whether I like or dislike this weather"));
}
 
Example 18
Source File: StudentDenyAllValidatorTest.java    From secure-data-service with Apache License 2.0 4 votes vote down vote up
@Test
public void testValidate() {
    Assert.assertEquals(Collections.emptySet(), validator.validate(null, null));
    Assert.assertEquals(Collections.emptySet(), validator.validate(new String(), new HashSet<String>()));
}
 
Example 19
Source File: ThreadScopeTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void testInOtherThread() {
	Assert.assertNull(threadedService.getValue());
	threadedService.setValue(VALUE_OTHER);
	Assert.assertEquals(VALUE_OTHER, threadedService.getValue());
}
 
Example 20
Source File: PerfTester.java    From zstack with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws ApiSenderException, InterruptedException {
    api.setAdminSession(api.loginAsAdmin());
    final L3NetworkInventory l3 = api.listL3Network(null).get(0);
    final InstanceOfferingInventory ioinv = api.listInstanceOffering(null).get(0);
    final ImageInventory imginv = api.listImage(null).get(0);

    latch = new CountDownLatch(total);
    for (int i = 0; i < total; i++) {
        final int finalI = i;
        thdf.syncSubmit(new SyncTask<Object>() {
            @Override
            public String getSyncSignature() {
                return "creating-vm";
            }

            @Override
            public int getSyncLevel() {
                return syncLevel;
            }

            @Override
            public String getName() {
                return getSyncSignature();
            }

            @Override
            public Object call() throws Exception {
                long start = System.currentTimeMillis();
                try {
                    VmCreator creator = new VmCreator(api);
                    creator.addL3Network(l3.getUuid());
                    creator.instanceOfferingUuid = ioinv.getUuid();
                    creator.imageUuid = imginv.getUuid();
                    creator.name = "vm-" + finalI;
                    creator.timeout = (int) TimeUnit.MINUTES.toSeconds(10);
                    creator.create();
                    System.out.println(String.format("created %s", creator.name));
                } finally {
                    timeCost.add(System.currentTimeMillis() - start);
                    latch.countDown();
                }
                return null;
            }
        });
    }

    latch.await(timeout, TimeUnit.MINUTES);
    SimpleQuery<VmInstanceVO> q = dbf.createQuery(VmInstanceVO.class);
    q.add(VmInstanceVO_.state, Op.EQ, VmInstanceState.Running);
    long count = q.count();
    Assert.assertEquals(total, count);

    long min = 0;
    long max = 0;
    long totalTime = 0;
    for (long t : timeCost) {
        totalTime += t;
        min = Math.min(min, t);
        max = Math.max(max, t);
    }
    long avg = totalTime / timeCost.size();

    String info = ln(
            "Created {0} VMs with parallel level: {1}",
            "Total Time: {2} secs",
            "Max Time: {3} secs",
            "Min Time: {4} secs",
            "Avg Time: {5} secs"
    ).format(total, syncLevel,
            TimeUnit.MILLISECONDS.toMinutes(totalTime),
            TimeUnit.MILLISECONDS.toMinutes(max),
            TimeUnit.MILLISECONDS.toMinutes(min),
            TimeUnit.MILLISECONDS.toMinutes(avg)
    );

    System.out.println(info);
}