Java Code Examples for junit.framework.TestCase#assertTrue()

The following examples show how to use junit.framework.TestCase#assertTrue() . 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: CRBuiltInArtifactTest.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldDeserializeFromAPILikeObject()
{
    String json = "{\n" +
            "      \"source\": \"test\",\n" +
            "      \"destination\": \"res1\",\n" +
            "      \"type\": \"test\"\n" +
            "    }";
    CRArtifact deserializedValue = gson.fromJson(json,CRArtifact.class);
    CRBuiltInArtifact crBuiltInArtifact = (CRBuiltInArtifact) deserializedValue;
    assertThat(crBuiltInArtifact.getSource(),is("test"));
    assertThat(crBuiltInArtifact.getDestination(),is("res1"));
    assertThat(crBuiltInArtifact.getType(),is(CRArtifactType.test));

    ErrorCollection errors = deserializedValue.getErrors();
    TestCase.assertTrue(errors.isEmpty());
}
 
Example 2
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service, String clientHome) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientHome, null);
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

    AxisModule axisModule = DeploymentEngine.buildModule(file,axisConfiguration);
    axisConfiguration.addModule(axisModule);

    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example 3
Source File: BndEvalCliTest.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void testValidator() throws IOException, UnindexableDataException {
  try (TestDirectory dir = new TestDirectory("bndevalcli")) {
    final File out = new File(dir, "out");
    final File calls = new File(dir, "calls");
    final File mutations = new File(dir, "mutations");
    final String[] flagStrings = {
      "-o", out.getPath()
      , "-c", calls.getPath()
      , "-b", mutations.getPath()
    };
    TestUtils.containsAllUnwrapped(checkHandleFlagsErr(flagStrings), "--baseline file", "does not exist");

    TestCase.assertTrue(mutations.createNewFile());
    FileHelper.stringToGzFile(VcfHeader.MINIMAL_HEADER + "\tSAMPLE\n", mutations);
    new TabixIndexer(mutations).saveVcfIndex();
    TestUtils.containsAllUnwrapped(checkHandleFlagsErr(flagStrings), "--calls file", "does not exist");

    FileHelper.stringToGzFile(VcfHeader.MINIMAL_HEADER + "\tSAMPLE\n", calls);
    new TabixIndexer(calls).saveVcfIndex();

    checkHandleFlags(flagStrings);

    TestCase.assertTrue(out.mkdir());
    checkHandleFlagsErr(flagStrings);
  }
}
 
Example 4
Source File: TestAbstractAnalogInput.java    From Bulldog with Apache License 2.0 5 votes vote down vote up
@Test
public void testMonitoring() {
	MockedAnalogInput input = pin.as(MockedAnalogInput.class);
	TestCase.assertFalse(input.isBlocking());
	TestCase.assertTrue(input.isSetup());
	
	double[] samples = new double[20];
	for(int i = 0; i < 20; i++) {
		samples[i] = Math.sin(Math.PI / i);
	}
	
	input.setSamples(samples);
	input.stopMonitor(); // should do nothing
	TestCase.assertFalse(input.isBlocking());
	
	input.startMonitor(10, new ThresholdListener() {

		@Override
		public void thresholdReached() {
			
		}

		@Override
		public boolean isThresholdReached(double thresholdValue) {
			return thresholdValue >= 0.5;
		}
		
	});
	TestCase.assertTrue(input.isBlocking());
	BulldogUtil.sleepMs(1000);
	input.stopMonitor();
	TestCase.assertFalse(input.isBlocking());
}
 
Example 5
Source File: IntegrationUtilityTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testUidIsValid() {
    TestCase.assertFalse(Utils.uidIsValid("hello"));
    TestCase.assertFalse(Utils.uidIsValid("abcd/1234"));
    TestCase.assertFalse(Utils.uidIsValid("6thm1hz4z"));

    TestCase.assertTrue(Utils.uidIsValid("abcd-1234"));
    TestCase.assertTrue(Utils.uidIsValid("vysc-frub"));
    TestCase.assertTrue(Utils.uidIsValid("6thm-hz4z"));
}
 
