public void testLoadInvalid() throws Exception { try { Properties p = PropertiesUtil.loadProperties("invalidTest.properties"); fail("Expected: IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals( "Cannot override non-overrideable property flibble = flobble with new value flooble", e.getMessage()); } }
/** Tests the gauge accessor methods. */ public void testAccessors() { Gauge gauge = new Gauge(null, false, POSITIVE_INT, 0); assertTrue("Should be noninteractive", !gauge.isInteractive()); assertEquals("Maxvalues don't match", POSITIVE_INT, gauge.getMaxValue()); assertEquals("Labels don't match", null, gauge.getLabel()); gauge.setLabel(label); assertEquals("Labels don't match", label, gauge.getLabel()); gauge.setValue(NEGATIVE_INT); assertEquals("Values mismatch", 0, gauge.getValue()); gauge.setValue(POSITIVE_INT * 2); assertEquals("Values mismatch", POSITIVE_INT, gauge.getValue()); gauge.setValue(0); try { gauge.setMaxValue(NEGATIVE_INT); fail("1. IllegalArgumentException expected"); } catch (IllegalArgumentException iae) { } gauge.setMaxValue(Gauge.INDEFINITE); try { gauge.setValue(NEGATIVE_INT); fail("2. IllegalArgumentException expected"); } catch (IllegalArgumentException iae) { } try { gauge.setValue(Gauge.CONTINUOUS_IDLE); gauge.setValue(Gauge.INCREMENTAL_IDLE); gauge.setValue(Gauge.CONTINUOUS_RUNNING); gauge.setValue(Gauge.INCREMENTAL_UPDATING); } catch (IllegalArgumentException iae) { fail("3. IllegalArgumentException thrown " + iae.getMessage()); } try { gauge.setValue(POSITIVE_INT); fail("4. IllegalArgumentException expected"); } catch (IllegalArgumentException iae) { } // Test minimum bounds, non-interactive: gauge.setLabel(null); assertTrue("Minimum height was zero or negative, case 1.", gauge.getMinimumHeight() > 0); // print("non-interactive minimum height: " // + gauge.getMinimumHeight()); assertTrue("Minimum width was zero or negative, case 1.", gauge.getMinimumWidth() > 0); // print("non-interactive minimum width: " // + gauge.getMinimumWidth()); // Minimum bounds, interactive: Gauge gauge2 = new Gauge(null, true, POSITIVE_INT, 0); assertTrue("Minimum height was zero or negative, case 2.", gauge2.getMinimumHeight() > 0); // print("interactive minimum height: " // + gauge2.getMinimumHeight()); assertTrue("Minimum width was zero or negative, case 2.", gauge2.getMinimumWidth() > 0); // print("interactive minimum width: " // + gauge2.getMinimumWidth()); // Minimum bounds, non-interactive with label: Gauge gauge3 = new Gauge("label", false, POSITIVE_INT, 0); assertTrue("Minimum height was zero or negative, case 3.", gauge3.getMinimumHeight() > 0); // print("labeled non-interactive minimum height: " // + gauge3.getMinimumHeight()); assertTrue("Minimum width was zero or negative, case 3.", gauge3.getMinimumWidth() > 0); // print("labeled non-interactive minimum width: " // + gauge3.getMinimumWidth()); // Minimum bounds, interactive with label: Gauge gauge4 = new Gauge("label", true, POSITIVE_INT, 0); assertTrue("Minimum height was zero or negative, case 4.", gauge4.getMinimumHeight() > 0); // print("labeled interactive minimum height: " // + gauge4.getMinimumHeight()); assertTrue("Minimum width was zero or negative, case 4.", gauge4.getMinimumWidth() > 0); // print("labeled interactive minimum width: " // + gauge4.getMinimumWidth()); }