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

The following examples show how to use junit.framework.TestCase#assertFalse() . 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: BehaviorSettingsFactoryTest.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testLoadBehaviorSettings() throws IOException, SAXException, ParserConfigurationException {
    // Test loading a good behavior settings file.
    testFactory.behaviorMap.clear();
    TestCase.assertTrue(testFactory.loadBehaviorSettings(buildTestDocument()));
    TestCase.assertEquals(5, testFactory.behaviorMap.size());
    String[] expectedBehaviors = new String[]
            {BehaviorSettingsFactoryTestConstants.NM_RECKLESS,
                    BehaviorSettingsFactoryTestConstants.NM_COWARDLY,
                    BehaviorSettingsFactoryTestConstants.NM_ESCAPE,
                    BehaviorSettingsFactoryTestConstants.NM_DEFAULT,
                    BehaviorSettingsFactory.BERSERK_BEHAVIOR_DESCRIPTION};
    TestCase.assertEquals(Sets.newSet(expectedBehaviors), Sets.newSet(testFactory.getBehaviorNames()));

    // Test loading a null behavior settings file.
    testFactory.behaviorMap.clear();
    TestCase.assertFalse(testFactory.loadBehaviorSettings(null));
    TestCase.assertEquals(4, testFactory.behaviorMap.size());
    expectedBehaviors = new String[]{BehaviorSettingsFactory.BERSERK_BEHAVIOR_DESCRIPTION,
            BehaviorSettingsFactory.COWARDLY_BEHAVIOR_DESCRIPTION,
            BehaviorSettingsFactory.DEFAULT_BEHAVIOR_DESCRIPTION,
            BehaviorSettingsFactory.ESCAPE_BEHAVIOR_DESCRIPTION};
    Assert.assertArrayEquals(expectedBehaviors, testFactory.getBehaviorNames());
}
 
Example 2
Source File: GoogleMapShapeConverterUtils.java    From geopackage-android-map with MIT License 6 votes vote down vote up
/**
 * Test the MultiLineString conversion
 * 
 * @param converter
 * @param multiLineString
 */
private static void convertMultiLineString(
		GoogleMapShapeConverter converter, MultiLineString multiLineString) {

	MultiPolylineOptions polylines = converter.toPolylines(multiLineString);
	TestCase.assertNotNull(polylines);
	TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());

	List<LineString> lineStrings = multiLineString.getLineStrings();
	compareLineStringsAndPolylines(converter, lineStrings,
			polylines.getPolylineOptions());

	MultiLineString multiLineString2 = converter
			.toMultiLineStringFromOptions(polylines);
	compareLineStrings(lineStrings, multiLineString2.getLineStrings());
}
 
Example 3
Source File: TestQueueMuxBatchmgr.java    From oodt with Apache License 2.0 6 votes vote down vote up
public void testKillJob() {
    try {
        ResourceNode node1 = new ResourceNode();
        ResourceNode node2 = new ResourceNode();

        JobSpec spec1 = this.getSpecFromQueue("queue-1");
        queue.executeRemotely(spec1, node1);

        JobSpec spec2 = this.getSpecFromQueue("queue-2");
        queue.executeRemotely(spec2, node2);
        //Make sure that one can kill a job, and the other job is running
        TestCase.assertTrue(queue.killJob(spec1.getJob().getId(), node1));
        TestCase.assertEquals(mock1.getCurrentJobSpec(),null);
        TestCase.assertEquals(mock2.getCurrentJobSpec(),spec2);
        //Make sure kill fails with bad queue
        TestCase.assertFalse(queue.killJob(this.getSpecFromQueue("queue-3").getJob().getId(), node1));
    } catch (JobExecutionException e) {
        TestCase.fail("Unexpected Exception: "+e.getMessage());
    }
}
 
Example 4
Source File: TestAbstractPwm.java    From Bulldog with Apache License 2.0 5 votes vote down vote up
@Test
public void testEnable() {
	MockedPwm pwm = pin.as(MockedPwm.class);
	TestCase.assertFalse(pwm.enableImplCalled());
	TestCase.assertFalse(pwm.disableImplCalled());
	pwm.enable();
	TestCase.assertTrue(pwm.isEnabled());
	TestCase.assertTrue(pwm.enableImplCalled());
	TestCase.assertFalse(pwm.disableImplCalled());
	pwm.disable();
	TestCase.assertFalse(pwm.isEnabled());
	TestCase.assertTrue(pwm.disableImplCalled());
}
 