Example 6
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void validateRowIcons(FeatureTableStyles featureTableStyles,
                                     FeatureRow featureRow, GeometryType geometryType,
                                     IconRow tableIconDefault,
                                     Map<GeometryType, IconRow> geometryTypeTableIcons,
                                     Map<Long, Map<GeometryType, IconRow>> featureResultsIcons) {

    IconRow iconRow = null;
    if (geometryType == null) {
        iconRow = featureTableStyles.getIcon(featureRow);
        geometryType = featureRow.getGeometryType();
    } else {
        iconRow = featureTableStyles.getIcon(featureRow, geometryType);
    }

    IconRow expectedIconRow = getExpectedRowIcon(featureRow, geometryType,
            tableIconDefault, geometryTypeTableIcons, featureResultsIcons);

    if (expectedIconRow != null) {
        TestCase.assertEquals(expectedIconRow.getId(), iconRow.getId());
        TestCase.assertNotNull(iconRow.getTable());
        TestCase.assertTrue(iconRow.getId() >= 0);
        iconRow.getName();
        iconRow.getDescription();
        iconRow.getWidth();
        iconRow.getHeight();
        iconRow.getAnchorU();
        iconRow.getAnchorV();
    } else {
        TestCase.assertNull(iconRow);
    }

}
 
Example 7
Source File: TxtInstanceChecker.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
protected void checkJoins(INode instance, Map<String, List<IExpectedTuple>> instanceMap, String expectedInstanceFile) {
    List<ExpectedTuplePair> expectedTuplePairs = buildExpectedTuplePairs(instanceMap);
    List<InstanceTuplePair> spicyTuplePairs = buildInstanceTuplePairs(instance);
    List<InstanceTuplePair> spicyTuplePairsClone = new ArrayList<InstanceTuplePair>(spicyTuplePairs);
    for (ExpectedTuplePair expectedTuplePair : expectedTuplePairs) {
        TestCase.assertTrue("Unable to find tuple pair: " + expectedTuplePair.toString() + getJoinMessage(expectedInstanceFile, instanceMap, instance, expectedTuplePairs, spicyTuplePairs), checkTuplePairs(expectedTuplePair, spicyTuplePairsClone));
    }
    TestCase.assertEquals("Extra tuple pairs were generated: " + spicyTuplePairsClone + getJoinMessage(expectedInstanceFile, instanceMap, instance, expectedTuplePairs, spicyTuplePairs), 0, spicyTuplePairsClone.size());
}
 
Example 8
Source File: AlwaysEnabledActionTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void checkPreferencesAction(Action a, Preferences prefsNode) throws Exception {
    prefsNode.putBoolean("myKey", true);
    prefsNode.sync();
    class L implements PreferenceChangeListener {
        boolean notified;

        public synchronized void preferenceChange(PreferenceChangeEvent evt) {
            notified = true;
            notifyAll();
        }

        public synchronized void waitFor() throws Exception {
            while (!notified) {
                wait();
            }
            notified = false;
        }
    }
    L listener = new L();

    // Verify value
    assertTrue("Expected true as preference value", prefsNode.getBoolean("myKey", false));

    TestCase.assertTrue("Expected to be instance of Presenter.Menu", a instanceof Presenter.Menu);
    JMenuItem item = ((Presenter.Menu) a).getMenuPresenter();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.addPreferenceChangeListener(listener);
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
    TestCase.assertFalse("Expected to not be selected", item.isSelected());
    a.actionPerformed(null); // new ActionEvent(null, 0, ""));
    listener.waitFor();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
}
 
Example 9
Source File: CRTabTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDeserializeFromAPILikeObject()
{
    String json = "{\n" +
            "      \"name\": \"cobertura\",\n" +
            "      \"path\": \"target/site/cobertura/index.html\"\n" +
            "    }";
    CRTab deserializedValue = gson.fromJson(json,CRTab.class);

    assertThat(deserializedValue.getName(),is("cobertura"));
    assertThat(deserializedValue.getPath(),is("target/site/cobertura/index.html"));

    ErrorCollection errors = deserializedValue.getErrors();
    TestCase.assertTrue(errors.isEmpty());
}
 
Example 10
Source File: AlterTableUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Compare two lists of ids
 *
 * @param ids  ids
 * @param ids2 ids 2
 */
private static void compareIds(List<Long> ids, List<Long> ids2) {
    if (ids == null) {
        TestCase.assertNull(ids2);
    } else {
        TestCase.assertNotNull(ids2);
        TestCase.assertEquals(ids.size(), ids2.size());
        for (long id : ids) {
            TestCase.assertTrue(ids2.contains(id));
        }
    }
}
 
Example 11
Source File: FeatureIndexManagerUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Validate a Feature Row result
 *
 * @param featureIndexManager
 * @param featureRow
 * @param queryEnvelope
 */
