create changelog entry
[debian/openrocket] / core / test / net / sf / openrocket / database / MotorSetDatabaseTest.java
1 package net.sf.openrocket.database;
2
3 import static org.junit.Assert.*;
4
5 import java.util.List;
6
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;
11
12 import org.junit.Test;
13
14
15 public class MotorSetDatabaseTest {
16
17         @Test
18         public void testMotorLoading() {
19                 
20                 ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(true) {
21                         @Override
22                         protected void loadMotors() {
23                                 try {
24                                         Thread.sleep(200);
25                                 } catch (InterruptedException e) {
26                                         throw new RuntimeException(e);
27                                 }
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"));
40                         }
41                 };
42                 
43                 assertFalse(db.isLoaded());
44                 db.startLoading();
45                 assertFalse(db.isLoaded());
46                 List<ThrustCurveMotorSet> list = db.getMotorSets();
47                 assertTrue(db.isLoaded());
48                 
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());
54         }
55         
56 }