Example 5
Source File: AbstractConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppendParameters1() throws Exception {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("default.num", "one");
    parameters.put("num", "ONE");
    AbstractConfig.appendParameters(parameters, new ParameterConfig(1, "hello/world", 30, "password"), "prefix");
    TestCase.assertEquals("one", parameters.get("prefix.key.1"));
    TestCase.assertEquals("two", parameters.get("prefix.key.2"));
    TestCase.assertEquals("ONE,one,1", parameters.get("prefix.num"));
    TestCase.assertEquals("hello%2Fworld", parameters.get("prefix.naming"));
    TestCase.assertEquals("30", parameters.get("prefix.age"));
    TestCase.assertFalse(parameters.containsKey("prefix.key-2"));
    TestCase.assertFalse(parameters.containsKey("prefix.secret"));
}
 
Example 6
Source File: IntegrationJobTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testIntegrationJobReplaceViaHTTP() throws IOException, LongRunningQueryException, SodaError {
    IntegrationJob jobToRun = getIntegrationJobWithUserPrefs();
    jobToRun.setDatasetID(UNITTEST_DATASET_ID);
    jobToRun.setFileToPublish("src/test/resources/datasync_unit_test_two_rows.csv");
    jobToRun.setPublishMethod(PublishMethod.replace);
    jobToRun.setFileToPublishHasHeaderRow(true);
    jobToRun.setPublishViaFTP(false);
    JobStatus status = jobToRun.run();
    TestCase.assertEquals(false, jobToRun.getPublishViaFTP());
    TestCase.assertEquals(JobStatus.SUCCESS, status);
    TestCase.assertFalse(status.isError());
    TestCase.assertEquals(2, getTotalRows(UNITTEST_DATASET_ID));
}
 
Example 7
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 8
Source File: MustThrows.java    From json-smart-v2 with Apache License 2.0 5 votes vote down vote up
public static void testInvalidJson(String json, int permissifMode, int execptionType, Class<?> cls)
		throws Exception {
	JSONParser p = new JSONParser(permissifMode);
	try {
		if (cls == null)
			p.parse(json);
		else
			p.parse(json, cls);
		TestCase.assertFalse("Exception Should Occure parsing:" + json, true);
	} catch (ParseException e) {
		if (execptionType == -1)
			execptionType = e.getErrorType();
		TestCase.assertEquals(execptionType, e.getErrorType());
	}
}
 
Example 9
Source File: ControlFileModelTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testIgnoredColumns() throws IOException, LongRunningQueryException, InterruptedException, HttpException, URISyntaxException {
    ControlFile cf = getTestControlFile();
    ControlFileModel model = getTestModel(cf);
    int columnLengthBeforeUpdate = model.getColumnCount();
    //Verify that the location column is part of the ignored list
    TestCase.assertTrue(model.isIgnored("foo"));
    //Now add it back to the columns list
    model.updateColumnAtPosition("foo",0);
    //Verify that the column that was there is no longer part of the ignored columns list.
    TestCase.assertFalse(model.isIgnored("id"));
    // Ignoring a column should not change how many columns there are.
    // Verify that we have the same number of columns in the control file as we did when we started
    TestCase.assertEquals(model.getColumnCount(), columnLengthBeforeUpdate);
}
 