private static void validateFeatureRow(
        FeatureIndexManager featureIndexManager, FeatureRow featureRow,
        GeometryEnvelope queryEnvelope, boolean includeEmpty) {
    TestCase.assertNotNull(featureRow);
    GeometryEnvelope envelope = featureRow.getGeometryEnvelope();

    if (!includeEmpty) {
        TestCase.assertNotNull(envelope);

        if (queryEnvelope != null) {
            TestCase.assertTrue(envelope.getMinX() <= queryEnvelope
                    .getMaxX());
            TestCase.assertTrue(envelope.getMaxX() >= queryEnvelope
                    .getMinX());
            TestCase.assertTrue(envelope.getMinY() <= queryEnvelope
                    .getMaxY());
            TestCase.assertTrue(envelope.getMaxY() >= queryEnvelope
                    .getMinY());
            if (envelope.isHasZ()) {
                if (queryEnvelope.hasZ()) {
                    TestCase.assertTrue(envelope.getMinZ() <= queryEnvelope
                            .getMaxZ());
                    TestCase.assertTrue(envelope.getMaxZ() >= queryEnvelope
                            .getMinZ());
                }
            }
            if (envelope.isHasM()) {
                if (queryEnvelope.hasM()) {
                    TestCase.assertTrue(envelope.getMinM() <= queryEnvelope
                            .getMaxM());
                    TestCase.assertTrue(envelope.getMaxM() >= queryEnvelope
                            .getMinM());
                }
            }
        }
    }
}
 
Example 12
Source File: TestQueueMuxMonitor.java    From oodt with Apache License 2.0 5 votes vote down vote up
public void testReduceLoad() {
    try {
        TestCase.assertTrue(monitor.reduceLoad(map.get(mock1).get(2), 5));
        TestCase.assertTrue(monitor.reduceLoad(map.get(mock2).get(2), 3));
        TestCase.assertEquals(map.get(mock1).get(2).getCapacity(),25);
        TestCase.assertEquals(map.get(mock2).get(2).getCapacity(),27);
        try {
            monitor.reduceLoad(superfluous, 2);
            TestCase.fail("Exception not thrown for unknown queue.");
        } catch (MonitorException ignored) {}
    } catch(MonitorException e) {
        TestCase.fail("Unanticipated monitor exception caught: "+e.getMessage());
    }
}
 
Example 13
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static ConfigurationContext createClientConfigurationContext() throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext =
            ConfigurationContextFactory .createConfigurationContextFromFileSystem(
                    "target/test-resources/integrationRepo",
                    "target/test-resources/integrationRepo/conf/axis2.xml");
    AxisModule axisModule = DeploymentEngine.buildModule(file,
                                                         configContext.getAxisConfiguration());
    configContext.getAxisConfiguration().addModule(axisModule);
    return configContext;
}
 
Example 14
Source File: ConstraintTest.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Test the constraint
 * 
 * @param constraint
 *            constraint
 * @param name
 *            expected name
 * @param type
 *            constraint type
 */
private void testConstraintHelper(Constraint constraint, String name,
		ConstraintType type) {
	TestCase.assertNotNull(constraint);
	String constraintSql = constraint.buildSql();
	TestCase.assertEquals(type, constraint.getType());
	TestCase.assertTrue(ConstraintParser.isType(type, constraintSql));
	TestCase.assertEquals(type, ConstraintParser.getType(constraintSql));
	TestCase.assertEquals(name, constraint.getName());
	TestCase.assertEquals(name, ConstraintParser.getName(constraintSql));
}
 
Example 15
Source File: GeoPackageExample.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test the GeoPackage example NGA extensions
 *
 * @throws SQLException upon error
 * @throws IOException  upon error
 */
@Test
public void testExampleNGAExtensions() throws SQLException, IOException, NameNotFoundException {

    create();

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);
    GeoPackage geoPackage = manager.open(GEOPACKAGE_NAME);

    validateExtensions(geoPackage, true);
    validateNGAExtensions(geoPackage, true);

    NGAExtensions.deleteExtensions(geoPackage);

    validateExtensions(geoPackage, true);
    validateNGAExtensions(geoPackage, false);

    geoPackage.close();

    TestCase.assertTrue(manager.delete(GEOPACKAGE_NAME));
}
 
