From c55a6518fb749ae7131948b6c91001275f7c56fe Mon Sep 17 00:00:00 2001 From: rodinia814 Date: Tue, 20 Jul 2010 06:13:55 +0000 Subject: [PATCH] DGP - added isCompatible checks for all Rocksim components git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@59 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../file/rocksim/AttachedPartsHandler.java | 14 +- .../openrocket/file/rocksim/BaseHandler.java | 20 + .../file/rocksim/BodyTubeHandler.java | 7 +- .../file/rocksim/FinSetHandler.java | 86 +-- .../file/rocksim/InnerBodyTubeHandler.java | 7 +- .../file/rocksim/LaunchLugHandler.java | 8 +- .../file/rocksim/MassObjectHandler.java | 7 +- .../file/rocksim/NoseConeHandler.java | 10 +- .../file/rocksim/ParachuteHandler.java | 8 +- .../openrocket/file/rocksim/RingHandler.java | 7 +- .../file/rocksim/RocksimHandler.java | 6 +- .../file/rocksim/StreamerHandler.java | 8 +- .../file/rocksim/TransitionHandler.java | 7 +- .../file/rocksim/BodyTubeHandlerTest.java | 17 +- .../rocksim/InnerBodyTubeHandlerTest.java | 18 +- .../file/rocksim/LaunchLugHandlerTest.java | 15 +- .../file/rocksim/MassObjectHandlerTest.java | 19 +- .../file/rocksim/NoseConeHandlerTest.java | 19 +- .../file/rocksim/ParachuteHandlerTest.java | 17 +- .../sf/openrocket/file/rocksim/PodFins.rkt | 605 ++++++++++++++++++ .../file/rocksim/RingHandlerTest.java | 15 +- .../file/rocksim/RocksimLoaderTest.java | 27 +- .../file/rocksim/StreamerHandlerTest.java | 16 +- .../file/rocksim/TransitionHandlerTest.java | 13 +- 24 files changed, 825 insertions(+), 151 deletions(-) create mode 100644 test/net/sf/openrocket/file/rocksim/PodFins.rkt diff --git a/src/net/sf/openrocket/file/rocksim/AttachedPartsHandler.java b/src/net/sf/openrocket/file/rocksim/AttachedPartsHandler.java index 76085748..2ced5a7e 100644 --- a/src/net/sf/openrocket/file/rocksim/AttachedPartsHandler.java +++ b/src/net/sf/openrocket/file/rocksim/AttachedPartsHandler.java @@ -39,25 +39,25 @@ class AttachedPartsHandler extends ElementHandler { return new FinSetHandler(component); } if ("LaunchLug".equals(element)) { - return new LaunchLugHandler(component); + return new LaunchLugHandler(component, warnings); } if ("Parachute".equals(element)) { - return new ParachuteHandler(component); + return new ParachuteHandler(component, warnings); } if ("Streamer".equals(element)) { - return new StreamerHandler(component); + return new StreamerHandler(component, warnings); } if ("MassObject".equals(element)) { - return new MassObjectHandler(component); + return new MassObjectHandler(component, warnings); } if ("Ring".equals(element)) { - return new RingHandler(component); + return new RingHandler(component, warnings); } if ("BodyTube".equals(element)) { - return new InnerBodyTubeHandler(component); + return new InnerBodyTubeHandler(component, warnings); } if ("Transition".equals(element)) { - return new TransitionHandler(component); + return new TransitionHandler(component, warnings); } if ("TubeFinSet".equals(element)) { warnings.add("Tube fins are not currently supported. Ignoring."); diff --git a/src/net/sf/openrocket/file/rocksim/BaseHandler.java b/src/net/sf/openrocket/file/rocksim/BaseHandler.java index 700c2f9b..c4e9c11e 100644 --- a/src/net/sf/openrocket/file/rocksim/BaseHandler.java +++ b/src/net/sf/openrocket/file/rocksim/BaseHandler.java @@ -180,6 +180,26 @@ public abstract class BaseHandler extends ElementHand materialName = content; } + /** + * Add child to parent only if the child is compatible. Otherwise add to warning set. + * + * @param parent the parent component + * @param child the child component + * @param warnings the warning set + * + * @return true if the child is compatible with parent + */ + protected static boolean isCompatible(RocketComponent parent, Class child, WarningSet warnings) { + if (!parent.isCompatible(child)) { + warnings.add(child.getName() + " can not be attached to " + + parent.getComponentName() + ", ignoring component."); + return false; + } + else { + return true; + } + } + /** * Create a custom material based on the density. * diff --git a/src/net/sf/openrocket/file/rocksim/BodyTubeHandler.java b/src/net/sf/openrocket/file/rocksim/BodyTubeHandler.java index 6347d3b2..a645827f 100644 --- a/src/net/sf/openrocket/file/rocksim/BodyTubeHandler.java +++ b/src/net/sf/openrocket/file/rocksim/BodyTubeHandler.java @@ -26,14 +26,17 @@ class BodyTubeHandler extends BaseHandler { * Constructor. * * @param c parent component + * @param warnings the warning set * @throws IllegalArgumentException thrown if c is null */ - public BodyTubeHandler(RocketComponent c) throws IllegalArgumentException { + public BodyTubeHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of a body tube may not be null."); } bodyTube = new BodyTube(); - c.addChild(bodyTube); + if (isCompatible(c, BodyTube.class, warnings)) { + c.addChild(bodyTube); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/FinSetHandler.java b/src/net/sf/openrocket/file/rocksim/FinSetHandler.java index fb8add58..9b9239dc 100644 --- a/src/net/sf/openrocket/file/rocksim/FinSetHandler.java +++ b/src/net/sf/openrocket/file/rocksim/FinSetHandler.java @@ -7,26 +7,26 @@ import net.sf.openrocket.aerodynamics.WarningSet; 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.RocketComponent; -import net.sf.openrocket.rocketcomponent.FinSet; -import net.sf.openrocket.rocketcomponent.ExternalComponent; -import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.rocketcomponent.EllipticalFinSet; +import net.sf.openrocket.rocketcomponent.ExternalComponent; +import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.IllegalFinPointException; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.util.Coordinate; import org.xml.sax.SAXException; -import java.util.HashMap; -import java.util.List; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; +import java.util.List; /** - * A SAX handler for Rocksim fin sets. Because the type of - * fin may not be known first (in Rocksim file format, the fin shape type is in the middle of the XML structure), - * and because we're using SAX not DOM, all of the fin characteristics are kept here until the closing FinSet tag. - * At that point, asOpenRocket method is called to construct the corresponding OpenRocket FinSet. + * A SAX handler for Rocksim fin sets. Because the type of fin may not be known first (in Rocksim file format, the fin + * shape type is in the middle of the XML structure), and because we're using SAX not DOM, all of the fin + * characteristics are kept here until the closing FinSet tag. At that point, asOpenRocket method is called + * to construct the corresponding OpenRocket FinSet. */ class FinSetHandler extends ElementHandler { /** @@ -47,7 +47,7 @@ class FinSetHandler extends ElementHandler { */ private double location = 0.0d; /** - * The OpenRocket Position which gives the absolute/relative positiong for location. + * The OpenRocket Position which gives the absolute/relative positioning for location. */ private RocketComponent.Position position; /** @@ -141,9 +141,9 @@ class FinSetHandler extends ElementHandler { * * @param c the parent * - * @throws IllegalArgumentException thrown if c is null + * @throws IllegalArgumentException thrown if c is null */ - public FinSetHandler(RocketComponent c) throws IllegalArgumentException { + public FinSetHandler (RocketComponent c) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of a fin set may not be null."); } @@ -151,12 +151,12 @@ class FinSetHandler extends ElementHandler { } @Override - public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) { + public ElementHandler openElement (String element, HashMap attributes, WarningSet warnings) { return PlainTextHandler.INSTANCE; } @Override - public void closeElement(String element, HashMap attributes, String content, WarningSet warnings) + public void closeElement (String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { try { if ("Name".equals(element)) { @@ -241,20 +241,26 @@ class FinSetHandler extends ElementHandler { } @Override - public void endHandler(String element, HashMap attributes, - String content, WarningSet warnings) throws SAXException { + public void endHandler (String element, HashMap attributes, + String content, WarningSet warnings) throws SAXException { //Create the fin set and correct for overrides and actual material densities final FinSet finSet = asOpenRocket(warnings); - BaseHandler.setOverride(finSet, override, mass, cg); - if (!override && finSet.getCrossSection().equals(FinSet.CrossSection.AIRFOIL)) { - //Override mass anyway. This is done only for AIRFOIL because Rocksim does not compute different - //mass/cg for different cross sections, but OpenRocket does. This can lead to drastic differences - //in mass. To counteract that, the cross section value is retained but the mass/cg is overridden - //with the calculated values from Rocksim. This will best approximate the Rocksim design in OpenRocket. - BaseHandler.setOverride(finSet, true, calcMass, calcCg); + if (component.isCompatible(finSet)) { + BaseHandler.setOverride(finSet, override, mass, cg); + if (!override && finSet.getCrossSection().equals(FinSet.CrossSection.AIRFOIL)) { + //Override mass anyway. This is done only for AIRFOIL because Rocksim does not compute different + //mass/cg for different cross sections, but OpenRocket does. This can lead to drastic differences + //in mass. To counteract that, the cross section value is retained but the mass/cg is overridden + //with the calculated values from Rocksim. This will best approximate the Rocksim design in OpenRocket. + BaseHandler.setOverride(finSet, true, calcMass, calcCg); + } + BaseHandler.updateComponentMaterial(finSet, materialName, Material.Type.BULK, density); + component.addChild(finSet); + } + else { + warnings.add(finSet.getComponentName() + " can not be attached to " + + component.getComponentName() + ", ignoring component."); } - BaseHandler.updateComponentMaterial(finSet, materialName, Material.Type.BULK, density); - component.addChild(finSet); } @@ -262,9 +268,10 @@ class FinSetHandler extends ElementHandler { * Convert the parsed Rocksim data values in this object to an instance of OpenRocket's FinSet. * * @param warnings the warning set to convey incompatibilities to the user + * * @return a FinSet instance */ - public FinSet asOpenRocket(WarningSet warnings) { + public FinSet asOpenRocket (WarningSet warnings) { FinSet result; if (shapeCode == 0) { @@ -313,26 +320,26 @@ class FinSetHandler extends ElementHandler { * * @param pointList a comma and pipe delimited string of X,Y coordinates from Rocksim. This is of the format: *
x0,y0|x1,y1|x2,y2|... 
- * @param warnings the warning set to convey incompatibilities to the user + * @param warnings the warning set to convey incompatibilities to the user * * @return an array of OpenRocket Coordinates */ - private Coordinate[] toCoordinates(String pointList, WarningSet warnings) { + private Coordinate[] toCoordinates (String pointList, WarningSet warnings) { List result = new ArrayList(); if (pointList != null && !pointList.isEmpty()) { String[] points = pointList.split("\\Q|\\E"); for (String point : points) { String[] aPoint = point.split(","); try { - if (aPoint.length > 1) { - Coordinate c = new Coordinate( - Double.parseDouble(aPoint[0]) / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, - Double.parseDouble(aPoint[1]) / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); - result.add(c); - } - else { - warnings.add("Invalid fin point pair."); - } + if (aPoint.length > 1) { + Coordinate c = new Coordinate( + Double.parseDouble(aPoint[0]) / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, + Double.parseDouble(aPoint[1]) / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH); + result.add(c); + } + else { + warnings.add("Invalid fin point pair."); + } } catch (NumberFormatException nfe) { warnings.add("Fin point not in numeric format."); @@ -356,9 +363,10 @@ class FinSetHandler extends ElementHandler { * Convert a Rocksim tip shape to an OpenRocket CrossSection. * * @param tipShape the tip shape code from Rocksim + * * @return a CrossSection instance */ - private FinSet.CrossSection convertTipShapeCode(int tipShape) { + private FinSet.CrossSection convertTipShapeCode (int tipShape) { switch (tipShape) { case 0: return FinSet.CrossSection.SQUARE; diff --git a/src/net/sf/openrocket/file/rocksim/InnerBodyTubeHandler.java b/src/net/sf/openrocket/file/rocksim/InnerBodyTubeHandler.java index 1c7b41c2..eaa10148 100644 --- a/src/net/sf/openrocket/file/rocksim/InnerBodyTubeHandler.java +++ b/src/net/sf/openrocket/file/rocksim/InnerBodyTubeHandler.java @@ -27,14 +27,17 @@ class InnerBodyTubeHandler extends PositionDependentHandler { * Constructor. * * @param c the parent component + * @param warnings the warning set * @throws IllegalArgumentException thrown if c is null */ - public InnerBodyTubeHandler(RocketComponent c) throws IllegalArgumentException { + public InnerBodyTubeHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of an inner tube may not be null."); } bodyTube = new InnerTube(); - c.addChild(bodyTube); + if (isCompatible(c, InnerTube.class, warnings)) { + c.addChild(bodyTube); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/LaunchLugHandler.java b/src/net/sf/openrocket/file/rocksim/LaunchLugHandler.java index 969cfdbf..049feedd 100644 --- a/src/net/sf/openrocket/file/rocksim/LaunchLugHandler.java +++ b/src/net/sf/openrocket/file/rocksim/LaunchLugHandler.java @@ -27,14 +27,18 @@ class LaunchLugHandler extends PositionDependentHandler { * Constructor. * * @param c the parent + * @param warnings the warning set + * * @throws IllegalArgumentException thrown if c is null */ - public LaunchLugHandler(RocketComponent c) throws IllegalArgumentException { + public LaunchLugHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of a launch lug may not be null."); } lug = new LaunchLug(); - c.addChild(lug); + if (isCompatible(c, LaunchLug.class, warnings)) { + c.addChild(lug); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/MassObjectHandler.java b/src/net/sf/openrocket/file/rocksim/MassObjectHandler.java index 31ddef70..479242d9 100644 --- a/src/net/sf/openrocket/file/rocksim/MassObjectHandler.java +++ b/src/net/sf/openrocket/file/rocksim/MassObjectHandler.java @@ -36,15 +36,18 @@ class MassObjectHandler extends PositionDependentHandler { * Constructor. *l * @param c the parent component + * @param warnings the warning set * * @throws IllegalArgumentException thrown if c is null */ - public MassObjectHandler(RocketComponent c) throws IllegalArgumentException { + public MassObjectHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of a mass component may not be null."); } mass = new MassComponent(); - c.addChild(mass); + if (isCompatible(c, MassComponent.class, warnings)) { + c.addChild(mass); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/NoseConeHandler.java b/src/net/sf/openrocket/file/rocksim/NoseConeHandler.java index 6dc4efa3..ec5c2df7 100644 --- a/src/net/sf/openrocket/file/rocksim/NoseConeHandler.java +++ b/src/net/sf/openrocket/file/rocksim/NoseConeHandler.java @@ -33,14 +33,18 @@ class NoseConeHandler extends BaseHandler { * Constructor. * * @param c the parent component to the nosecone + * @param warnings the warning set + * * @throws IllegalArgumentException thrown if c is null */ - public NoseConeHandler(RocketComponent c) throws IllegalArgumentException { + public NoseConeHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent component of a nose cone may not be null."); } - c.addChild(noseCone); - noseCone.setAftRadiusAutomatic(false); + if (isCompatible(c, NoseCone.class, warnings)) { + c.addChild(noseCone); + noseCone.setAftRadiusAutomatic(false); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/ParachuteHandler.java b/src/net/sf/openrocket/file/rocksim/ParachuteHandler.java index 6cadaff5..44418fae 100644 --- a/src/net/sf/openrocket/file/rocksim/ParachuteHandler.java +++ b/src/net/sf/openrocket/file/rocksim/ParachuteHandler.java @@ -32,14 +32,18 @@ class ParachuteHandler extends RecoveryDeviceHandler { * Constructor. * * @param c the parent component + * @param warnings the warning set + * * @throws IllegalArgumentException thrown if c is null */ - public ParachuteHandler(RocketComponent c) throws IllegalArgumentException { + public ParachuteHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent of a parachute may not be null."); } chute = new Parachute(); - c.addChild(chute); + if (isCompatible(c, Parachute.class, warnings)) { + c.addChild(chute); + } } /** diff --git a/src/net/sf/openrocket/file/rocksim/RingHandler.java b/src/net/sf/openrocket/file/rocksim/RingHandler.java index ccfcfb06..22394201 100644 --- a/src/net/sf/openrocket/file/rocksim/RingHandler.java +++ b/src/net/sf/openrocket/file/rocksim/RingHandler.java @@ -27,14 +27,17 @@ class RingHandler extends PositionDependentHandler { * Constructor. * * @param c the parent component + * @param warnings the warning set * @throws IllegalArgumentException thrown if c is null */ - public RingHandler(RocketComponent c) throws IllegalArgumentException { + public RingHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent of a ring may not be null."); } ring = new CenteringRing(); - c.addChild(ring); + if (isCompatible(c, CenteringRing.class, warnings)) { + c.addChild(ring); + } } @Override diff --git a/src/net/sf/openrocket/file/rocksim/RocksimHandler.java b/src/net/sf/openrocket/file/rocksim/RocksimHandler.java index 51c20514..7198b90f 100644 --- a/src/net/sf/openrocket/file/rocksim/RocksimHandler.java +++ b/src/net/sf/openrocket/file/rocksim/RocksimHandler.java @@ -360,13 +360,13 @@ class StageHandler extends ElementHandler { @Override public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) { if ("NoseCone".equals(element)) { - return new NoseConeHandler(component); + return new NoseConeHandler(component, warnings); } if ("BodyTube".equals(element)) { - return new BodyTubeHandler(component); + return new BodyTubeHandler(component, warnings); } if ("Transition".equals(element)) { - return new TransitionHandler(component); + return new TransitionHandler(component, warnings); } return null; } diff --git a/src/net/sf/openrocket/file/rocksim/StreamerHandler.java b/src/net/sf/openrocket/file/rocksim/StreamerHandler.java index d638f62b..73a8c2e8 100644 --- a/src/net/sf/openrocket/file/rocksim/StreamerHandler.java +++ b/src/net/sf/openrocket/file/rocksim/StreamerHandler.java @@ -26,14 +26,18 @@ class StreamerHandler extends RecoveryDeviceHandler { * Constructor. * * @param c the parent component + * @param warnings the warning set + * * @throws IllegalArgumentException thrown if c is null */ - public StreamerHandler(RocketComponent c) throws IllegalArgumentException { + public StreamerHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent of a streamer may not be null."); } streamer = new Streamer(); - c.addChild(streamer); + if (isCompatible(c, Streamer.class, warnings)) { + c.addChild(streamer); + } } /** diff --git a/src/net/sf/openrocket/file/rocksim/TransitionHandler.java b/src/net/sf/openrocket/file/rocksim/TransitionHandler.java index 1f3b02e1..54ea3237 100644 --- a/src/net/sf/openrocket/file/rocksim/TransitionHandler.java +++ b/src/net/sf/openrocket/file/rocksim/TransitionHandler.java @@ -31,13 +31,16 @@ class TransitionHandler extends BaseHandler { * Constructor. * * @param c the parent component + * @param warnings the warning set * @throws IllegalArgumentException thrown if c is null */ - public TransitionHandler(RocketComponent c) throws IllegalArgumentException { + public TransitionHandler(RocketComponent c, WarningSet warnings) throws IllegalArgumentException { if (c == null) { throw new IllegalArgumentException("The parent of a transition may not be null."); } - c.addChild(transition); + if (isCompatible(c, Transition.class, warnings)) { + c.addChild(transition); + } } @Override diff --git a/test/net/sf/openrocket/file/rocksim/BodyTubeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/BodyTubeHandlerTest.java index 915ed03d..8cbd6f78 100644 --- a/test/net/sf/openrocket/file/rocksim/BodyTubeHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/BodyTubeHandlerTest.java @@ -6,12 +6,11 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; -import net.sf.openrocket.rocketcomponent.Stage; import net.sf.openrocket.rocketcomponent.ExternalComponent; +import net.sf.openrocket.rocketcomponent.Stage; import java.util.HashMap; @@ -72,7 +71,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new BodyTubeHandler(null); + new BodyTubeHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -80,7 +79,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { } Stage stage = new Stage(); - BodyTubeHandler handler = new BodyTubeHandler(stage); + BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); BodyTube component = (BodyTube) getField(handler, "bodyTube"); assertContains(component, stage.getChildren()); } @@ -91,8 +90,8 @@ public class BodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage()).openElement(null, null, null)); - assertNotNull(new BodyTubeHandler(new Stage()).openElement("AttachedParts", null, null)); + assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); + assertNotNull(new BodyTubeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); } /** @@ -103,7 +102,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { */ public void testCloseElement() throws Exception { Stage stage = new Stage(); - BodyTubeHandler handler = new BodyTubeHandler(stage); + BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); BodyTube component = (BodyTube) getField(handler, "bodyTube"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -173,7 +172,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new BodyTubeHandler(new Stage()).getComponent() instanceof BodyTube); + assertTrue(new BodyTubeHandler(new Stage(), new WarningSet()).getComponent() instanceof BodyTube); } /** @@ -182,7 +181,7 @@ public class BodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage()).getMaterialType()); + assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage(), new WarningSet()).getMaterialType()); } } diff --git a/test/net/sf/openrocket/file/rocksim/InnerBodyTubeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/InnerBodyTubeHandlerTest.java index 5a8827e3..d8d892c6 100644 --- a/test/net/sf/openrocket/file/rocksim/InnerBodyTubeHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/InnerBodyTubeHandlerTest.java @@ -6,13 +6,11 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; 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 net.sf.openrocket.rocketcomponent.Stage; import java.util.HashMap; @@ -73,7 +71,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new InnerBodyTubeHandler(null); + new InnerBodyTubeHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -81,7 +79,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); InnerTube component = (InnerTube) getField(handler, "bodyTube"); assertContains(component, tube.getChildren()); } @@ -92,8 +90,8 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube()).openElement(null, null, null)); - assertNotNull(new InnerBodyTubeHandler(new BodyTube()).openElement("AttachedParts", null, null)); + assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + assertNotNull(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement("AttachedParts", null, null)); } /** @@ -104,7 +102,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { */ public void testCloseElement() throws Exception { BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); InnerTube component = (InnerTube) getField(handler, "bodyTube"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -167,7 +165,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); InnerTube component = (InnerTube) getField(handler, "bodyTube"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -179,7 +177,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new InnerBodyTubeHandler(new BodyTube()).getComponent() instanceof InnerTube); + assertTrue(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube); } /** @@ -188,7 +186,7 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getMaterialType()); } diff --git a/test/net/sf/openrocket/file/rocksim/LaunchLugHandlerTest.java b/test/net/sf/openrocket/file/rocksim/LaunchLugHandlerTest.java index 6eb3263b..689c86f2 100644 --- a/test/net/sf/openrocket/file/rocksim/LaunchLugHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/LaunchLugHandlerTest.java @@ -6,7 +6,6 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; @@ -72,7 +71,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new LaunchLugHandler(null); + new LaunchLugHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -80,7 +79,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); LaunchLug component = (LaunchLug) getField(handler, "lug"); assertContains(component, tube.getChildren()); } @@ -91,7 +90,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); } /** @@ -102,7 +101,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { */ public void testCloseElement() throws Exception { BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); LaunchLug component = (LaunchLug) getField(handler, "lug"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -156,7 +155,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); LaunchLug component = (LaunchLug) getField(handler, "lug"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -168,7 +167,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new LaunchLugHandler(new BodyTube()).getComponent() instanceof LaunchLug); + assertTrue(new LaunchLugHandler(new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug); } /** @@ -177,7 +176,7 @@ public class LaunchLugHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube(), new WarningSet()).getMaterialType()); } diff --git a/test/net/sf/openrocket/file/rocksim/MassObjectHandlerTest.java b/test/net/sf/openrocket/file/rocksim/MassObjectHandlerTest.java index ce4bdded..36f17c11 100644 --- a/test/net/sf/openrocket/file/rocksim/MassObjectHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/MassObjectHandlerTest.java @@ -5,15 +5,12 @@ 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 net.sf.openrocket.rocketcomponent.Stage; -import net.sf.openrocket.rocketcomponent.NoseCone; -import net.sf.openrocket.rocketcomponent.Transition; -import net.sf.openrocket.aerodynamics.WarningSet; import java.util.HashMap; @@ -73,7 +70,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new MassObjectHandler(null); + new MassObjectHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -81,7 +78,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - MassObjectHandler handler = new MassObjectHandler(tube); + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); MassComponent component = (MassComponent) getField(handler, "mass"); assertContains(component, tube.getChildren()); } @@ -92,7 +89,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); } /** @@ -106,7 +103,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); - MassObjectHandler handler = new MassObjectHandler(tube); + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); MassComponent component = (MassComponent) getField(handler, "mass"); handler.closeElement("Len", attributes, "-1", warnings); @@ -138,7 +135,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - MassObjectHandler handler = new MassObjectHandler(tube); + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); MassComponent component = (MassComponent) getField(handler, "mass"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -150,7 +147,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new MassObjectHandler(new BodyTube()).getComponent() instanceof MassComponent); + assertTrue(new MassObjectHandler(new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent); } /** @@ -159,7 +156,7 @@ public class MassObjectHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube(), new WarningSet()).getMaterialType()); } diff --git a/test/net/sf/openrocket/file/rocksim/NoseConeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/NoseConeHandlerTest.java index 9cce15d3..75bc9146 100644 --- a/test/net/sf/openrocket/file/rocksim/NoseConeHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/NoseConeHandlerTest.java @@ -5,14 +5,13 @@ 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.NoseCone; import net.sf.openrocket.rocketcomponent.Stage; import net.sf.openrocket.rocketcomponent.Transition; -import net.sf.openrocket.rocketcomponent.ExternalComponent; -import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import java.util.HashMap; @@ -72,7 +71,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new NoseConeHandler(null); + new NoseConeHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -80,7 +79,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { } Stage stage = new Stage(); - NoseConeHandler handler = new NoseConeHandler(stage); + NoseConeHandler handler = new NoseConeHandler(stage, new WarningSet()); NoseCone component = (NoseCone) getField(handler, "noseCone"); assertContains(component, stage.getChildren()); } @@ -91,8 +90,8 @@ public class NoseConeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage()).openElement(null, null, null)); - assertNotNull(new NoseConeHandler(new Stage()).openElement("AttachedParts", null, null)); + assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); + assertNotNull(new NoseConeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); } /** @@ -107,7 +106,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); - NoseConeHandler handler = new NoseConeHandler(stage); + NoseConeHandler handler = new NoseConeHandler(stage, warnings); NoseCone component = (NoseCone) getField(handler, "noseCone"); handler.closeElement("ShapeCode", attributes, "0", warnings); @@ -225,7 +224,7 @@ public class NoseConeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new NoseConeHandler(new Stage()).getComponent() instanceof NoseCone); + assertTrue(new NoseConeHandler(new Stage(), new WarningSet()).getComponent() instanceof NoseCone); } /** @@ -234,6 +233,6 @@ public class NoseConeHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage()).getMaterialType()); + assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage(), new WarningSet()).getMaterialType()); } } diff --git a/test/net/sf/openrocket/file/rocksim/ParachuteHandlerTest.java b/test/net/sf/openrocket/file/rocksim/ParachuteHandlerTest.java index f71461f8..ae9ca2aa 100644 --- a/test/net/sf/openrocket/file/rocksim/ParachuteHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/ParachuteHandlerTest.java @@ -6,7 +6,6 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; @@ -68,7 +67,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); } /** @@ -79,7 +78,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { public void testCloseElement() throws Exception { BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); Parachute component = (Parachute) getField(handler, "chute"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -129,7 +128,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new ParachuteHandler(null); + new ParachuteHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -137,7 +136,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); Parachute component = (Parachute) getField(handler, "chute"); assertContains(component, tube.getChildren()); } @@ -149,7 +148,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); Parachute component = (Parachute) getField(handler, "chute"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -161,7 +160,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new ParachuteHandler(new BodyTube()).getComponent() instanceof Parachute); + assertTrue(new ParachuteHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Parachute); } /** @@ -170,7 +169,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube(), new WarningSet()).getMaterialType()); } /** @@ -180,7 +179,7 @@ public class ParachuteHandlerTest extends RocksimTestBase { */ public void testEndHandler() throws Exception { BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); Parachute component = (Parachute) getField(handler, "chute"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); diff --git a/test/net/sf/openrocket/file/rocksim/PodFins.rkt b/test/net/sf/openrocket/file/rocksim/PodFins.rkt new file mode 100644 index 00000000..a137008f --- /dev/null +++ b/test/net/sf/openrocket/file/rocksim/PodFins.rkt @@ -0,0 +1,605 @@ + + 4 + + + 1 + 1 + 1 + 0.75 + 0.8 + 0.81 + 0.95 + 0.95 + 1 + 0. + 0. + 0. + 0. + 0. + 0. + 0. + 0. + 1 + 914.4 + 0 + 0 + 0 + 1 + 0 + 1 + 7 + 1 + 0 + 0,567.719,0,0 + 0,19.2193,0,0 + 0,571.25,0,0 + 0,28.2677,0,0 + 0,0,0,0 + 0,0,0,0 + 0 + 1 + 0 + 1 + 0. + 0. + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0. + 10. + 10. + 10. + 10. + 0 + 0 + 0 + 10. + 0.15 + black + 259.588 + 56.388 + 717.499 + 717.499 + 0. + 717.499 + 0,56.388,0,0 + 0,717.499,0,0 + + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +Apogee +24.0999 +1049.21 +Polystyrene PS +Nose cone +65.3999 +1 +0. +94.7384 +208.434 +0.0323955 +0.0323955 +0. +0 +19470 +PNC-70A +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +1 +0 +0 +0 +blue +2. +0.126958 +2. +0.126958 +1 +0 +8 +0 +0. +272.999 +56.2991 +0 +1 +1 +58.3997 +2.159 +0. +53.1012 +0. +0. +0. + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +0. +44.4492 +222.25 +0.0787423 +0.0787423 +0. +0 +Estes +BT-70 +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +2 +1 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +272.999 +56.388 +55.372 +444.5 +0 +0 +0. +0.5 +0. +0. +0 +0 + + +Public Missiles +0. +1905.24 +G10 fiberglass +Fin set +0. +0 +273.05 +75.5033 +110.067 +0.0167742 +0.0503225 +0. +0 +FIN-A-04 +Fins +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +4 +0 +0 +0 +blue +16.5474 +0.628599 +23.7789 +0.628599 +1 +0 +8 +0 +546.049 +3 +165.1 +0. +101.6 +130.909 +165.1 +1.5748 +0 +0 +1 +0. +0. +0. +1 +1.02001 +0. +62.0607 +13.7288 +0. +0. +0. + + + + +Apogee +0. +1121.29 +Paper +Body tube +0. +0 +107.95 +1.7435 +55.5625 +0. +0. +0. +0 +10062 +13 mm +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +5 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +380.949 +13.8176 +13.1572 +111.125 +0 +0 +13. +0.5 +0. +0. +1 +0 + + +Public Missiles +0. +1905.24 +G10 fiberglass +Fin set +0. +0 +0. +5.53666 +44.5707 +0.00365927 +0.00365927 +0. +0 +FIN-A-06 +Fins +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +7 +0 +0 +0 +blue +0.671866 +0.380349 +2.4888 +0.380349 +1 +0 +8 +0 +349.199 +1 +66.675 +38.1 +34.925 +42.7843 +39.0017 +1.5875 +0 +0 +0 +0. +0. +0. +1 +0.366519 +0. +44.069 +2.87382 +0.571429 +0. +0. + + + + + + +Custom +0. +0. +Pod +0. +0 +76.2 +0. +0. +0. +0. +0. +0 +28.194 +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +6 +1 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +349.199 +1 +1 +1 + + +Public Missiles +0. +1905.24 +G10 fiberglass +Fin set +0. +0 +0. +5.53666 +44.5707 +0.00365927 +0.00365927 +0. +0 +FIN-A-06 +Fins +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr(0)|flips(0)|flipt=(0)|preventseam=(1) +1. +0. +1. +0. +1. +blue +blue +white +1 +7 +0 +0 +0 +blue +0.671866 +0.380349 +2.4888 +0.380349 +1 +0 +8 +0 +349.199 +1 +66.675 +38.1 +34.925 +42.7843 +39.0017 +1.5875 +0 +0 +0 +0. +0. +0. +1 +0.366519 +0. +44.069 +2.87382 +0.571429 +0. +0. + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/net/sf/openrocket/file/rocksim/RingHandlerTest.java b/test/net/sf/openrocket/file/rocksim/RingHandlerTest.java index 5495d560..e96355a9 100644 --- a/test/net/sf/openrocket/file/rocksim/RingHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/RingHandlerTest.java @@ -6,7 +6,6 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; @@ -68,7 +67,7 @@ public class RingHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); } /** @@ -79,7 +78,7 @@ public class RingHandlerTest extends RocksimTestBase { public void testCloseElement() throws Exception { BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube); + RingHandler handler = new RingHandler(tube, new WarningSet()); CenteringRing component = (CenteringRing) getField(handler, "ring"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -123,7 +122,7 @@ public class RingHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new RingHandler(null); + new RingHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -131,7 +130,7 @@ public class RingHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube); + RingHandler handler = new RingHandler(tube, new WarningSet()); CenteringRing component = (CenteringRing) getField(handler, "ring"); assertContains(component, tube.getChildren()); } @@ -143,7 +142,7 @@ public class RingHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube); + RingHandler handler = new RingHandler(tube, new WarningSet()); CenteringRing component = (CenteringRing) getField(handler, "ring"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -155,7 +154,7 @@ public class RingHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new RingHandler(new BodyTube()).getComponent() instanceof CenteringRing); + assertTrue(new RingHandler(new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing); } /** @@ -164,7 +163,7 @@ public class RingHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new RingHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.BULK, new RingHandler(new BodyTube(), new WarningSet()).getMaterialType()); } diff --git a/test/net/sf/openrocket/file/rocksim/RocksimLoaderTest.java b/test/net/sf/openrocket/file/rocksim/RocksimLoaderTest.java index 45551aea..9b33319d 100644 --- a/test/net/sf/openrocket/file/rocksim/RocksimLoaderTest.java +++ b/test/net/sf/openrocket/file/rocksim/RocksimLoaderTest.java @@ -4,9 +4,6 @@ */ package net.sf.openrocket.file.rocksim; -import java.io.BufferedInputStream; -import java.io.InputStream; - import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -14,6 +11,9 @@ import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.Stage; +import java.io.BufferedInputStream; +import java.io.InputStream; + /** * RocksimLoader Tester. * @@ -62,6 +62,27 @@ public class RocksimLoaderTest extends TestCase { super.tearDown(); } + /** + * 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. + */ + public void testFinsOnInnerTube() throws Exception { + RocksimLoader loader = new RocksimLoader(); + InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt"); + assertNotNull("Could not open PodFins.rkt", stream); + try { + OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream)); + assertNotNull(doc); + Rocket rocket = doc.getRocket(); + assertNotNull(rocket); + } + catch (IllegalStateException ise) { + fail(ise.getMessage()); + } + assertTrue(loader.getWarnings().size() == 2); + } + /** * * Method: loadFromStream(InputStream source) diff --git a/test/net/sf/openrocket/file/rocksim/StreamerHandlerTest.java b/test/net/sf/openrocket/file/rocksim/StreamerHandlerTest.java index 3051398d..092f5d09 100644 --- a/test/net/sf/openrocket/file/rocksim/StreamerHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/StreamerHandlerTest.java @@ -67,7 +67,7 @@ public class StreamerHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); } /** @@ -78,7 +78,7 @@ public class StreamerHandlerTest extends RocksimTestBase { public void testCloseElement() throws Exception { BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); Streamer component = (Streamer) getField(handler, "streamer"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); @@ -122,7 +122,7 @@ public class StreamerHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new StreamerHandler(null); + new StreamerHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -130,7 +130,7 @@ public class StreamerHandlerTest extends RocksimTestBase { } BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); Streamer component = (Streamer) getField(handler, "streamer"); assertContains(component, tube.getChildren()); } @@ -142,7 +142,7 @@ public class StreamerHandlerTest extends RocksimTestBase { */ public void testSetRelativePosition() throws Exception { BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); Streamer component = (Streamer) getField(handler, "streamer"); handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); @@ -154,7 +154,7 @@ public class StreamerHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new StreamerHandler(new BodyTube()).getComponent() instanceof Streamer); + assertTrue(new StreamerHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Streamer); } /** @@ -163,7 +163,7 @@ public class StreamerHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube()).getMaterialType()); + assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube(), new WarningSet()).getMaterialType()); } /** @@ -173,7 +173,7 @@ public class StreamerHandlerTest extends RocksimTestBase { */ public void testEndHandler() throws Exception { BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); Streamer component = (Streamer) getField(handler, "streamer"); HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); diff --git a/test/net/sf/openrocket/file/rocksim/TransitionHandlerTest.java b/test/net/sf/openrocket/file/rocksim/TransitionHandlerTest.java index f199f9aa..d28f53f8 100644 --- a/test/net/sf/openrocket/file/rocksim/TransitionHandlerTest.java +++ b/test/net/sf/openrocket/file/rocksim/TransitionHandlerTest.java @@ -6,7 +6,6 @@ package net.sf.openrocket.file.rocksim; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.database.Databases; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.ExternalComponent; @@ -70,7 +69,7 @@ public class TransitionHandlerTest extends RocksimTestBase { public void testConstructor() throws Exception { try { - new TransitionHandler(null); + new TransitionHandler(null, new WarningSet()); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { @@ -78,7 +77,7 @@ public class TransitionHandlerTest extends RocksimTestBase { } Stage stage = new Stage(); - TransitionHandler handler = new TransitionHandler(stage); + TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); Transition component = (Transition) getField(handler, "transition"); assertContains(component, stage.getChildren()); } @@ -89,7 +88,7 @@ public class TransitionHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testOpenElement() throws Exception { - assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage()).openElement(null, null, null)); + assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage(), new WarningSet()).openElement(null, null, null)); } /** @@ -103,7 +102,7 @@ public class TransitionHandlerTest extends RocksimTestBase { HashMap attributes = new HashMap(); WarningSet warnings = new WarningSet(); - TransitionHandler handler = new TransitionHandler(stage); + TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); Transition component = (Transition) getField(handler, "transition"); handler.closeElement("ShapeCode", attributes, "0", warnings); @@ -252,7 +251,7 @@ public class TransitionHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetComponent() throws Exception { - assertTrue(new TransitionHandler(new Stage()).getComponent() instanceof Transition); + assertTrue(new TransitionHandler(new Stage(), new WarningSet()).getComponent() instanceof Transition); } /** @@ -261,7 +260,7 @@ public class TransitionHandlerTest extends RocksimTestBase { * @throws Exception thrown if something goes awry */ public void testGetMaterialType() throws Exception { - assertEquals(Material.Type.BULK, new TransitionHandler(new Stage()).getMaterialType()); + assertEquals(Material.Type.BULK, new TransitionHandler(new Stage(), new WarningSet()).getMaterialType()); } -- 2.30.2