[fix][test] Fixed RocketTest, FlightConfigurationTest
This commit is contained in:
parent
356ec09094
commit
b84de68575
@ -399,16 +399,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
if (rocket.getModID() != boundsModID) {
|
if (rocket.getModID() != boundsModID) {
|
||||||
boundsModID = rocket.getModID();
|
boundsModID = rocket.getModID();
|
||||||
|
|
||||||
// System.err.println(String.format(">> generating bounds for configuration: %s (%d)(%s)", getName(), this.instanceNumber, getId() ));
|
|
||||||
|
|
||||||
BoundingBox bounds = new BoundingBox();
|
BoundingBox bounds = new BoundingBox();
|
||||||
|
|
||||||
for (RocketComponent component : this.getActiveComponents()) {
|
for (RocketComponent component : this.getActiveComponents()) {
|
||||||
BoundingBox componentBounds = new BoundingBox( component.getComponentBounds() );
|
BoundingBox componentBounds = new BoundingBox( component.getComponentBounds() );
|
||||||
|
|
||||||
bounds.compare( componentBounds );
|
bounds.compare( componentBounds );
|
||||||
|
|
||||||
// System.err.println(String.format(" [%s] %s >> %s", component.getName(), componentBounds.toString(), bounds.toString() ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedLength = bounds.span().x;
|
cachedLength = bounds.span().x;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import net.sf.openrocket.rocketcomponent.DeploymentConfiguration.DeployEvent;
|
|||||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||||
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
|
import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
@ -400,11 +401,14 @@ public class TestRockets {
|
|||||||
return values[rnd.nextInt(values.length)];
|
return values[rnd.nextInt(values.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String ESTES_ALPHA_III_FCID_1="test_config #1: A8-0";
|
final static FlightConfigurationId ESTES_ALPHA_III_FCID[] = {
|
||||||
public final static String ESTES_ALPHA_III_FCID_2="test_config #2: B4-3";
|
null, // treat the array as 1-indexed.
|
||||||
public final static String ESTES_ALPHA_III_FCID_3="test_config #3: C6-3";
|
new FlightConfigurationId("test_config #1: A8-0"),
|
||||||
public final static String ESTES_ALPHA_III_FCID_4="test_config #4: C6-5";
|
new FlightConfigurationId("test_config #2: B4-3"),
|
||||||
public final static String ESTES_ALPHA_III_FCID_5="test_config #5: C6-7";
|
new FlightConfigurationId("test_config #3: C6-3"),
|
||||||
|
new FlightConfigurationId("test_config #4: C6-5"),
|
||||||
|
new FlightConfigurationId("test_config #5: C6-7"),
|
||||||
|
};
|
||||||
|
|
||||||
// This is a Estes Alpha III
|
// This is a Estes Alpha III
|
||||||
// http://www.rocketreviews.com/alpha-iii---estes-221256.html
|
// http://www.rocketreviews.com/alpha-iii---estes-221256.html
|
||||||
@ -413,11 +417,11 @@ public class TestRockets {
|
|||||||
public static final Rocket makeEstesAlphaIII(){
|
public static final Rocket makeEstesAlphaIII(){
|
||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
||||||
fcid[0] = rocket.createFlightConfiguration( new FlightConfigurationId( ESTES_ALPHA_III_FCID_1 ));
|
fcid[0] = rocket.createFlightConfiguration( ESTES_ALPHA_III_FCID[1] );
|
||||||
fcid[1] = rocket.createFlightConfiguration( new FlightConfigurationId( ESTES_ALPHA_III_FCID_2 ));
|
fcid[1] = rocket.createFlightConfiguration( ESTES_ALPHA_III_FCID[2] );
|
||||||
fcid[2] = rocket.createFlightConfiguration( new FlightConfigurationId( ESTES_ALPHA_III_FCID_3 ));
|
fcid[2] = rocket.createFlightConfiguration( ESTES_ALPHA_III_FCID[3] );
|
||||||
fcid[3] = rocket.createFlightConfiguration( new FlightConfigurationId( ESTES_ALPHA_III_FCID_4 ));
|
fcid[3] = rocket.createFlightConfiguration( ESTES_ALPHA_III_FCID[4] );
|
||||||
fcid[4] = rocket.createFlightConfiguration( new FlightConfigurationId( ESTES_ALPHA_III_FCID_5 ));
|
fcid[4] = rocket.createFlightConfiguration( ESTES_ALPHA_III_FCID[5] );
|
||||||
|
|
||||||
|
|
||||||
rocket.setName("Estes Alpha III / Code Verification Rocket");
|
rocket.setName("Estes Alpha III / Code Verification Rocket");
|
||||||
@ -555,250 +559,73 @@ public class TestRockets {
|
|||||||
|
|
||||||
// This is an extra stage tacked onto the end of an Estes Alpha III
|
// This is an extra stage tacked onto the end of an Estes Alpha III
|
||||||
// http://www.rocketreviews.com/alpha-iii---estes-221256.html
|
// http://www.rocketreviews.com/alpha-iii---estes-221256.html
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
//
|
||||||
|
// This function is used for unit, integration tests, DO NOT CHANGE WITHOUT UPDATING TESTS
|
||||||
public static final Rocket makeBeta(){
|
public static final Rocket makeBeta(){
|
||||||
Rocket rocket = new Rocket();
|
Rocket rocket = makeEstesAlphaIII();
|
||||||
rocket.setName("Kit-bash Beta");
|
rocket.setName("Kit-bash Beta");
|
||||||
AxialStage sustainerStage = new AxialStage();
|
|
||||||
sustainerStage.setName("Sustainer Stage");
|
|
||||||
rocket.addChild(sustainerStage);
|
|
||||||
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
|
||||||
for( int i=0; i< fcid.length; ++i){
|
|
||||||
fcid[i] = new FlightConfigurationId();
|
|
||||||
rocket.createFlightConfiguration(fcid[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
double noseconeLength = 0.07;
|
|
||||||
double noseconeRadius = 0.012;
|
|
||||||
NoseCone nosecone = new NoseCone(Transition.Shape.OGIVE, noseconeLength, noseconeRadius);
|
|
||||||
nosecone.setAftShoulderLength(0.025);
|
|
||||||
nosecone.setAftShoulderRadius(0.012);
|
|
||||||
nosecone.setName("Nose Cone");
|
|
||||||
sustainerStage.addChild(nosecone);
|
|
||||||
|
|
||||||
double bodytubeLength = 0.20;
|
AxialStage sustainerStage = (AxialStage)rocket.getChild(0);
|
||||||
double bodytubeRadius = 0.012;
|
sustainerStage.setName( "Sustainer Stage");
|
||||||
double bodyTubeThickness = 0.0003;
|
BodyTube sustainerBody = (BodyTube)sustainerStage.getChild(1);
|
||||||
BodyTube bodytube = new BodyTube(bodytubeLength, bodytubeRadius, bodyTubeThickness);
|
final double sustainerRadius = sustainerBody.getAftRadius();
|
||||||
bodytube.setName("Body Tube");
|
final double sustainerThickness = sustainerBody.getThickness();
|
||||||
sustainerStage.addChild(bodytube);
|
|
||||||
|
|
||||||
TrapezoidFinSet finset;
|
AxialStage boosterStage = new AxialStage();
|
||||||
|
boosterStage.setName("Booster Stage");
|
||||||
|
rocket.addChild( boosterStage );
|
||||||
{
|
{
|
||||||
int finCount = 3;
|
BodyTube boosterBody = new BodyTube(0.06, sustainerRadius, sustainerThickness);
|
||||||
double finRootChord = .05;
|
boosterBody.setName("Booster Body");
|
||||||
double finTipChord = .03;
|
boosterStage.addChild( boosterBody);
|
||||||
double finSweep = 0.02;
|
|
||||||
double finHeight = 0.05;
|
|
||||||
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
|
||||||
finset.setThickness( 0.0032);
|
|
||||||
finset.setRelativePosition(Position.BOTTOM);
|
|
||||||
finset.setName("3 Fin Set");
|
|
||||||
bodytube.addChild(finset);
|
|
||||||
|
|
||||||
LaunchLug lug = new LaunchLug();
|
|
||||||
lug.setName("Launch Lugs");
|
|
||||||
lug.setRelativePosition(Position.TOP);
|
|
||||||
lug.setAxialOffset(0.111);
|
|
||||||
lug.setLength(0.050);
|
|
||||||
lug.setOuterRadius(0.0022);
|
|
||||||
lug.setInnerRadius(0.0020);
|
|
||||||
bodytube.addChild(lug);
|
|
||||||
|
|
||||||
InnerTube inner = new InnerTube();
|
|
||||||
inner.setRelativePosition(Position.TOP);
|
|
||||||
inner.setAxialOffset(0.133);
|
|
||||||
inner.setLength(0.07);
|
|
||||||
inner.setOuterRadius(0.009);
|
|
||||||
inner.setThickness(0.0003);
|
|
||||||
inner.setMotorMount(true);
|
|
||||||
inner.setName("Motor Mount Tube");
|
|
||||||
bodytube.addChild(inner);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// MotorBlock
|
TubeCoupler coupler = new TubeCoupler();
|
||||||
EngineBlock thrustBlock= new EngineBlock();
|
coupler.setName("Coupler");
|
||||||
thrustBlock.setRelativePosition(Position.TOP);
|
coupler.setOuterRadiusAutomatic(true);
|
||||||
thrustBlock.setAxialOffset(0.0);
|
coupler.setThickness( sustainerThickness );
|
||||||
thrustBlock.setLength(0.005);
|
coupler.setLength(0.03);
|
||||||
thrustBlock.setOuterRadius(0.009);
|
coupler.setRelativePosition(Position.TOP);
|
||||||
thrustBlock.setThickness(0.0008);
|
coupler.setAxialOffset(-0.015);
|
||||||
thrustBlock.setName("Engine Block");
|
boosterBody.addChild(coupler);
|
||||||
inner.addChild(thrustBlock);
|
|
||||||
inner.setMotorMount( true);
|
|
||||||
|
|
||||||
{
|
int finCount = 3;
|
||||||
MotorConfiguration motorConfig = new MotorConfiguration(inner,fcid[0]);
|
double finRootChord = .05;
|
||||||
Motor mtr = TestRockets.generateMotor_A8_18mm();
|
double finTipChord = .03;
|
||||||
motorConfig.setEjectionDelay(0.0);
|
double finSweep = 0.02;
|
||||||
motorConfig.setMotor( mtr);
|
double finHeight = 0.05;
|
||||||
inner.setMotorConfig( motorConfig, fcid[0]);
|
FinSet finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
||||||
}
|
finset.setName("Booster Fins");
|
||||||
{
|
finset.setThickness( 0.0032);
|
||||||
MotorConfiguration motorConfig = new MotorConfiguration(inner,fcid[1]);
|
finset.setRelativePosition(Position.BOTTOM);
|
||||||
Motor mtr = TestRockets.generateMotor_B4_18mm();
|
finset.setAxialOffset(0.);
|
||||||
motorConfig.setEjectionDelay(3.0);
|
boosterBody.addChild(finset);
|
||||||
motorConfig.setMotor( mtr);
|
|
||||||
inner.setMotorConfig( motorConfig, fcid[1]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
MotorConfiguration motorConfig = new MotorConfiguration(inner,fcid[2]);
|
|
||||||
Motor mtr = TestRockets.generateMotor_C6_18mm();
|
|
||||||
motorConfig.setEjectionDelay(3.0);
|
|
||||||
motorConfig.setMotor( mtr);
|
|
||||||
inner.setMotorConfig( motorConfig, fcid[2]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
MotorConfiguration motorConfig = new MotorConfiguration(inner,fcid[3]);
|
|
||||||
Motor mtr = TestRockets.generateMotor_C6_18mm();
|
|
||||||
motorConfig.setEjectionDelay(5.0);
|
|
||||||
motorConfig.setMotor( mtr);
|
|
||||||
inner.setMotorConfig( motorConfig, fcid[3]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
MotorConfiguration motorConfig = new MotorConfiguration(inner,fcid[4]);
|
|
||||||
Motor mtr = TestRockets.generateMotor_C6_18mm();
|
|
||||||
motorConfig.setEjectionDelay(7.0);
|
|
||||||
motorConfig.setMotor( mtr);
|
|
||||||
inner.setMotorConfig( motorConfig, fcid[4]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// parachute
|
|
||||||
Parachute chute = new Parachute();
|
|
||||||
chute.setRelativePosition(Position.TOP);
|
|
||||||
chute.setName("Parachute");
|
|
||||||
chute.setAxialOffset(0.028);
|
|
||||||
chute.setOverrideMass(0.002);
|
|
||||||
chute.setMassOverridden(true);
|
|
||||||
bodytube.addChild(chute);
|
|
||||||
|
|
||||||
// bulkhead x2
|
|
||||||
CenteringRing centerings = new CenteringRing();
|
|
||||||
centerings.setName("Centering Rings");
|
|
||||||
centerings.setRelativePosition(Position.TOP);
|
|
||||||
centerings.setAxialOffset(0.14);
|
|
||||||
centerings.setLength(0.006);
|
|
||||||
centerings.setInstanceCount(2);
|
|
||||||
centerings.setInstanceSeparation(0.035);
|
|
||||||
bodytube.addChild(centerings);
|
|
||||||
}
|
|
||||||
|
|
||||||
Material material = Application.getPreferences().getDefaultComponentMaterial(null, Material.Type.BULK);
|
|
||||||
nosecone.setMaterial(material);
|
|
||||||
bodytube.setMaterial(material);
|
|
||||||
finset.setMaterial(material);
|
|
||||||
|
|
||||||
{
|
|
||||||
AxialStage boosterStage = new AxialStage();
|
|
||||||
boosterStage.setName("Booster");
|
|
||||||
|
|
||||||
BodyTube boosterTube = new BodyTube(0.06, bodytubeRadius, bodyTubeThickness);
|
|
||||||
boosterStage.addChild(boosterTube);
|
|
||||||
|
|
||||||
TubeCoupler coupler = new TubeCoupler();
|
|
||||||
coupler.setName("Interstage");
|
|
||||||
coupler.setOuterRadiusAutomatic(true);
|
|
||||||
coupler.setThickness( bodyTubeThickness);
|
|
||||||
coupler.setLength(0.03);
|
|
||||||
coupler.setRelativePosition(Position.TOP);
|
|
||||||
coupler.setAxialOffset(-1.5);
|
|
||||||
boosterTube.addChild(coupler);
|
|
||||||
|
|
||||||
int finCount = 3;
|
|
||||||
double finRootChord = .05;
|
|
||||||
double finTipChord = .03;
|
|
||||||
double finSweep = 0.02;
|
|
||||||
double finHeight = 0.05;
|
|
||||||
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
|
||||||
finset.setThickness( 0.0032);
|
|
||||||
finset.setRelativePosition(Position.BOTTOM);
|
|
||||||
finset.setAxialOffset(1);
|
|
||||||
finset.setName("Booster Fins");
|
|
||||||
boosterTube.addChild(finset);
|
|
||||||
|
|
||||||
// Motor mount
|
|
||||||
InnerTube boosterMMT = new InnerTube();
|
|
||||||
boosterMMT.setName("Booster MMT");
|
|
||||||
boosterMMT.setAxialOffset(0.005);
|
|
||||||
boosterMMT.setRelativePosition(Position.BOTTOM);
|
|
||||||
boosterMMT.setOuterRadius(0.019 / 2);
|
|
||||||
boosterMMT.setInnerRadius(0.018 / 2);
|
|
||||||
boosterMMT.setLength(0.075);
|
|
||||||
boosterTube.addChild(boosterMMT);
|
|
||||||
|
|
||||||
rocket.addChild(boosterStage);
|
|
||||||
|
|
||||||
boosterMMT.setMotorMount(true);
|
// Motor mount
|
||||||
{
|
InnerTube boosterMMT = new InnerTube();
|
||||||
MotorConfiguration motorConfig= new MotorConfiguration(boosterMMT,fcid[0]);
|
boosterMMT.setName("Booster MMT");
|
||||||
Motor mtr = generateMotor_D21_18mm();
|
boosterMMT.setAxialOffset(0.005);
|
||||||
motorConfig.setMotor(mtr);
|
boosterMMT.setRelativePosition(Position.BOTTOM);
|
||||||
boosterMMT.setMotorConfig( motorConfig, fcid[0]);
|
boosterMMT.setOuterRadius(0.019 / 2);
|
||||||
|
boosterMMT.setInnerRadius(0.018 / 2);
|
||||||
|
boosterMMT.setLength(0.05);
|
||||||
|
boosterMMT.setMotorMount(true);
|
||||||
|
{
|
||||||
|
MotorConfiguration motorConfig= new MotorConfiguration(boosterMMT, ESTES_ALPHA_III_FCID[1] );
|
||||||
|
Motor mtr = generateMotor_D21_18mm();
|
||||||
|
motorConfig.setMotor(mtr);
|
||||||
|
boosterMMT.setMotorConfig( motorConfig, ESTES_ALPHA_III_FCID[1]);
|
||||||
|
}
|
||||||
|
boosterBody.addChild(boosterMMT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rocket.setSelectedConfiguration( ESTES_ALPHA_III_FCID[1] );
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
rocket.setSelectedConfiguration( fcid[0] );
|
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
|
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Rocket makeSmallFlyable() {
|
|
||||||
double noseconeLength = 0.10, noseconeRadius = 0.01;
|
|
||||||
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
|
|
||||||
|
|
||||||
int finCount = 3;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
double finRootChord = 0.04, finTipChord = 0.05, finSweep = 0.01, finThickness = 0.003, finHeight = 0.03;
|
|
||||||
|
|
||||||
Rocket rocket;
|
|
||||||
AxialStage stage;
|
|
||||||
NoseCone nosecone;
|
|
||||||
BodyTube bodytube;
|
|
||||||
TrapezoidFinSet finset;
|
|
||||||
|
|
||||||
rocket = new Rocket();
|
|
||||||
stage = new AxialStage();
|
|
||||||
stage.setName("Stage1");
|
|
||||||
|
|
||||||
nosecone = new NoseCone(Transition.Shape.ELLIPSOID, noseconeLength, noseconeRadius);
|
|
||||||
bodytube = new BodyTube(bodytubeLength, bodytubeRadius, bodytubeThickness);
|
|
||||||
|
|
||||||
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
|
||||||
|
|
||||||
// Stage construction
|
|
||||||
rocket.addChild(stage);
|
|
||||||
|
|
||||||
// Component construction
|
|
||||||
stage.addChild(nosecone);
|
|
||||||
stage.addChild(bodytube);
|
|
||||||
|
|
||||||
bodytube.addChild(finset);
|
|
||||||
|
|
||||||
Material material = Application.getPreferences().getDefaultComponentMaterial(null, Material.Type.BULK);
|
|
||||||
nosecone.setMaterial(material);
|
|
||||||
bodytube.setMaterial(material);
|
|
||||||
finset.setMaterial(material);
|
|
||||||
|
|
||||||
FlightConfiguration config = rocket.getSelectedConfiguration();
|
|
||||||
FlightConfigurationId fcid = config.getFlightConfigurationID();
|
|
||||||
|
|
||||||
ThrustCurveMotor motor = getTestMotor();
|
|
||||||
MotorConfiguration instance = new MotorConfiguration( bodytube, fcid );
|
|
||||||
instance.setMotor( motor);
|
|
||||||
instance.setEjectionDelay(5);
|
|
||||||
|
|
||||||
bodytube.setMotorConfig( instance, fcid);
|
|
||||||
bodytube.setMotorOverhang(0.005);
|
|
||||||
|
|
||||||
config.setAllStages();
|
|
||||||
rocket.enableEvents();
|
|
||||||
return rocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Rocket makeBigBlue() {
|
public static Rocket makeBigBlue() {
|
||||||
Rocket rocket;
|
Rocket rocket;
|
||||||
AxialStage stage;
|
AxialStage stage;
|
||||||
@ -1592,7 +1419,7 @@ public class TestRockets {
|
|||||||
|
|
||||||
|
|
||||||
public static OpenRocketDocument makeTestRocket_v107_withSimulationExtension(String script) {
|
public static OpenRocketDocument makeTestRocket_v107_withSimulationExtension(String script) {
|
||||||
Rocket rocket = makeSmallFlyable();
|
Rocket rocket = makeEstesAlphaIII();
|
||||||
OpenRocketDocument document = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
OpenRocketDocument document = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
||||||
Simulation sim = new Simulation(rocket);
|
Simulation sim = new Simulation(rocket);
|
||||||
ScriptingExtension ext = new ScriptingExtension();
|
ScriptingExtension ext = new ScriptingExtension();
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyRocket() {
|
public void testEmptyRocket() {
|
||||||
Rocket r1 = TestRockets.makeSmallFlyable();
|
Rocket r1 = TestRockets.makeEstesAlphaIII();
|
||||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||||
|
|
||||||
FlightConfiguration configClone = config.clone();
|
FlightConfiguration configClone = config.clone();
|
||||||
@ -28,17 +28,36 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
assertTrue(config.getRocket() == configClone.getRocket());
|
assertTrue(config.getRocket() == configClone.getRocket());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test flight configuration ID methods
|
@Test
|
||||||
*/
|
public void testFlightConfigurationRocketLength() {
|
||||||
|
Rocket rocket = TestRockets.makeBeta();
|
||||||
|
FlightConfiguration config = rocket.getEmptyConfiguration();
|
||||||
|
rocket.setSelectedConfiguration( config.getId() );
|
||||||
|
|
||||||
|
config.setAllStages();
|
||||||
|
|
||||||
|
// preconditions
|
||||||
|
assertThat("active stage count doesn't match", config.getActiveStageCount(), equalTo(2));
|
||||||
|
|
||||||
|
final double expectedLength = 0.33;
|
||||||
|
final double calculatedLength = config.getLength();
|
||||||
|
assertEquals("source config length doesn't match: ", expectedLength, calculatedLength, EPSILON);
|
||||||
|
|
||||||
|
double expectedReferenceLength = 0.024;
|
||||||
|
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, config.getReferenceLength(), EPSILON);
|
||||||
|
|
||||||
|
double expectedReferenceArea = Math.pow(expectedReferenceLength/2,2)*Math.PI;
|
||||||
|
double actualReferenceArea = config.getReferenceArea();
|
||||||
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloneBasic() {
|
public void testCloneBasic() {
|
||||||
Rocket rkt1 = TestRockets.makeBeta();
|
Rocket rkt1 = TestRockets.makeBeta();
|
||||||
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
||||||
|
|
||||||
// final String treedump = rkt1.toDebugTree();
|
|
||||||
// System.err.println("treedump: \n" + treedump);
|
|
||||||
|
|
||||||
// preconditions
|
// preconditions
|
||||||
config1.setAllStages();
|
config1.setAllStages();
|
||||||
int expectedStageCount = 2;
|
int expectedStageCount = 2;
|
||||||
@ -48,15 +67,14 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
int actualMotorCount = config1.getActiveMotors().size();
|
int actualMotorCount = config1.getActiveMotors().size();
|
||||||
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
double expectedLength = 0.33;
|
double expectedLength = 0.33;
|
||||||
double actualLength = config1.getLength();
|
assertEquals("source config length doesn't match: ", expectedLength, config1.getLength(), EPSILON);
|
||||||
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
|
||||||
double expectedReferenceLength = 0.024;
|
double expectedReferenceLength = 0.024;
|
||||||
double actualReferenceLength = config1.getReferenceLength();
|
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, config1.getReferenceLength(), EPSILON);
|
||||||
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
|
||||||
double expectedReferenceArea = Math.pow(expectedReferenceLength/2,2)*Math.PI;
|
double expectedReferenceArea = Math.pow(expectedReferenceLength/2,2)*Math.PI;
|
||||||
double actualReferenceArea = config1.getReferenceArea();
|
double actualReferenceArea = config1.getReferenceArea();
|
||||||
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||||
|
|
||||||
|
|
||||||
// vvvv test target vvvv
|
// vvvv test target vvvv
|
||||||
FlightConfiguration config2= config1.clone();
|
FlightConfiguration config2= config1.clone();
|
||||||
// ^^^^ test target ^^^^
|
// ^^^^ test target ^^^^
|
||||||
@ -68,12 +86,9 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
expectedMotorCount = 2;
|
expectedMotorCount = 2;
|
||||||
actualMotorCount = config2.getActiveMotors().size();
|
actualMotorCount = config2.getActiveMotors().size();
|
||||||
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
actualLength = config2.getLength();
|
assertEquals("source config length doesn't match: ", expectedLength, config2.getLength(), EPSILON);
|
||||||
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, config2.getReferenceLength(), EPSILON);
|
||||||
actualReferenceLength = config2.getReferenceLength();
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, config2.getReferenceArea(), EPSILON);
|
||||||
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
|
||||||
actualReferenceArea = config2.getReferenceArea();
|
|
||||||
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,8 @@ import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
|||||||
|
|
||||||
public class RocketTest extends BaseTestCase {
|
public class RocketTest extends BaseTestCase {
|
||||||
|
|
||||||
|
final double EPSILON = MathUtil.EPSILON;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopyIndependence() {
|
public void testCopyIndependence() {
|
||||||
Rocket rkt1 = TestRockets.makeEstesAlphaIII();
|
Rocket rkt1 = TestRockets.makeEstesAlphaIII();
|
||||||
@ -54,7 +56,6 @@ public class RocketTest extends BaseTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEstesAlphaIII(){
|
public void testEstesAlphaIII(){
|
||||||
final double EPSILON = MathUtil.EPSILON;
|
|
||||||
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
||||||
|
|
||||||
// String treeDump = rocket.toDebugTree();
|
// String treeDump = rocket.toDebugTree();
|
||||||
@ -141,4 +142,41 @@ public class RocketTest extends BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBeta(){
|
||||||
|
Rocket rocket = TestRockets.makeBeta();
|
||||||
|
|
||||||
|
AxialStage boosterStage= (AxialStage)rocket.getChild(1);
|
||||||
|
|
||||||
|
Coordinate expLoc;
|
||||||
|
Coordinate actLoc;
|
||||||
|
Coordinate actLocs[];
|
||||||
|
{
|
||||||
|
BodyTube body = (BodyTube)boosterStage.getChild(0);
|
||||||
|
Coordinate[] bodyLocs = body.getComponentLocations();
|
||||||
|
expLoc = new Coordinate(0.27, 0, 0);
|
||||||
|
assertThat(body.getName()+" not positioned correctly: ", bodyLocs[0], equalTo(expLoc));
|
||||||
|
|
||||||
|
{
|
||||||
|
TubeCoupler coupler = (TubeCoupler)body.getChild(0);
|
||||||
|
actLocs = coupler.getComponentLocations();
|
||||||
|
expLoc = new Coordinate(0.255, 0, 0);
|
||||||
|
assertThat(coupler.getName()+" not positioned correctly: ", actLocs[0], equalTo(expLoc) );
|
||||||
|
|
||||||
|
FinSet fins = (FinSet)body.getChild(1);
|
||||||
|
actLocs = fins.getComponentLocations();
|
||||||
|
assertThat(fins.getName()+" have incorrect count: ", fins.getInstanceCount(), equalTo(3));
|
||||||
|
{ // fin #1
|
||||||
|
expLoc = new Coordinate(0.28, 0.012, 0);
|
||||||
|
assertThat(fins.getName()+" not positioned correctly: ", actLocs[0], equalTo(expLoc));
|
||||||
|
}
|
||||||
|
|
||||||
|
InnerTube mmt = (InnerTube)body.getChild(2);
|
||||||
|
actLoc = mmt.getComponentLocations()[0];
|
||||||
|
expLoc = new Coordinate(0.285, 0, 0);
|
||||||
|
assertThat(mmt.getName()+" not positioned correctly: ", actLoc, equalTo( expLoc ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user