Example 16
Source File: MetadataReferenceUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test delete
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDelete(GeoPackage geoPackage) throws SQLException {

	MetadataReferenceDao dao = geoPackage.getMetadataReferenceDao();

	if (dao.isTableExists()) {
		List<MetadataReference> results = dao.queryForAll();

		if (!results.isEmpty()) {

			// Choose random metadata
			int random = (int) (Math.random() * results.size());
			MetadataReference metadataReference = results.get(random);

			// Delete the metadata reference
			dao.delete(metadataReference);

			// Verify deleted
			List<MetadataReference> queryMetadataReferenceList = dao
					.queryByMetadata(metadataReference.getFileId(),
							metadataReference.getParentId());
			TestCase.assertTrue(queryMetadataReferenceList.isEmpty());

			// Choose prepared deleted
			results = dao.queryForAll();
			if (!results.isEmpty()) {

				// Choose random metadata
				random = (int) (Math.random() * results.size());
				metadataReference = results.get(random);

				// Find which metadata to delete
				QueryBuilder<MetadataReference, Void> qb = dao
						.queryBuilder();
				qb.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedQuery<MetadataReference> query = qb.prepare();
				List<MetadataReference> queryResults = dao.query(query);
				int count = queryResults.size();

				// Delete
				DeleteBuilder<MetadataReference, Void> db = dao
						.deleteBuilder();
				db.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedDelete<MetadataReference> deleteQuery = db
						.prepare();
				int deleted = dao.delete(deleteQuery);

				TestCase.assertEquals(count, deleted);

			}
		}
	}
}
 
Example 17
Source File: ConccCompileTests.java    From Concurnas with MIT License 4 votes vote down vote up
@Test
public void makeOutputdir() throws Throwable {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	ConccTestMockFileWriter mockWriter = new ConccTestMockFileWriter(mockFL);
	
	Path root = mockFL.fs.getPath("/work/hg");
	Files.createDirectory(root);

	
	Path myClass = root.resolve("MyClass.conc"); 
	Files.write(myClass, ListMaker.make("def doings() => 'hi there'"), StandardCharsets.UTF_8);

	Concc concc = new Concc("-d /bin -a /work", mockFL, mockWriter);
	
	TestCase.assertEquals("", concc.doit());
	
	byte[] code = Files.readAllBytes(mockFL.fs.getPath("/bin/hg/MyClass.class"));
	String res = new Executor().execute("hg.MyClass", code);
	TestCase.assertEquals("hi there", res);

	TestCase.assertTrue(Files.exists(mockFL.fs.getPath("/bin")));
}
 
Example 18
Source File: GuardUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void verifyGuardAttr(TestCase test, GuardedDocument doc, int startPosition, int endPosition) {
    for (int i = startPosition; i <= endPosition; i++) {
        test.assertTrue("element should be guarded; pos: " + i, doc.isPosGuarded(i));
    }
}
 
Example 19
Source File: SpatialReferenceSystemUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test SF/SQL read
 * 
 * @param geoPackage
 * @param expectedResults
 * @throws SQLException
 */
public static void testSfSqlRead(GeoPackage geoPackage,
		Integer expectedResults) throws SQLException {

	SpatialReferenceSystemSfSqlDao dao = geoPackage
			.getSpatialReferenceSystemSfSqlDao();
	List<SpatialReferenceSystemSfSql> results = dao.queryForAll();
	if (expectedResults != null) {
		TestCase.assertEquals(
				"Unexpected number of spatial reference system rows",
				expectedResults.intValue(), results.size());
	}

	if (!results.isEmpty()) {

		// Verify non nulls
		for (SpatialReferenceSystemSfSql result : results) {
			TestCase.assertNotNull(result.getSrid());
			TestCase.assertNotNull(result.getAuthName());
			TestCase.assertNotNull(result.getAuthSrid());
		}

		// Choose random srs
		int random = (int) (Math.random() * results.size());
		SpatialReferenceSystemSfSql srs = results.get(random);

		// Query by id
		SpatialReferenceSystemSfSql querySrs = dao
				.queryForId(srs.getSrid());
		TestCase.assertNotNull(querySrs);
		TestCase.assertEquals(srs.getSrid(), querySrs.getSrid());

		// Query for equal
		List<SpatialReferenceSystemSfSql> querySrsList = dao.queryForEq(
				SpatialReferenceSystemSfSql.COLUMN_AUTH_NAME,
				srs.getAuthName());
		TestCase.assertNotNull(querySrsList);
		TestCase.assertTrue(querySrsList.size() >= 1);
		boolean found = false;
		for (SpatialReferenceSystemSfSql querySrsValue : querySrsList) {
			TestCase.assertEquals(srs.getAuthName(),
					querySrsValue.getAuthName());
			if (!found) {
				found = srs.getSrid() == querySrsValue.getSrid();
			}
		}
		TestCase.assertTrue(found);

	}
}
 
Example 20
Source File: MockTypingSink.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
public void expectFinished() {
  TestCase.assertTrue(finished && expectedOps.isEmpty());
}