Example 10
Source File: TestPin.java    From Bulldog with Apache License 2.0 5 votes vote down vote up
@Test
public void testFeatureActivation() {
	TestCase.assertFalse(pin.isFeatureActive(MockedPinFeature1.class));
	TestCase.assertFalse(pin.isFeatureActive(MockedPinFeature2.class));
	TestCase.assertFalse(pin.isFeatureActive(MockedPinFeature3.class));
	
	pin.activateFeature(MockedPinFeature2.class);
	PinFeature feature = pin.getActiveFeature();
	TestCase.assertTrue(feature.isSetup());
	TestCase.assertEquals(type2, feature);
	TestCase.assertFalse(pin.isFeatureActive(MockedPinFeature3.class));
	
	pin.activateFeature(MockedPinFeature3.class);
	feature = pin.getActiveFeature();
	TestCase.assertEquals(type3, feature);
	TestCase.assertTrue(pin.isFeatureActive(MockedPinFeature3.class));
	TestCase.assertTrue(pin.isFeatureActive(MockedPinFeature2.class));	//Type 3 is subclass of Type 2
	TestCase.assertTrue(pin.isFeatureActive(pin.getFeature(MockedPinFeature3.class)));
	TestCase.assertFalse(pin.isFeatureActive(pin.getFeature(MockedPinFeature2.class)));
	
	feature = pin.as(MockedPinFeature2.class);
	TestCase.assertEquals(type2, feature);

	feature = pin.as(MockedPinFeature3.class);
	TestCase.assertEquals(type3, feature);
	feature = pin.getActiveFeature();
	TestCase.assertEquals(type3, feature);
	
	pin.removeFeature(MockedPinFeature2.class);
	TestCase.assertEquals(2, pin.getFeatures().size());
	feature = pin.as(MockedPinFeature2.class);  //type3 is still present and extends type2
	TestCase.assertEquals(type3, feature);
	
	pin.removeFeature(MockedPinFeature2.class);
}
 
Example 11
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void phaseFive( TestData data )
{
  TestCase.assertEquals(
      "Extract uninstaller jar",
      OK,
      Utils.extractUninstallerJar( data )
    );
  TestCase.assertEquals("Load engine classes", OK, Utils.loadEngineClasses(data));
  TestCase.assertEquals("Run uninstaller main class", OK, Utils.runUninstaller(data));

  Utils.stepUninstall(data);

  Utils.stepFinish();

  Utils.waitSecond(data, 5);

  TestCase.assertEquals("Uninstaller Finshed", 0, ((Integer) System.getProperties().get("nbi.exit.code")).intValue());

  TestCase.assertFalse(
      "NetBeans dir deleted",
      Utils.dirExist( data.GetNetBeansInstallPath( ) ).equals( OK )
    );
  TestCase.assertFalse(
      "GlassFish2 dir deleted",
      Utils.dirExist( data.GetApplicationServerInstallPath( ) ).equals( OK )
    );
  if( data.m_bPreludePresents )
  {
    TestCase.assertFalse(
        "Prelude dir deleted",
        Utils.dirExist( data.GetApplicationServerPreludeInstallPath( ) ).equals( OK )
    );
  }
  TestCase.assertFalse(
      "Tomcat dir deleted",
      Utils.dirExist( data.GetTomcatInstallPath( ) ).equals( OK )
    );
  //TestCase.assertFalse("GlassFish3 dir deleted", Utils.dirExist(GF3_DIR_NAME, data).equals(OK));
}
 
Example 12
Source File: ControlFileTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testDeserializationCompleteControlFile() throws IOException {
    File controlFile = new File("src/test/resources/datasync_complex_control.json");
    ControlFile cf = mapper.readValue(controlFile, ControlFile.class);

    TestCase.assertEquals("someSillyUUIDforMyInternalUse", cf.opaque);
    TestCase.assertEquals("Delete", cf.action);
    TestCase.assertNotNull(cf.getCsvFtc());
    TestCase.assertNull(cf.getTsvFtc());
    TestCase.assertEquals(3, cf.getCsvFtc().columns.length);
    TestCase.assertEquals(1, cf.getCsvFtc().ignoreColumns.length);
    TestCase.assertEquals(skip, cf.getCsvFtc().skip);
    TestCase.assertEquals(4, cf.getCsvFtc().fixedTimestampFormat.length);
    TestCase.assertEquals(4, cf.getCsvFtc().floatingTimestampFormat.length);
    TestCase.assertEquals(encoding, cf.getCsvFtc().encoding);
    TestCase.assertEquals(emptyTextIsNull, cf.getCsvFtc().emptyTextIsNull);
    TestCase.assertEquals(trimSpace, cf.getCsvFtc().trimServerWhitespace);
    TestCase.assertEquals(trimSpace, cf.getCsvFtc().trimWhitespace);
    TestCase.assertEquals("TenPercent", cf.getCsvFtc().dropUninterpretableRows);
    TestCase.assertEquals("\\\\", cf.getCsvFtc().escape);
    TestCase.assertEquals(useGeocoding, cf.getCsvFtc().useSocrataGeocoding);
    TestCase.assertNotNull(cf.getCsvFtc().overrides);
    TestCase.assertNotNull(cf.getCsvFtc().syntheticLocations);
    TestCase.assertFalse(cf.getCsvFtc().overrides.get("column1").useSocrataGeocoding);

    ColumnOverride co = cf.getCsvFtc().overrides.get("column1");
    TestCase.assertTrue(co.emptyTextIsNull);
    TestCase.assertNull(co.trimServerWhitespace);
    TestCase.assertEquals(2, co.timestampFormat.length);
    TestCase.assertEquals("PDT", co.timezone);

    LocationColumn lc = cf.getCsvFtc().syntheticLocations.get("loc1");
    TestCase.assertEquals("WA", lc.state);
    TestCase.assertNull(lc.latitude);
}
 
