1 package net.sf.openrocket.database;
3 import static org.junit.Assert.*;
7 import net.sf.openrocket.motor.Manufacturer;
8 import net.sf.openrocket.motor.Motor;
9 import net.sf.openrocket.motor.ThrustCurveMotor;
10 import net.sf.openrocket.util.Coordinate;
12 import org.junit.Test;
15 public class MotorSetDatabaseTest {
18 public void testMotorLoading() {
20 ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(true) {
22 protected void loadMotors() {
25 } catch (InterruptedException e) {
26 throw new RuntimeException(e);
28 this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
29 "Foo", "Desc", Motor.Type.SINGLE, new double[] { 0 },
30 0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
31 new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestA"));
32 this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
33 "Bar", "Desc", Motor.Type.SINGLE, new double[] { 0 },
34 0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
35 new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestB"));
36 this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
37 "Foo", "Desc", Motor.Type.UNKNOWN, new double[] { 0 },
38 0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
39 new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestA"));
43 assertFalse(db.isLoaded());
45 assertFalse(db.isLoaded());
46 List<ThrustCurveMotorSet> list = db.getMotorSets();
47 assertTrue(db.isLoaded());
49 assertEquals(2, list.size());
50 assertEquals(1, list.get(0).getMotors().size());
51 assertEquals(1, list.get(1).getMotors().size());
52 assertEquals("Bar", list.get(0).getMotors().get(0).getDesignation());
53 assertEquals("Foo", list.get(1).getMotors().get(0).getDesignation());