}
/**
- * Create a custom material based on the density.
+ * Create a custom material based on the density. The name of the material is prepended with 'RS: ' to
+ * indicate it came from a RockSim material.
*
* @param type the type of the material
* @param name the name of the component
- * @param density the density in g/cm^3
+ * @param density the density
*
* @return a Material instance
*/
public abstract class PositionDependentHandler<C extends RocketComponent> extends BaseHandler<C> {
/** Temporary position value. */
- private Double positionValue;
+ private Double positionValue = 0d;
/** Temporary position. */
- private RocketComponent.Position position;
+ private RocketComponent.Position position = RocketComponent.Position.TOP;
/**
* {@inheritDoc}
import net.sf.openrocket.file.simplesax.ElementHandler;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.rocketcomponent.Bulkhead;
import net.sf.openrocket.rocketcomponent.CenteringRing;
+import net.sf.openrocket.rocketcomponent.EngineBlock;
+import net.sf.openrocket.rocketcomponent.RingComponent;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.rocketcomponent.TubeCoupler;
import org.xml.sax.SAXException;
import java.util.HashMap;
/**
- * A SAX handler for centering rings and bulkheads.
+ * A SAX handler for centering rings, tube couplers, and bulkheads.
*/
class RingHandler extends PositionDependentHandler<CenteringRing> {
/**
* The OpenRocket Ring.
*/
- private final CenteringRing ring;
+ private final CenteringRing ring = new CenteringRing();
+
+ /**
+ * The parent component.
+ */
+ private final RocketComponent parent;
+
+ /**
+ * The parsed Rocksim UsageCode.
+ */
+ private int usageCode = 0;
/**
* Constructor.
*
- * @param c the parent component
+ * @param theParent the parent component
* @param warnings the warning set
* @throws IllegalArgumentException thrown if <code>c</code> is null
*/
- public RingHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException {
- if (c == null) {
+ public RingHandler(RocketComponent theParent, WarningSet warnings) throws IllegalArgumentException {
+ if (theParent == null) {
throw new IllegalArgumentException("The parent of a ring may not be null.");
}
- ring = new CenteringRing();
- if (isCompatible(c, CenteringRing.class, warnings)) {
- c.addChild(ring);
- }
+ parent = theParent;
}
@Override
if ("Material".equals(element)) {
setMaterialName(content);
}
- }
- catch (NumberFormatException nfe) {
+ if ("UsageCode".equals(element)) {
+ usageCode = Integer.parseInt(content);
+ }
+ } catch (NumberFormatException nfe) {
warnings.add("Could not convert " + element + " value of " + content + ". It is expected to be a number.");
}
}
/**
* Get the ring component this handler is working upon.
- *
+ *
* @return a component
*/
@Override
}
/**
- * Set the relative position onto the component. This cannot be done directly because setRelativePosition is not
+ * This method adds the CenteringRing as a child of the parent rocket component.
+ *
+ * @param warnings the warning set
+ */
+ public void asCenteringRing(WarningSet warnings) {
+
+ if (isCompatible(parent, CenteringRing.class, warnings)) {
+ parent.addChild(ring);
+ }
+ }
+
+ /**
+ * Convert the parsed Rocksim data values in this object to an instance of OpenRocket's Bulkhead.
+ * <p/>
+ * Side Effect Warning: This method adds the resulting Bulkhead as a child of the parent rocket component!
+ *
+ * @param warnings the warning set
+ */
+ public void asBulkhead(WarningSet warnings) {
+
+ Bulkhead result = new Bulkhead();
+
+ copyValues(result);
+
+ if (isCompatible(parent, Bulkhead.class, warnings)) {
+ parent.addChild(result);
+ }
+ }
+
+ /**
+ * Convert the parsed Rocksim data values in this object to an instance of OpenRocket's TubeCoupler.
+ * <p/>
+ * Side Effect Warning: This method adds the resulting TubeCoupler as a child of the parent rocket component!
+ *
+ * @param warnings the warning set
+ */
+ public void asTubeCoupler(WarningSet warnings) {
+
+ TubeCoupler result = new TubeCoupler();
+
+ copyValues(result);
+
+ if (isCompatible(parent, TubeCoupler.class, warnings)) {
+ parent.addChild(result);
+ }
+ }
+
+ /**
+ * Convert the parsed Rocksim data values in this object to an instance of OpenRocket's Engine Block.
+ * <p/>
+ * Side Effect Warning: This method adds the resulting EngineBlock as a child of the parent rocket component!
+ *
+ * @param warnings the warning set
+ */
+ public void asEngineBlock(WarningSet warnings) {
+
+ EngineBlock result = new EngineBlock();
+
+ copyValues(result);
+
+ if (isCompatible(parent, EngineBlock.class, warnings)) {
+ parent.addChild(result);
+ }
+ }
+
+ /**
+ * Copy values from the base ring to the specific component.
+ *
+ * @param result the target to which ring values will be copied
+ */
+ private void copyValues(RingComponent result) {
+ result.setOuterRadius(ring.getOuterRadius());
+ result.setInnerRadius(ring.getInnerRadius());
+ result.setLength(ring.getLength());
+ result.setName(ring.getName());
+ PositionDependentHandler.setOverride(result, ring.isOverrideSubcomponentsEnabled(), ring.getOverrideMass(), ring.getOverrideCGX());
+ result.setRelativePosition(ring.getRelativePosition());
+ result.setPositionValue(ring.getPositionValue());
+ result.setMaterial(ring.getMaterial());
+ }
+
+ /**
+ * Set the relative position onto the component. This cannot be done directly because setRelativePosition is not
* public in all components.
- *
- * @param position the OpenRocket position
+ *
+ * @param position the OpenRocket position
*/
@Override
public void setRelativePosition(RocketComponent.Position position) {
ring.setRelativePosition(position);
}
+ @Override
+ public void endHandler(String element, HashMap<String, String> attributes, String content, WarningSet warnings) throws SAXException {
+ super.endHandler(element, attributes, content, warnings);
+
+ // The <Ring> XML element in Rocksim design file is used for many types of components, unfortunately.
+ // Additional subelements are used to indicate the type of the rocket component. When parsing using SAX
+ // this poses a problem because we can't "look ahead" to see what type is being represented at the start
+ // of parsing - something that would be nice to do so that we can instantiate the correct OR component
+ // at the start, then just call setters for the appropriate data.
+
+ // To overcome that, a CenteringRing is instantiated at the start of parsing, it's mutators are called,
+ // and then at the end (this method) converts the CenteringRing to a more appropriate type. CenteringRing
+ // is generic enough to support the representation of all similar types without loss of data.
+
+ //UsageCode
+ // 0 == Centering Ring
+ // 1 == Bulkhead
+ // 2 == Engine Block
+ // 3 == Sleeve
+ // 4 == Tube Coupler
+
+ if (usageCode == 1) {
+ //Bulkhead
+ asBulkhead(warnings);
+ } else if (usageCode == 2) {
+ asEngineBlock(warnings);
+ } else if (usageCode == 4) {
+ //TubeCoupler
+ asTubeCoupler(warnings);
+ } else {
+ //Default
+ asCenteringRing(warnings);
+ }
+ }
+
/**
* Get the required type of material for this component.
*
public Material.Type getMaterialType() {
return Material.Type.BULK;
}
-}
-
+}
\ No newline at end of file
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.ExternalComponent;
import net.sf.openrocket.rocketcomponent.Stage;
+import org.junit.Assert;
+import org.junit.Test;
import java.util.HashMap;
*/
public class BodyTubeHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = BodyTubeHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = BodyTubeHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(BodyTubeHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public BodyTubeHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testConstructor() throws Exception {
try {
new BodyTubeHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage(), new WarningSet()).openElement(null, null, null));
- assertNotNull(new BodyTubeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage(), new WarningSet()).openElement(null, null, null));
+ Assert.assertNotNull(new BodyTubeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testCloseElement() throws Exception {
Stage stage = new Stage();
BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet());
WarningSet warnings = new WarningSet();
handler.closeElement("OD", attributes, "-1", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ID", attributes, "-1", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings);
- assertTrue(component.isMotorMount());
+ Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings);
- assertFalse(component.isMotorMount());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
- assertFalse(component.isMotorMount());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
- assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("FinishCode", attributes, "-1", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "100", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetComponent() throws Exception {
- assertTrue(new BodyTubeHandler(new Stage(), new WarningSet()).getComponent() instanceof BodyTube);
+ Assert.assertTrue(new BodyTubeHandler(new Stage(), new WarningSet()).getComponent() instanceof BodyTube);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage(), new WarningSet()).getMaterialType());
}
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
*/
public class FinSetHandlerTest extends TestCase {
- /**
- * The class under test.
- */
- public static final Class classUT = FinSetHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = FinSetHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(FinSetHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public FinSetHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
-
/**
* Method: asOpenRocket(WarningSet warnings)
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testAsOpenRocket() throws Exception {
FinSetHandler dto = new FinSetHandler(new BodyTube());
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testToCoordinates() throws Exception {
FinSetHandler holder = new FinSetHandler(new BodyTube());
Method method = FinSetHandler.class.getDeclaredMethod("toCoordinates", String.class, WarningSet.class);
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.InnerTube;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import org.junit.Assert;
import java.util.HashMap;
*/
public class InnerBodyTubeHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = InnerBodyTubeHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = InnerBodyTubeHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(InnerBodyTubeHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public InnerBodyTubeHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new InnerBodyTubeHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
- assertNotNull(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement("AttachedParts", null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertNotNull(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement("AttachedParts", null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet());
WarningSet warnings = new WarningSet();
handler.closeElement("OD", attributes, "-1", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("OD", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ID", attributes, "-1", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings);
- assertTrue(component.isMotorMount());
+ Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings);
- assertFalse(component.isMotorMount());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
- assertFalse(component.isMotorMount());
+ Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
- assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
handler.closeElement("EngineOverhang", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet());
InnerTube component = (InnerTube) getField(handler, "bodyTube");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube);
+ Assert.assertTrue(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
-
-
-
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.ExternalComponent;
import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import org.junit.Assert;
import java.util.HashMap;
*/
public class LaunchLugHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = LaunchLugHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = LaunchLugHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(LaunchLugHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public LaunchLugHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new LaunchLugHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet());
WarningSet warnings = new WarningSet();
handler.closeElement("OD", attributes, "-1", warnings);
- assertEquals(0d, component.getOuterRadius());
+ Assert.assertEquals(0d, component.getOuterRadius(), 0.001);
handler.closeElement("OD", attributes, "0", warnings);
- assertEquals(0d, component.getOuterRadius());
+ Assert.assertEquals(0d, component.getOuterRadius(), 0.001);
handler.closeElement("OD", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001);
handler.closeElement("OD", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ID", attributes, "-1", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("FinishCode", attributes, "-1", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "100", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet());
LaunchLug component = (LaunchLug) getField(handler, "lug");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new LaunchLugHandler(new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug);
+ Assert.assertTrue(new LaunchLugHandler(new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import org.junit.Assert;
import java.util.HashMap;
*/
public class MassObjectHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = MassObjectHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = MassObjectHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(MassObjectHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public MassObjectHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new MassObjectHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
HashMap<String, String> attributes = new HashMap<String, String>();
MassComponent component = (MassComponent) getField(handler, "mass");
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH)
- , component.getLength());
+ Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH)
+ , component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH)
- , component.getLength());
+ Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH)
+ , component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("KnownMass", attributes, "-1", warnings);
- assertEquals(0d, component.getComponentMass());
+ Assert.assertEquals(0d, component.getComponentMass(), 0.001);
handler.closeElement("KnownMass", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS, component.getComponentMass());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS, component.getComponentMass(), 0.001);
handler.closeElement("KnownMass", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
}
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet());
MassComponent component = (MassComponent) getField(handler, "mass");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new MassObjectHandler(new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent);
+ Assert.assertTrue(new MassObjectHandler(new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
-
-
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.Transition;
+import org.junit.Assert;
+import org.junit.Test;
import java.util.HashMap;
*/
public class NoseConeHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = NoseConeHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = NoseConeHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(NoseConeHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public NoseConeHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testConstructor() throws Exception {
try {
new NoseConeHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage(), new WarningSet()).openElement(null, null, null));
- assertNotNull(new NoseConeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage(), new WarningSet()).openElement(null, null, null));
+ Assert.assertNotNull(new NoseConeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testCloseElement() throws Exception {
Stage stage = new Stage();
NoseCone component = (NoseCone) getField(handler, "noseCone");
handler.closeElement("ShapeCode", attributes, "0", warnings);
- assertEquals(Transition.Shape.CONICAL, component.getType());
+ Assert.assertEquals(Transition.Shape.CONICAL, component.getType());
handler.closeElement("ShapeCode", attributes, "1", warnings);
- assertEquals(Transition.Shape.OGIVE, component.getType());
+ Assert.assertEquals(Transition.Shape.OGIVE, component.getType());
handler.closeElement("ShapeCode", attributes, "17", warnings);
- assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default
+ Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default
handler.closeElement("ShapeCode", attributes, "foo", warnings);
- assertNotNull(component.getType());
- assertEquals(1, warnings.size());
+ Assert.assertNotNull(component.getType());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("BaseDia", attributes, "-1", warnings);
- assertEquals(0d, component.getAftRadius());
+ Assert.assertEquals(0d, component.getAftRadius(), 0.001);
handler.closeElement("BaseDia", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001);
handler.closeElement("BaseDia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
component.setAftShoulderRadius(1.1d);
handler.closeElement("WallThickness", attributes, "-1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(component.getAftRadius(), component.getThickness());
- assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness());
+ Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001);
+ Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "100", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(aft, component.getThickness());
+ Assert.assertEquals(aft, component.getThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "foo", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ConstructionType", attributes, "1", warnings);
component.setAftShoulderRadius(1.1d);
handler.closeElement("WallThickness", attributes, "-1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(0d, component.getThickness());
- assertEquals(0d, component.getAftShoulderThickness());
+ Assert.assertEquals(0d, component.getThickness(), 0.001);
+ Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "1.1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness());
- assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness());
+ Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001);
+ Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001);
handler.closeElement("ShoulderLen", attributes, "-1", warnings);
- assertEquals(0d, component.getAftShoulderLength());
+ Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001);
handler.closeElement("ShoulderLen", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001);
handler.closeElement("ShoulderLen", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001);
handler.closeElement("ShoulderLen", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ShoulderOD", attributes, "-1", warnings);
- assertEquals(0d, component.getAftShoulderRadius());
+ Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001);
handler.closeElement("ShoulderOD", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001);
handler.closeElement("ShoulderOD", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
component.setType(Transition.Shape.HAACK);
handler.closeElement("ShapeParameter", attributes, "-1", warnings);
- assertEquals(0d, component.getShapeParameter());
+ Assert.assertEquals(0d, component.getShapeParameter(), 0.001);
handler.closeElement("ShapeParameter", attributes, "100", warnings);
- assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter());
+ Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001);
handler.closeElement("ShapeParameter", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
- assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.",
+ Assert.assertEquals(1, warnings.size());
+ Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.",
warnings.iterator().next().toString());
warnings.clear();
component.setType(Transition.Shape.CONICAL);
component.setShapeParameter(0d);
handler.closeElement("ShapeParameter", attributes, "100", warnings);
- assertEquals(0d, component.getShapeParameter());
+ Assert.assertEquals(0d, component.getShapeParameter(), 0.001);
handler.closeElement("FinishCode", attributes, "-1", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "100", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
handler.closeElement("Material", attributes, "Some Material", warnings);
handler.endHandler("NoseCone", attributes, null, warnings);
- assertTrue(component.getMaterial().getName().contains("Some Material"));
+ Assert.assertTrue(component.getMaterial().getName().contains("Some Material"));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetComponent() throws Exception {
- assertTrue(new NoseConeHandler(new Stage(), new WarningSet()).getComponent() instanceof NoseCone);
+ Assert.assertTrue(new NoseConeHandler(new Stage(), new WarningSet()).getComponent() instanceof NoseCone);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage(), new WarningSet()).getMaterialType());
}
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.Parachute;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import org.junit.Assert;
import java.util.HashMap;
*/
public class ParachuteHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = ParachuteHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = ParachuteHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(ParachuteHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public ParachuteHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: openElement(String element, HashMap<String, String> attributes, WarningSet warnings)
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
WarningSet warnings = new WarningSet();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
handler.closeElement("DragCoefficient", attributes, "0.94", warnings);
- assertEquals(0.94d, component.getCD());
+ Assert.assertEquals(0.94d, component.getCD(), 0.001);
handler.closeElement("DragCoefficient", attributes, "-0.94", warnings);
- assertEquals(-0.94d, component.getCD());
+ Assert.assertEquals(-0.94d, component.getCD(), 0.001);
handler.closeElement("DragCoefficient", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Dia", attributes, "-1", warnings);
- assertEquals(-1d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter());
+ Assert.assertEquals(-1d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001);
handler.closeElement("Dia", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001);
handler.closeElement("Dia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ShroudLineCount", attributes, "-1", warnings);
- assertEquals(0, component.getLineCount());
+ Assert.assertEquals(0, component.getLineCount());
handler.closeElement("ShroudLineCount", attributes, "10", warnings);
- assertEquals(10, component.getLineCount());
+ Assert.assertEquals(10, component.getLineCount());
handler.closeElement("ShroudLineCount", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ShroudLineLen", attributes, "-1", warnings);
- assertEquals(0d, component.getLineLength());
+ Assert.assertEquals(0d, component.getLineLength(), 0.001);
handler.closeElement("ShroudLineLen", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLineLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLineLength(), 0.001);
handler.closeElement("ShroudLineLen", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
}
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new ParachuteHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet());
Parachute component = (Parachute) getField(handler, "chute");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new ParachuteHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Parachute);
+ Assert.assertTrue(new ParachuteHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Parachute);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testEndHandler() throws Exception {
BodyTube tube = new BodyTube();
ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet());
handler.closeElement("Xb", attributes, "-10", warnings);
handler.closeElement("LocationMode", attributes, "1", warnings);
handler.endHandler("Parachute", attributes, null, warnings);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
- assertEquals(component.getPositionValue(), -10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(component.getPositionValue(), -10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
handler.closeElement("Xb", attributes, "-10", warnings);
handler.closeElement("LocationMode", attributes, "2", warnings);
handler.endHandler("Parachute", attributes, null, warnings);
- assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition());
- assertEquals(component.getPositionValue(), 10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+ Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition());
+ Assert.assertEquals(component.getPositionValue(), 10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
}
-
-
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
+import net.sf.openrocket.rocketcomponent.Bulkhead;
import net.sf.openrocket.rocketcomponent.CenteringRing;
+import net.sf.openrocket.rocketcomponent.EngineBlock;
+import net.sf.openrocket.rocketcomponent.RingComponent;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.rocketcomponent.TubeCoupler;
+import org.junit.Assert;
+import org.junit.Test;
import java.util.HashMap;
*/
public class RingHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = RingHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = RingHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(RingHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public RingHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: openElement(String element, HashMap<String, String> attributes, WarningSet warnings)
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
WarningSet warnings = new WarningSet();
handler.closeElement("OD", attributes, "0", warnings);
- assertEquals(0d, component.getOuterRadius());
+ Assert.assertEquals(0d, component.getOuterRadius(), 0.001);
handler.closeElement("OD", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001);
handler.closeElement("OD", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ID", attributes, "0", warnings);
- assertEquals(0d, component.getInnerRadius());
+ Assert.assertEquals(0d, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "75", warnings);
- assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius());
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001);
handler.closeElement("ID", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
}
+ /**
+ * Test a bulkhead.
+ *
+ * @throws Exception thrown if something goes awry
+ */
+ @Test
+ public void testBulkhead() throws Exception {
+ BodyTube tube = new BodyTube();
+ RingHandler handler = new RingHandler(tube, new WarningSet());
+ CenteringRing component = (CenteringRing) getField(handler, "ring");
+ HashMap<String, String> attributes = new HashMap<String, String>();
+ WarningSet warnings = new WarningSet();
+
+ handler.closeElement("OD", attributes, "75", warnings);
+ handler.closeElement("ID", attributes, "0", warnings);
+ handler.closeElement("Len", attributes, "10", warnings);
+ handler.closeElement("Name", attributes, "Test Name", warnings);
+ handler.closeElement("KnownMass", attributes, "109.9", warnings);
+ handler.closeElement("UsageCode", attributes, "1", warnings);
+ handler.closeElement("UseKnownCG", attributes, "1", warnings);
+ handler.endHandler("", attributes, "", warnings);
+
+ Assert.assertEquals(1, tube.getChildren().size());
+ RingComponent child = (RingComponent)tube.getChild(0);
+
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001);
+ Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001);
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001);
+ Assert.assertEquals("Test Name", child.getName());
+ Assert.assertEquals(109.9/1000, child.getMass(), 0.001);
+ Assert.assertEquals(0, child.getPositionValue(), 0.0);
+ Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition());
+ Assert.assertTrue(child instanceof Bulkhead);
+
+ }
+
+ /**
+ * Test a tube coupler.
+ *
+ * @throws Exception thrown if something goes awry
+ */
+ @Test
+ public void testTubeCoupler() throws Exception {
+ BodyTube tube = new BodyTube();
+ RingHandler handler = new RingHandler(tube, new WarningSet());
+ HashMap<String, String> attributes = new HashMap<String, String>();
+ WarningSet warnings = new WarningSet();
+
+ handler.closeElement("OD", attributes, "75", warnings);
+ handler.closeElement("ID", attributes, "70", warnings);
+ handler.closeElement("Len", attributes, "10", warnings);
+ handler.closeElement("Name", attributes, "Test Name", warnings);
+ handler.closeElement("KnownMass", attributes, "109.9", warnings);
+ handler.closeElement("UsageCode", attributes, "4", warnings);
+ handler.closeElement("UseKnownCG", attributes, "1", warnings);
+ handler.endHandler("", attributes, "", warnings);
+
+ Assert.assertEquals(1, tube.getChildren().size());
+ RingComponent child = (RingComponent)tube.getChild(0);
+ Assert.assertTrue(child instanceof TubeCoupler);
+
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001);
+ Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001);
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001);
+ Assert.assertEquals("Test Name", child.getName());
+ Assert.assertEquals(109.9/1000, child.getMass(), 0.001);
+ Assert.assertEquals(0, child.getPositionValue(), 0.0);
+ Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition());
+ }
+
+ /**
+ * Test a engine block.
+ *
+ * @throws Exception thrown if something goes awry
+ */
+ @Test
+ public void testEngineBlock() throws Exception {
+ BodyTube tube = new BodyTube();
+ RingHandler handler = new RingHandler(tube, new WarningSet());
+ HashMap<String, String> attributes = new HashMap<String, String>();
+ WarningSet warnings = new WarningSet();
+
+ handler.closeElement("OD", attributes, "75", warnings);
+ handler.closeElement("ID", attributes, "70", warnings);
+ handler.closeElement("Len", attributes, "10", warnings);
+ handler.closeElement("Name", attributes, "Test Name", warnings);
+ handler.closeElement("KnownMass", attributes, "109.9", warnings);
+ handler.closeElement("UsageCode", attributes, "2", warnings);
+ handler.closeElement("KnownCG", attributes, "4", warnings);
+ handler.closeElement("UseKnownCG", attributes, "1", warnings);
+ handler.endHandler("", attributes, "", warnings);
+
+ Assert.assertEquals(1, tube.getChildren().size());
+ RingComponent child = (RingComponent)tube.getChild(0);
+ Assert.assertTrue(child instanceof EngineBlock);
+
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001);
+ Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001);
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001);
+ Assert.assertEquals("Test Name", child.getName());
+ Assert.assertEquals(109.9/1000, child.getMass(), 0.001);
+ Assert.assertEquals(0, child.getPositionValue(), 0.0);
+ Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition());
+ Assert.assertEquals(4d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getCG().x, 0.000001);
+
+ }
+
+ /**
+ * Test a centering ring
+ *
+ * @throws Exception thrown if something goes awry
+ */
+ @Test
+ public void testRing() throws Exception {
+ BodyTube tube = new BodyTube();
+ RingHandler handler = new RingHandler(tube, new WarningSet());
+ HashMap<String, String> attributes = new HashMap<String, String>();
+ WarningSet warnings = new WarningSet();
+
+ handler.closeElement("OD", attributes, "75", warnings);
+ handler.closeElement("ID", attributes, "0", warnings);
+ handler.closeElement("Len", attributes, "10", warnings);
+ handler.closeElement("Name", attributes, "Test Name", warnings);
+ handler.closeElement("KnownMass", attributes, "109.9", warnings);
+ handler.closeElement("UsageCode", attributes, "0", warnings);
+ handler.closeElement("UseKnownCG", attributes, "1", warnings);
+ handler.endHandler("", attributes, "", warnings);
+
+ Assert.assertEquals(1, tube.getChildren().size());
+ RingComponent child = (RingComponent)tube.getChild(0);
+
+ Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001);
+ Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001);
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001);
+ Assert.assertEquals("Test Name", child.getName());
+ Assert.assertEquals(109.9/1000, child.getMass(), 0.001);
+ Assert.assertEquals(0, child.getPositionValue(), 0.0);
+ Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition());
+ Assert.assertTrue(child instanceof CenteringRing);
+ }
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new RingHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
BodyTube tube = new BodyTube();
RingHandler handler = new RingHandler(tube, new WarningSet());
CenteringRing component = (CenteringRing) getField(handler, "ring");
- assertContains(component, tube.getChildren());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
RingHandler handler = new RingHandler(tube, new WarningSet());
CenteringRing component = (CenteringRing) getField(handler, "ring");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
+
/**
* Method: getComponent()
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new RingHandler(new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing);
+ Assert.assertTrue(new RingHandler(new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new RingHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new RingHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
+import org.junit.Assert;
/**
* RocksimContentHandler Tester.
*
*/
-public class RocksimContentHandlerTest extends TestCase {
-
- /**
- * The class under test.
- */
- public static final Class classUT = RocksimContentHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = RocksimContentHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(RocksimContentHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public RocksimContentHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
+public class RocksimContentHandlerTest {
/**
*
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetDocument() throws Exception {
RocksimContentHandler handler = new RocksimContentHandler();
- assertNotNull(handler.getDocument());
+ Assert.assertNotNull(handler.getDocument());
}
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.Stage;
+import org.junit.Assert;
import java.io.BufferedInputStream;
import java.io.InputStream;
* RocksimLoader Tester.
*
*/
-public class RocksimLoaderTest extends TestCase {
-
- /**
- * The class under test.
- */
- public static final Class classUT = RocksimLoader.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = RocksimLoaderTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(RocksimLoaderTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public RocksimLoaderTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
+public class RocksimLoaderTest {
/**
* Test a bug reported via automated bug report. I have been unable to reproduce this bug
* (hanging finset off of an inner body tube) when creating a Rocksim file using Rocksim. The bug
* is reproducible when manually modifying the Rocksim file, which is what is tested here.
*/
+ @org.junit.Test
public void testFinsOnInnerTube() throws Exception {
RocksimLoader loader = new RocksimLoader();
InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt");
- assertNotNull("Could not open PodFins.rkt", stream);
+ Assert.assertNotNull("Could not open PodFins.rkt", stream);
try {
OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream));
- assertNotNull(doc);
+ Assert.assertNotNull(doc);
Rocket rocket = doc.getRocket();
- assertNotNull(rocket);
+ Assert.assertNotNull(rocket);
}
catch (IllegalStateException ise) {
- fail(ise.getMessage());
+ Assert.fail(ise.getMessage());
}
- assertTrue(loader.getWarnings().size() == 2);
+ Assert.assertTrue(loader.getWarnings().size() == 2);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testLoadFromStream() throws Exception {
RocksimLoader loader = new RocksimLoader();
//Stupid single stage rocket
InputStream stream = this.getClass().getResourceAsStream("rocksimTestRocket1.rkt");
- assertNotNull("Could not open rocksimTestRocket1.rkt", stream);
+ Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream);
OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream));
- assertNotNull(doc);
+ Assert.assertNotNull(doc);
Rocket rocket = doc.getRocket();
- assertNotNull(rocket);
- assertEquals("FooBar Test", doc.getRocket().getName());
- assertTrue(loader.getWarnings().isEmpty());
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals("FooBar Test", doc.getRocket().getName());
+ Assert.assertTrue(loader.getWarnings().isEmpty());
stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt");
- assertNotNull("Could not open rocksimTestRocket2.rkt", stream);
+ Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream);
doc = loader.loadFromStream(new BufferedInputStream(stream));
- assertNotNull(doc);
+ Assert.assertNotNull(doc);
rocket = doc.getRocket();
- assertNotNull(rocket);
+ Assert.assertNotNull(rocket);
//Do some simple asserts; the important thing here is just validating that the mass and cg were
//not overridden for each stage.
- assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName());
- assertEquals(1, loader.getWarnings().size());
- assertEquals(3, rocket.getStageCount());
+ Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName());
+ Assert.assertEquals(1, loader.getWarnings().size());
+ Assert.assertEquals(3, rocket.getStageCount());
Stage stage1 = (Stage)rocket.getChild(0);
- assertFalse(stage1.isMassOverridden());
- assertFalse(stage1.isCGOverridden());
+ Assert.assertFalse(stage1.isMassOverridden());
+ Assert.assertFalse(stage1.isCGOverridden());
Stage stage2 = (Stage)rocket.getChild(1);
- assertFalse(stage2.isMassOverridden());
- assertFalse(stage2.isCGOverridden());
+ Assert.assertFalse(stage2.isMassOverridden());
+ Assert.assertFalse(stage2.isCGOverridden());
Stage stage3 = (Stage)rocket.getChild(2);
- assertFalse(stage3.isMassOverridden());
- assertFalse(stage3.isCGOverridden());
+ Assert.assertFalse(stage3.isMassOverridden());
+ Assert.assertFalse(stage3.isCGOverridden());
stream = this.getClass().getResourceAsStream("rocksimTestRocket3.rkt");
- assertNotNull("Could not open rocksimTestRocket3.rkt", stream);
+ Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream);
doc = loader.loadFromStream(new BufferedInputStream(stream));
- assertNotNull(doc);
+ Assert.assertNotNull(doc);
rocket = doc.getRocket();
- assertNotNull(rocket);
- assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName());
- assertEquals(3, rocket.getStageCount());
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName());
+ Assert.assertEquals(3, rocket.getStageCount());
stage1 = (Stage)rocket.getChild(0);
stage2 = (Stage)rocket.getChild(1);
stage3 = (Stage)rocket.getChild(2);
//Do some 1st level and simple asserts; the idea here is to not do a deep validation as that
//should have been covered elsewhere. Assert that the stage overrides are correct.
- assertEquals(2, stage1.getChildCount());
- assertEquals("Nose cone", stage1.getChild(0).getName());
- assertEquals("Body tube", stage1.getChild(1).getName());
- assertTrue(stage1.isMassOverridden());
- assertEquals(0.185d, stage1.getOverrideMass());
- assertTrue(stage1.isCGOverridden());
- assertEquals(0.3d, stage1.getOverrideCG().x);
- assertEquals(4, loader.getWarnings().size());
+ Assert.assertEquals(2, stage1.getChildCount());
+ Assert.assertEquals("Nose cone", stage1.getChild(0).getName());
+ Assert.assertEquals("Body tube", stage1.getChild(1).getName());
+ Assert.assertTrue(stage1.isMassOverridden());
+ Assert.assertEquals(0.185d, stage1.getOverrideMass(), 0.001);
+ Assert.assertTrue(stage1.isCGOverridden());
+ Assert.assertEquals(0.3d, stage1.getOverrideCG().x, 0.001);
+ Assert.assertEquals(4, loader.getWarnings().size());
- assertEquals(1, stage2.getChildCount());
- assertEquals("2nd Stage Tube", stage2.getChild(0).getName());
- assertTrue(stage2.isMassOverridden());
- assertEquals(0.21d, stage2.getOverrideMass());
- assertTrue(stage2.isCGOverridden());
- assertEquals(0.4d, stage2.getOverrideCG().x);
+ Assert.assertEquals(1, stage2.getChildCount());
+ Assert.assertEquals("2nd Stage Tube", stage2.getChild(0).getName());
+ Assert.assertTrue(stage2.isMassOverridden());
+ Assert.assertEquals(0.21d, stage2.getOverrideMass(), 0.001);
+ Assert.assertTrue(stage2.isCGOverridden());
+ Assert.assertEquals(0.4d, stage2.getOverrideCG().x, 0.001);
BodyTube bt = (BodyTube)stage2.getChild(0);
LaunchLug ll = (LaunchLug)bt.getChild(6);
- assertEquals(1.22d, ll.getRadialDirection());
+ Assert.assertEquals(1.22d, ll.getRadialDirection(), 0.001);
- assertEquals(2, stage3.getChildCount());
- assertEquals("Transition", stage3.getChild(0).getName());
- assertEquals("Body tube", stage3.getChild(1).getName());
- assertTrue(stage2.isMassOverridden());
- assertEquals(0.33d, stage3.getOverrideMass());
- assertTrue(stage2.isCGOverridden());
- assertEquals(0.5d, stage3.getOverrideCG().x);
+ Assert.assertEquals(2, stage3.getChildCount());
+ Assert.assertEquals("Transition", stage3.getChild(0).getName());
+ Assert.assertEquals("Body tube", stage3.getChild(1).getName());
+ Assert.assertTrue(stage2.isMassOverridden());
+ Assert.assertEquals(0.33d, stage3.getOverrideMass(), 0.001);
+ Assert.assertTrue(stage2.isCGOverridden());
+ Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001);
}
}
*/
package net.sf.openrocket.file.rocksim;
-import java.lang.reflect.Field;
-import java.util.List;
-
-import junit.framework.TestCase;
import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
+import org.junit.Assert;
+import org.junit.Before;
+
+import java.lang.reflect.Field;
+import java.util.List;
/**
* A base class for the Rocksim tests. Includes code from the junitx.addons project.
*/
-public abstract class RocksimTestBase extends TestCase {
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public RocksimTestBase(String name) {
- super(name);
- }
-
+public abstract class RocksimTestBase {
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Application.setPreferences( new SwingPreferences() );
+ @Before
+ public void setUp() throws Exception {
+ Application.setPreferences( new SwingPreferences() );
}
public void assertContains(RocketComponent child, List<RocketComponent> components) {
- assertTrue("Components did not contain child", components.contains(child));
+ Assert.assertTrue("Components did not contain child", components.contains(child));
}
/**
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Streamer;
+import org.junit.Assert;
+import org.junit.Test;
import java.util.HashMap;
*/
public class StreamerHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = StreamerHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = StreamerHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(StreamerHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public StreamerHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: openElement(String element, HashMap<String, String> attributes, WarningSet warnings)
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
WarningSet warnings = new WarningSet();
handler.closeElement("Width", attributes, "0", warnings);
- assertEquals(0d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth());
+ Assert.assertEquals(0d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001);
handler.closeElement("Width", attributes, "10", warnings);
- assertEquals(10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth());
+ Assert.assertEquals(10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001);
handler.closeElement("Width", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getStripLength());
+ Assert.assertEquals(0d, component.getStripLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
handler.closeElement("DragCoefficient", attributes, "0.94", warnings);
- assertEquals(0.94d, component.getCD());
+ Assert.assertEquals(0.94d, component.getCD(), 0.001);
handler.closeElement("DragCoefficient", attributes, "-0.94", warnings);
- assertEquals(-0.94d, component.getCD());
+ Assert.assertEquals(-0.94d, component.getCD(), 0.001);
handler.closeElement("DragCoefficient", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
}
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testConstructor() throws Exception {
try {
new StreamerHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testSetRelativePosition() throws Exception {
BodyTube tube = new BodyTube();
StreamerHandler handler = new StreamerHandler(tube, new WarningSet());
Streamer component = (Streamer) getField(handler, "streamer");
handler.setRelativePosition(RocketComponent.Position.ABSOLUTE);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetComponent() throws Exception {
- assertTrue(new StreamerHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Streamer);
+ Assert.assertTrue(new StreamerHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Streamer);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube(), new WarningSet()).getMaterialType());
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @Test
public void testEndHandler() throws Exception {
BodyTube tube = new BodyTube();
StreamerHandler handler = new StreamerHandler(tube, new WarningSet());
handler.closeElement("Xb", attributes, "-10", warnings);
handler.closeElement("LocationMode", attributes, "1", warnings);
handler.endHandler("Streamer", attributes, null, warnings);
- assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
- assertEquals(component.getPositionValue(), -10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+ Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition());
+ Assert.assertEquals(component.getPositionValue(), -10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
handler.closeElement("Xb", attributes, "-10", warnings);
handler.closeElement("LocationMode", attributes, "2", warnings);
handler.endHandler("Streamer", attributes, null, warnings);
- assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition());
- assertEquals(component.getPositionValue(), 10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+ Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition());
+ Assert.assertEquals(component.getPositionValue(), 10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
handler.closeElement("Thickness", attributes, "0.02", warnings);
- assertEquals(0.01848, handler.computeDensity(RocksimDensityType.ROCKSIM_BULK, 924d));
+ Assert.assertEquals(0.01848, handler.computeDensity(RocksimDensityType.ROCKSIM_BULK, 924d), 0.001);
//Test Density Type 0 (Bulk)
handler.closeElement("Density", attributes, "924.0", warnings);
handler.closeElement("DensityType", attributes, "0", warnings);
handler.endHandler("Streamer", attributes, null, warnings);
- assertEquals(0.01848d, component.getMaterial().getDensity());
+ Assert.assertEquals(0.01848d, component.getMaterial().getDensity(), 0.001);
//Test Density Type 1 (Surface)
handler.closeElement("Density", attributes, "0.006685", warnings);
handler.closeElement("DensityType", attributes, "1", warnings);
handler.endHandler("Streamer", attributes, null, warnings);
- assertTrue(Math.abs(0.06685d - component.getMaterial().getDensity()) < 0.00001);
+ Assert.assertTrue(Math.abs(0.06685d - component.getMaterial().getDensity()) < 0.00001);
//Test Density Type 2 (Line)
handler.closeElement("Density", attributes, "0.223225", warnings);
handler.closeElement("Width", attributes, "203.2", warnings);
handler.endHandler("Streamer", attributes, null, warnings);
- assertEquals(1.728190092, component.getMass());
+ Assert.assertEquals(1.728190092, component.getMass(), 0.001);
}
*/
package net.sf.openrocket.file.rocksim;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.simplesax.PlainTextHandler;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.ExternalComponent;
import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.Transition;
+import org.junit.Assert;
import java.util.HashMap;
*/
public class TransitionHandlerTest extends RocksimTestBase {
- /**
- * The class under test.
- */
- public static final Class classUT = TransitionHandler.class;
-
- /**
- * The test class (this class).
- */
- public static final Class testClass = TransitionHandlerTest.class;
-
- /**
- * Create a test suite of all tests within this test class.
- *
- * @return a suite of tests
- */
- public static Test suite() {
- return new TestSuite(TransitionHandlerTest.class);
- }
-
- /**
- * Test constructor.
- *
- * @param name the name of the test to run.
- */
- public TransitionHandlerTest(String name) {
- super(name);
- }
-
- /**
- * Setup the fixture.
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Teardown the fixture.
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
* Method: constructor
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testConstructor() throws Exception {
try {
new TransitionHandler(null, new WarningSet());
- fail("Should have thrown IllegalArgumentException");
+ Assert.fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException iae) {
//success
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testOpenElement() throws Exception {
- assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage(), new WarningSet()).openElement(null, null, null));
+ Assert.assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage(), new WarningSet()).openElement(null, null, null));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testCloseElement() throws Exception {
Stage stage = new Stage();
Transition component = (Transition) getField(handler, "transition");
handler.closeElement("ShapeCode", attributes, "0", warnings);
- assertEquals(Transition.Shape.CONICAL, component.getType());
+ Assert.assertEquals(Transition.Shape.CONICAL, component.getType());
handler.closeElement("ShapeCode", attributes, "1", warnings);
- assertEquals(Transition.Shape.OGIVE, component.getType());
+ Assert.assertEquals(Transition.Shape.OGIVE, component.getType());
handler.closeElement("ShapeCode", attributes, "17", warnings);
- assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default
+ Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default
handler.closeElement("ShapeCode", attributes, "foo", warnings);
- assertNotNull(component.getType());
- assertEquals(1, warnings.size());
+ Assert.assertNotNull(component.getType());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Len", attributes, "-1", warnings);
- assertEquals(0d, component.getLength());
+ Assert.assertEquals(0d, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001);
handler.closeElement("Len", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("FrontDia", attributes, "-1", warnings);
- assertEquals(0d, component.getForeRadius());
+ Assert.assertEquals(0d, component.getForeRadius(), 0.001);
handler.closeElement("FrontDia", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeRadius(), 0.001);
handler.closeElement("FrontDia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("RearDia", attributes, "-1", warnings);
- assertEquals(0d, component.getAftRadius());
+ Assert.assertEquals(0d, component.getAftRadius(), 0.001);
handler.closeElement("RearDia", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001);
handler.closeElement("RearDia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
final double aft = 100d;
component.setForeShoulderRadius(1.1d);
handler.closeElement("WallThickness", attributes, "-1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(component.getAftRadius(), component.getThickness());
- assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness());
- assertEquals(component.getForeShoulderThickness(), component.getForeShoulderThickness());
+ Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001);
+ Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001);
+ Assert.assertEquals(component.getForeShoulderThickness(), component.getForeShoulderThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "100", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(aft, component.getThickness());
+ Assert.assertEquals(aft, component.getThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "foo", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("ConstructionType", attributes, "1", warnings);
component.setForeShoulderRadius(1.1d);
handler.closeElement("WallThickness", attributes, "-1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(0d, component.getThickness());
- assertEquals(0d, component.getAftShoulderThickness());
- assertEquals(0d, component.getForeShoulderThickness());
+ Assert.assertEquals(0d, component.getThickness(), 0.001);
+ Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001);
+ Assert.assertEquals(0d, component.getForeShoulderThickness(), 0.001);
handler.closeElement("WallThickness", attributes, "1.1", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness());
- assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness());
- assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderThickness());
+ Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001);
+ Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001);
+ Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderThickness(), 0.001);
handler.closeElement("FrontShoulderLen", attributes, "-1", warnings);
- assertEquals(0d, component.getForeShoulderLength());
+ Assert.assertEquals(0d, component.getForeShoulderLength(), 0.001);
handler.closeElement("FrontShoulderLen", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001);
handler.closeElement("FrontShoulderLen", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001);
handler.closeElement("FrontShoulderLen", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("RearShoulderLen", attributes, "-1", warnings);
- assertEquals(0d, component.getAftShoulderLength());
+ Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001);
handler.closeElement("RearShoulderLen", attributes, "10", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001);
handler.closeElement("RearShoulderLen", attributes, "10.0", warnings);
- assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength());
+ Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001);
handler.closeElement("RearShoulderLen", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("FrontShoulderDia", attributes, "-1", warnings);
- assertEquals(0d, component.getForeShoulderRadius());
+ Assert.assertEquals(0d, component.getForeShoulderRadius(), 0.001);
handler.closeElement("FrontShoulderDia", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeShoulderRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeShoulderRadius(), 0.001);
handler.closeElement("FrontShoulderDia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("RearShoulderDia", attributes, "-1", warnings);
- assertEquals(0d, component.getAftShoulderRadius());
+ Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001);
handler.closeElement("RearShoulderDia", attributes, "100", warnings);
- assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius());
+ Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001);
handler.closeElement("RearShoulderDia", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
component.setType(Transition.Shape.HAACK);
handler.closeElement("ShapeParameter", attributes, "-1", warnings);
- assertEquals(0d, component.getShapeParameter());
+ Assert.assertEquals(0d, component.getShapeParameter(), 0.001);
handler.closeElement("ShapeParameter", attributes, "100", warnings);
- assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter());
+ Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001);
handler.closeElement("ShapeParameter", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
- assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.",
+ Assert.assertEquals(1, warnings.size());
+ Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.",
warnings.iterator().next().toString());
warnings.clear();
component.setType(Transition.Shape.CONICAL);
component.setShapeParameter(0d);
handler.closeElement("ShapeParameter", attributes, "100", warnings);
- assertEquals(0d, component.getShapeParameter());
+ Assert.assertEquals(0d, component.getShapeParameter(), 0.001);
handler.closeElement("FinishCode", attributes, "-1", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "100", warnings);
- assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
+ Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish());
handler.closeElement("FinishCode", attributes, "foo", warnings);
- assertEquals(1, warnings.size());
+ Assert.assertEquals(1, warnings.size());
warnings.clear();
handler.closeElement("Name", attributes, "Test Name", warnings);
- assertEquals("Test Name", component.getName());
+ Assert.assertEquals("Test Name", component.getName());
handler.closeElement("Material", attributes, "Some Material", warnings);
handler.endHandler("Transition", attributes, null, warnings);
- assertTrue(component.getMaterial().getName().contains("Some Material"));
+ Assert.assertTrue(component.getMaterial().getName().contains("Some Material"));
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetComponent() throws Exception {
- assertTrue(new TransitionHandler(new Stage(), new WarningSet()).getComponent() instanceof Transition);
+ Assert.assertTrue(new TransitionHandler(new Stage(), new WarningSet()).getComponent() instanceof Transition);
}
/**
*
* @throws Exception thrown if something goes awry
*/
+ @org.junit.Test
public void testGetMaterialType() throws Exception {
- assertEquals(Material.Type.BULK, new TransitionHandler(new Stage(), new WarningSet()).getMaterialType());
+ Assert.assertEquals(Material.Type.BULK, new TransitionHandler(new Stage(), new WarningSet()).getMaterialType());
}