Example 13
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 14
Source File: LoadPreferencesJobTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testValidationOfArgs() throws ParseException {

    String[] goodArgs = {"-c", "myConfig.json"};
    String[] incompleteArgs = {"-t", "LoadPreferences"};

    TestCase.assertTrue(job.validateArgs(parser.parse(cmd.options, goodArgs)));
    TestCase.assertFalse(job.validateArgs(parser.parse(cmd.options, incompleteArgs)));
}
 
Example 15
Source File: AbstractConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppendAttributes2() throws Exception {
    Map<Object, Object> parameters = new HashMap<Object, Object>();
    AbstractConfig.appendAttributes(parameters, new AttributeConfig('l', true, (byte) 0x01));
    TestCase.assertEquals('l', parameters.get("let"));
    TestCase.assertEquals(true, parameters.get("activate"));
    TestCase.assertFalse(parameters.containsKey("flag"));
}
 
Example 16
Source File: TestSignal.java    From Bulldog with Apache License 2.0 5 votes vote down vote up
@Test
public void testBooleanValue() {
	TestCase.assertTrue(Signal.High.getBooleanValue());
	TestCase.assertFalse(Signal.Low.getBooleanValue());
	
	TestCase.assertEquals(Signal.Low, Signal.fromBooleanValue(false));
	TestCase.assertEquals(Signal.High, Signal.fromBooleanValue(true));
}
 
Example 17
Source File: TestAbstractPwm.java    From Bulldog with Apache License 2.0 4 votes vote down vote up
@Test
public void testPwm() {
	MockedPwm pwm = pin.as(MockedPwm.class);
	TestCase.assertTrue(pwm.isSetup());
	TestCase.assertFalse(pwm.isBlocking());
}
 
Example 18
Source File: FeatureTableIndexUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test table index delete all
 *
 * @param geoPackage
 * @throws SQLException
 */
public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {

    // Test indexing each feature table
    List<String> featureTables = geoPackage.getFeatureTables();
    for (String featureTable : featureTables) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        FeatureTableIndex featureTableIndex = new FeatureTableIndex(
                geoPackage, featureDao);

        if(featureTableIndex.isIndexed()){
            featureTableIndex.deleteIndex();
        }

        TestCase.assertFalse(featureTableIndex.isIndexed());

        TestUtils.validateGeoPackage(geoPackage);

        // Test indexing
        featureTableIndex.index();
        TestUtils.validateGeoPackage(geoPackage);

        TestCase.assertTrue(featureTableIndex.isIndexed());

    }

    ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
    GeometryIndexDao geometryIndexDao = geoPackage.getGeometryIndexDao();
    TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();

    TestCase.assertTrue(geometryIndexDao.isTableExists());
    TestCase.assertTrue(tableIndexDao.isTableExists());
    TestCase.assertTrue(extensionsDao.queryByExtension(
            FeatureTableIndex.EXTENSION_NAME).size() > 0);

    TestCase.assertTrue(geometryIndexDao.countOf() > 0);
    long count = tableIndexDao.countOf();
    TestCase.assertTrue(count > 0);

    int deleteCount = tableIndexDao.deleteAllCascade();
    TestCase.assertEquals(count, deleteCount);

    TestCase.assertTrue(geometryIndexDao.countOf() == 0);
    TestCase.assertTrue(tableIndexDao.countOf() == 0);
}
 
Example 19
Source File: PropertiesExtensionTest.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test property names
 */
