Java Code Examples for junit.framework.Assert#assertTrue()
The following examples show how to use
junit.framework.Assert#assertTrue() .
These examples are extracted from open source projects.
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 Project: binnavi File: BackwardRegisterTrackingTransformationProviderTest.java License: Apache License 2.0 | 6 votes |
@Test public void testTransformBsh() { final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP)); final ReilInstruction instruction = ReilHelpers.createBsh(0, OperandSize.DWORD, "eax", OperandSize.DWORD, "ebx", OperandSize.DWORD, "ecx"); final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformBsh(instruction, createTaintedState("ecx")); Assert.assertFalse(transformationResult.first().getTaintedRegisters().contains("ecx")); Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax")); Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ebx")); transformationResult.first().onInstructionExit(); Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ecx")); Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("eax")); Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("ebx")); Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty()); Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("ecx")); }
Example 2
Source Project: dubbox-hystrix File: MockClusterInvokerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFound(){ URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName()) .addParameter("getBoolean2.mock","force:throw java.lang.RuntimeException2") .addParameter("invoke_return_error", "true" ); Invoker<IHelloService> cluster = getClusterInvoker(url); //方法配置了mock RpcInvocation invocation = new RpcInvocation(); invocation.setMethodName("getBoolean2"); try { cluster.invoke(invocation); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e.getCause() instanceof IllegalStateException); } }
Example 3
Source Project: product-ei File: ESBJAVA4423CustomStatusDescriptionTest.java License: Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Test custom status description", enabled = true) public void testCustomStatusDescription() { String expectedResponse = "HTTP/1.1 417 Custom response\r\nServer: testServer\r\n" + "Content-Type: text/xml; charset=UTF-8\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<test></test>"; //start socket server simpleSocketServer = new SimpleSocketServer(5389, expectedResponse); simpleSocketServer.start(); try { //this will spawn an exception with the custom response included axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("ESBJAVA4423HttpCustomProxyTest"), "", "IBM"); } catch (IOException e) { Assert.assertTrue(e.getMessage().contains("Custom response")); } }
Example 4
Source Project: reladomo File: SybaseBcpTest.java License: Apache License 2.0 | 6 votes |
private void assertEndBits() { BcpEndBits happy = BcpEndBitsFinder.findOneBypassCache(BcpEndBitsFinder.name().eq("Happy")); Assert.assertFalse(happy.isDopey()); Assert.assertTrue(happy.isHappy()); BcpEndBits dopey = BcpEndBitsFinder.findOneBypassCache(BcpEndBitsFinder.name().eq("Dopey")); Assert.assertTrue(dopey.isDopey()); Assert.assertFalse(dopey.isHappy()); BcpEndBits snowWhite = BcpEndBitsFinder.findOneBypassCache(BcpEndBitsFinder.id().eq(100)); Assert.assertTrue(snowWhite.isDopey()); Assert.assertFalse(snowWhite.isHappy()); final BcpEndBitsList list = new BcpEndBitsList(BcpEndBitsFinder.all()); list.setBypassCache(true); Assert.assertEquals(7, list.size()); BcpEndBits evilQueen = BcpEndBitsFinder.findOneBypassCache(BcpEndBitsFinder.id().eq(101)); Assert.assertFalse(evilQueen.isDopey()); Assert.assertFalse(evilQueen.isHappy()); }
Example 5
Source Project: Zebra File: SingleDBLifeCycleTest.java License: Apache License 2.0 | 6 votes |
@Test public void testMultiRouterResult15() throws Exception { DataSource ds = (DataSource) context.getBean("zebraDS"); Connection conn = null; try { conn = ds.getConnection(); Statement stmt = conn.createStatement(); stmt.execute("select distinct score from test order by score asc limit 16,3"); ResultSet rs = stmt.getResultSet(); while (rs.next()) { Assert.fail(); } Assert.assertTrue(true); } catch (Exception e) { Assert.fail(); } finally { if (conn != null) { conn.close(); } } }
Example 6
Source Project: ensemble-clustering File: TestBagOfWordsEditDistance.java License: MIT License | 6 votes |
@Test public void testDistance5() { BagOfWordsFeature t1 = new BagOfWordsFeature(); t1.incrementValue("cats"); t1.incrementValue("felines"); t1.incrementValue("tigers"); BagOfWordsFeature t2 = new BagOfWordsFeature(); t2.incrementValue("dogs"); t2.incrementValue("canines"); EditDistance d = new EditDistance(); double distance = d.aveMinDistance(Collections.singletonList(t1), Collections.singletonList(t2)); System.out.println(distance); Assert.assertTrue(isEqual(distance, 0.555556)); //0.5714 + 0.4286 + 0.666667 / 3 }
Example 7
Source Project: deerlet-redis-client File: DeerletRedisClientStringTest.java License: Apache License 2.0 | 5 votes |
@Test public void testSetex() throws InterruptedException { Assert.assertTrue(deerletRedisClient.setex("testKey", 3, "testValue")); Assert.assertTrue(deerletRedisClient.exists("testKey")); Thread.sleep(3000); Assert.assertFalse(deerletRedisClient.exists("testKey")); }
Example 8
Source Project: blueflood File: CassandraModelTest.java License: Apache License 2.0 | 5 votes |
@Test public void test_getColumnFamily_RetrievesNumericCF_ForNullMetadata() { RollupType nullType = null; MetricColumnFamily cf = CassandraModel.getColumnFamily(nullType, Granularity.FULL); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_FULL.getName())); cf = CassandraModel.getColumnFamily(nullType, Granularity.MIN_5); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_5M.getName())); cf = CassandraModel.getColumnFamily(nullType, Granularity.MIN_20); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_20M.getName())); cf = CassandraModel.getColumnFamily(nullType, Granularity.MIN_60); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_60M.getName())); cf = CassandraModel.getColumnFamily(nullType, Granularity.MIN_240); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_240M.getName())); cf = CassandraModel.getColumnFamily(nullType, Granularity.MIN_1440); Assert.assertTrue(cf != null); Assert.assertTrue(cf.getName().equals(CassandraModel.CF_METRICS_1440M.getName())); }
Example 9
Source Project: azure-storage-android File: TestHelper.java License: Apache License 2.0 | 5 votes |
public static void verifyServiceStats(ServiceStats stats) { Assert.assertNotNull(stats); if (stats.getGeoReplication().getLastSyncTime() != null) { Assert.assertEquals(GeoReplicationStatus.LIVE, stats.getGeoReplication().getStatus()); } else { Assert.assertTrue(stats.getGeoReplication().getStatus() == GeoReplicationStatus.BOOTSTRAP || stats.getGeoReplication().getStatus() == GeoReplicationStatus.UNAVAILABLE); } }
Example 10
Source Project: secure-data-service File: EdOrgOwnershipArbiterTest.java License: Apache License 2.0 | 5 votes |
@Test public void testEdOrgReferenceEntities() { securityContextInjector.setEducatorContext(); Entity edorg = createEntity(EntityNames.SCHOOL, "edorg1", new HashMap<String, Object>()); Mockito.when(repo.findAll(Mockito.eq(EntityNames.EDUCATION_ORGANIZATION), argThat(new BaseMatcher<NeutralQuery>() { @Override public boolean matches(Object item) { NeutralQuery matching = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.OPERATOR_EQUAL, "edorg1")); NeutralQuery other = (NeutralQuery) item; return matching.getCriteria().equals(other.getCriteria()); } @Override public void describeTo(Description description) { // TODO Auto-generated method stub } }))).thenReturn(Arrays.asList(edorg)); Map<String, Object> attendanceBody = new HashMap<String, Object>(); attendanceBody.put(ParameterConstants.SCHOOL_ID, "edorg1"); Entity attendance = createEntity(EntityNames.ATTENDANCE, "attendance1", attendanceBody); Set<String> edorgIds = arbiter.determineEdorgs(Arrays.asList(attendance), EntityNames.ATTENDANCE); Assert.assertEquals(1, edorgIds.size()); Assert.assertTrue(edorgIds.contains("edorg1")); }
Example 11
Source Project: incubator-sentry File: TestKafkaPolicyNegative.java License: Apache License 2.0 | 5 votes |
@Test public void testauthorizedKafkaInPolicyFile() throws Exception { append("[groups]", globalPolicyFile); append("other_group = other_role", globalPolicyFile); append("[roles]", globalPolicyFile); append("other_role = host=host1->topic=t1->action=read, host=host1->consumergroup=l1->action=read", globalPolicyFile); PolicyEngine policy = new KafkaPolicyFileProviderBackend(globalPolicyFile.getPath()); //malicious_group has no privilege ImmutableSet<String> permissions = policy.getAllPrivileges(Sets.newHashSet("malicious_group"), ActiveRoleSet.ALL); Assert.assertTrue(permissions.toString(), permissions.isEmpty()); //other_group has two privileges permissions = policy.getAllPrivileges(Sets.newHashSet("other_group"), ActiveRoleSet.ALL); Assert.assertTrue(permissions.toString(), permissions.size() == 2); }
Example 12
Source Project: YiBo File: GroupMembersMethods.java License: Apache License 2.0 | 5 votes |
@Test public void addGroupMember() { try { Paging<User> paging = new Paging<User>(); paging.moveToFirst(); List<User> users = weibo.getFriends(paging); Group userList = weibo.createGroupMember(testGroup.getId(), users.get(0).getUserId()); Assert.assertTrue(userList != null); } catch (Exception e) { e.printStackTrace(); Assert.assertTrue(false); } }
Example 13
Source Project: jprotobuf File: ComplexIDLGenerateTest.java License: Apache License 2.0 | 5 votes |
@Test public void testProtobufIDLGeneratorGetIDLTypesReturns() { final Set<Class<?>> cachedTypes = new HashSet<Class<?>>(); final Set<Class<?>> cachedEnumTypes = new HashSet<Class<?>>(); String code = ProtobufIDLGenerator.getIDL(EmptyClass.class, cachedTypes, cachedEnumTypes); Assert.assertTrue(code.indexOf("message") != -1); Assert.assertEquals(1, cachedTypes.size()); Assert.assertEquals(0, cachedEnumTypes.size()); code = ProtobufIDLGenerator.getIDL(EmptyClass.class, cachedTypes, cachedEnumTypes); Assert.assertNull(code); }
Example 14
Source Project: hadoop-gpu File: TestJobConf.java License: Apache License 2.0 | 5 votes |
public void testProfileParamsDefaults() { JobConf configuration = new JobConf(); Assert.assertNull(configuration.get("mapred.task.profile.params")); String result = configuration.getProfileParams(); Assert.assertNotNull(result); Assert.assertTrue(result.contains("file=%s")); Assert.assertTrue(result.startsWith("-agentlib:hprof")); }
Example 15
Source Project: objectlabkit File: WorkingWeekTest.java License: Apache License 2.0 | 5 votes |
public void testIsWorkingDayFromCalendar() { final WorkingWeek ww = new WorkingWeek(); Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY)); Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY)); Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY)); Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY)); Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY)); Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY)); Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY)); }
Example 16
Source Project: kite File: TestDatasetDescriptor.java License: Apache License 2.0 | 5 votes |
@Test public void testEmbeddedPartitionStrategy() { Schema schema = new Schema.Parser().parse("{" + " \"type\": \"record\"," + " \"name\": \"User\"," + " \"partitions\": [" + " {\"type\": \"hash\", \"source\": \"username\", \"buckets\": 16}," + " {\"type\": \"identity\", \"source\": \"username\", \"name\": \"u\"}" + " ]," + " \"fields\": [" + " {\"name\": \"id\", \"type\": \"long\"}," + " {\"name\": \"username\", \"type\": \"string\"}," + " {\"name\": \"real_name\", \"type\": \"string\"}" + " ]" + "}"); DatasetDescriptor descriptor = new DatasetDescriptor.Builder() .schema(schema) .build(); Assert.assertTrue("Descriptor should have partition strategy", descriptor.isPartitioned()); PartitionStrategy expected = new PartitionStrategy.Builder() .hash("username", 16) .identity("username", "u") .build(); Assert.assertEquals(expected, descriptor.getPartitionStrategy()); // check that strategies set on the builder override those in the schema expected = new PartitionStrategy.Builder() .identity("real_name", "n") .build(); DatasetDescriptor override = new DatasetDescriptor.Builder() .schema(schema) .partitionStrategy(expected) .build(); Assert.assertEquals(expected, override.getPartitionStrategy()); }
Example 17
Source Project: cloudstack File: Merovingian2Test.java License: Apache License 2.0 | 5 votes |
@Test public void testLockAndRelease() { s_logger.info("Testing first acquire"); boolean result = _lockMaster.acquire("first" + 1234, 5); Assert.assertTrue(result); s_logger.info("Testing acquire of different lock"); result = _lockMaster.acquire("second" + 1234, 5); Assert.assertTrue(result); s_logger.info("Testing reacquire of the same lock"); result = _lockMaster.acquire("first" + 1234, 5); Assert.assertTrue(result); int count = _lockMaster.owns("first" + 1234); Assert.assertEquals(count, 2); count = _lockMaster.owns("second" + 1234); Assert.assertEquals(count, 1); s_logger.info("Testing release of the first lock"); result = _lockMaster.release("first" + 1234); Assert.assertTrue(result); count = _lockMaster.owns("first" + 1234); Assert.assertEquals(count, 1); s_logger.info("Testing release of the second lock"); result = _lockMaster.release("second" + 1234); Assert.assertTrue(result); result = _lockMaster.release("first" + 1234); Assert.assertTrue(result); }
Example 18
Source Project: opensoc-streaming File: CellTimestampComparatorTest.java License: Apache License 2.0 | 5 votes |
/** * Test_greater. */ @Test public void test_greater() { // mocking Cell cell1 = Mockito.mock(Cell.class); Mockito.when(cell1.getTimestamp()).thenReturn(13745345808L); Cell cell2 = Mockito.mock(Cell.class); Mockito.when(cell2.getTimestamp()).thenReturn(13945345808L); CellTimestampComparator comparator = new CellTimestampComparator(); // actual call and verify Assert.assertTrue(comparator.compare(cell2, cell1) == 1); }
Example 19
Source Project: olat File: ForumRTFFormatterTest.java License: Apache License 2.0 | 4 votes |
@Test public void testListsWithDollarSign() throws Exception { Assert.assertTrue(convert("<ol> <li>$</li> </ol>").contains("$")); }
Example 20
Source Project: natasha File: TestBase.java License: MIT License | 2 votes |
/** * Short for Assert.assertTrue * * @param condition */ protected void at(String msg, boolean condition) { Assert.assertTrue(msg, condition); }