Change handling of Motor Digests. The computed digest value is now stored as a membe...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 15 Jan 2012 02:46:13 +0000 (02:46 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 15 Jan 2012 02:46:13 +0000 (02:46 +0000)
The android db now stores the digest.  Also changed persistance mechanism for delays to store as comma delimited string.

The TestMotorLoader is now failing because the digests have changed.

git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@356 180e2498-e6e9-4542-8430-84ac67f01cd8

19 files changed:
android/src/net/sf/openrocket/android/db/ConversionUtils.java
android/src/net/sf/openrocket/android/db/DbAdapter.java
android/src/net/sf/openrocket/android/db/MotorDao.java
android/src/net/sf/openrocket/android/motor/MotorHierarchicalBrowser.java
core/src/net/sf/openrocket/database/ThrustCurveMotorSet.java
core/src/net/sf/openrocket/file/motor/RASPMotorLoader.java
core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java
core/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java
core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java
core/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java
core/src/net/sf/openrocket/motor/Motor.java
core/src/net/sf/openrocket/motor/ThrustCurveMotor.java
core/src/net/sf/openrocket/utils/MotorCorrelation.java
core/src/net/sf/openrocket/utils/MotorDigester.java
core/src/net/sf/openrocket/utils/MotorPrinter.java
core/test/net/sf/openrocket/database/MotorSetDatabaseTest.java
core/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java
core/test/net/sf/openrocket/file/motor/TestMotorLoader.java
core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java

index a5695a1d8d7365d557b4d6ed8fac4d6983a47272..a66fc28cf9e09ca804af2f698206b0519bf4db21 100644 (file)
@@ -5,10 +5,47 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;\r
 import java.io.ObjectOutputStream;\r
 \r
+import net.sf.openrocket.motor.Motor;\r
 import net.sf.openrocket.util.Coordinate;\r
 \r
 abstract class ConversionUtils {\r
 \r
+       static double[] stringToDelays( String value ) {\r
+               if (value == null || "".equals(value) ) {\r
+                       return new double[0];\r
+               }\r
+               String[] parts = value.split(",");\r
+               double[] values = new double[parts.length];\r
+               for( int i =0; i<parts.length; i++ ) {\r
+                       String p = parts[i];\r
+                       if ( "P".equals(p) ) {\r
+                               values[i] = Motor.PLUGGED;\r
+                       } else {\r
+                               double d = Double.parseDouble(p);\r
+                               values[i] = d;\r
+                       }\r
+               }\r
+               return values;\r
+       }\r
+       \r
+       static String delaysToString( double[] delays ) {\r
+               StringBuilder s = new StringBuilder();\r
+               boolean first = true;\r
+               for( double d:delays ) {\r
+                       if (!first) {\r
+                               s .append(",");\r
+                       } else {\r
+                               first = false;\r
+                       }\r
+                       if ( d == Motor.PLUGGED ) {\r
+                               s.append("P");\r
+                       } else {\r
+                               s.append(Math.round(d));\r
+                       }\r
+               }\r
+               return s.toString();\r
+       }\r
+       \r
        static double[] deserializeArrayOfDouble( byte[] bytes ) throws Exception {\r
                double[] data = null;\r
                if (bytes != null ) {\r
index a61e6a75fc1d8f20630d74fc8f71f488a7f6a705..216f47a1ef89ccdd1d99198e1764c9b7d0f85544 100644 (file)
@@ -13,7 +13,7 @@ public class DbAdapter {
     private SQLiteDatabase mDb;\r
 \r
     private static final String DATABASE_NAME = "rocketflightnotebook";\r
-    private static final int DATABASE_VERSION = 2;\r
+    private static final int DATABASE_VERSION = 3;\r
 \r
     private final Context mCtx;\r
 \r
index 303f18307b9eadf231f188f80c22755017dbd153..5e72272dad25acd166e52934f884318998c32041 100644 (file)
@@ -23,8 +23,9 @@ public class MotorDao {
                        "create table "+ DATABASE_TABLE + " ( " +\r
                                        "_id integer primary key, "+\r
                                        "unique_name text unique, "+\r
+                                       "digest string, " +\r
                                        "designation text, "+\r
-                                       "delays blob, "+\r
+                                       "delays text, "+\r
                                        "diameter number, "+\r
                                        "tot_impulse_ns number, "+\r
                                        "avg_thrust_n number, "+\r
@@ -54,6 +55,7 @@ public class MotorDao {
 \r
        public final static String ID = "_id";\r
        public final static String UNIQUE_NAME = "unique_name";\r
+       public final static String DIGEST = "digest";\r
        public final static String DESIGNATION = "designation";\r
        public final static String DELAYS = "delays";\r
        public final static String DIAMETER = "diameter";\r
@@ -72,6 +74,7 @@ public class MotorDao {
 \r
        private final static String[] ALL_COLS = new String[] {\r
                ID,\r
+               DIGEST,\r
                DESIGNATION ,\r
                DELAYS ,\r
                DIAMETER ,\r
@@ -94,8 +97,9 @@ public class MotorDao {
                final ThrustCurveMotor tcm = mi.getThrustCurveMotor();\r
                initialValues.put(ID, mi.getId());\r
                initialValues.put(UNIQUE_NAME, tcm.getManufacturer()+tcm.getDesignation());\r
+               initialValues.put(DIGEST, tcm.getDigest());\r
                initialValues.put(DESIGNATION, tcm.getDesignation());\r
-               initialValues.put(DELAYS, ConversionUtils.serializeArrayOfDouble(tcm.getStandardDelays()));\r
+               initialValues.put(DELAYS, ConversionUtils.delaysToString(tcm.getStandardDelays()));\r
                initialValues.put(DIAMETER,tcm.getDiameter());\r
                initialValues.put(TOTAL_IMPULSE,tcm.getTotalImpulseEstimate());\r
                initialValues.put(AVG_THRUST,tcm.getAverageThrustEstimate());\r
@@ -187,8 +191,10 @@ public class MotorDao {
                mi.setImpulseClass(mCursor.getString(mCursor.getColumnIndex(IMPULSE_CLASS)));\r
 \r
                {\r
+                       String digest = mCursor.getString(mCursor.getColumnIndex(DIGEST));\r
                        String designation = mCursor.getString(mCursor.getColumnIndex(DESIGNATION));\r
-                       double[] delays = ConversionUtils.deserializeArrayOfDouble( mCursor.getBlob(mCursor.getColumnIndex(DELAYS)));\r
+                       String delayString = mCursor.getString(mCursor.getColumnIndex(DELAYS));\r
+                       double[] delays = ConversionUtils.stringToDelays(delayString);\r
                        double diameter = mCursor.getDouble(mCursor.getColumnIndex(DIAMETER));\r
                        double totImpulse = mCursor.getDouble(mCursor.getColumnIndex(TOTAL_IMPULSE));\r
                        double avgImpulse = mCursor.getDouble(mCursor.getColumnIndex(AVG_THRUST));\r
@@ -209,7 +215,8 @@ public class MotorDao {
                                        length,\r
                                        timeData,\r
                                        thrustData,\r
-                                       cgData\r
+                                       cgData,\r
+                                       digest\r
                                        );\r
                        mi.setThrustCurveMotor(tcm);\r
                }\r
@@ -265,27 +272,4 @@ public class MotorDao {
 \r
        }\r
        \r
-       public static String extractPrettyDelayString( Cursor c ) {\r
-               byte[] blob = c.getBlob(c.getColumnIndex(MotorDao.DELAYS));\r
-               String s = "";\r
-               try {\r
-                       double[] delayarry = ConversionUtils.deserializeArrayOfDouble(blob);\r
-                       boolean first = true;\r
-                       for( double d:delayarry ) {\r
-                               if (!first) {\r
-                                       s += ",";\r
-                               } else {\r
-                                       first = false;\r
-                               }\r
-                               if ( d == Motor.PLUGGED ) {\r
-                                       s+= "P";\r
-                               } else {\r
-                                       s += Math.round(d);\r
-                               }\r
-                       }\r
-               } catch ( Exception ex ) {\r
-               }\r
-               return s;\r
-       }\r
-       \r
 }\r
index 6dd754d24e6d689fafb32a09ee47831ad167b7cd..f940e110d5d727ba2db6910e3afe637cbce90d77 100644 (file)
@@ -76,9 +76,6 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                        return groupPosition;\r
                }\r
 \r
-               //new String[] { MotorDao.MANUFACTURER, MotorDao.DESIGNATION, MotorDao.CASE_INFO, MotorDao.TOTAL_IMPULSE }, // Number for child layouts\r
-               //new int[] { R.id.motorChildManu, R.id.motorChildName, R.id.motorChildDelays, R.id.motorChildImpulse }\r
-\r
                /* (non-Javadoc)\r
                 * @see android.widget.CursorTreeAdapter#bindChildView(android.view.View, android.content.Context, android.database.Cursor, boolean)\r
                 */\r
@@ -93,7 +90,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                        desig.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DESIGNATION)));\r
                        \r
                        TextView delays = (TextView) arg0.findViewById(R.id.motorChildDelays);\r
-                       delays.setText( MotorDao.extractPrettyDelayString( arg2 ));\r
+                       delays.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DELAYS)));\r
                        \r
                        TextView totImpulse = (TextView) arg0.findViewById(R.id.motorChildImpulse);\r
                        totImpulse.setText( arg2.getString(arg2.getColumnIndex(MotorDao.TOTAL_IMPULSE)));\r
index 99c422e314c1a515217e5e758539e98ce799cac4..3bcadad9033929df40d5c27abca444c1b0f75090 100644 (file)
@@ -14,7 +14,6 @@ import net.sf.openrocket.motor.DesignationComparator;
 import net.sf.openrocket.motor.Manufacturer;
 import net.sf.openrocket.motor.Motor;
 import net.sf.openrocket.motor.Motor.Type;
-import net.sf.openrocket.motor.MotorDigest;
 import net.sf.openrocket.motor.ThrustCurveMotor;
 import net.sf.openrocket.util.ArrayList;
 import net.sf.openrocket.util.MathUtil;
@@ -95,7 +94,7 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
                
 
                // Check whether to add as new motor or overwrite existing
-               final String digest = MotorDigest.digestMotor(motor);
+               final String digest = motor.getDigest();
                for (int index = 0; index < motors.size(); index++) {
                        Motor m = motors.get(index);
                        
index ae653e6660dd7b99ea365d41ea0f13c520d60b3a..cbe517e74d6d917506207b18a82112d8ef410337 100644 (file)
@@ -196,15 +196,13 @@ public class RASPMotorLoader extends AbstractMotorLoader {
                motorDigest.update(DataType.TIME_ARRAY, timeArray);
                motorDigest.update(DataType.MASS_SPECIFIC, totalW, totalW - propW);
                motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
-               // TODO: HIGH: Motor digest?
-               //              final String digest = motorDigest.getDigest();
-               
+               final String digest = motorDigest.getDigest();
 
                try {
                        
                        Manufacturer m = Manufacturer.getManufacturer(manufacturer);
                        return new ThrustCurveMotor(m, designation, comment, m.getMotorType(),
-                                       delays, diameter, length, timeArray, thrustArray, cgArray);
+                                       delays, diameter, length, timeArray, thrustArray, cgArray, digest);
                        
                } catch (IllegalArgumentException e) {
                        
index 5b0743e144cfcfae13694acd60e7f4d915842b62..5e04c98c5c2be4f1eb790b8a1e4cd998a8c38df0 100644 (file)
@@ -353,8 +353,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
                                motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
                        }
                        motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
-                       // TODO: HIGH: Motor digest?
-                       //                      final String digest = motorDigest.getDigest();
+                       final String digest = motorDigest.getDigest();
                        
 
                        try {
@@ -372,7 +371,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
                                }
                                
                                return new ThrustCurveMotor(m, designation, description, t,
-                                               delays, diameter, length, timeArray, thrustArray, cgArray);
+                                               delays, diameter, length, timeArray, thrustArray, cgArray, digest);
                        } catch (IllegalArgumentException e) {
                                throw new SAXException("Illegal motor data", e);
                        }
index c4fc7d7376a0ccadd767483e84f31165f26dbd89..518f1e44c6c080eecb07cc5f6da3d7def56d6088 100644 (file)
@@ -23,8 +23,6 @@ import net.sf.openrocket.file.simplesax.SimpleSAX;
 import net.sf.openrocket.logging.LogHelper;
 import net.sf.openrocket.material.Material;
 import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.MotorDigest;
-import net.sf.openrocket.motor.ThrustCurveMotor;
 import net.sf.openrocket.rocketcomponent.BodyComponent;
 import net.sf.openrocket.rocketcomponent.BodyTube;
 import net.sf.openrocket.rocketcomponent.Bulkhead;
@@ -1015,7 +1013,7 @@ class MotorHandler extends ElementHandler {
                // One motor
                if (motors.size() == 1) {
                        Motor m = motors.get(0);
-                       if (digest != null && !MotorDigest.digestMotor(m).equals(digest)) {
+                       if (digest != null && !digest.equals(m.getDigest())) {
                                String str = "Motor with designation '" + designation + "'";
                                if (manufacturer != null)
                                        str += " for manufacturer '" + manufacturer + "'";
@@ -1030,7 +1028,7 @@ class MotorHandler extends ElementHandler {
                        
                        // Check for motor with correct digest
                        for (Motor m : motors) {
-                               if (MotorDigest.digestMotor(m).equals(digest)) {
+                               if (digest.equals(m.getDigest())) {
                                        return m;
                                }
                        }
@@ -1045,7 +1043,7 @@ class MotorHandler extends ElementHandler {
                        // No digest, check for preferred digest (OpenRocket <= 1.1.0)
                        // TODO: MEDIUM: This should only be done for document versions 1.1 and below
                        for (Motor m : motors) {
-                               if (PreferredMotorDigests.DIGESTS.contains(MotorDigest.digestMotor(m))) {
+                               if (PreferredMotorDigests.DIGESTS.contains(m.getDigest())) {
                                        return m;
                                }
                        }
index 44e71e4b9e8dd638409cf99d3437667905e30042..3cd29acb14de07113c8d0fb859b4dc47432e2d9f 100644 (file)
@@ -7,7 +7,6 @@ import java.util.List;
 import net.sf.openrocket.file.RocketSaver;
 import net.sf.openrocket.material.Material;
 import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.MotorDigest;
 import net.sf.openrocket.motor.ThrustCurveMotor;
 import net.sf.openrocket.rocketcomponent.ComponentAssembly;
 import net.sf.openrocket.rocketcomponent.MotorMount;
@@ -128,7 +127,7 @@ public class RocketComponentSaver {
                                ThrustCurveMotor m = (ThrustCurveMotor) motor;
                                elements.add("    <manufacturer>" + RocketSaver.escapeXML(m.getManufacturer().getSimpleName()) +
                                                "</manufacturer>");
-                               elements.add("    <digest>" + MotorDigest.digestMotor(m) + "</digest>");
+                               elements.add("    <digest>" + m.getDigest() + "</digest>");
                        }
                        elements.add("    <designation>" + RocketSaver.escapeXML(motor.getDesignation()) + "</designation>");
                        elements.add("    <diameter>" + motor.getDiameter() + "</diameter>");
index e4c22229447814ed41d05be797c4d2dc0e055f61..d49e58f56feb718cd314a3f75f3f2e3a64479c3e 100644 (file)
@@ -589,7 +589,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
                // Store selected motor in preferences node, set all others to false
                Preferences prefs = ((SwingPreferences) Application.getPreferences()).getNode(net.sf.openrocket.startup.Preferences.PREFERRED_THRUST_CURVE_MOTOR_NODE);
                for (ThrustCurveMotor m : set.getMotors()) {
-                       String digest = MotorDigest.digestMotor(m);
+                       String digest = m.getDigest();
                        prefs.putBoolean(digest, m == motor);
                }
        }
@@ -689,7 +689,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
                                selectedMotor.getEmptyCG().weight));
                dataPointsLabel.setText("" + (selectedMotor.getTimePoints().length - 1));
                if (digestLabel != null) {
-                       digestLabel.setText(MotorDigest.digestMotor(selectedMotor));
+                       digestLabel.setText(selectedMotor.getDigest());
                }
                
                setComment(selectedMotor.getDescription());
@@ -819,7 +819,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
                List<ThrustCurveMotor> list = set.getMotors();
                Preferences prefs = ((SwingPreferences) Application.getPreferences()).getNode(net.sf.openrocket.startup.Preferences.PREFERRED_THRUST_CURVE_MOTOR_NODE);
                for (ThrustCurveMotor m : list) {
-                       String digest = MotorDigest.digestMotor(m);
+                       String digest = m.getDigest();
                        if (prefs.getBoolean(digest, false)) {
                                return m;
                        }
index afe062126afee169068fddeb3d2443adcc1876f6..21104f0d6e6f3259bce8e118c01e732b6a23aa5a 100644 (file)
@@ -128,6 +128,7 @@ public interface Motor {
         */
        public double getLength();
        
+       public String getDigest();
 
        public MotorInstance getInstance();
        
index 1f8acd2aa8a0316e877491138d0d3f0d7b9d3f24..e1ba1d77ca6c7b6f02d8aa4e5870e8a39b6fd107 100644 (file)
@@ -1,6 +1,5 @@
 package net.sf.openrocket.motor;
 
-import java.io.Serializable;
 import java.text.Collator;
 import java.util.Arrays;
 import java.util.Locale;
@@ -26,7 +25,7 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
        }
        private static final DesignationComparator DESIGNATION_COMPARATOR = new DesignationComparator();
        
-
+       private final String digest;
 
        private final Manufacturer manufacturer;
        private final String designation;
@@ -61,8 +60,8 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
         */
        public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
                        Motor.Type type, double[] delays, double diameter, double length,
-                       double[] time, double[] thrust, Coordinate[] cg) {
-               
+                       double[] time, double[] thrust, Coordinate[] cg, String digest) {
+               this.digest = digest;
                // Check argument validity
                if ((time.length != thrust.length) || (time.length != cg.length)) {
                        throw new IllegalArgumentException("Array lengths do not match, " +
@@ -253,6 +252,10 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor> {
                return totalImpulse;
        }
        
+       @Override
+       public String getDigest() {
+               return digest;
+       }
        
 
        /**
index 3394a59e0b60f93de423e427886c5533846346e9..e978b0cf42e9a8e30ab7a0685c2272f7ae57feb1 100644 (file)
@@ -129,7 +129,7 @@ public class MotorCorrelation {
                // Output motor digests
                final int count = motors.size();
                for (int i = 0; i < count; i++) {
-                       System.out.println(files.get(i) + ": " + MotorDigest.digestMotor((ThrustCurveMotor) motors.get(i)));
+                       System.out.println(files.get(i) + ": " + ((ThrustCurveMotor) motors.get(i)).getDigest());
                }
                
                // Cross-correlate every pair
index 754d4075a9796632efbd60b3d7ab6a12a18d9bca..27b6d23f6c92ab15c90e880aaeac9da6c187c8bc 100644 (file)
@@ -47,7 +47,7 @@ public class MotorDigester {
                                        continue;
                                }
                                
-                               String digest = MotorDigest.digestMotor((ThrustCurveMotor) m);
+                               String digest = ((ThrustCurveMotor) m).getDigest();
                                if (printFileNames) {
                                        System.out.print(file + ": ");
                                }
index 0ca4e98714847518dd2b75fa97ada3d2061ed32e..0f6b7b7865f4160527d470d52a0c159147115b9e 100644 (file)
@@ -39,7 +39,7 @@ public class MotorPrinter {
                                System.out.printf("  Total impulse: %.2f Ns\n", m.getTotalImpulseEstimate());
                                System.out.println("  Diameter:      " + m.getDiameter() * 1000 + " mm");
                                System.out.println("  Length:        " + m.getLength() * 1000 + " mm");
-                               System.out.println("  Digest:        " + MotorDigest.digestMotor(m));
+                               System.out.println("  Digest:        " + m.getDigest());
                                
                                if (m instanceof ThrustCurveMotor) {
                                        ThrustCurveMotor tc = (ThrustCurveMotor) m;
index 33ced0c8e826bf9f9776c319380c2b92aa3fcaed..06e8d835e11fa67132df00d6bf499fcbaeb352ed 100644 (file)
@@ -28,15 +28,15 @@ public class MotorSetDatabaseTest {
                                this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
                                                "Foo", "Desc", Motor.Type.SINGLE, new double[] { 0 },
                                                0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
-                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}));
+                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestA"));
                                this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
                                                "Bar", "Desc", Motor.Type.SINGLE, new double[] { 0 },
                                                0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
-                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}));
+                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestB"));
                                this.addMotor(new ThrustCurveMotor(Manufacturer.getManufacturer("A"),
                                                "Foo", "Desc", Motor.Type.UNKNOWN, new double[] { 0 },
                                                0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
-                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}));
+                                               new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestA"));
                        }
                };
                
index 56e30b2dd0eaf1f6364d03f86f97db9fe3c76261..2432f279adf5dd731822c4c953384a710c5a2c62 100644 (file)
@@ -19,25 +19,25 @@ public class ThrustCurveMotorSetTest {
                        Manufacturer.getManufacturer("A"),
                        "F12X", "Desc", Motor.Type.UNKNOWN, new double[] { },
                        0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
-                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL});
+                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestA");
        
        private static final ThrustCurveMotor motor2 = new ThrustCurveMotor(
                        Manufacturer.getManufacturer("A"),
                        "F12H", "Desc", Motor.Type.SINGLE, new double[] { 5 },
                        0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 1, 0},
-                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL});
+                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestB");
        
        private static final ThrustCurveMotor motor3 = new ThrustCurveMotor(
                        Manufacturer.getManufacturer("A"),
                        "F12", "Desc", Motor.Type.UNKNOWN, new double[] { 0, Motor.PLUGGED },
                        0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 2, 0},
-                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL});
+                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestC");
 
        private static final ThrustCurveMotor motor4 = new ThrustCurveMotor(
                        Manufacturer.getManufacturer("A"),
                        "F12", "Desc", Motor.Type.HYBRID, new double[] { 0 },
                        0.024, 0.07, new double[] { 0, 1, 2 }, new double[] {0, 2, 0},
-                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL});
+                       new Coordinate[] {Coordinate.NUL, Coordinate.NUL, Coordinate.NUL}, "digestD");
        
        
        @Test
index 8200310a053db5abf386e105c41fad3488bfe690..74391bdc56fea0f6bd453e8fae9c2a022de0442c 100644 (file)
@@ -1,6 +1,8 @@
 package net.sf.openrocket.file.motor;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -8,7 +10,6 @@ import java.util.Arrays;
 import java.util.List;
 
 import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.MotorDigest;
 import net.sf.openrocket.motor.ThrustCurveMotor;
 
 import org.junit.Test;
@@ -52,12 +53,12 @@ public class TestMotorLoader {
                
                String[] d = new String[digests.length];
                for (int i = 0; i < motors.size(); i++) {
-                       d[i] = MotorDigest.digestMotor((ThrustCurveMotor) motors.get(i));
+                       d[i] = ((ThrustCurveMotor) motors.get(i)).getDigest();
                }
                
                Arrays.sort(digests);
                Arrays.sort(d);
-               assertTrue(Arrays.equals(d, digests));
+               assertTrue("d = " + Arrays.toString(d) + " digests = " + Arrays.toString(digests), Arrays.equals(d, digests));
        }
        
 }
index 7ca43d7166ec35e9efbb80da8c82c598bef846dd..327ec375eeaddbb92df49e1ee4dd2341c3b6f282 100644 (file)
@@ -26,7 +26,7 @@ public class ThrustCurveMotorTest {
                                        new Coordinate(0.02,0,0,0.05),
                                        new Coordinate(0.02,0,0,0.05),
                                        new Coordinate(0.03,0,0,0.03)
-               });
+               }, "digestA");
        
        @Test 
        public void testMotorData() {