@Test
public void testPropertyNames() {

    PropertiesExtension extension = new PropertiesExtension(geoPackage);

    int count = 0;

    count += testPropertyName(extension, PropertyNames.CONTRIBUTOR);
    count += testPropertyName(extension, PropertyNames.COVERAGE);
    count += testPropertyName(extension, PropertyNames.CREATED);
    count += testPropertyName(extension, PropertyNames.CREATOR);
    count += testPropertyName(extension, PropertyNames.DATE);
    count += testPropertyName(extension, PropertyNames.DESCRIPTION);
    count += testPropertyName(extension, PropertyNames.IDENTIFIER);
    count += testPropertyName(extension, PropertyNames.LICENSE);
    count += testPropertyName(extension, PropertyNames.MODIFIED);
    count += testPropertyName(extension, PropertyNames.PUBLISHER);
    count += testPropertyName(extension, PropertyNames.REFERENCES);
    count += testPropertyName(extension, PropertyNames.RELATION);
    count += testPropertyName(extension, PropertyNames.SOURCE);
    count += testPropertyName(extension, PropertyNames.SPATIAL);
    count += testPropertyName(extension, PropertyNames.SUBJECT);
    count += testPropertyName(extension, PropertyNames.TAG);
    count += testPropertyName(extension, PropertyNames.TEMPORAL);
    count += testPropertyName(extension, PropertyNames.TITLE);
    count += testPropertyName(extension, PropertyNames.TYPE);
    count += testPropertyName(extension, PropertyNames.URI);
    count += testPropertyName(extension, PropertyNames.VALID);
    count += testPropertyName(extension, PropertyNames.VERSION);

    TestCase.assertEquals(22, extension.numProperties());
    TestCase.assertEquals(count, extension.numValues());

    TestCase.assertEquals(count, extension.deleteAll());

    TestCase.assertEquals(0, extension.numProperties());
    TestCase.assertEquals(0, extension.numValues());

    extension.removeExtension();
    TestCase.assertFalse(extension.has());
}
 
Example 20
Source File: GeoPackageGeometryDataUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test transforming geometries between projections
 *
 * @param geoPackage
 * @throws SQLException
 * @throws IOException
 */
public static void testGeometryProjectionTransform(GeoPackage geoPackage)
        throws SQLException, IOException {

    GeometryColumnsDao geometryColumnsDao = geoPackage
            .getGeometryColumnsDao();

    if (geometryColumnsDao.isTableExists()) {
        List<GeometryColumns> results = geometryColumnsDao.queryForAll();

        for (GeometryColumns geometryColumns : results) {

            FeatureDao dao = geoPackage.getFeatureDao(geometryColumns);
            TestCase.assertNotNull(dao);

            FeatureCursor cursor = dao.queryForAll();

            while (cursor.moveToNext()) {

                GeoPackageGeometryData geometryData = cursor.getGeometry();
                if (geometryData != null) {

                    Geometry geometry = geometryData.getGeometry();

                    if (geometry != null) {

                        SpatialReferenceSystemDao srsDao = geoPackage
                                .getSpatialReferenceSystemDao();
                        long srsId = geometryData.getSrsId();
                        SpatialReferenceSystem srs = srsDao
                                .queryForId(srsId);

                        long epsg = srs.getOrganizationCoordsysId();
                        Projection projection = srs.getProjection();
                        long toEpsg = -1;
                        if (epsg == ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) {
                            toEpsg = ProjectionConstants.EPSG_WEB_MERCATOR;
                        } else {
                            toEpsg = ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM;
                        }
                        ProjectionTransform transformTo = projection
                                .getTransformation(toEpsg);
                        ProjectionTransform transformFrom = srs.getTransformation(transformTo
                                .getToProjection());

                        byte[] bytes = geometryData.getWkbBytes();

                        Geometry projectedGeometry = transformTo
                                .transform(geometry);
                        GeoPackageGeometryData projectedGeometryData = new GeoPackageGeometryData(
                                -1);
                        projectedGeometryData
                                .setGeometry(projectedGeometry);
                        projectedGeometryData.toBytes();
                        byte[] projectedBytes = projectedGeometryData
                                .getWkbBytes();

                        if (epsg > 0) {
                            TestCase.assertFalse(equalByteArrays(bytes,
                                    projectedBytes));
                        }

                        Geometry restoredGeometry = transformFrom
                                .transform(projectedGeometry);

                        compareGeometries(geometry, restoredGeometry, .001);
                    }
                }

            }
            cursor.close();
        }
    }
}