From: kruland2607 Date: Sun, 8 Jan 2012 02:25:52 +0000 (+0000) Subject: moving to core/ X-Git-Tag: upstream/12.03~1^2~171 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=87240bdf30c42745c22bb8fbabe020061c723e71;p=debian%2Fopenrocket moving to core/ git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@300 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/test/net/sf/openrocket/Estes_A8.rse b/core/test/net/sf/openrocket/Estes_A8.rse new file mode 100644 index 00000000..1098ffe1 --- /dev/null +++ b/core/test/net/sf/openrocket/Estes_A8.rse @@ -0,0 +1,40 @@ + + + +Estes A8 RASP.ENG file made from NAR published data +File produced October 3, 2000 +The total impulse, peak thrust, average thrust and burn time are +the same as the averaged static test data on the NAR web site in +the certification file. The curve drawn with these data points is as +close to the certification curve as can be with such a limited +number of points (32) allowed with wRASP up to v1.6. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/test/net/sf/openrocket/IntegrationTest.java b/core/test/net/sf/openrocket/IntegrationTest.java new file mode 100644 index 00000000..af73af34 --- /dev/null +++ b/core/test/net/sf/openrocket/IntegrationTest.java @@ -0,0 +1,325 @@ +package net.sf.openrocket; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.io.InputStream; + +import javax.swing.Action; + +import net.sf.openrocket.aerodynamics.AerodynamicCalculator; +import net.sf.openrocket.aerodynamics.BarrowmanCalculator; +import net.sf.openrocket.aerodynamics.FlightConditions; +import net.sf.openrocket.database.ThrustCurveMotorSetDatabase; +import net.sf.openrocket.document.OpenRocketDocument; +import net.sf.openrocket.document.Simulation; +import net.sf.openrocket.file.GeneralRocketLoader; +import net.sf.openrocket.file.RocketLoadException; +import net.sf.openrocket.file.motor.GeneralMotorLoader; +import net.sf.openrocket.gui.main.UndoRedoAction; +import net.sf.openrocket.l10n.ResourceBundleTranslator; +import net.sf.openrocket.masscalc.BasicMassCalculator; +import net.sf.openrocket.masscalc.MassCalculator; +import net.sf.openrocket.masscalc.MassCalculator.MassCalcType; +import net.sf.openrocket.motor.Motor; +import net.sf.openrocket.motor.ThrustCurveMotor; +import net.sf.openrocket.rocketcomponent.Configuration; +import net.sf.openrocket.rocketcomponent.EngineBlock; +import net.sf.openrocket.rocketcomponent.MassComponent; +import net.sf.openrocket.rocketcomponent.NoseCone; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.simulation.FlightDataType; +import net.sf.openrocket.simulation.exception.SimulationException; +import net.sf.openrocket.startup.Application; +import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.BaseTestCase.BaseTestCase; + +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This class contains various integration tests that simulate user actions that + * might be performed. + */ +public class IntegrationTest extends BaseTestCase { + + private OpenRocketDocument document; + private Action undoAction, redoAction; + + private AerodynamicCalculator aeroCalc = new BarrowmanCalculator(); + private MassCalculator massCalc = new BasicMassCalculator(); + private Configuration config; + private FlightConditions conditions; + + + @BeforeClass + public static void initialize() { + ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(false) { + @Override + protected void loadMotors() { + GeneralMotorLoader loader = new GeneralMotorLoader(); + InputStream is = this.getClass().getResourceAsStream("Estes_A8.rse"); + assertNotNull("Problem in unit test, cannot find Estes_A8.rse", is); + try { + for (Motor m : loader.load(is, "Estes_A8.rse")) { + addMotor((ThrustCurveMotor) m); + } + is.close(); + } catch (IOException e) { + e.printStackTrace(); + fail("IOException: " + e); + } + } + }; + db.startLoading(); + assertEquals(1, db.getMotorSets().size()); + Application.setMotorSetDatabase(db); + Application.setBaseTranslator(new ResourceBundleTranslator("l10n.messages")); + } + + /** + * Tests loading a rocket design, modifying it, simulating it and the undo/redo + * mechanism in various combinations. + */ + @Test + public void test1() throws RocketLoadException, IOException, SimulationException { + System.setProperty("openrocket.unittest", "true"); + + // Load the rocket + GeneralRocketLoader loader = new GeneralRocketLoader(); + InputStream is = this.getClass().getResourceAsStream("simplerocket.ork"); + assertNotNull("Problem in unit test, cannot find simplerocket.ork", is); + document = loader.load(is); + is.close(); + + undoAction = UndoRedoAction.newUndoAction(document ); + redoAction = UndoRedoAction.newRedoAction(document); + config = document.getSimulation(0).getConfiguration(); + conditions = new FlightConditions(config); + + + // Test undo state + checkUndoState(null, null); + + + // Compute cg+cp + altitude + checkCgCp(0.248, 0.0645, 0.320, 12.0); + checkAlt(48.2); + + + // Mass modification + document.addUndoPosition("Modify mass"); + checkUndoState(null, null); + massComponent().setComponentMass(0.01); + checkUndoState("Modify mass", null); + + + // Check cg+cp + altitude + checkCgCp(0.230, 0.0745, 0.320, 12.0); + checkAlt(37.2); + + + // Non-change + document.addUndoPosition("No change"); + checkUndoState("Modify mass", null); + + + // Non-funcitonal change + document.addUndoPosition("Name change"); + checkUndoState("Modify mass", null); + massComponent().setName("Foobar component"); + checkUndoState("Name change", null); + + + // Check cg+cp + checkCgCp(0.230, 0.0745, 0.320, 12.0); + + + // Aerodynamic modification + document.addUndoPosition("Remove component"); + checkUndoState("Name change", null); + document.getRocket().getChild(0).removeChild(0); + checkUndoState("Remove component", null); + + + // Check cg+cp + altitude + checkCgCp(0.163, 0.0613, 0.275, 9.95); + checkAlt(45.0); + + + // Undo "Remove component" change + undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertTrue(document.getRocket().getChild(0).getChild(0) instanceof NoseCone); + checkUndoState("Name change", "Remove component"); + + + // Check cg+cp + altitude + checkCgCp(0.230, 0.0745, 0.320, 12.0); + checkAlt(37.2); + + + // Undo "Name change" change + undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertEquals("Extra mass", massComponent().getName()); + checkUndoState("Modify mass", "Name change"); + + + // Check cg+cp + checkCgCp(0.230, 0.0745, 0.320, 12.0); + + + // Undo "Modify mass" change + undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertEquals(0, massComponent().getComponentMass(), 0); + checkUndoState(null, "Modify mass"); + + + // Check cg+cp + altitude + checkCgCp(0.248, 0.0645, 0.320, 12.0); + checkAlt(48.2); + + + // Redo "Modify mass" change + redoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertEquals(0.010, massComponent().getComponentMass(), 0.00001); + checkUndoState("Modify mass", "Name change"); + + + // Check cg+cp + altitude + checkCgCp(0.230, 0.0745, 0.320, 12.0); + checkAlt(37.2); + + + // Mass modification + document.addUndoPosition("Modify mass2"); + checkUndoState("Modify mass", "Name change"); + massComponent().setComponentMass(0.015); + checkUndoState("Modify mass2", null); + + + // Check cg+cp + altitude + checkCgCp(0.223, 0.0795, 0.320, 12.0); + checkAlt(32.7); + + + // Perform component movement + document.startUndo("Move component"); + document.getRocket().freeze(); + RocketComponent bodytube = document.getRocket().getChild(0).getChild(1); + RocketComponent innertube = bodytube.getChild(2); + RocketComponent engineblock = innertube.getChild(0); + assertTrue(innertube.removeChild(engineblock)); + bodytube.addChild(engineblock, 0); + checkUndoState("Modify mass2", null); + document.getRocket().thaw(); + checkUndoState("Move component", null); + document.stopUndo(); + + + // Check cg+cp + altitude + checkCgCp(0.221, 0.0797, 0.320, 12.0); + checkAlt(32.7); + + + // Modify mass without setting undo description + massComponent().setComponentMass(0.020); + checkUndoState("Modify mass2", null); + + + // Check cg+cp + altitude + checkCgCp(0.215, 0.0847, 0.320, 12.0); + checkAlt(29.0); + + + // Undo "Modify mass2" change + undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertEquals(0.015, massComponent().getComponentMass(), 0.0000001); + checkUndoState("Move component", "Modify mass2"); + + + // Check cg+cp + altitude + checkCgCp(0.221, 0.0797, 0.320, 12.0); + checkAlt(32.7); + + + // Undo "Move component" change + undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertTrue(document.getRocket().getChild(0).getChild(1).getChild(2).getChild(0) instanceof EngineBlock); + checkUndoState("Modify mass2", "Move component"); + + + // Check cg+cp + altitude + checkCgCp(0.223, 0.0795, 0.320, 12.0); + checkAlt(32.7); + + + // Redo "Move component" change + redoAction.actionPerformed(new ActionEvent(this, 0, "foo")); + assertTrue(document.getRocket().getChild(0).getChild(1).getChild(0) instanceof EngineBlock); + checkUndoState("Move component", "Modify mass2"); + + + // Check cg+cp + altitude + checkCgCp(0.221, 0.0797, 0.320, 12.0); + checkAlt(32.7); + + + } + + private String massComponentID = null; + + private MassComponent massComponent() { + if (massComponentID == null) { + massComponentID = document.getRocket().getChild(0).getChild(1).getChild(0).getID(); + } + return (MassComponent) document.getRocket().findComponent(massComponentID); + } + + + private void checkUndoState(String undoDesc, String redoDesc) { + if (undoDesc == null) { + assertEquals("Undo", undoAction.getValue(Action.NAME)); + assertFalse(undoAction.isEnabled()); + } else { + assertEquals("Undo (" + undoDesc + ")", undoAction.getValue(Action.NAME)); + assertTrue(undoAction.isEnabled()); + } + if (redoDesc == null) { + assertEquals("Redo", redoAction.getValue(Action.NAME)); + assertFalse(redoAction.isEnabled()); + } else { + assertEquals("Redo (" + redoDesc + ")", redoAction.getValue(Action.NAME)); + assertTrue(redoAction.isEnabled()); + } + } + + + private void checkCgCp(double cgx, double mass, double cpx, double cna) { + Coordinate cg, cp; + + cg = massCalc.getCG(config, MassCalcType.LAUNCH_MASS); + assertEquals(cgx, cg.x, 0.001); + assertEquals(mass, cg.weight, 0.0005); + + cp = aeroCalc.getWorstCP(config, conditions, null); + assertEquals(cpx, cp.x, 0.001); + assertEquals(cna, cp.weight, 0.1); + } + + + private void checkAlt(double expected) throws SimulationException { + Simulation simulation = document.getSimulation(0); + double actual; + + // Simulate + check altitude + simulation.simulate(); + actual = simulation.getSimulatedData().getBranch(0).getMaximum(FlightDataType.TYPE_ALTITUDE); + assertEquals(expected, actual, 0.5); + } + +} diff --git a/core/test/net/sf/openrocket/arch/TestSystemInfo.java b/core/test/net/sf/openrocket/arch/TestSystemInfo.java new file mode 100644 index 00000000..80c65584 --- /dev/null +++ b/core/test/net/sf/openrocket/arch/TestSystemInfo.java @@ -0,0 +1,73 @@ +package net.sf.openrocket.arch; + +import static org.junit.Assert.assertEquals; + +import java.io.File; + +import org.junit.Test; + +/* + * Note: These tests have not been tested on Windows, they might fail there + * due to a different directory separator character. + */ +public class TestSystemInfo { + + private String osname; + private String userhome; + + + public void setup() { + this.osname = System.getProperty("os.name"); + this.userhome = System.getProperty("user.home"); + } + + public void tearDown() { + System.setProperty("os.name", this.osname); + System.setProperty("user.home", this.userhome); + } + + @Test + public void testWindows() { + setup(); + + System.setProperty("os.name", "Windows Me"); + System.setProperty("user.home", "C:/Users/my user"); + assertEquals(SystemInfo.Platform.WINDOWS, SystemInfo.getPlatform()); + if (System.getenv("APPDATA") != null) { + assertEquals(new File(System.getenv("APPDATA") + "/OpenRocket/"), SystemInfo.getUserApplicationDirectory()); + } else { + assertEquals(new File("C:/Users/my user/OpenRocket/"), SystemInfo.getUserApplicationDirectory()); + } + + tearDown(); + } + + @Test + public void testMacOS() { + setup(); + + System.setProperty("os.name", "Mac OS X"); + System.setProperty("user.home", "/Users/My User"); + assertEquals(SystemInfo.Platform.MAC_OS, SystemInfo.getPlatform()); + assertEquals(new File("/Users/My User/Library/Application Support/OpenRocket/"), + SystemInfo.getUserApplicationDirectory()); + + tearDown(); + } + + @Test + public void testUnix() { + setup(); + + System.setProperty("user.home", "/home/myuser"); + for (String os : new String[] { "Linux", "Solaris", "Foobar" }) { + System.setProperty("os.name", os); + + assertEquals(SystemInfo.Platform.UNIX, SystemInfo.getPlatform()); + assertEquals(new File("/home/myuser/.openrocket"), SystemInfo.getUserApplicationDirectory()); + } + + tearDown(); + } + +} diff --git a/core/test/net/sf/openrocket/communication/BugReportTest.java b/core/test/net/sf/openrocket/communication/BugReportTest.java new file mode 100644 index 00000000..e178ec7f --- /dev/null +++ b/core/test/net/sf/openrocket/communication/BugReportTest.java @@ -0,0 +1,75 @@ +package net.sf.openrocket.communication; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; + +import net.sf.openrocket.util.BuildProperties; + +import org.junit.Test; + + +public class BugReportTest { + + private HttpURLConnectionMock setup() { + HttpURLConnectionMock connection = new HttpURLConnectionMock(); + Communicator.setConnectionSource(new ConnectionSourceStub(connection)); + + connection.setUseCaches(true); + return connection; + } + + private void check(HttpURLConnectionMock connection) { + assertEquals(Communicator.BUG_REPORT_URL, connection.getTrueUrl()); + assertTrue(connection.getConnectTimeout() > 0); + assertEquals(BuildProperties.getVersion(), connection.getRequestProperty("X-OpenRocket-Version")); + assertTrue(connection.getInstanceFollowRedirects()); + assertEquals("POST", connection.getRequestMethod()); + assertFalse(connection.getUseCaches()); + } + + + @Test + public void testBugReportSuccess() throws IOException { + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(Communicator.BUG_REPORT_RESPONSE_CODE); + + String message = + "MyMessage\n"+ + "is important\n"+ + "h\u00e4h?"; + + BugReporter.sendBugReport(message); + + check(connection); + + String msg = connection.getOutputStreamString(); + assertTrue(msg.indexOf("version=" + BuildProperties.getVersion()) >= 0); + assertTrue(msg.indexOf(Communicator.encode(message)) >= 0); + } + + + @Test + public void testBugReportFailure() throws IOException { + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(200); + + String message = + "MyMessage\n"+ + "is important\n"+ + "h\u00e4h?"; + + try { + BugReporter.sendBugReport(message); + fail("Exception did not occur"); + } catch (IOException e) { + // Success + } + + check(connection); + } + +} diff --git a/core/test/net/sf/openrocket/communication/ConnectionSourceStub.java b/core/test/net/sf/openrocket/communication/ConnectionSourceStub.java new file mode 100644 index 00000000..4cd5470b --- /dev/null +++ b/core/test/net/sf/openrocket/communication/ConnectionSourceStub.java @@ -0,0 +1,22 @@ +package net.sf.openrocket.communication; + +import java.io.IOException; +import java.net.HttpURLConnection; + +public class ConnectionSourceStub implements ConnectionSource { + + private final HttpURLConnection connection; + + public ConnectionSourceStub(HttpURLConnection connection) { + this.connection = connection; + } + + @Override + public HttpURLConnection getConnection(String url) throws IOException { + if (connection instanceof HttpURLConnectionMock) { + ((HttpURLConnectionMock)connection).setTrueUrl(url); + } + return connection; + } + +} diff --git a/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java b/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java new file mode 100644 index 00000000..ab5c48ab --- /dev/null +++ b/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java @@ -0,0 +1,550 @@ +package net.sf.openrocket.communication; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.security.Permission; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.openrocket.util.BugException; + +public class HttpURLConnectionMock extends HttpURLConnection { + + private static final URL MOCK_URL; + static { + try { + MOCK_URL = new URL("http://localhost/"); + } catch (MalformedURLException e) { + throw new BugException(e); + } + } + + private volatile boolean instanceFollowRedirects = false; + private volatile String requestMethod = ""; + private volatile int responseCode; + private Map requestProperties = new HashMap(); + private volatile int connectTimeout = -1; + private volatile String contentEncoding = ""; + + private volatile boolean doInput = false; + private volatile boolean doOutput = false; + + private volatile byte[] content = null; + private volatile String contentType = null; + private volatile boolean useCaches = false; + + + private volatile InputStream inputStream = null; + private volatile ByteArrayOutputStream outputStream = null; + + private volatile String trueUrl = null; + + + private volatile boolean connected = false; + private volatile int connectionDelay = 0; + + private volatile boolean failed = false; + + + + + public HttpURLConnectionMock() { + super(MOCK_URL); + } + + public HttpURLConnectionMock(URL u) { + super(u); + } + + + + public String getTrueUrl() { + return trueUrl; + } + + public void setTrueUrl(String url) { + assertNull(this.trueUrl); + this.trueUrl = url; + } + + + public boolean hasFailed() { + return failed; + } + + + public void setConnectionDelay(int delay) { + this.connectionDelay = delay; + } + + + + @Override + public void connect() { + if (!connected) { + try { + Thread.sleep(connectionDelay); + } catch (InterruptedException e) { + } + connected = true; + } + } + + @Override + public void disconnect() { + + } + + @Override + public boolean usingProxy() { + return false; + } + + + + + @Override + public boolean getInstanceFollowRedirects() { + return this.instanceFollowRedirects; + } + + @Override + public void setInstanceFollowRedirects(boolean followRedirects) { + assertFalse(connected); + this.instanceFollowRedirects = followRedirects; + } + + @Override + public String getRequestMethod() { + return this.requestMethod; + } + + @Override + public void setRequestMethod(String method) throws ProtocolException { + assertFalse(connected); + this.requestMethod = method; + } + + @Override + public int getResponseCode() throws IOException { + connect(); + return this.responseCode; + } + + public void setResponseCode(int code) { + this.responseCode = code; + } + + + @Override + public void addRequestProperty(String key, String value) { + assertFalse(connected); + assertFalse(this.requestProperties.containsKey(key.toLowerCase())); + this.requestProperties.put(key.toLowerCase(), value); + } + + + @Override + public void setRequestProperty(String key, String value) { + assertFalse(connected); + this.requestProperties.put(key.toLowerCase(), value); + } + + + @Override + public String getRequestProperty(String key) { + return this.requestProperties.get(key.toLowerCase()); + } + + + @Override + public int getConnectTimeout() { + return this.connectTimeout; + } + + @Override + public void setConnectTimeout(int timeout) { + assertFalse(connected); + this.connectTimeout = timeout; + } + + + + @Override + public String getContentEncoding() { + connect(); + return this.contentEncoding; + } + + public void setContentEncoding(String encoding) { + this.contentEncoding = encoding; + } + + + + @Override + public int getContentLength() { + connect(); + if (content == null) + return 0; + return content.length; + } + + public void setContent(byte[] content) { + this.content = content; + } + + public void setContent(String content) { + try { + this.content = content.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + fail("UTF-8"); + } + } + + + @Override + public String getContentType() { + connect(); + return this.contentType; + } + + public void setContentType(String type) { + this.contentType = type; + } + + + + @Override + public boolean getDoInput() { + return this.doInput; + } + + + @Override + public void setDoInput(boolean doinput) { + assertFalse(connected); + this.doInput = doinput; + } + + + @Override + public boolean getDoOutput() { + return this.doOutput; + } + + + @Override + public void setDoOutput(boolean dooutput) { + assertFalse(connected); + this.doOutput = dooutput; + } + + + @Override + public InputStream getInputStream() throws IOException { + assertTrue(doInput); + assertNull(inputStream); + assertNotNull(content); + + connect(); + inputStream = new ByteArrayInputStream(content); + return inputStream; + } + + + @Override + public OutputStream getOutputStream() throws IOException { + assertTrue(doOutput); + assertNull(outputStream); + outputStream = new ByteArrayOutputStream(); + return outputStream; + } + + public byte[] getOutputStreamData() { + return outputStream.toByteArray(); + } + + public String getOutputStreamString() { + try { + return outputStream.toString("UTF-8"); + } catch (UnsupportedEncodingException e) { + fail("UTF-8"); + return null; + } + } + + + + @Override + public void setUseCaches(boolean usecaches) { + assertFalse(connected); + this.useCaches = usecaches; + } + + + + @Override + public boolean getUseCaches() { + return this.useCaches; + } + + + + + + + + + private void assertNull(Object o) { + try { + org.junit.Assert.assertNull(o); + } catch (AssertionError e) { + failed = true; + throw e; + } + } + + private void assertNotNull(Object o) { + try { + org.junit.Assert.assertNotNull(o); + } catch (AssertionError e) { + failed = true; + throw e; + } + } + + private void assertTrue(boolean o) { + try { + org.junit.Assert.assertTrue(o); + } catch (AssertionError e) { + failed = true; + throw e; + } + } + + private void assertFalse(boolean o) { + try { + org.junit.Assert.assertFalse(o); + } catch (AssertionError e) { + failed = true; + throw e; + } + } + + private void fail(String msg) { + failed = true; + org.junit.Assert.fail(msg); + } + + + + + + + + + + + + + + + + + + + @Override + public InputStream getErrorStream() { + throw new UnsupportedOperationException(); + } + + + + @Override + public String getHeaderField(int n) { + throw new UnsupportedOperationException(); + } + + + + @Override + public long getHeaderFieldDate(String name, long Default) { + throw new UnsupportedOperationException(); + } + + + + @Override + public String getHeaderFieldKey(int n) { + throw new UnsupportedOperationException(); + } + + + @Override + public Permission getPermission() throws IOException { + throw new UnsupportedOperationException(); + } + + + @Override + public String getResponseMessage() throws IOException { + throw new UnsupportedOperationException(); + } + + + + @Override + public void setChunkedStreamingMode(int chunklen) { + throw new UnsupportedOperationException(); + } + + + + @Override + public void setFixedLengthStreamingMode(int contentLength) { + throw new UnsupportedOperationException(); + } + + + + + + @Override + public boolean getAllowUserInteraction() { + throw new UnsupportedOperationException(); + } + + + + @Override + public Object getContent() throws IOException { + throw new UnsupportedOperationException(); + } + + + + @SuppressWarnings("unchecked") + @Override + public Object getContent(Class[] classes) throws IOException { + throw new UnsupportedOperationException(); + } + + + @Override + public long getDate() { + throw new UnsupportedOperationException(); + } + + + + @Override + public boolean getDefaultUseCaches() { + throw new UnsupportedOperationException(); + } + + + @Override + public long getExpiration() { + throw new UnsupportedOperationException(); + } + + + + @Override + public String getHeaderField(String name) { + throw new UnsupportedOperationException(); + } + + + + @Override + public int getHeaderFieldInt(String name, int Default) { + throw new UnsupportedOperationException(); + } + + + + @Override + public Map> getHeaderFields() { + throw new UnsupportedOperationException(); + } + + + + @Override + public long getIfModifiedSince() { + throw new UnsupportedOperationException(); + } + + + @Override + public long getLastModified() { + throw new UnsupportedOperationException(); + } + + @Override + public int getReadTimeout() { + throw new UnsupportedOperationException(); + } + + + + @Override + public Map> getRequestProperties() { + throw new UnsupportedOperationException(); + } + + + @Override + public URL getURL() { + throw new UnsupportedOperationException(); + } + + + + @Override + public void setAllowUserInteraction(boolean allowuserinteraction) { + throw new UnsupportedOperationException(); + } + + @Override + public void setDefaultUseCaches(boolean defaultusecaches) { + throw new UnsupportedOperationException(); + } + + + @Override + public void setIfModifiedSince(long ifmodifiedsince) { + throw new UnsupportedOperationException(); + } + + + @Override + public void setReadTimeout(int timeout) { + throw new UnsupportedOperationException(); + } + + + + + + @Override + public String toString() { + throw new UnsupportedOperationException(); + } + + + + +} diff --git a/core/test/net/sf/openrocket/communication/UpdateInfoTest.java b/core/test/net/sf/openrocket/communication/UpdateInfoTest.java new file mode 100644 index 00000000..d09db759 --- /dev/null +++ b/core/test/net/sf/openrocket/communication/UpdateInfoTest.java @@ -0,0 +1,236 @@ +package net.sf.openrocket.communication; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +import net.sf.openrocket.util.BuildProperties; +import net.sf.openrocket.util.ComparablePair; +import net.sf.openrocket.util.BaseTestCase.BaseTestCase; + +import org.junit.Test; + +public class UpdateInfoTest extends BaseTestCase { + + /** The connection delay */ + private static final int DELAY = 100; + + /** How much long does the test allow it to take */ + private static final int ALLOWANCE = 2000; + + + private HttpURLConnectionMock setup() { + HttpURLConnectionMock connection = new HttpURLConnectionMock(); + Communicator.setConnectionSource(new ConnectionSourceStub(connection)); + + connection.setConnectionDelay(DELAY); + connection.setUseCaches(true); + connection.setContentType("text/plain"); + return connection; + } + + private void check(HttpURLConnectionMock connection) { + assertEquals(Communicator.UPDATE_INFO_URL + "?version=" + BuildProperties.getVersion(), + connection.getTrueUrl()); + assertTrue(connection.getConnectTimeout() > 0); + assertEquals(BuildProperties.getVersion() + "+" + BuildProperties.getBuildSource(), + connection.getRequestProperty("X-OpenRocket-Version")); + assertNotNull(connection.getRequestProperty("X-OpenRocket-Country")); + assertNotNull(connection.getRequestProperty("X-OpenRocket-ID")); + assertNotNull(connection.getRequestProperty("X-OpenRocket-OS")); + assertNotNull(connection.getRequestProperty("X-OpenRocket-Java")); + assertTrue(connection.getInstanceFollowRedirects()); + assertEquals("GET", connection.getRequestMethod()); + assertFalse(connection.getUseCaches()); + } + + + @Test + public void testUpdateAvailable() throws IOException { + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); + + String content = + "Version: 6.6.6pre A \n" + + "Extra: information\n" + + "100:hundred\n" + + "50: m\u00e4 \n\n" + + "1: one\n" + + "-2: none"; + connection.setContent(content); + + UpdateInfoRetriever retriever = new UpdateInfoRetriever(); + retriever.start(); + + // Info is null while processing + assertNull(retriever.getUpdateInfo()); + + waitfor(retriever); + assertFalse(connection.hasFailed()); + + UpdateInfo info = retriever.getUpdateInfo(); + assertNotNull(info); + + check(connection); + + assertEquals("6.6.6pre A", info.getLatestVersion()); + + List> updates = info.getUpdates(); + assertEquals(3, updates.size()); + Collections.sort(updates); + assertEquals(1, (int)updates.get(0).getU()); + assertEquals("one", updates.get(0).getV()); + assertEquals(50, (int)updates.get(1).getU()); + assertEquals("m\u00e4", updates.get(1).getV()); + assertEquals(100, (int)updates.get(2).getU()); + assertEquals("hundred", updates.get(2).getV()); + } + + + + + @Test + public void testUpdateNotAvailable() throws IOException { + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_NO_UPDATE_CODE); + + String content = + "Version: 6.6.6pre A \n" + + "Extra: information\n" + + "100:hundred\n" + + "50: m\u00e4 \n\n" + + "1: one\n" + + "-2: none"; + connection.setContent(content); + + UpdateInfoRetriever retriever = new UpdateInfoRetriever(); + retriever.start(); + + // Info is null while processing + assertNull(retriever.getUpdateInfo()); + + waitfor(retriever); + assertFalse(connection.hasFailed()); + + UpdateInfo info = retriever.getUpdateInfo(); + assertNotNull(info); + + check(connection); + + assertEquals(BuildProperties.getVersion(), info.getLatestVersion()); + assertEquals(0, info.getUpdates().size()); + } + + + + @Test + public void testInvalidResponses() { + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(404); + connection.setContent("Version: 1.2.3"); + + UpdateInfoRetriever retriever = new UpdateInfoRetriever(); + retriever.start(); + assertNull(retriever.getUpdateInfo()); + waitfor(retriever); + assertFalse(connection.hasFailed()); + assertNull(retriever.getUpdateInfo()); + check(connection); + + + connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); + connection.setContentType("text/xml"); + + retriever = new UpdateInfoRetriever(); + retriever.start(); + assertNull(retriever.getUpdateInfo()); + waitfor(retriever); + assertFalse(connection.hasFailed()); + assertNull(retriever.getUpdateInfo()); + check(connection); + + + + connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); + String content = + "100:hundred\n" + + "50: m\u00e4 \n\n" + + "1: one\n"; + connection.setContent(content); + + retriever = new UpdateInfoRetriever(); + retriever.start(); + assertNull(retriever.getUpdateInfo()); + waitfor(retriever); + assertFalse(connection.hasFailed()); + assertNull(retriever.getUpdateInfo()); + check(connection); + + + connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); + connection.setContent(new byte[0]); + + retriever = new UpdateInfoRetriever(); + retriever.start(); + assertNull(retriever.getUpdateInfo()); + waitfor(retriever); + assertFalse(connection.hasFailed()); + assertNull(retriever.getUpdateInfo()); + check(connection); + + } + + @Test + public void testRandomInputData() { + + Random rnd = new Random(); + for (int i=0; i<10; i++) { + int size = (int) ((1 + 0.3 * rnd.nextGaussian()) * Math.pow(i, 6)); + byte[] buf = new byte[size]; + rnd.nextBytes(buf); + + HttpURLConnectionMock connection = setup(); + connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); + connection.setContent(buf); + + UpdateInfoRetriever retriever = new UpdateInfoRetriever(); + retriever.start(); + assertNull(retriever.getUpdateInfo()); + waitfor(retriever); + assertFalse(connection.hasFailed()); + assertNull(retriever.getUpdateInfo()); + check(connection); + } + + } + + + + private void waitfor(UpdateInfoRetriever retriever) { + long t = System.currentTimeMillis(); + + while (retriever.isRunning()) { + if (System.currentTimeMillis() >= t+ALLOWANCE) { + fail("retriever took too long to respond"); + } + + try { + Thread.sleep(10); + } catch (InterruptedException e) { } + } + + System.out.println("Waiting took " + (System.currentTimeMillis()-t) + " ms"); + } + +} diff --git a/core/test/net/sf/openrocket/database/MotorSetDatabaseTest.java b/core/test/net/sf/openrocket/database/MotorSetDatabaseTest.java new file mode 100644 index 00000000..33ced0c8 --- /dev/null +++ b/core/test/net/sf/openrocket/database/MotorSetDatabaseTest.java @@ -0,0 +1,56 @@ +package net.sf.openrocket.database; + +import static org.junit.Assert.*; + +import java.util.List; + +import net.sf.openrocket.motor.Manufacturer; +import net.sf.openrocket.motor.Motor; +import net.sf.openrocket.motor.ThrustCurveMotor; +import net.sf.openrocket.util.Coordinate; + +import org.junit.Test; + + +public class MotorSetDatabaseTest { + + @Test + public void testMotorLoading() { + + ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(true) { + @Override + protected void loadMotors() { + try { + Thread.sleep(200); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + 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})); + 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})); + 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})); + } + }; + + assertFalse(db.isLoaded()); + db.startLoading(); + assertFalse(db.isLoaded()); + List list = db.getMotorSets(); + assertTrue(db.isLoaded()); + + assertEquals(2, list.size()); + assertEquals(1, list.get(0).getMotors().size()); + assertEquals(1, list.get(1).getMotors().size()); + assertEquals("Bar", list.get(0).getMotors().get(0).getDesignation()); + assertEquals("Foo", list.get(1).getMotors().get(0).getDesignation()); + } + +} diff --git a/core/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java b/core/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java new file mode 100644 index 00000000..56e30b2d --- /dev/null +++ b/core/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java @@ -0,0 +1,123 @@ +package net.sf.openrocket.database; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collections; + +import net.sf.openrocket.motor.Manufacturer; +import net.sf.openrocket.motor.Motor; +import net.sf.openrocket.motor.ThrustCurveMotor; +import net.sf.openrocket.util.Coordinate; + +import org.junit.Test; + +public class ThrustCurveMotorSetTest { + + + private static final ThrustCurveMotor motor1 = new ThrustCurveMotor( + 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}); + + 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}); + + 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}); + + 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}); + + + @Test + public void testSimplifyDesignation() { + assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("J115")); + assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation(" J115 ")); + assertEquals("H115", ThrustCurveMotorSet.simplifyDesignation("241H115-KS")); + assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("384 J115")); + assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("384-J115")); + assertEquals("A2", ThrustCurveMotorSet.simplifyDesignation("A2T")); + assertEquals("1/2A2T", ThrustCurveMotorSet.simplifyDesignation("1/2A2T")); + assertEquals("Micro Maxx II", ThrustCurveMotorSet.simplifyDesignation("Micro Maxx II")); + } + + @Test + public void testAdding() { + ThrustCurveMotorSet set = new ThrustCurveMotorSet(); + + // Test empty set + assertNull(set.getManufacturer()); + assertEquals(0, set.getMotors().size()); + + // Add motor1 + assertTrue(set.matches(motor1)); + set.addMotor(motor1); + assertEquals(motor1.getManufacturer(), set.getManufacturer()); + assertEquals(motor1.getDesignation(), set.getDesignation()); + assertEquals(Motor.Type.UNKNOWN, set.getType()); + assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); + assertEquals(motor1.getLength(), set.getLength(), 0.00001); + assertEquals(1, set.getMotors().size()); + assertEquals(motor1, set.getMotors().get(0)); + assertEquals(Collections.emptyList(), set.getDelays()); + + // Add motor1 again + assertTrue(set.matches(motor1)); + set.addMotor(motor1); + assertEquals(motor1.getManufacturer(), set.getManufacturer()); + assertEquals(motor1.getDesignation(), set.getDesignation()); + assertEquals(Motor.Type.UNKNOWN, set.getType()); + assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); + assertEquals(motor1.getLength(), set.getLength(), 0.00001); + assertEquals(1, set.getMotors().size()); + assertEquals(motor1, set.getMotors().get(0)); + assertEquals(Collections.emptyList(), set.getDelays()); + + // Add motor2 + assertTrue(set.matches(motor2)); + set.addMotor(motor2); + assertEquals(motor1.getManufacturer(), set.getManufacturer()); + assertEquals(motor3.getDesignation(), set.getDesignation()); + assertEquals(Motor.Type.SINGLE, set.getType()); + assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); + assertEquals(motor1.getLength(), set.getLength(), 0.00001); + assertEquals(2, set.getMotors().size()); + assertEquals(motor2, set.getMotors().get(0)); + assertEquals(motor1, set.getMotors().get(1)); + assertEquals(Arrays.asList(5.0), set.getDelays()); + + // Add motor3 + assertTrue(set.matches(motor3)); + set.addMotor(motor3); + assertEquals(motor1.getManufacturer(), set.getManufacturer()); + assertEquals(motor3.getDesignation(), set.getDesignation()); + assertEquals(Motor.Type.SINGLE, set.getType()); + assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); + assertEquals(motor1.getLength(), set.getLength(), 0.00001); + assertEquals(3, set.getMotors().size()); + assertEquals(motor3, set.getMotors().get(0)); + assertEquals(motor2, set.getMotors().get(1)); + assertEquals(motor1, set.getMotors().get(2)); + assertEquals(Arrays.asList(0.0, 5.0, Motor.PLUGGED), set.getDelays()); + + // Test that adding motor4 fails + assertFalse(set.matches(motor4)); + try { + set.addMotor(motor4); + fail("Did not throw exception"); + } catch (IllegalArgumentException e) { + } + } + +} diff --git a/core/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java b/core/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java new file mode 100644 index 00000000..dce14861 --- /dev/null +++ b/core/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java @@ -0,0 +1,25 @@ +package net.sf.openrocket.file.iterator; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; + +import org.junit.Test; + +public class TestDirectoryIterator { + + @Test + public void testDirectoryIterator() throws IOException { + DirectoryIterator iterator = new DirectoryIterator(new File("test/net/sf/openrocket/file"), new FileFilter() { + @Override + public boolean accept(File pathname) { + return pathname.getName().matches("^Test(Directory|File)Iterator.java"); + } + }, true); + + while (iterator.hasNext()) { + System.out.println("" + iterator.next()); + } + + } +} diff --git a/core/test/net/sf/openrocket/file/iterator/TestFileIterator.java b/core/test/net/sf/openrocket/file/iterator/TestFileIterator.java new file mode 100644 index 00000000..c3e424ee --- /dev/null +++ b/core/test/net/sf/openrocket/file/iterator/TestFileIterator.java @@ -0,0 +1,41 @@ +package net.sf.openrocket.file.iterator; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import net.sf.openrocket.util.Pair; + +import org.junit.Test; + +public class TestFileIterator { + + @Test + public void testFileIterator() { + final Pair one = new Pair("one", new ByteArrayInputStream(new byte[] { 1 })); + final Pair two = new Pair("two", new ByteArrayInputStream(new byte[] { 2 })); + + FileIterator iterator = new FileIterator() { + private int count = 0; + + @Override + protected Pair findNext() { + count++; + switch (count) { + case 1: + return one; + case 2: + return two; + default: + return null; + } + } + }; + + assertTrue(iterator.hasNext()); + assertEquals(one, iterator.next()); + assertEquals(two, iterator.next()); + assertFalse(iterator.hasNext()); + } +} diff --git a/core/test/net/sf/openrocket/file/motor/TestMotorLoader.java b/core/test/net/sf/openrocket/file/motor/TestMotorLoader.java new file mode 100644 index 00000000..8200310a --- /dev/null +++ b/core/test/net/sf/openrocket/file/motor/TestMotorLoader.java @@ -0,0 +1,63 @@ +package net.sf.openrocket.file.motor; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; +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; + +public class TestMotorLoader { + + @Test + public void testGeneralMotorLoader() throws IOException { + MotorLoader loader = new GeneralMotorLoader(); + + test(loader, "test1.eng", "c056cf25df6751f7bb8a94bc4f64750f"); + test(loader, "test2.rse", "b2fe203ee319ae28b9ccdad26a8f21de"); + test(loader, "test.zip", "b2fe203ee319ae28b9ccdad26a8f21de", "c056cf25df6751f7bb8a94bc4f64750f"); + + } + + @Test + public void testRASPMotorLoader() throws IOException { + test(new RASPMotorLoader(), "test1.eng", "c056cf25df6751f7bb8a94bc4f64750f"); + } + + @Test + public void testRocksimMotorLoader() throws IOException { + test(new RockSimMotorLoader(), "test2.rse", "b2fe203ee319ae28b9ccdad26a8f21de"); + } + + @Test + public void testZipMotorLoader() throws IOException { + test(new ZipFileMotorLoader(), "test.zip", "b2fe203ee319ae28b9ccdad26a8f21de", "c056cf25df6751f7bb8a94bc4f64750f"); + } + + + private void test(MotorLoader loader, String file, String... digests) throws IOException { + List motors; + + InputStream is = this.getClass().getResourceAsStream(file); + assertNotNull("File " + file + " not found", is); + motors = loader.load(is, file); + is.close(); + assertEquals(digests.length, motors.size()); + + String[] d = new String[digests.length]; + for (int i = 0; i < motors.size(); i++) { + d[i] = MotorDigest.digestMotor((ThrustCurveMotor) motors.get(i)); + } + + Arrays.sort(digests); + Arrays.sort(d); + assertTrue(Arrays.equals(d, digests)); + } + +} diff --git a/core/test/net/sf/openrocket/file/motor/test.txt b/core/test/net/sf/openrocket/file/motor/test.txt new file mode 100644 index 00000000..4b43be8f --- /dev/null +++ b/core/test/net/sf/openrocket/file/motor/test.txt @@ -0,0 +1 @@ +boo bah diff --git a/core/test/net/sf/openrocket/file/motor/test.zip b/core/test/net/sf/openrocket/file/motor/test.zip new file mode 100644 index 00000000..eeb5ef7c Binary files /dev/null and b/core/test/net/sf/openrocket/file/motor/test.zip differ diff --git a/core/test/net/sf/openrocket/file/motor/test1.eng b/core/test/net/sf/openrocket/file/motor/test1.eng new file mode 100644 index 00000000..06dc100e --- /dev/null +++ b/core/test/net/sf/openrocket/file/motor/test1.eng @@ -0,0 +1,24 @@ +D10 18 70 7 0.009800000000000001 0.0259 AT + 0.0070 23.0 + 0.018 25.0 + 0.027 20.25 + 0.066 20.25 + 0.073 18.5 + 0.094 20.25 + 0.112 20.75 + 0.137 19.75 + 0.163 21.5 + 0.202 20.75 + 0.231 20.75 + 0.254 22.75 + 0.27 20.75 + 0.504 20.0 + 0.536 18.25 + 0.607 17.0 + 0.687 14.75 + 0.751 14.25 + 0.84 11.25 + 0.998 8.25 + 1.024 8.25 + 1.248 2.5 + 1.385 0.0 diff --git a/core/test/net/sf/openrocket/file/motor/test2.rse b/core/test/net/sf/openrocket/file/motor/test2.rse new file mode 100644 index 00000000..a77408f8 --- /dev/null +++ b/core/test/net/sf/openrocket/file/motor/test2.rse @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java b/core/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java new file mode 100644 index 00000000..7feb8d23 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java @@ -0,0 +1,66 @@ +package net.sf.openrocket.file.rocksim.export; + +import net.sf.openrocket.document.OpenRocketDocument; +import net.sf.openrocket.file.rocksim.importt.RocksimLoader; +import net.sf.openrocket.file.rocksim.importt.RocksimLoaderTest; +import net.sf.openrocket.file.rocksim.importt.RocksimTestBase; +import org.junit.Assert; +import org.junit.Test; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import java.io.File; +import java.io.FileWriter; +import java.io.StringWriter; + +/** + */ +public class RocksimDocumentDTOTest extends RocksimTestBase { + + @Test + public void testDTO() throws Exception { + JAXBContext binder = JAXBContext.newInstance(RocksimDocumentDTO.class); + Marshaller marshaller = binder.createMarshaller(); + marshaller.setProperty("jaxb.fragment", Boolean.TRUE); + + NoseConeDTO noseCone = new NoseConeDTO(); + noseCone.setBaseDia(10d); + noseCone.setCalcCG(1.3d); + + StageDTO stage1 = new StageDTO(); + stage1.addExternalPart(noseCone); + + RocketDesignDTO design2 = new RocketDesignDTO(); + design2.setName("Test"); + design2.setStage3(stage1); + + RocksimDesignDTO design = new RocksimDesignDTO(); + design.setDesign(design2); + RocksimDocumentDTO message = new RocksimDocumentDTO(); + message.setDesign(design); + + + StringWriter stringWriter = new StringWriter(); + marshaller.marshal(message, stringWriter); + + String response = stringWriter.toString(); + + System.err.println(response); + } + + @Test + public void testRoundTrip() throws Exception { + OpenRocketDocument ord = RocksimLoaderTest.loadRocksimRocket3(new RocksimLoader()); + + Assert.assertNotNull(ord); + String result = new RocksimSaver().marshalToRocksim(ord); + +// System.err.println(result); + + File output = new File("rt.rkt"); + FileWriter fw = new FileWriter(output); + fw.write(result); + fw.flush(); + fw.close(); + } +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java new file mode 100644 index 00000000..b69a3bd9 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java @@ -0,0 +1,149 @@ +/* + * BodyTubeHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.ExternalComponent; +import net.sf.openrocket.rocketcomponent.Stage; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +/** + * BodyTubeHandler Tester. + * + */ +public class BodyTubeHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testConstructor() throws Exception { + + try { + new BodyTubeHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + Stage stage = new Stage(); + BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); + BodyTube component = (BodyTube) getField(handler, "bodyTube"); + assertContains(component, stage.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); + Assert.assertNotNull(new BodyTubeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); + } + + /** + * + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testCloseElement() throws Exception { + Stage stage = new Stage(); + BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); + BodyTube component = (BodyTube) getField(handler, "bodyTube"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ID", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("IsMotorMount", attributes, "1", warnings); + Assert.assertTrue(component.isMotorMount()); + handler.closeElement("IsMotorMount", attributes, "0", warnings); + Assert.assertFalse(component.isMotorMount()); + handler.closeElement("IsMotorMount", attributes, "foo", warnings); + Assert.assertFalse(component.isMotorMount()); + + handler.closeElement("EngineOverhang", attributes, "-1", warnings); + Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("FinishCode", attributes, "-1", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "100", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new BodyTubeHandler(new Stage(), new WarningSet()).getComponent() instanceof BodyTube); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage(), new WarningSet()).getMaterialType()); + } + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java new file mode 100644 index 00000000..503654bc --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java @@ -0,0 +1,185 @@ +/* + * FinSetHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +import junit.framework.TestCase; +import net.sf.openrocket.aerodynamics.WarningSet; +import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.EllipticalFinSet; +import net.sf.openrocket.rocketcomponent.FinSet; +import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; +import net.sf.openrocket.util.Coordinate; + +import java.lang.reflect.Method; +import java.util.HashMap; + +/** + * FinSetHandler Tester. + * + */ +public class FinSetHandlerTest extends TestCase { + + /** + * Method: asOpenRocket(WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testAsOpenRocket() throws Exception { + + FinSetHandler dto = new FinSetHandler(new BodyTube()); + + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + dto.closeElement("Name", attributes, "The name", warnings); + dto.closeElement("ShapeCode", attributes, "0", warnings); + dto.closeElement("Xb", attributes, "2", warnings); + dto.closeElement("FinCount", attributes, "4", warnings); + dto.closeElement("RootChord", attributes, "10", warnings); + dto.closeElement("TipChord", attributes, "11", warnings); + dto.closeElement("SemiSpan", attributes, "12", warnings); + dto.closeElement("MidChordLen", attributes, "13", warnings); + dto.closeElement("SweepDistance", attributes, "14", warnings); + dto.closeElement("Thickness", attributes, "200", warnings); + dto.closeElement("TipShapeCode", attributes, "1", warnings); + dto.closeElement("TabLength", attributes, "400", warnings); + dto.closeElement("TabDepth", attributes, "500", warnings); + dto.closeElement("TabOffset", attributes, "30", warnings); + dto.closeElement("RadialAngle", attributes, ".123", warnings); + dto.closeElement("PointList", attributes, "20,0|2,2|0,0", warnings); + dto.closeElement("LocationMode", attributes, "0", warnings); + + WarningSet set = new WarningSet(); + FinSet fins = dto.asOpenRocket(set); + assertNotNull(fins); + assertEquals(0, set.size()); + + assertEquals("The name", fins.getName()); + assertTrue(fins instanceof TrapezoidFinSet); + assertEquals(4, fins.getFinCount()); + + assertEquals(0.012d, ((TrapezoidFinSet) fins).getHeight()); + assertEquals(0.012d, fins.getSpan()); + + assertEquals(0.2d, fins.getThickness()); + assertEquals(0.4d, fins.getTabLength()); + assertEquals(0.5d, fins.getTabHeight()); + assertEquals(0.03d, fins.getTabShift()); + assertEquals(.123d, fins.getBaseRotation()); + + dto.closeElement("ShapeCode", attributes, "1", warnings); + fins = dto.asOpenRocket(set); + assertNotNull(fins); + assertEquals(0, set.size()); + + assertEquals("The name", fins.getName()); + assertTrue(fins instanceof EllipticalFinSet); + assertEquals(4, fins.getFinCount()); + + assertEquals(0.2d, fins.getThickness()); + assertEquals(0.4d, fins.getTabLength()); + assertEquals(0.5d, fins.getTabHeight()); + assertEquals(0.03d, fins.getTabShift()); + assertEquals(.123d, fins.getBaseRotation()); + } + + + /** + * Method: toCoordinates(String pointList) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testToCoordinates() throws Exception { + FinSetHandler holder = new FinSetHandler(new BodyTube()); + Method method = FinSetHandler.class.getDeclaredMethod("toCoordinates", String.class, WarningSet.class); + method.setAccessible(true); + + WarningSet warnings = new WarningSet(); + //Null finlist + String finlist = null; + Coordinate[] result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(0 == result.length); + + //Empty string finlist + finlist = ""; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(0 == result.length); + + //Invalid finlist (only x coordinate) + finlist = "10.0"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(0 == result.length); + assertEquals(1, warnings.size()); + warnings.clear(); + + //Invalid finlist (non-numeric character) + finlist = "10.0,asdf"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(0 == result.length); + assertEquals(1, warnings.size()); + warnings.clear(); + + //Invalid finlist (all delimiters) + finlist = "||||||"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(0 == result.length); + assertEquals(0, warnings.size()); + warnings.clear(); + + //One point finlist - from a parsing view it's valid; from a practical view it may not be, but that's outside + //the scope of this test case + finlist = "10.0,5.0"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(1 == result.length); + assertEquals(0, warnings.size()); + warnings.clear(); + + //Two point finlist - from a parsing view it's valid; from a practical view it may not be, but that's outside + //the scope of this test case + finlist = "10.0,5.0|3.3,4.4"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(2 == result.length); + assertEquals(0, warnings.size()); + warnings.clear(); + + //Normal four point finlist. + finlist = "518.16,0|517.494,37.2145|1.31261,6.77283|0,0|"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(4 == result.length); + assertEquals(new Coordinate(0,0), result[0]); + assertEquals(0, warnings.size()); + warnings.clear(); + + //Normal four point finlist with spaces. + finlist = "518.16 , 0 | 517.494 , 37.2145 | 1.31261,6.77283|0,0|"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(4 == result.length); + assertEquals(new Coordinate(0,0), result[0]); + assertEquals(new Coordinate(.51816,0), result[3]); + assertEquals(0, warnings.size()); + warnings.clear(); + + //Reversed Normal four point finlist. + finlist = "0,0|1.31261,6.77283|517.494,37.2145|518.16,0|"; + result = (Coordinate[])method.invoke(holder, finlist, warnings); + assertNotNull(result); + assertTrue(4 == result.length); + assertEquals(new Coordinate(0,0), result[0]); + assertEquals(new Coordinate(.51816,0), result[3]); + assertEquals(0, warnings.size()); + warnings.clear(); + + } +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java new file mode 100644 index 00000000..fa070ce7 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java @@ -0,0 +1,154 @@ +/* + * InnerBodyTubeHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.InnerTube; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import org.junit.Assert; + +import java.util.HashMap; + +/** + * InnerBodyTubeHandler Tester. + * + */ +public class InnerBodyTubeHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new InnerBodyTubeHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); + InnerTube component = (InnerTube) getField(handler, "bodyTube"); + assertContains(component, tube.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + Assert.assertNotNull(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement("AttachedParts", null, null)); + } + + /** + * + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + BodyTube tube = new BodyTube(); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); + InnerTube component = (InnerTube) getField(handler, "bodyTube"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("OD", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ID", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("IsMotorMount", attributes, "1", warnings); + Assert.assertTrue(component.isMotorMount()); + handler.closeElement("IsMotorMount", attributes, "0", warnings); + Assert.assertFalse(component.isMotorMount()); + handler.closeElement("IsMotorMount", attributes, "foo", warnings); + Assert.assertFalse(component.isMotorMount()); + + handler.closeElement("EngineOverhang", attributes, "-1", warnings); + Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); + handler.closeElement("EngineOverhang", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); + InnerTube component = (InnerTube) getField(handler, "bodyTube"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java new file mode 100644 index 00000000..503ce805 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java @@ -0,0 +1,146 @@ +/* + * LaunchLugHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.ExternalComponent; +import net.sf.openrocket.rocketcomponent.LaunchLug; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import org.junit.Assert; + +import java.util.HashMap; + +/** + * LaunchLugHandler Tester. + * + */ +public class LaunchLugHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new LaunchLugHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); + LaunchLug component = (LaunchLug) getField(handler, "lug"); + assertContains(component, tube.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + } + + /** + * + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + BodyTube tube = new BodyTube(); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); + LaunchLug component = (LaunchLug) getField(handler, "lug"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getOuterRadius(), 0.001); + handler.closeElement("OD", attributes, "0", warnings); + Assert.assertEquals(0d, component.getOuterRadius(), 0.001); + handler.closeElement("OD", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001); + handler.closeElement("OD", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ID", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("FinishCode", attributes, "-1", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "100", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); + LaunchLug component = (LaunchLug) getField(handler, "lug"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new LaunchLugHandler(new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } + + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java new file mode 100644 index 00000000..e5360a12 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java @@ -0,0 +1,124 @@ +/* + * MassObjectHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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 org.junit.Assert; + +import java.util.HashMap; + +/** + * MassObjectHandler Tester. + * + */ +public class MassObjectHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new MassObjectHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); + MassComponent component = (MassComponent) getField(handler, "mass"); + assertContains(component, tube.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + } + + /** + * + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + BodyTube tube = new BodyTube(); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); + MassComponent component = (MassComponent) getField(handler, "mass"); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH) + , component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH) + , component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("KnownMass", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getComponentMass(), 0.001); + handler.closeElement("KnownMass", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS, component.getComponentMass(), 0.001); + handler.closeElement("KnownMass", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); + MassComponent component = (MassComponent) getField(handler, "mass"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new MassObjectHandler(new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java new file mode 100644 index 00000000..593434c4 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java @@ -0,0 +1,201 @@ +/* + * NoseConeHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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 org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +/** + * NoseConeHandler Tester. + * + */ +public class NoseConeHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testConstructor() throws Exception { + + try { + new NoseConeHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + Stage stage = new Stage(); + NoseConeHandler handler = new NoseConeHandler(stage, new WarningSet()); + NoseCone component = (NoseCone) getField(handler, "noseCone"); + assertContains(component, stage.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); + Assert.assertNotNull(new NoseConeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); + } + + /** + * + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testCloseElement() throws Exception { + + Stage stage = new Stage(); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + NoseConeHandler handler = new NoseConeHandler(stage, warnings); + NoseCone component = (NoseCone) getField(handler, "noseCone"); + + handler.closeElement("ShapeCode", attributes, "0", warnings); + Assert.assertEquals(Transition.Shape.CONICAL, component.getType()); + handler.closeElement("ShapeCode", attributes, "1", warnings); + Assert.assertEquals(Transition.Shape.OGIVE, component.getType()); + handler.closeElement("ShapeCode", attributes, "17", warnings); + Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default + handler.closeElement("ShapeCode", attributes, "foo", warnings); + Assert.assertNotNull(component.getType()); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("BaseDia", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftRadius(), 0.001); + handler.closeElement("BaseDia", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001); + handler.closeElement("BaseDia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + + final double aft = 100d; + component.setAftRadius(aft); + + handler.closeElement("ConstructionType", attributes, "0", warnings); + component.setAftShoulderRadius(1.1d); + handler.closeElement("WallThickness", attributes, "-1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001); + Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "100", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(aft, component.getThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "foo", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ConstructionType", attributes, "1", warnings); + component.setAftShoulderRadius(1.1d); + handler.closeElement("WallThickness", attributes, "-1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(0d, component.getThickness(), 0.001); + Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "1.1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001); + Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001); + + handler.closeElement("ShoulderLen", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001); + handler.closeElement("ShoulderLen", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); + handler.closeElement("ShoulderLen", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); + handler.closeElement("ShoulderLen", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ShoulderOD", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001); + handler.closeElement("ShoulderOD", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001); + handler.closeElement("ShoulderOD", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + component.setType(Transition.Shape.HAACK); + handler.closeElement("ShapeParameter", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getShapeParameter(), 0.001); + handler.closeElement("ShapeParameter", attributes, "100", warnings); + Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001); + handler.closeElement("ShapeParameter", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.", + warnings.iterator().next().toString()); + + warnings.clear(); + + component.setType(Transition.Shape.CONICAL); + component.setShapeParameter(0d); + handler.closeElement("ShapeParameter", attributes, "100", warnings); + Assert.assertEquals(0d, component.getShapeParameter(), 0.001); + + handler.closeElement("FinishCode", attributes, "-1", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "100", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + + handler.closeElement("Material", attributes, "Some Material", warnings); + handler.endHandler("NoseCone", attributes, null, warnings); + Assert.assertTrue(component.getMaterial().getName().contains("Some Material")); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new NoseConeHandler(new Stage(), new WarningSet()).getComponent() instanceof NoseCone); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage(), new WarningSet()).getMaterialType()); + } +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java new file mode 100644 index 00000000..20ab19fb --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java @@ -0,0 +1,163 @@ +/* + * ParachuteHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.Parachute; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import org.junit.Assert; + +import java.util.HashMap; + +/** + * ParachuteHandler Tester. + */ +public class ParachuteHandlerTest extends RocksimTestBase { + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + } + + /** + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + + BodyTube tube = new BodyTube(); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); + Parachute component = (Parachute) getField(handler, "chute"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + + handler.closeElement("DragCoefficient", attributes, "0.94", warnings); + Assert.assertEquals(0.94d, component.getCD(), 0.001); + handler.closeElement("DragCoefficient", attributes, "-0.94", warnings); + Assert.assertEquals(-0.94d, component.getCD(), 0.001); + handler.closeElement("DragCoefficient", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Dia", attributes, "-1", warnings); + Assert.assertEquals(-1d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001); + handler.closeElement("Dia", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001); + handler.closeElement("Dia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ShroudLineCount", attributes, "-1", warnings); + Assert.assertEquals(0, component.getLineCount()); + handler.closeElement("ShroudLineCount", attributes, "10", warnings); + Assert.assertEquals(10, component.getLineCount()); + handler.closeElement("ShroudLineCount", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ShroudLineLen", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLineLength(), 0.001); + handler.closeElement("ShroudLineLen", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLineLength(), 0.001); + handler.closeElement("ShroudLineLen", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + } + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new ParachuteHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); + Parachute component = (Parachute) getField(handler, "chute"); + assertContains(component, tube.getChildren()); + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); + Parachute component = (Parachute) getField(handler, "chute"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new ParachuteHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Parachute); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } + + /** + * Method: endHandler() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testEndHandler() throws Exception { + BodyTube tube = new BodyTube(); + ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); + Parachute component = (Parachute) getField(handler, "chute"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("Xb", attributes, "-10", warnings); + handler.closeElement("LocationMode", attributes, "1", warnings); + handler.endHandler("Parachute", attributes, null, warnings); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + Assert.assertEquals(component.getPositionValue(), -10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); + + handler.closeElement("Xb", attributes, "-10", warnings); + handler.closeElement("LocationMode", attributes, "2", warnings); + handler.endHandler("Parachute", attributes, null, warnings); + Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition()); + Assert.assertEquals(component.getPositionValue(), 10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); + } +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/PodFins.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/PodFins.rkt new file mode 100644 index 00000000..a137008f --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/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/core/test/net/sf/openrocket/file/rocksim/importt/RingHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RingHandlerTest.java new file mode 100644 index 00000000..af64a820 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RingHandlerTest.java @@ -0,0 +1,278 @@ +/* + * RingHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.Bulkhead; +import net.sf.openrocket.rocketcomponent.CenteringRing; +import net.sf.openrocket.rocketcomponent.EngineBlock; +import net.sf.openrocket.rocketcomponent.RingComponent; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.rocketcomponent.TubeCoupler; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +/** + * RingHandler Tester. + */ +public class RingHandlerTest extends RocksimTestBase { + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + } + + /** + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + CenteringRing component = (CenteringRing) getField(handler, "ring"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "0", warnings); + Assert.assertEquals(0d, component.getOuterRadius(), 0.001); + handler.closeElement("OD", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001); + handler.closeElement("OD", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ID", attributes, "0", warnings); + Assert.assertEquals(0d, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "75", warnings); + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); + handler.closeElement("ID", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + } + + /** + * Test a bulkhead. + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testBulkhead() throws Exception { + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + CenteringRing component = (CenteringRing) getField(handler, "ring"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "75", warnings); + handler.closeElement("ID", attributes, "0", warnings); + handler.closeElement("Len", attributes, "10", warnings); + handler.closeElement("Name", attributes, "Test Name", warnings); + handler.closeElement("KnownMass", attributes, "109.9", warnings); + handler.closeElement("UsageCode", attributes, "1", warnings); + handler.closeElement("UseKnownCG", attributes, "1", warnings); + handler.endHandler("", attributes, "", warnings); + + Assert.assertEquals(1, tube.getChildren().size()); + RingComponent child = (RingComponent)tube.getChild(0); + + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); + Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); + Assert.assertEquals("Test Name", child.getName()); + Assert.assertEquals(109.9/1000, child.getMass(), 0.001); + Assert.assertEquals(0, child.getPositionValue(), 0.0); + Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); + Assert.assertTrue(child instanceof Bulkhead); + + } + + /** + * Test a tube coupler. + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testTubeCoupler() throws Exception { + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "75", warnings); + handler.closeElement("ID", attributes, "70", warnings); + handler.closeElement("Len", attributes, "10", warnings); + handler.closeElement("Name", attributes, "Test Name", warnings); + handler.closeElement("KnownMass", attributes, "109.9", warnings); + handler.closeElement("UsageCode", attributes, "4", warnings); + handler.closeElement("UseKnownCG", attributes, "1", warnings); + handler.endHandler("", attributes, "", warnings); + + Assert.assertEquals(1, tube.getChildren().size()); + RingComponent child = (RingComponent)tube.getChild(0); + Assert.assertTrue(child instanceof TubeCoupler); + + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); + Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); + Assert.assertEquals("Test Name", child.getName()); + Assert.assertEquals(109.9/1000, child.getMass(), 0.001); + Assert.assertEquals(0, child.getPositionValue(), 0.0); + Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); + } + + /** + * Test a engine block. + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testEngineBlock() throws Exception { + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "75", warnings); + handler.closeElement("ID", attributes, "70", warnings); + handler.closeElement("Len", attributes, "10", warnings); + handler.closeElement("Name", attributes, "Test Name", warnings); + handler.closeElement("KnownMass", attributes, "109.9", warnings); + handler.closeElement("UsageCode", attributes, "2", warnings); + handler.closeElement("KnownCG", attributes, "4", warnings); + handler.closeElement("UseKnownCG", attributes, "1", warnings); + handler.endHandler("", attributes, "", warnings); + + Assert.assertEquals(1, tube.getChildren().size()); + RingComponent child = (RingComponent)tube.getChild(0); + Assert.assertTrue(child instanceof EngineBlock); + + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); + Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); + Assert.assertEquals("Test Name", child.getName()); + Assert.assertEquals(109.9/1000, child.getMass(), 0.001); + Assert.assertEquals(0, child.getPositionValue(), 0.0); + Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); + Assert.assertEquals(4d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getCG().x, 0.000001); + + } + + /** + * Test a centering ring + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testRing() throws Exception { + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("OD", attributes, "75", warnings); + handler.closeElement("ID", attributes, "0", warnings); + handler.closeElement("Len", attributes, "10", warnings); + handler.closeElement("Name", attributes, "Test Name", warnings); + handler.closeElement("KnownMass", attributes, "109.9", warnings); + handler.closeElement("UsageCode", attributes, "0", warnings); + handler.closeElement("UseKnownCG", attributes, "1", warnings); + handler.endHandler("", attributes, "", warnings); + + Assert.assertEquals(1, tube.getChildren().size()); + RingComponent child = (RingComponent)tube.getChild(0); + + Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); + Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); + Assert.assertEquals("Test Name", child.getName()); + Assert.assertEquals(109.9/1000, child.getMass(), 0.001); + Assert.assertEquals(0, child.getPositionValue(), 0.0); + Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); + Assert.assertTrue(child instanceof CenteringRing); + } + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new RingHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + CenteringRing component = (CenteringRing) getField(handler, "ring"); + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + RingHandler handler = new RingHandler(tube, new WarningSet()); + CenteringRing component = (CenteringRing) getField(handler, "ring"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new RingHandler(new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new RingHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } + + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java new file mode 100644 index 00000000..0eb1d625 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java @@ -0,0 +1,26 @@ +/* + * RocksimContentHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +import org.junit.Assert; + +/** + * RocksimContentHandler Tester. + * + */ +public class RocksimContentHandlerTest { + + /** + * + * Method: getDocument() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetDocument() throws Exception { + RocksimContentHandler handler = new RocksimContentHandler(); + Assert.assertNotNull(handler.getDocument()); + } + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java new file mode 100644 index 00000000..92a0eea3 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java @@ -0,0 +1,150 @@ +/* + * RocksimLoaderTest.java + * + */ +package net.sf.openrocket.file.rocksim.importt; + +import net.sf.openrocket.document.OpenRocketDocument; +import net.sf.openrocket.file.RocketLoadException; +import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.LaunchLug; +import net.sf.openrocket.rocketcomponent.Rocket; +import net.sf.openrocket.rocketcomponent.Stage; +import org.junit.Assert; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * RocksimLoader Tester. + */ +public class RocksimLoaderTest { + + /** + * 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. + */ + @org.junit.Test + public void testFinsOnInnerTube() throws Exception { + RocksimLoader loader = new RocksimLoader(); + InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt"); + Assert.assertNotNull("Could not open PodFins.rkt", stream); + try { + OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream)); + Assert.assertNotNull(doc); + Rocket rocket = doc.getRocket(); + Assert.assertNotNull(rocket); + } catch (IllegalStateException ise) { + Assert.fail(ise.getMessage()); + } + Assert.assertTrue(loader.getWarnings().size() == 2); + } + + /** + * Method: loadFromStream(InputStream source) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testLoadFromStream() throws Exception { + RocksimLoader loader = new RocksimLoader(); + //Stupid single stage rocket + OpenRocketDocument doc = loadRocksimRocket(loader); + InputStream stream; + + Assert.assertNotNull(doc); + Rocket rocket = doc.getRocket(); + Assert.assertNotNull(rocket); + Assert.assertEquals("FooBar Test", doc.getRocket().getName()); + Assert.assertTrue(loader.getWarnings().isEmpty()); + + stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt"); + Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream); + doc = loader.loadFromStream(new BufferedInputStream(stream)); + + Assert.assertNotNull(doc); + rocket = doc.getRocket(); + Assert.assertNotNull(rocket); + + //Do some simple asserts; the important thing here is just validating that the mass and cg were + //not overridden for each stage. + Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName()); + Assert.assertEquals(1, loader.getWarnings().size()); + Assert.assertEquals(3, rocket.getStageCount()); + Stage stage1 = (Stage) rocket.getChild(0); + Assert.assertFalse(stage1.isMassOverridden()); + Assert.assertFalse(stage1.isCGOverridden()); + Stage stage2 = (Stage) rocket.getChild(1); + Assert.assertFalse(stage2.isMassOverridden()); + Assert.assertFalse(stage2.isCGOverridden()); + Stage stage3 = (Stage) rocket.getChild(2); + Assert.assertFalse(stage3.isMassOverridden()); + Assert.assertFalse(stage3.isCGOverridden()); + + stream = this.getClass().getResourceAsStream("rocksimTestRocket3.rkt"); + Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream); + doc = loader.loadFromStream(new BufferedInputStream(stream)); + + Assert.assertNotNull(doc); + rocket = doc.getRocket(); + Assert.assertNotNull(rocket); + Assert.assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName()); + Assert.assertEquals(3, rocket.getStageCount()); + stage1 = (Stage) rocket.getChild(0); + stage2 = (Stage) rocket.getChild(1); + stage3 = (Stage) rocket.getChild(2); + + //Do some 1st level and simple asserts; the idea here is to not do a deep validation as that + //should have been covered elsewhere. Assert that the stage overrides are correct. + Assert.assertEquals(2, stage1.getChildCount()); + Assert.assertEquals("Nose cone", stage1.getChild(0).getName()); + Assert.assertEquals("Body tube", stage1.getChild(1).getName()); + Assert.assertTrue(stage1.isMassOverridden()); + Assert.assertEquals(0.185d, stage1.getOverrideMass(), 0.001); + Assert.assertTrue(stage1.isCGOverridden()); + Assert.assertEquals(0.3d, stage1.getOverrideCG().x, 0.001); + Assert.assertEquals(4, loader.getWarnings().size()); + + Assert.assertEquals(1, stage2.getChildCount()); + Assert.assertEquals("2nd Stage Tube", stage2.getChild(0).getName()); + Assert.assertTrue(stage2.isMassOverridden()); + Assert.assertEquals(0.21d, stage2.getOverrideMass(), 0.001); + Assert.assertTrue(stage2.isCGOverridden()); + Assert.assertEquals(0.4d, stage2.getOverrideCG().x, 0.001); + + BodyTube bt = (BodyTube) stage2.getChild(0); + LaunchLug ll = (LaunchLug) bt.getChild(6); + Assert.assertEquals(1.22d, ll.getRadialDirection(), 0.001); + + Assert.assertEquals(2, stage3.getChildCount()); + Assert.assertEquals("Transition", stage3.getChild(0).getName()); + Assert.assertEquals("Body tube", stage3.getChild(1).getName()); + Assert.assertTrue(stage2.isMassOverridden()); + Assert.assertEquals(0.33d, stage3.getOverrideMass(), 0.001); + Assert.assertTrue(stage2.isCGOverridden()); + Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001); + } + + public static OpenRocketDocument loadRocksimRocket(RocksimLoader theLoader) throws IOException, RocketLoadException { + InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket1.rkt"); + try { + Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream); + return theLoader.loadFromStream(new BufferedInputStream(stream)); + } finally { + stream.close(); + } + } + + public static OpenRocketDocument loadRocksimRocket3(RocksimLoader theLoader) throws IOException, RocketLoadException { + InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket3.rkt"); + try { + Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream); + return theLoader.loadFromStream(new BufferedInputStream(stream)); + } finally { + stream.close(); + } + } + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java new file mode 100644 index 00000000..14b2494d --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java @@ -0,0 +1,100 @@ +/* + * BaseRocksimTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +import net.sf.openrocket.gui.util.SwingPreferences; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.startup.Application; +import org.junit.Assert; +import org.junit.Before; + +import java.lang.reflect.Field; +import java.util.List; + +/** + * A base class for the Rocksim tests. Includes code from the junitx.addons project. + */ +public abstract class RocksimTestBase { + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + @Before + public void setUp() throws Exception { + Application.setPreferences( new SwingPreferences() ); + } + + + public void assertContains(RocketComponent child, List components) { + Assert.assertTrue("Components did not contain child", components.contains(child)); + } + + /** + * Returns the value of the field on the specified object. The name + * parameter is a String specifying the simple name of the + * desired field.

+ * + * The object is first searched for any matching field. If no matching + * field is found, the superclasses are recursively searched. + * + * @exception NoSuchFieldException if a field with the specified name is + * not found. + */ + public static Object getField(Object object, + String name) + throws NoSuchFieldException { + if (object == null) { + throw new IllegalArgumentException("Invalid null object argument"); + } + for (Class cls = object.getClass(); cls != null; cls = cls.getSuperclass()) { + try { + Field field = cls.getDeclaredField(name); + field.setAccessible(true); + return field.get(object); + } catch (Exception ex) { + /* in case of an exception, we will throw a new + * NoSuchFieldException object */ + ; + } + } + throw new NoSuchFieldException("Could get value for field " + + object.getClass().getName() + "." + name); + } + + /** + * Returns the value of the field on the specified class. The name + * parameter is a String specifying the simple name of the + * desired field.

+ * + * The class is first searched for any matching field. If no matching + * field is found, the superclasses are recursively searched. + * + * @exception NoSuchFieldException if a field with the specified name is + * not found. + */ + public static Object getField(Class cls, + String name) + throws NoSuchFieldException { + if (cls == null) { + throw new IllegalArgumentException("Invalid null cls argument"); + } + Class base = cls; + while (base != null) { + try { + Field field = base.getDeclaredField(name); + field.setAccessible(true); + return field.get(base); + } catch (Exception ex) { + /* in case of an exception, we will throw a new + * NoSuchFieldException object */ + ; + } + base = base.getSuperclass(); + } + throw new NoSuchFieldException("Could get value for static field " + + cls.getName() + "." + name); + } + + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java new file mode 100644 index 00000000..a1dea0aa --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java @@ -0,0 +1,184 @@ +/* + * StreamerHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.RocketComponent; +import net.sf.openrocket.rocketcomponent.Streamer; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +/** + * StreamerHandler Tester. + */ +public class StreamerHandlerTest extends RocksimTestBase { + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); + } + + /** + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testCloseElement() throws Exception { + + BodyTube tube = new BodyTube(); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); + Streamer component = (Streamer) getField(handler, "streamer"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("Width", attributes, "0", warnings); + Assert.assertEquals(0d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001); + handler.closeElement("Width", attributes, "10", warnings); + Assert.assertEquals(10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001); + handler.closeElement("Width", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getStripLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + + handler.closeElement("DragCoefficient", attributes, "0.94", warnings); + Assert.assertEquals(0.94d, component.getCD(), 0.001); + handler.closeElement("DragCoefficient", attributes, "-0.94", warnings); + Assert.assertEquals(-0.94d, component.getCD(), 0.001); + handler.closeElement("DragCoefficient", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + } + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testConstructor() throws Exception { + + try { + new StreamerHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + BodyTube tube = new BodyTube(); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); + Streamer component = (Streamer) getField(handler, "streamer"); + assertContains(component, tube.getChildren()); + } + + /** + * Method: setRelativePosition(RocketComponent.Position position) + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testSetRelativePosition() throws Exception { + BodyTube tube = new BodyTube(); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); + Streamer component = (Streamer) getField(handler, "streamer"); + handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new StreamerHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Streamer); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube(), new WarningSet()).getMaterialType()); + } + + /** + * Method: endHandler() + * + * @throws Exception thrown if something goes awry + */ + @Test + public void testEndHandler() throws Exception { + BodyTube tube = new BodyTube(); + StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); + Streamer component = (Streamer) getField(handler, "streamer"); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + handler.closeElement("Xb", attributes, "-10", warnings); + handler.closeElement("LocationMode", attributes, "1", warnings); + handler.endHandler("Streamer", attributes, null, warnings); + Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); + Assert.assertEquals(component.getPositionValue(), -10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); + + handler.closeElement("Xb", attributes, "-10", warnings); + handler.closeElement("LocationMode", attributes, "2", warnings); + handler.endHandler("Streamer", attributes, null, warnings); + Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition()); + Assert.assertEquals(component.getPositionValue(), 10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); + + handler.closeElement("Thickness", attributes, "0.02", warnings); + Assert.assertEquals(0.01848, handler.computeDensity(RocksimDensityType.ROCKSIM_BULK, 924d), 0.001); + + //Test Density Type 0 (Bulk) + handler.closeElement("Density", attributes, "924.0", warnings); + handler.closeElement("DensityType", attributes, "0", warnings); + handler.endHandler("Streamer", attributes, null, warnings); + Assert.assertEquals(0.01848d, component.getMaterial().getDensity(), 0.001); + + //Test Density Type 1 (Surface) + handler.closeElement("Density", attributes, "0.006685", warnings); + handler.closeElement("DensityType", attributes, "1", warnings); + handler.endHandler("Streamer", attributes, null, warnings); + Assert.assertTrue(Math.abs(0.06685d - component.getMaterial().getDensity()) < 0.00001); + + //Test Density Type 2 (Line) + handler.closeElement("Density", attributes, "0.223225", warnings); + handler.closeElement("DensityType", attributes, "2", warnings); + handler.closeElement("Len", attributes, "3810.", warnings); + handler.closeElement("Width", attributes, "203.2", warnings); + handler.endHandler("Streamer", attributes, null, warnings); + + Assert.assertEquals(1.728190092, component.getMass(), 0.001); + + } + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java new file mode 100644 index 00000000..cea3a07f --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java @@ -0,0 +1,229 @@ +/* + * TransitionHandlerTest.java + */ +package net.sf.openrocket.file.rocksim.importt; + +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.Stage; +import net.sf.openrocket.rocketcomponent.Transition; +import org.junit.Assert; + +import java.util.HashMap; + +/** + * TransitionHandler Tester. + */ +public class TransitionHandlerTest extends RocksimTestBase { + + /** + * Method: constructor + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testConstructor() throws Exception { + + try { + new TransitionHandler(null, new WarningSet()); + Assert.fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException iae) { + //success + } + + Stage stage = new Stage(); + TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); + Transition component = (Transition) getField(handler, "transition"); + assertContains(component, stage.getChildren()); + } + + /** + * Method: openElement(String element, HashMap attributes, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testOpenElement() throws Exception { + Assert.assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage(), new WarningSet()).openElement(null, null, null)); + } + + /** + * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testCloseElement() throws Exception { + + Stage stage = new Stage(); + HashMap attributes = new HashMap(); + WarningSet warnings = new WarningSet(); + + TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); + Transition component = (Transition) getField(handler, "transition"); + + handler.closeElement("ShapeCode", attributes, "0", warnings); + Assert.assertEquals(Transition.Shape.CONICAL, component.getType()); + handler.closeElement("ShapeCode", attributes, "1", warnings); + Assert.assertEquals(Transition.Shape.OGIVE, component.getType()); + handler.closeElement("ShapeCode", attributes, "17", warnings); + Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default + handler.closeElement("ShapeCode", attributes, "foo", warnings); + Assert.assertNotNull(component.getType()); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Len", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); + handler.closeElement("Len", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("FrontDia", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getForeRadius(), 0.001); + handler.closeElement("FrontDia", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeRadius(), 0.001); + handler.closeElement("FrontDia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("RearDia", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftRadius(), 0.001); + handler.closeElement("RearDia", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001); + handler.closeElement("RearDia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + final double aft = 100d; + component.setAftRadius(aft); + + handler.closeElement("ConstructionType", attributes, "0", warnings); + component.setAftShoulderRadius(1.1d); + component.setForeShoulderRadius(1.1d); + handler.closeElement("WallThickness", attributes, "-1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001); + Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001); + Assert.assertEquals(component.getForeShoulderThickness(), component.getForeShoulderThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "100", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(aft, component.getThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "foo", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("ConstructionType", attributes, "1", warnings); + component.setAftShoulderRadius(1.1d); + component.setForeShoulderRadius(1.1d); + handler.closeElement("WallThickness", attributes, "-1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(0d, component.getThickness(), 0.001); + Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001); + Assert.assertEquals(0d, component.getForeShoulderThickness(), 0.001); + handler.closeElement("WallThickness", attributes, "1.1", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001); + Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001); + Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderThickness(), 0.001); + + + handler.closeElement("FrontShoulderLen", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getForeShoulderLength(), 0.001); + handler.closeElement("FrontShoulderLen", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001); + handler.closeElement("FrontShoulderLen", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001); + handler.closeElement("FrontShoulderLen", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("RearShoulderLen", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001); + handler.closeElement("RearShoulderLen", attributes, "10", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); + handler.closeElement("RearShoulderLen", attributes, "10.0", warnings); + Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); + handler.closeElement("RearShoulderLen", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("FrontShoulderDia", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getForeShoulderRadius(), 0.001); + handler.closeElement("FrontShoulderDia", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeShoulderRadius(), 0.001); + handler.closeElement("FrontShoulderDia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("RearShoulderDia", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001); + handler.closeElement("RearShoulderDia", attributes, "100", warnings); + Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001); + handler.closeElement("RearShoulderDia", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + component.setType(Transition.Shape.HAACK); + handler.closeElement("ShapeParameter", attributes, "-1", warnings); + Assert.assertEquals(0d, component.getShapeParameter(), 0.001); + handler.closeElement("ShapeParameter", attributes, "100", warnings); + Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001); + handler.closeElement("ShapeParameter", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.", + warnings.iterator().next().toString()); + + warnings.clear(); + + component.setType(Transition.Shape.CONICAL); + component.setShapeParameter(0d); + handler.closeElement("ShapeParameter", attributes, "100", warnings); + Assert.assertEquals(0d, component.getShapeParameter(), 0.001); + + handler.closeElement("FinishCode", attributes, "-1", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "100", warnings); + Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); + handler.closeElement("FinishCode", attributes, "foo", warnings); + Assert.assertEquals(1, warnings.size()); + warnings.clear(); + + handler.closeElement("Name", attributes, "Test Name", warnings); + Assert.assertEquals("Test Name", component.getName()); + + handler.closeElement("Material", attributes, "Some Material", warnings); + handler.endHandler("Transition", attributes, null, warnings); + Assert.assertTrue(component.getMaterial().getName().contains("Some Material")); + } + + /** + * Method: getComponent() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetComponent() throws Exception { + Assert.assertTrue(new TransitionHandler(new Stage(), new WarningSet()).getComponent() instanceof Transition); + } + + /** + * Method: getMaterialType() + * + * @throws Exception thrown if something goes awry + */ + @org.junit.Test + public void testGetMaterialType() throws Exception { + Assert.assertEquals(Material.Type.BULK, new TransitionHandler(new Stage(), new WarningSet()).getMaterialType()); + } + + +} diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt new file mode 100644 index 00000000..79f7b003 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt @@ -0,0 +1,743 @@ + +3 + + + FooBar Test +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 +11 +1 +0 +0,1215.49,0,0 +0,35.9506,0,0 +0,1226.38,0,0 +0,47.5027,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 +424.688 +66.04 +1417.95 +1332.23 +0. +1417.95 +0,66.04,0,0 +0,1332.23,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,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.1 +1049.21 +Polystyrene PS +Nose cone +65.3999 +1 +0. +126.438 +348.443 +0.0356487 +0.0356487 +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 +2 +0 +0 +0 +blue +2. +0.264319 +2. +0.264319 +1 +0 +8 +0 +0. +396.875 +57.15 +0 +0 +1 +58.3997 +2.159 +0. +53.1012 +66.675 +0. +0. + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +0. +10.636 +180.34 +0.0748306 +0.0748306 +0. +0 +EST 3090 +BT-80 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +3 +1 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +463.55 +66.04 +65.786 +360.68 +0 +0 +0. +0.5 +0. +0. +0 +0 + + + + +BalsaMachining.com +0. +128.148 +Balsa +Transition +0. +0 +0. +39.355 +37.0332 +0.0096001 +0.0096001 +0. +0 +TA7080 +Transition T70 to T80 2 in long +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.92852 +0.848729 +-0.92852 +0.848729 +1 +0 +8 +0 +824.23 +66.04 +53.34 +50.8 +0 +35.56 +35.56 +0 +0. +55.118 +53.34 +0. +0 +0. +264.12 +213.32 + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +0. +44.449 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +8 +1 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +875.03 +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 +260.35 +153.85 +155.575 +0.0339112 +0.101734 +0. +0 +FIN-A-01 +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 +9 +0 +0 +0 +blue +34.8792 +1.26026 +46.4312 +1.26026 +1 +0 +8 +0 +1135.38 +3 +184.15 +0. +184.15 +264.956 +282.575 +1.5875 +0 +0 +0 +0. +0. +0. +1 +0.990003 +0. +89.5773 +26.8071 +0. +0. +0. + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +0. +13.008 +228.6 +0. +0. +0. +0 +EST 3086 +BT-50 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +11 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +875.03 +24.7904 +24.13 +457.2 +0 +1 +24. +12.7 +0. +0. +1 +0 + + + + + + + + + + + + + + + + + + + + +445.129 +68.7587 +76.6476 +10.8263 +4.765 +1 +33.4284 +405.535 +2 +8.06125 +4 +6.06125 +22.4787 +8.06125 +1.35915 +65.9349 +1.0686 +76.5426 +4.01173 +172.076 +0. +0. +0 +1828.8 +0 +0. +0 +0.0523599 +0. +0. +770.314 +43. +0. +70. +7.22222 +304.8 +0. +0 +3 +1.34112 +3.53162 +2 +0.01 +0.02 +0 +5 +0. +0.1 +1 +0. +0 +3 +300. +2000. +1 +5.99999 +0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +2 +0.99 +2000. +1500. +2 +0.98 +1 +0. +0 +0.08 +1 +0. +1 +0. +1 +0. +1. +1. +0. +0 +0 +3600. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +0. +[E6-2] +15.4098 +0. +0. +0.25875 +5.69125 +0.11125 +10 +1 +800. +0 +Earth +Standard earth condistions. +4.078 +-172.076 +0. +56.537 +-3.38254 +-56.4357 +0. +0,0,8.06125,0,0 +-1,-1,-1,-1,-1 +0,0,0,0,0 +32,32,32,32,32 +1. +1 +0.233111 +0.739954 +0.0208295 +0.000194272 +{b33e529e-1ada-4524-9885-7382d7cf4d64} + + +0 +0 +0. +0. +0 +0. +0. +0. +0. +-1 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 + + + + +0 +0 +0. +0. +0 +0. +0. +0. +0. +-1 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 + + + + + + + + + + +1 +E6 +0. +Apogee +0.50038 +0. +5 +2. +0. +0. + + + + + + + diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt new file mode 100644 index 00000000..39b3411b --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt @@ -0,0 +1,1583 @@ + +3 + + +Three Stage Everything Included Rocket +1 +1 +1 +0.75 +0.8 +0.81 +0.95 +0.95 +3 +0. +0. +0. +0. +0. +0. +0. +0. +1 +914.4 +0 +0 +0 +1 +0 +1 +25 +7 +0 +0,29.6333,326.159,887.03 +0,2,4.93008,33.0782 +0,29.6333,384.174,883.929 +0,2,6.91103,47.1184 +0,0,0,0 +0,0,0,0 +0 +3 +0 +3 +0. +0. +0 +0 +0 +0 +0 +0 +0 +0 +0. +10. +10. +10. +10. +0 +0 +0 +10. +0.15 +black +339.43 +66.3 +2104.53 +2104.53 +0. +1150.33 +0,66.3,66.3,66.3 +0,296.8,954.2,2104.53 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +Aerospace Speciality Products +0. +128.148 +Balsa +Nose cone +0. +0 +0. +42.0747 +75.3029 +0.0152945 +0.0152945 +0. +0 +BNC80S + +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.0296333 +2. +0.0296333 +1 +0 +8 +0 +0. +88.9 +66.3 +0 +3 +0 +38.1 +0. +0. +64.3 +0. +0. +0. + + +Custom +20. +0. +Custom +Clay +17.8 +1 +17.8 +0. +0. +0. +0. +0. +0 +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 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +17.8 +0 +0. + + + + +Apogee +0. +1121.29 +Paper +Attachment Rod +0. +0 +6.1 +2.47301 +78.85 +0.00684683 +0.00684683 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +3 +1 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +6.1 +13.82 +13.16 +157.7 +0 +0 +0. +0.5 +0. +0. +1 +0 + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Plate +0. +0 +78.9 +7.86272 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +4 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +85. +66. +13.82 +3.17 +0 +0 +0 + + + + +Custom +0. +1400. +Carbon Fiber +Sleeve +0. +0 +0. +17.5527 +13.85 +0. +0. +0. +0 +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 +2 +blue +0. +0. +0. +0. +1 +0 +8 +0 +136.1 +27.7 +13.82 +27.7 +0 +3 +0 + + + + +LOC Precision +170. +0.006685 +Rip stop nylon +Nose Cone Parachute +0. +1 +142.6 +15.8812 +34.5417 +0. +0. +0. +1 +LP-50 +50 In. 16 lines +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 +6 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +148.7 +414.5 +0. +15 +16 +0.05 +1350. +1 +0.00032972 +Carpet String (Apogee 29500) +0.95 + + + + + + + + +Estes +15. +1121.29 +Paper +Body tube +100. +1 +0. +5.80486 +100. +0.0414942 +0.0414942 +0. +0 +EST 3090 +BT-80 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +7 +1 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +88.9 +66.04 +65.79 +200. +0 +0 +0. +0.5 +0. +0. +0 +0 + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +190.2 +7.65502 +1.59 +0. +0. +0. +0 +LOC CR-2.56-0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +8 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +279.1 +65.02 +25.4 +3.18 +0 +0 +0 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +165. +7.62626 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +9 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +253.9 +65. +25.4 +3.17 +0 +0 +0 + + + + +Public Missiles Ltd. +0. +958.705 +Kraft phenolic +Body tube +0. +0 +137.9 +9.8818 +35. +0. +0. +0. +0 +KS-1.1 +KwikSwitch MMT 29mm +0. +-1.58371 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +10 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +226.8 +32.26 +29.21 +70. +0 +1 +29. +0.5 +0. +0. +1 +0 + + + + + + + + +Estes +0. +1121.29 +Paper +2nd Stage Tube +0. +0 +0. +10.4685 +180.34 +0.0748306 +0.0748306 +0. +0 +EST 3090 +BT-80 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +11 +1 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +288.9 +66.04 +65.79 +360.68 +0 +0 +0. +0.5 +0. +0. +0 +0 + + +LOC Precision +15.025 +1121.29 +Paper +Tube coupler +0. +1 +-10. +20.465 +35.45 +0. +0. +0. +0 +TC-2.56 +Tube Coupler +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 +12 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +278.9 +65.79 +63.25 +70.9 +0 +4 +1 + + + + +Custom +40. +0. +Custom +Electronics +138.3 +1 +138.3 +0. +0. +0. +0. +0. +0 +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 +13 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +427.2 +0 +0. + + + + +Quest +0. +128.148 +Balsa +Fin set +0. +0 +228.6 +1.32269 +19.05 +0.0028791 +0.0086373 +0. +0 +Payloader One +Fin +0. +0.0830777 +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 +14 +0 +0 +0 +blue +2.93008 +0.52856 +5.49629 +0.52856 +1 +0 +8 +0 +517.5 +3 +38.1 +24.9 +45.7 +45.7 +6.6 +2.39 +0 +0 +2 +0. +0. +0. +1 +0.139993 +0. +54.2741 +2.83538 +0.653543 +0. +0. + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +302. +7.65502 +1.59 +0. +0. +0. +0 +LOC CR-2.56-0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +15 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +590.9 +65.02 +25.4 +3.18 +0 +0 +0 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +335.5 +7.62626 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +16 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +624.4 +65. +25.4 +3.17 +0 +0 +0 + + + + +Public Missiles Ltd. +0. +958.705 +Kraft phenolic +Body tube +0. +0 +587.4 +9.8818 +35. +0. +0. +0. +0 +KS-1.1 +KwikSwitch MMT 29mm +0. +-1.58371 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +17 +1 +0 +1 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +587.4 +32.26 +29.21 +70. +0 +1 +29. +0.5 +0. +0. +1 +0 + + +Semroc +0. +1121.29 +Paper +Engine block +0. +0 +0. +2.69315 +2.39 +0. +0. +0. +0 +TB-7 +Thrust Block +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 +18 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +587.4 +29.21 +14.61 +4.78 +0 +2 +1 + + + + + + + + + + +BalsaMachining.com +0. +128.148 +Balsa +Transition +0. +0 +0. +8.62096 +25.1578 +0.00986655 +0.00986655 +0. +0 +TA6080 +Transition T60 to T80 2.25 in long +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 +19 +0 +0 +0 +blue +-1.20451 +0.675971 +-1.20451 +0.675971 +1 +0 +8 +0 +649.58 +66.04 +41.4 +57.15 +0 +20. +38.1 +1 +3. +64.77 +41.38 +0. +0 +0. +153.172 +96.022 + + + + +LOC/Precision +0. +1121.29 +Paper +Body tube +0. +0 +0. +33.5306 +209.2 +0.0604643 +0.0604643 +0. +0 +LOC BT-2.14 +Airframe tube +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +20 +1 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +706.73 +46. +45. +418.4 +0 +0 +0. +0.5 +0. +0. +0 +0 + + +Quest +0. +1121.29 +Paper +Elliptical Fins +0. +0 +69.7 +36.2048 +46. +0.00676907 +0.0203072 +0. +0 +0. +-0.519061 +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 +21 +0 +0 +0 +blue +3.64017 +0.802926 +6.19583 +0.802926 +1 +0 +8 +0 +776.43 +3 +92. +46. +46.9 +46.9 +33.49 +3.18 +1 +0 +0 +0. +0. +0. +1 +0.349066 +0. +43.8444 +3.30201 +0.5 +0. +0. + + + + +Public Missiles +0. +1905.24 +G10 fiberglass +Custom Fins +0. +0 +241.7 +256.292 +78.9922 +0.0355266 +0.10658 +0. +0 +FIN-C-02 +Fins +0. +0.357967 +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 +22 +0 +0 +0 +blue +25.7124 +0.996591 +34.6308 +0.996926 +1 +0 +8 +0 +948.43 +3 +152.4 +83.83 +146.72 +146.81 +39.42 +2.38 +2 +0 +2 +101.6 +10.6 +35.6 +1 +0. +0. +89.2598 +19.9941 +0.550066 +0. +0. +121.07 +83.8257 +152.4,0|126.202,146.715|36.455,146.715|0,0| +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +379.5 +2.55395 +1.59 +0. +0. +0. +0 +LOC FCR-1.52-1.14 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +23 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +1086.23 +45. +24.79 +3.18 +0 +0 +1 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +272. +2.55395 +1.59 +0. +0. +0. +0 +LOC FCR-1.52-1.14 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +24 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +978.73 +45. +24.79 +3.18 +0 +0 +1 + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +259.7 +5.22902 +91.95 +0. +0. +0. +0 +EST 3086 +BT-50 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +25 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +966.43 +24.79 +24.13 +183.9 +0 +1 +24. +0.5 +0. +0. +1 +0 + + + + + + + + + + + + + + + + + diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt new file mode 100644 index 00000000..df1788c2 --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt @@ -0,0 +1,1961 @@ + +3 + + +Three Stage Everything Included Rocket - Override Total Mass/CG +1 +1 +1 +0.75 +0.8 +0.81 +0.95 +0.95 +3 +185. +210. +330. +0. +0. +300. +400. +500. +1 +914.4 +0 +0 +0 +1 +0 +1 +32 +7 +0 +0,29.6333,327.236,966.855 +0,2,4.95647,83.562 +0,29.6333,385.082,953.76 +0,2,6.95476,97.0629 +0,0,0,0 +0,0,0,0 +0 +3 +0 +3 +0. +0. +0 +0 +0 +0 +0 +0 +0 +0 +0. +10. +10. +10. +10. +0 +0 +0 +10. +0.15 +black +334.83 +66. +2155.23 +2155.23 +0. +1150.33 +0,66,66,66 +0,347.5,1004.9,2155.23 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +Aerospace Speciality Products +0. +128.148 +Balsa +Nose cone +0. +0 +0. +42.6368 +76.0242 +0.0152192 +0.0152192 +0. +0 +BNC80S + +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 +1 +0 +0 +blue +2. +0.0296333 +2. +0.0296333 +1 +0 +8 +0 +0. +88.9 +66. +0 +3 +0 +38.1 +0. +0. +65.9 +0. +0. +0. + + +Custom +20. +0. +Custom +Clay +17.8 +1 +17.8 +0. +0. +0. +0. +0. +0 +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 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +17.8 +0 +0. + + + + +Apogee +0. +1121.29 +Paper +Attachment Rod +0. +0 +6.1 +2.47301 +78.85 +0.00684683 +0.00684683 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +3 +1 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +6.1 +13.82 +13.16 +157.7 +0 +0 +0. +0.5 +0. +0. +1 +0 + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Plate +0. +0 +78.9 +7.86272 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +4 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +85. +66. +13.82 +3.17 +0 +0 +0 + + + + +Custom +0. +1400. +Carbon Fiber +Sleeve +0. +0 +0. +17.5527 +13.85 +0. +0. +0. +0 +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 +2 +blue +0. +0. +0. +0. +1 +0 +8 +0 +136.1 +27.7 +13.82 +27.7 +0 +3 +0 + + + + +LOC Precision +170. +0.006685 +Rip stop nylon +Nose Cone Parachute +0. +1 +142.6 +15.8812 +34.5417 +0. +0. +0. +1 +LP-50 +50 In. 16 lines +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 +6 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +148.7 +414.5 +0. +15 +16 +0.05 +1350. +1 +0.00032972 +Carpet String (Apogee 29500) +0.95 + + + + + + + + +Estes +15. +1121.29 +Paper +Body tube +100. +1 +0. +5.805 +100. +0.0414942 +0.0414942 +0. +0 +EST 3090 +BT-80 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +7 +1 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +88.9 +66. +65.79 +200. +0 +0 +0. +0.5 +0. +0. +0 +0 + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +190.2 +7.65502 +1.59 +0. +0. +0. +0 +LOC CR-2.56-0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +8 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +279.1 +65.02 +25.4 +3.18 +0 +0 +0 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +165. +7.62626 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +9 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +253.9 +65. +25.4 +3.17 +0 +0 +0 + + + + +Public Missiles Ltd. +0. +958.705 +Kraft phenolic +Body tube +0. +0 +137.9 +9.8818 +35. +0. +0. +0. +0 +KS-1.1 +KwikSwitch MMT 29mm +0. +-1.58371 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +10 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +226.8 +32.26 +29.21 +70. +0 +1 +29. +0.5 +0. +0. +1 +0 + + + + +Apogee +0. +1121.29 +Paper +Launch lug +0. +0 +77.2 +1.11942 +38.1 +0.00374518 +0.00199411 +0. +0 +13056 + +37.185 +3.14 +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 +26 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +166.1 +8.33 +7.26 +76.2 +0 + + + + +Custom +0. +0. +Pod +0. +0 +200. +0. +0. +0. +0. +0. +0 +36.175 +-1.50735 +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 +29 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +288.9 +1 +1 +1 + + +Apogee +0. +958.705 +Kraft phenolic +Body tube +0. +0 +0. +0.400397 +29.3 +0.00116902 +0.00116902 +0. +0 +9601 +6 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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +30 +0 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +288.9 +6.35 +5.59 +58.6 +0 +0 +0. +0.5 +0. +0. +0 +0 + + + + + + + + + + +Estes +0. +1121.29 +Paper +2nd Stage Tube +0. +0 +0. +10.468 +180.34 +0.0748306 +0.0748306 +0. +0 +EST 3090 +BT-80 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +11 +0 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +288.9 +66. +65.79 +360.68 +0 +0 +0. +0.5 +0. +0. +0 +0 + + +LOC Precision +15.025 +1121.29 +Paper +Tube coupler +0. +1 +-10. +20.465 +35.45 +0. +0. +0. +0 +TC-2.56 +Tube Coupler +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 +12 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +278.9 +65.79 +63.25 +70.9 +0 +4 +1 + + + + +Custom +40. +0. +Custom +Electronics +138.3 +1 +138.3 +0. +0. +0. +0. +0. +0 +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 +13 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +427.2 +0 +0. + + + + +Quest +0. +128.148 +Balsa +Fin set +0. +0 +228.6 +1.32269 +19.05 +0.0028791 +0.0086373 +0. +0 +Payloader One +Fin +0. +0.0830777 +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 +14 +0 +0 +0 +blue +2.95647 +0.52856 +5.54523 +0.52856 +1 +0 +8 +0 +517.5 +3 +38.1 +24.9 +45.7 +45.7 +6.6 +2.39 +0 +0 +2 +0. +0. +0. +1 +0.139993 +0. +54.2541 +2.86063 +0.653543 +0. +0. + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +302. +7.65502 +1.59 +0. +0. +0. +0 +LOC CR-2.56-0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +15 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +590.9 +65.02 +25.4 +3.18 +0 +0 +0 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +335.5 +7.62626 +1.585 +0. +0. +0. +0 +LOC CR-2.56-(2)0.95 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +16 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +624.4 +65. +25.4 +3.17 +0 +0 +0 + + + + +Public Missiles Ltd. +0. +958.705 +Kraft phenolic +Body tube +0. +0 +587.4 +9.8818 +35. +0. +0. +0. +0 +KS-1.1 +KwikSwitch MMT 29mm +0. +-1.58371 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +17 +0 +0 +1 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +587.4 +32.26 +29.21 +70. +0 +1 +29. +0.5 +0. +0. +1 +0 + + +Semroc +0. +1121.29 +Paper +Engine block +0. +0 +0. +2.69315 +2.39 +0. +0. +0. +0 +TB-7 +Thrust Block +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 +18 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +587.4 +29.21 +14.61 +4.78 +0 +2 +1 + + + + + + +Apogee +0. +1121.29 +Paper +Launch lug +0. +0 +265.8 +1.11942 +38.1 +0.00374518 +0.00199411 +0. +0 +13056 + +37.185 +1.22 +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 +27 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +554.7 +8.33 +7.26 +76.2 +0 + + + + + + + + +BalsaMachining.com +0. +128.148 +Balsa +Transition +0. +0 +0. +8.61936 +25.1551 +0.0098623 +0.0098623 +0. +0 +TA6080 +Transition T60 to T80 2.25 in long +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 +19 +0 +0 +0 +blue +-1.213 +0.675973 +-1.213 +0.675973 +1 +0 +8 +0 +649.58 +66. +41.4 +57.15 +0 +20. +38.1 +1 +3. +64.77 +41.38 +0. +0 +0. +153.339 +96.1895 + + + + +LOC/Precision +0. +1121.29 +Paper +Body tube +0. +0 +0. +0. +nan. +0.0544179 +0.0544179 +0. +0 +LOC BT-2.14 +Airframe tube +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +20 +0 +0 +0 +rgb(54,250,21) +0. +0. +0. +0. +1 +0 +8 +0 +706.73 +41.4 +41. +418.4 +0 +0 +0. +0.5 +0. +0. +0 +0 + + +Quest +0. +1121.29 +Paper +Elliptical Fins +0. +0 +69.7 +36.2048 +46. +0.00676907 +0.0203072 +0. +0 +0. +-0.519061 +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 +21 +0 +0 +0 +blue +3.61024 +0.802926 +6.03948 +0.802926 +1 +0 +8 +0 +776.43 +3 +92. +46. +46.9 +46.9 +33.49 +3.18 +1 +0 +0 +0. +0. +0. +1 +0.349066 +0. +41.5444 +3.21868 +0.5 +0. +0. + + + + +Public Missiles +0. +1905.24 +G10 fiberglass +Custom Fins +0. +0 +241.7 +256.292 +78.9922 +0.0355266 +0.10658 +0. +0 +FIN-C-02 +Fins +0. +0.357967 +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 +22 +0 +0 +0 +blue +25.7037 +0.996526 +34.1865 +0.996822 +1 +0 +8 +0 +948.43 +3 +152.4 +84.53 +146.72 +146.81 +39.07 +2.38 +2 +0 +2 +101.6 +10.6 +35.6 +1 +0. +0. +87.0529 +19.7376 +0.554659 +0. +0. +121.39 +84.5261 +152.4,0|126.202,146.715|36.455,146.715|0,0| +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +379.5 +1.99074 +1.59 +0. +0. +0. +0 +LOC FCR-1.52-1.14 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +23 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +1086.23 +41.4 +24.79 +3.18 +0 +0 +1 + + + + +LOC Precision +0. +724.996 +Aircraft plywood (LOC) +Centering ring +0. +0 +272. +1.99074 +1.59 +0. +0. +0. +0 +LOC FCR-1.52-1.14 +Centering Ring +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +24 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +978.73 +41.4 +24.79 +3.18 +0 +0 +1 + + + + +Estes +0. +1121.29 +Paper +Body tube +0. +0 +259.7 +5.22902 +91.95 +0. +0. +0. +0 +EST 3086 +BT-50 +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. +rgb(0,0,250) +rgb(0,0,250) +rgb(255,255,255) +1 +25 +0 +0 +0 +rgb(0,0,250) +0. +0. +0. +0. +1 +0 +8 +0 +966.43 +24.79 +24.13 +183.9 +0 +1 +24. +0.5 +0. +0. +1 +0 + + + + +Custom +0. +1121.29 +Paper +Tube fins +0. +0 +0. +12.6878 +24.79 +0.0688063 +0.0688063 +0. +0 +35.395 +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 +28 +0 +0 +0 +blue +10.866 +0.707815 +10.866 +0.707815 +1 +0 +8 +0 +706.73 +24.79 +24.13 +49.58 +0 +9 +0.715549 +9 + + + + +Custom +0. +688.794 +Cardboard +Ringtail +0. +0 +0. +2.93707 +10. +0.00474229 +0.00444249 +0. +0 +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 +31 +0 +0 +2 +rgb(255,9,18) +39.6386 +1.10463 +39.6386 +1.10463 +1 +0 +8 +0 +1105.13 +3 +20. +20. +7.495 +7.495 +0. +3. +0 +0 +0 +0. +0. +0. +1 +0. +0. +0. +0. +0. +0. +0. +56.39 +55.37 +20. +1121.29 +0 +Paper + + + + +Apogee +0. +1309. +Mylar +Streamer +0. +0 +149.4 +5.67514 +50.8 +0. +0. +0. +0 +29006 + +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 +32 +0 +0 +0 +blue +0. +0. +0. +0. +1 +0 +8 +0 +856.13 +1422.4 +101.6 +0.03 +1 +0.127 +0 +1 + + + + + + + + + + + + + + + + + diff --git a/core/test/net/sf/openrocket/gui/TestGUI.java b/core/test/net/sf/openrocket/gui/TestGUI.java new file mode 100644 index 00000000..6e05aabb --- /dev/null +++ b/core/test/net/sf/openrocket/gui/TestGUI.java @@ -0,0 +1,12 @@ +package net.sf.openrocket.gui; + +import org.junit.Test; + +public class TestGUI { + + @Test + public void test() { + // No-op + } + +} diff --git a/core/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java b/core/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java new file mode 100644 index 00000000..e45693bc --- /dev/null +++ b/core/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java @@ -0,0 +1,257 @@ +package net.sf.openrocket.gui.configdialog; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import net.sf.openrocket.gui.adaptors.DoubleModel; +import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.CenteringRing; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.util.BaseTestCase.BaseTestCase; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class FinSetConfigTest extends BaseTestCase { + + static Method method; + + @BeforeClass + public static void classSetup() throws Exception { + method = FinSetConfig.class.getDeclaredMethod("computeFinTabLength", List.class, Double.class, Double.class, DoubleModel.class, RocketComponent.class); + Assert.assertNotNull(method); + method.setAccessible(true); + } + + /** + * Test no centering rings. + * + * @throws Exception + */ + @Test + public void testComputeFinTabLength() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + RocketComponent parent = new BodyTube(); + + Double result = (Double)method.invoke(null, rings, 10d, 11d, dm, parent); + Assert.assertEquals(0.0001, 11d, result.doubleValue()); + result = (Double)method.invoke(null, null, 10d, 11d, dm, parent); + Assert.assertEquals(11d, result.doubleValue(), 0.0001); + } + + /** + * Test 2 rings both ahead of the fin. + */ + @Test + public void testCompute2LeadingRings() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + RocketComponent parent = new BodyTube(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setLength(0.004); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setPositionValue(0.43); + CenteringRing ring2 = new CenteringRing(); + ring2.setLength(0.004); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setPositionValue(0.45); + rings.add(ring1); + rings.add(ring2); + parent.addChild(ring1); + parent.addChild(ring2); + + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.01, result.doubleValue(), 0.0001); + + } + + /** + * Test one ring, ahead of the fin. + */ + @Test + public void testCompute1Ring() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setLength(0.004); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setPositionValue(0.43); + rings.add(ring1); + + RocketComponent parent = new BodyTube(); + parent.addChild(ring1); + + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.01, result.doubleValue(), 0.0001); + } + + /** + * Test one ring ahead of the fin, one ring within the root chord. + */ + @Test + public void testComputeOneLeadingOneRingWithinRoot() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setLength(0.004); + ring1.setPositionValue(0.43); + CenteringRing ring2 = new CenteringRing(); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setLength(0.004); + ring2.setPositionValue(0.45); + rings.add(ring1); + rings.add(ring2); + + RocketComponent parent = new BodyTube(1d, 0.01); + parent.addChild(ring1); + parent.addChild(ring2); + + Double result = (Double)method.invoke(null, rings, 0.45d, 0.01, dm, parent); + Assert.assertEquals(0.01 - 0.004, result.doubleValue(), 0.0001); + } + + /** + * Test one ring ahead of the fin, one ring beyond the root chord. + */ + @Test + public void testComputeOneLeadingOneTrailingRing() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setLength(0.004); + ring1.setPositionValue(0.43); + CenteringRing ring2 = new CenteringRing(); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setLength(0.004); + ring2.setPositionValue(0.48); + rings.add(ring1); + rings.add(ring2); + + RocketComponent parent = new BodyTube(); + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, ring1); + Assert.assertEquals(0.01, result.doubleValue(), 0.0001); + } + + /** + * Test one ring within the root chord, another ring beyond the root chord. + */ + @Test + public void testComputeOneWithinRootOneTrailingRing() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setLength(0.004); + ring1.setPositionValue(0.4701); + CenteringRing ring2 = new CenteringRing(); + ring2.setLength(0.004); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setPositionValue(0.48); + rings.add(ring1); + rings.add(ring2); + RocketComponent parent = new BodyTube(1.0d, 0.1d); + parent.addChild(ring1); + parent.addChild(ring2); + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.0059, result.doubleValue(), 0.0001); + } + + /** + * Test both rings within the root chord. + */ + @Test + public void testBothRingsWithinRootChord() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + RocketComponent parent = new BodyTube(1.0000d, 0.1d); + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setLength(0.004); + ring1.setPositionValue(0.4701); + parent.addChild(ring1); + CenteringRing ring2 = new CenteringRing(); + ring2.setLength(0.004); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setPositionValue(0.4750); + parent.addChild(ring2); + rings.add(ring1); + rings.add(ring2); + + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.0009, result.doubleValue(), 0.0002); + } + + + /** + * Test both rings beyond the root chord. + */ + @Test + public void testBothRingsBeyondRootChord() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.TOP); + ring1.setLength(0.004); + ring1.setPositionValue(0.48); + CenteringRing ring2 = new CenteringRing(); + ring2.setRelativePosition(RocketComponent.Position.TOP); + ring2.setLength(0.004); + ring2.setPositionValue(0.49); + rings.add(ring1); + rings.add(ring2); + RocketComponent parent = new BodyTube(1.0d, 0.1d); + parent.addChild(ring1); + parent.addChild(ring2); + + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.0, result.doubleValue(), 0.0001); + } + + /** + * Test both rings within the root chord - the top ring has an adjacent ring (so 3 rings total). + */ + @Test + public void test3RingsWithinRootChord() throws Exception { + DoubleModel dm = new DoubleModel(1d); + List rings = new ArrayList(); + + CenteringRing ring1 = new CenteringRing(); + ring1.setRelativePosition(RocketComponent.Position.ABSOLUTE); + ring1.setLength(0.004); + ring1.setPositionValue(0.47); + CenteringRing ring2 = new CenteringRing(); + ring2.setRelativePosition(RocketComponent.Position.ABSOLUTE); + ring2.setLength(0.004); + ring2.setPositionValue(0.4702); + CenteringRing ring3 = new CenteringRing(); + ring3.setRelativePosition(RocketComponent.Position.ABSOLUTE); + ring3.setLength(0.004); + ring3.setPositionValue(0.4770); + rings.add(ring1); + rings.add(ring2); + rings.add(ring3); + BodyTube parent = new BodyTube(1.0d, 0.1d); + parent.setPositionValue(0); + parent.addChild(ring1); + parent.addChild(ring2); + parent.addChild(ring3); + + Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); + Assert.assertEquals(0.0028, result.doubleValue(), 0.0001); + } + +} diff --git a/core/test/net/sf/openrocket/gui/print/TestPaperSize.java b/core/test/net/sf/openrocket/gui/print/TestPaperSize.java new file mode 100644 index 00000000..82677cdc --- /dev/null +++ b/core/test/net/sf/openrocket/gui/print/TestPaperSize.java @@ -0,0 +1,36 @@ +package net.sf.openrocket.gui.print; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class TestPaperSize { + + @Test + public void testGetDefaultForCountry() { + assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("US")); + assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("cA")); + assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("mx")); + + assertEquals(PaperSize.A4, PaperSize.getDefaultForCountry("FI")); + assertEquals(PaperSize.A4, PaperSize.getDefaultForCountry("xy")); + + assertNull(PaperSize.getDefaultForCountry("FIN")); + assertNull(PaperSize.getDefaultForCountry("a")); + assertNull(PaperSize.getDefaultForCountry("A4")); + assertNull(PaperSize.getDefaultForCountry(null)); + } + + @Test + public void testGetSizeFromString() { + assertEquals(PaperSize.LETTER, PaperSize.getSizeFromString("Letter")); + assertEquals(PaperSize.LEGAL, PaperSize.getSizeFromString(" legal\t")); + assertEquals(PaperSize.A4, PaperSize.getSizeFromString(" A4\n")); + assertEquals(PaperSize.A3, PaperSize.getSizeFromString("A3")); + + assertNull(PaperSize.getSizeFromString("#A4")); + assertNull(PaperSize.getSizeFromString("")); + assertNull(PaperSize.getSizeFromString(null)); + } + +} diff --git a/core/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java b/core/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java new file mode 100644 index 00000000..94909b0c --- /dev/null +++ b/core/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java @@ -0,0 +1,79 @@ +package net.sf.openrocket.l10n; + +import static org.junit.Assert.*; + +import java.util.MissingResourceException; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.auto.Mock; +import org.jmock.integration.junit4.JMock; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.Test; +import org.junit.runner.RunWith; + + +@RunWith(JMock.class) +public class TestClassBasedTranslator { + Mockery context = new JUnit4Mockery(); + + @Mock + Translator translator; + + @Test + public void testClassName() { + ClassBasedTranslator cbt = new ClassBasedTranslator(null, 0); + assertEquals("TestClassBasedTranslator", cbt.getClassName()); + + cbt = new ClassBasedTranslator(null, "foobar"); + assertEquals("foobar", cbt.getClassName()); + } + + @Test + public void testGetWithClassName() { + ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(returnValue("foobar")); + }}); + // @formatter:on + + assertEquals("foobar", cbt.get("fake.key")); + } + + + @Test + public void testGetWithoutClassName() { + ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); + oneOf(translator).get("fake.key"); will(returnValue("barbaz")); + }}); + // @formatter:on + + assertEquals("barbaz", cbt.get("fake.key")); + } + + + @Test + public void testMissing() { + ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); + oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); + }}); + // @formatter:on + + try { + fail("Returned: " + cbt.get("fake.key")); + } catch (MissingResourceException e) { + assertEquals("Neither key 'TestClassBasedTranslator.fake.key' nor 'fake.key' could be found", e.getMessage()); + } + + } +} diff --git a/core/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java b/core/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java new file mode 100644 index 00000000..153b921f --- /dev/null +++ b/core/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java @@ -0,0 +1,64 @@ +package net.sf.openrocket.l10n; + +import static org.junit.Assert.*; + +import java.util.MissingResourceException; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.auto.Mock; +import org.jmock.integration.junit4.JMock; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(JMock.class) +public class TestExceptionSuppressingTranslator { + Mockery context = new JUnit4Mockery(); + + @Mock + Translator translator; + + @Test + public void testSuccessful() { + ExceptionSuppressingTranslator est = new ExceptionSuppressingTranslator(translator); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(translator).get("fake.key"); will(returnValue("foobar")); + }}); + // @formatter:on + + assertEquals("foobar", est.get("fake.key")); + } + + + @Test + public void testFailure() { + ExceptionSuppressingTranslator est = new ExceptionSuppressingTranslator(translator); + + assertFalse("Prerequisite failed", ExceptionSuppressingTranslator.errorReported); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); + oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); + oneOf(translator).get("fake.key2"); will(throwException(new MissingResourceException("a", "b", "c"))); + }}); + // @formatter:on + + // Test first failure + assertEquals("fake.key", est.get("fake.key")); + assertTrue(ExceptionSuppressingTranslator.errorReported); + + // Test second failure + assertEquals("fake.key", est.get("fake.key")); + assertTrue(ExceptionSuppressingTranslator.errorReported); + + // Test failure with other key + assertEquals("fake.key2", est.get("fake.key2")); + assertTrue(ExceptionSuppressingTranslator.errorReported); + } + + +} diff --git a/core/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java b/core/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java new file mode 100644 index 00000000..db7dbfc7 --- /dev/null +++ b/core/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java @@ -0,0 +1,34 @@ +package net.sf.openrocket.l10n; + +import static org.junit.Assert.*; + +import java.util.Locale; +import java.util.MissingResourceException; + +import org.junit.Test; + +public class TestResourceBundleTranslator { + + @Test + public void testSuccessfulUS() { + ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.US); + assertEquals("messages.properties", trans.get("debug.currentFile")); + } + + @Test + public void testSuccessfulFR() { + ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.FRENCH); + assertEquals("messages_fr.properties", trans.get("debug.currentFile")); + } + + @Test + public void testFailure() { + ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.US); + try { + fail("Returned: " + trans.get("missing")); + } catch (MissingResourceException e) { + // Expected + } + } + +} diff --git a/core/test/net/sf/openrocket/logging/CyclicBufferTest.java b/core/test/net/sf/openrocket/logging/CyclicBufferTest.java new file mode 100644 index 00000000..c7672178 --- /dev/null +++ b/core/test/net/sf/openrocket/logging/CyclicBufferTest.java @@ -0,0 +1,162 @@ +package net.sf.openrocket.logging; + +import static org.junit.Assert.*; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Random; + +import org.junit.Test; + + +public class CyclicBufferTest { + + @Test + public void testBasic() { + CyclicBuffer buffer = new CyclicBuffer(5); + LinkedList correct = new LinkedList(); + + Random rnd = new Random(); + for (int i=0; i<50; i++) { + int n = rnd.nextInt(); + buffer.add(n); + correct.add(n); + if (correct.size() > 5) + correct.remove(); + assertEquals(correct, buffer.asList()); + } + } + + @Test + public void testComplex() { + CyclicBuffer buffer = new CyclicBuffer(5); + + testContents(buffer); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.offer(1); + testContents(buffer, 1); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.add(2); + testContents(buffer, 1, 2); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.add(3); + testContents(buffer, 1, 2, 3); + assertEquals(0, buffer.getOverwriteCount()); + + assertEquals(1, (int)buffer.remove()); + testContents(buffer, 2, 3); + assertEquals(0, buffer.getOverwriteCount()); + + assertEquals(2, (int)buffer.peek()); + testContents(buffer, 2, 3); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.offer(-2); + testContents(buffer, 2, 3, -2); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.offer(-3); + testContents(buffer, 2, 3, -2, -3); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.offer(-4); + testContents(buffer, 2, 3, -2, -3, -4); + assertEquals(0, buffer.getOverwriteCount()); + + buffer.offer(5); + testContents(buffer, 3, -2, -3, -4, 5); + assertEquals(1, buffer.getOverwriteCount()); + + buffer.offer(6); + testContents(buffer, -2, -3, -4, 5, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(-2, (int)buffer.peek()); + testContents(buffer, -2, -3, -4, 5, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(-2, (int)buffer.remove()); + testContents(buffer, -3, -4, 5, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(-3, (int)buffer.remove()); + testContents(buffer, -4, 5, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(-4, (int)buffer.poll()); + testContents(buffer, 5, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(5, (int)buffer.remove()); + testContents(buffer, 6); + assertEquals(2, buffer.getOverwriteCount()); + + assertEquals(6, (int)buffer.poll()); + testContents(buffer); + assertEquals(2, buffer.getOverwriteCount()); + + assertNull(buffer.peek()); + assertNull(buffer.poll()); + testContents(buffer); + assertEquals(2, buffer.getOverwriteCount()); + } + + + @Test + public void testRandom() { + CyclicBuffer buffer = new CyclicBuffer(4); + LinkedList correct = new LinkedList(); + + Random rnd = new Random(); + for (int i=0; i<500; i++) { + + if (rnd.nextBoolean()) { + int n = rnd.nextInt(); + buffer.add(n); + correct.add(n); + if (correct.size() > 4) + correct.remove(); + } else { + Integer n = buffer.poll(); + if (correct.size() > 0) { + assertEquals(correct.remove(), n); + } else { + assertNull(n); + } + } + + assertEquals(correct, buffer.asList()); + } + } + + + private void testContents(CyclicBuffer buffer, int ... values) { + + // Test using iterator + Iterator iterator = buffer.iterator(); + for (int v: values) { + assertTrue(iterator.hasNext()); + assertEquals(v, (int)iterator.next()); + } + assertFalse(iterator.hasNext()); + try { + iterator.next(); + fail(); + } catch (NoSuchElementException ignore) { } + + // Test using list + List list = buffer.asList(); + assertEquals("List: " + list, values.length, list.size()); + for (int i=0; i list = logger.getLogs(); + assertEquals(16, list.size()); + + assertEquals("user 1", list.get(0).getMessage()); + assertEquals("warn 1", list.get(1).getMessage()); + assertEquals("user 2", list.get(2).getMessage()); + assertEquals("===== 2 INFO lines removed =====", list.get(3).getMessage()); + assertEquals("info 3", list.get(4).getMessage()); + assertEquals("error 1", list.get(5).getMessage()); + assertEquals("===== 4 DEBUG lines removed =====", list.get(6).getMessage()); + assertEquals("debug 5", list.get(7).getMessage()); + assertEquals("warn 2", list.get(8).getMessage()); + assertEquals("debug 6", list.get(9).getMessage()); + assertEquals("user 3", list.get(10).getMessage()); + assertEquals("info 4", list.get(11).getMessage()); + assertEquals("debug 7", list.get(12).getMessage()); + assertEquals("info 5", list.get(13).getMessage()); + assertEquals("debug 8", list.get(14).getMessage()); + assertEquals("info 6", list.get(15).getMessage()); + + } + +} diff --git a/core/test/net/sf/openrocket/logging/LogLevelTest.java b/core/test/net/sf/openrocket/logging/LogLevelTest.java new file mode 100644 index 00000000..63c77012 --- /dev/null +++ b/core/test/net/sf/openrocket/logging/LogLevelTest.java @@ -0,0 +1,22 @@ +package net.sf.openrocket.logging; + +import static net.sf.openrocket.logging.LogLevel.*; +import static org.junit.Assert.*; + +import org.junit.Test; + +public class LogLevelTest { + + @Test + public void testLevels() { + assertTrue(DEBUG.atLeast(DEBUG)); + assertFalse(DEBUG.atLeast(INFO)); + assertTrue(ERROR.atLeast(WARN)); + + assertTrue(ERROR.moreThan(WARN)); + assertFalse(ERROR.moreThan(ERROR)); + + assertEquals(5, LENGTH); + } + +} diff --git a/core/test/net/sf/openrocket/logging/LoggingTest.java b/core/test/net/sf/openrocket/logging/LoggingTest.java new file mode 100644 index 00000000..39e4777d --- /dev/null +++ b/core/test/net/sf/openrocket/logging/LoggingTest.java @@ -0,0 +1,63 @@ +package net.sf.openrocket.logging; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; + +public class LoggingTest { + + @Test + public void testLoggers() { + // Ensure a sane stack trace + actualTest(); + } + + private void actualTest() { + BufferLogger log3 = new BufferLogger(3); + BufferLogger log4 = new BufferLogger(4); + + DelegatorLogger delegator = new DelegatorLogger(); + delegator.addLogger(log3); + delegator.addLogger(log4); + + delegator.debug("one"); + delegator.debug("two"); + delegator.info("three"); + delegator.warn(1, "four"); + delegator.error("five"); + + List logs = log4.getLogs(); + assertEquals(4, logs.size()); + assertTrue(logs.get(0).toString(), logs.get(0).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +DEBUG \\(-\\) two")); + assertTrue(logs.get(1).toString(), logs.get(1).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +INFO \\(LoggingTest.java:[0-9]+\\) three")); + assertTrue(logs.get(2).toString(), logs.get(2).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +WARN \\(LoggingTest.java:[0-9]+ LoggingTest.java:[0-9]+\\) four")); + assertTrue(logs.get(3).toString(), logs.get(3).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +ERROR \\(LoggingTest.java:[0-9]+\\) five")); + + logs = log3.getLogs(); + assertEquals(3, logs.size()); + assertTrue(logs.get(0).toString(), logs.get(0).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +INFO \\(LoggingTest.java:[0-9]+\\) three")); + assertTrue(logs.get(1).toString(), logs.get(1).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +WARN \\(LoggingTest.java:[0-9]+ LoggingTest.java:[0-9]+\\) four")); + assertTrue(logs.get(2).toString(), logs.get(2).toString().matches( + " *[0-9]+ +[0-9]+\\.[0-9]+ +ERROR \\(LoggingTest.java:[0-9]+\\) five")); + + } + + public static void main(String[] args) { + PrintStreamLogger logger = new PrintStreamLogger(); + + logger.debug("a debug message"); + logger.info("an info message"); + logger.warn("a warning message"); + logger.error("an error message"); + + logger.debug(4, "Debugging"); + } +} diff --git a/core/test/net/sf/openrocket/logging/TraceExceptionTest.java b/core/test/net/sf/openrocket/logging/TraceExceptionTest.java new file mode 100644 index 00000000..72f3c13a --- /dev/null +++ b/core/test/net/sf/openrocket/logging/TraceExceptionTest.java @@ -0,0 +1,89 @@ +package net.sf.openrocket.logging; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class TraceExceptionTest { + + private TraceException getViaAccess() { + + /* + * The SubClass test bases on the fact that getViaAccess method is defined on a row number < 20 + * and the return statement is on a row number > 20. + * + * The JRE sometimes adds an additional "access$NNN" method call between the calls with the + * row number equal to the method definition line. + * + * + * + * + * + * + * + */ + + return new TraceException(0, 1); + } + + + @Test + public void testBasic() { + TraceException trace = new TraceException(); + assertMatch("\\(TraceExceptionTest.java:[2-9][0-9]\\)", trace); + } + + + @Test + public void testOneLevelUp() { + // @formatter:off - these need to be on the same line number + TraceException trace = getOneLevelUp(); TraceException ref = new TraceException(); + // @formatter:on + assertEquals(ref.getMessage(), trace.getMessage()); + } + + private TraceException getOneLevelUp() { + return new TraceException(1); + } + + + @Test + public void testTwoLevels() { + TraceException trace = getTwoLevels(); + assertMatch("\\(TraceExceptionTest.java:[2-9][0-9] TraceExceptionTest.java:[2-9][0-9]\\)", trace); + } + + private TraceException getTwoLevels() { + return new TraceException(0, 1); + } + + + @Test + public void testViaSubclass() { + /* + * This tests that TraceException.getMessage ignores the synthetic "access$0" method calls. + */ + + TraceException trace = new SubClass().getTrace(); + assertMatch("\\(TraceExceptionTest.java:[2-9][0-9] TraceExceptionTest.java:[2-9][0-9]\\)", trace); + } + + private class SubClass { + private TraceException getTrace() { + return getViaAccess(); + } + } + + + + + + private void assertMatch(String regex, TraceException trace) { + boolean match = trace.getMessage().matches(regex); + if (!match) { + trace.printStackTrace(); + assertTrue("Was: " + trace.getMessage(), match); + } + } + +} diff --git a/core/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java b/core/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java new file mode 100644 index 00000000..a0aea634 --- /dev/null +++ b/core/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java @@ -0,0 +1,42 @@ +package net.sf.openrocket.models.gravity; + +import static org.junit.Assert.assertEquals; +import net.sf.openrocket.util.WorldCoordinate; + +import org.junit.Test; + + +public class WGSGravityModelTest { + + private WGSGravityModel model = new WGSGravityModel(); + + @Test + public void testSurfaceGravity() { + // Equator + test(0, 0, 0, 9.780); + // Mid-latitude + test(45, 0, 0, 9.806); + // Mid-latitude + test(45, 99, 0, 9.806); + // South pole + test(-90, 0, 0, 9.832); + } + + @Test + public void testAltitudeEffect() { + test(45, 0, -100, 9.806); + test(45, 0, 0, 9.806); + test(45, 0, 10, 9.806); + test(45, 0, 100, 9.806); + test(45, 0, 1000, 9.803); + test(45, 0, 10000, 9.775); + test(45, 0, 100000, 9.505); + } + + private void test(double lat, double lon, double alt, double g) { + WorldCoordinate wc = new WorldCoordinate(lat, lon, alt); + assertEquals(g, model.getGravity(wc), 0.001); + assertEquals(g, model.getGravity(wc), 0.001); + } + +} diff --git a/core/test/net/sf/openrocket/motor/ManufacturerTest.java b/core/test/net/sf/openrocket/motor/ManufacturerTest.java new file mode 100644 index 00000000..6870c5f2 --- /dev/null +++ b/core/test/net/sf/openrocket/motor/ManufacturerTest.java @@ -0,0 +1,85 @@ +package net.sf.openrocket.motor; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ManufacturerTest { + + @Test + public void testExisting() { + + Manufacturer m1, m2, m3, m4, m5; + + m1 = Manufacturer.getManufacturer("aerotech"); + m2 = Manufacturer.getManufacturer("a "); + m3 = Manufacturer.getManufacturer("-isp-"); + m4 = Manufacturer.getManufacturer("at/rcs"); + m5 = Manufacturer.getManufacturer("e"); + + assertTrue(m1 == m2); + assertTrue(m1 == m3); + assertTrue(m1 == m4); + assertFalse(m1 == m5); + + } + + @Test + public void testNew() { + + Manufacturer m1, m2, m3; + + m1 = Manufacturer.getManufacturer("Unknown"); + m2 = Manufacturer.getManufacturer(" Unknown/ "); + m3 = Manufacturer.getManufacturer("Unknown/a"); + + assertEquals(m1.getDisplayName(), "Unknown"); + assertEquals(m2.getDisplayName(), "Unknown"); + assertTrue(m1 == m2); + + assertEquals(m3.getDisplayName(), "Unknown/a"); + assertFalse(m1 == m3); + + } + + @Test + public void testSimpleName() { + + Manufacturer m1, m2, m3, m4; + + m1 = Manufacturer.getManufacturer("cs"); + m2 = Manufacturer.getManufacturer("Cesaroni Technology"); + m3 = Manufacturer.getManufacturer("Cesaroni Technology Inc"); + m4 = Manufacturer.getManufacturer("Cesaroni Technology Inc."); + + assertEquals(m1.getDisplayName(), "Cesaroni Technology Inc."); + assertEquals(m1.toString(), "Cesaroni Technology Inc."); + assertEquals(m1.getSimpleName(), "Cesaroni Technology"); + + assertTrue(m1 == m2); + assertTrue(m1 == m3); + assertTrue(m1 == m4); + + } + + @Test + public void testMatches() { + + Manufacturer m1; + + m1 = Manufacturer.getManufacturer("aerotech"); + + assertTrue(m1.matches("a")); + assertTrue(m1.matches("a/")); + assertTrue(m1.matches("a/rcs")); + assertTrue(m1.matches("a/rms")); + assertTrue(m1.matches("aerotech ...-/%#_!")); + assertTrue(m1.matches(" .isp/")); + + assertFalse(m1.matches("aero/tech")); + assertFalse(m1.matches("aero.tech")); + assertFalse(m1.matches("aero_tech")); + assertFalse(m1.matches("aero tech")); + } + +} diff --git a/core/test/net/sf/openrocket/motor/MotorDigestTest.java b/core/test/net/sf/openrocket/motor/MotorDigestTest.java new file mode 100644 index 00000000..916ab12c --- /dev/null +++ b/core/test/net/sf/openrocket/motor/MotorDigestTest.java @@ -0,0 +1,76 @@ +package net.sf.openrocket.motor; + +import static org.junit.Assert.assertEquals; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import net.sf.openrocket.motor.MotorDigest.DataType; +import net.sf.openrocket.util.TextUtil; + +import org.junit.Test; + + +public class MotorDigestTest { + + private static final double[] timeArray = { + 0.0, 0.123456789, 0.4115, Math.nextAfter(Math.nextAfter(1.4445, 0), 0) + }; + + private static final double[] massArray = { + 0.54321, 0.43211 + }; + + private static final double[] thrustArray = { + 0.0, 0.2345678, 9999.3335, 0.0 + }; + + private static final int[] intData = { + // Time (ms) + 0, 4, 0, 123, 412, 1445, + // Mass specific (0.1g) + 1, 2, 5432, 4321, + // Thrust (mN) + 5, 4, 0, 235, 9999334, 0 + }; + + + @Test + public void testMotorDigest() throws NoSuchAlgorithmException { + + MessageDigest correct = MessageDigest.getInstance("MD5"); + for (int value: intData) { + correct.update((byte) ((value >>> 24) & 0xFF)); + correct.update((byte) ((value >>> 16) & 0xFF)); + correct.update((byte) ((value >>> 8) & 0xFF)); + correct.update((byte) (value & 0xFF)); + } + + MotorDigest motor = new MotorDigest(); + motor.update(DataType.TIME_ARRAY, timeArray); + motor.update(DataType.MASS_SPECIFIC, massArray); + motor.update(DataType.FORCE_PER_TIME, thrustArray); + + + assertEquals(TextUtil.hexString(correct.digest()), motor.getDigest()); + } + + + @Test + public void testCommentDigest() throws NoSuchAlgorithmException, UnsupportedEncodingException { + + assertEquals(md5("Hello world!"), MotorDigest.digestComment("Hello world! ")); + assertEquals(md5("Hello world!"), MotorDigest.digestComment("\nHello\tworld!\n\r")); + assertEquals(md5("Hello world!"), MotorDigest.digestComment("Hello\r\r\r\nworld!")); + assertEquals(md5("Hello\u00e4 world!"), MotorDigest.digestComment("Hello\u00e4\r\r\nworld!")); + + } + + + private static String md5(String source) + throws NoSuchAlgorithmException, UnsupportedEncodingException { + MessageDigest digest = MessageDigest.getInstance("MD5"); + return TextUtil.hexString(digest.digest(source.getBytes("UTF-8"))); + } +} diff --git a/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java new file mode 100644 index 00000000..7ca43d71 --- /dev/null +++ b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java @@ -0,0 +1,74 @@ +package net.sf.openrocket.motor; + +import static org.junit.Assert.assertEquals; +import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.Inertia; + +import org.junit.Test; + +public class ThrustCurveMotorTest { + + private final double EPS = 0.000001; + + private final double radius = 0.025; + private final double length = 0.10; + private final double longitudinal = Inertia.filledCylinderLongitudinal(radius, length); + private final double rotational = Inertia.filledCylinderRotational(radius); + + private final ThrustCurveMotor motor = + new ThrustCurveMotor(Manufacturer.getManufacturer("foo"), + "X6", "Description of X6", Motor.Type.RELOAD, + new double[] {0, 2, Motor.PLUGGED}, radius*2, length, + new double[] {0, 1, 3, 4}, // time + new double[] {0, 2, 3, 0}, // thrust + new Coordinate[] { + new Coordinate(0.02,0,0,0.05), + new Coordinate(0.02,0,0,0.05), + new Coordinate(0.02,0,0,0.05), + new Coordinate(0.03,0,0,0.03) + }); + + @Test + public void testMotorData() { + + assertEquals("X6", motor.getDesignation()); + assertEquals("X6-5", motor.getDesignation(5.0)); + assertEquals("Description of X6", motor.getDescription()); + assertEquals(Motor.Type.RELOAD, motor.getMotorType()); + + } + + @Test + public void testInstance() { + MotorInstance instance = motor.getInstance(); + + verify(instance, 0, 0.05, 0.02); + instance.step(0.0, 0, null); + verify(instance, 0, 0.05, 0.02); + instance.step(0.5, 0, null); + verify(instance, 0.5, 0.05, 0.02); + instance.step(1.5, 0, null); + verify(instance, (1.5 + 2.125)/2, 0.05, 0.02); + instance.step(2.5, 0, null); + verify(instance, (2.125 + 2.875)/2, 0.05, 0.02); + instance.step(3.0, 0, null); + verify(instance, (2+3.0/4 + 3)/2, 0.05, 0.02); + instance.step(3.5, 0, null); + verify(instance, (1.5 + 3)/2, 0.045, 0.0225); + instance.step(4.5, 0, null); + // mass and cg is simply average of the end points + verify(instance, 1.5/4, 0.035, 0.0275); + instance.step(5.0, 0, null); + verify(instance, 0, 0.03, 0.03); + } + + private void verify(MotorInstance instance, double thrust, double mass, double cgx) { + assertEquals("Testing thrust", thrust, instance.getThrust(), EPS); + assertEquals("Testing mass", mass, instance.getCG().weight, EPS); + assertEquals("Testing cg x", cgx, instance.getCG().x, EPS); + assertEquals("Testing longitudinal inertia", mass*longitudinal, instance.getLongitudinalInertia(), EPS); + assertEquals("Testing rotational inertia", mass*rotational, instance.getRotationalInertia(), EPS); + } + + +} diff --git a/core/test/net/sf/openrocket/optimization/TestSearchPattern.java b/core/test/net/sf/openrocket/optimization/TestSearchPattern.java new file mode 100644 index 00000000..fcb618b8 --- /dev/null +++ b/core/test/net/sf/openrocket/optimization/TestSearchPattern.java @@ -0,0 +1,43 @@ +package net.sf.openrocket.optimization; + +import static org.junit.Assert.*; + +import java.util.List; + +import net.sf.openrocket.optimization.general.Point; +import net.sf.openrocket.optimization.general.multidim.SearchPattern; + +import org.junit.Test; + +public class TestSearchPattern { + + @Test + public void testRegularSimplex() { + for (int dim = 1; dim < 20; dim++) { + List points = SearchPattern.regularSimplex(dim); + assertEquals(dim, points.size()); + + for (int i = 0; i < dim; i++) { + // Test dot product + for (int j = i + 1; j < dim; j++) { + double[] x = points.get(i).asArray(); + double[] y = points.get(j).asArray(); + double dot = 0; + for (int k = 0; k < dim; k++) { + dot += x[k] * y[k]; + } + assertEquals(0.5, dot, 0.000000001); + } + + // Test positive coordinates + for (int j = 0; j < dim; j++) { + assertTrue(points.get(i).get(j) >= 0); + } + + // Test length + assertEquals(1.0, points.get(i).length(), 0.000000001); + } + } + } + +} diff --git a/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java b/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java new file mode 100644 index 00000000..48cc648b --- /dev/null +++ b/core/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java @@ -0,0 +1,212 @@ +package net.sf.openrocket.optimization.rocketoptimization; + +import static org.junit.Assert.*; +import net.sf.openrocket.document.Simulation; +import net.sf.openrocket.optimization.general.OptimizationException; +import net.sf.openrocket.optimization.general.Point; +import net.sf.openrocket.rocketcomponent.Rocket; +import net.sf.openrocket.unit.Unit; +import net.sf.openrocket.unit.UnitGroup; +import net.sf.openrocket.unit.Value; +import net.sf.openrocket.util.Pair; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.auto.Mock; +import org.jmock.integration.junit4.JMock; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.Test; +import org.junit.runner.RunWith; + + +@RunWith(JMock.class) +public class TestRocketOptimizationFunction { + Mockery context = new JUnit4Mockery(); + + @Mock + OptimizableParameter parameter; + @Mock + OptimizationGoal goal; + @Mock + SimulationDomain domain; + @Mock + SimulationModifier modifier1; + @Mock + SimulationModifier modifier2; + @Mock + RocketOptimizationListener listener; + + @Test + public void testNormalEvaluation() throws InterruptedException, OptimizationException { + final Rocket rocket = new Rocket(); + final Simulation simulation = new Simulation(rocket); + + final double p1 = 0.4; + final double p2 = 0.7; + final double ddist = -0.43; + final Value dref = new Value(ddist, Unit.NOUNIT2); + final double pvalue = 9.81; + final Value pvalueValue = new Value(9.81, Unit.NOUNIT2); + final double gvalue = 8.81; + final Point point = new Point(p1, p2); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(modifier1).modify(simulation, p1); + oneOf(modifier2).modify(simulation, p2); + oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); + oneOf(parameter).computeValue(simulation); will(returnValue(pvalue)); + oneOf(parameter).getUnitGroup(); will(returnValue(UnitGroup.UNITS_NONE)); + oneOf(goal).getMinimizationParameter(pvalue); will(returnValue(gvalue)); + oneOf(modifier1).getCurrentSIValue(simulation); will(returnValue(0.2)); + oneOf(modifier1).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); + oneOf(modifier2).getCurrentSIValue(simulation); will(returnValue(0.3)); + oneOf(modifier2).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); + oneOf(listener).evaluated(point, new Value[] { + new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()), + new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit()) + }, dref, pvalueValue, gvalue); + }}); + // @formatter:on + + RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, + parameter, goal, domain, modifier1, modifier2) { + @Override + Simulation newSimulationInstance(Simulation sim) { + return sim; + } + }; + function.addRocketOptimizationListener(listener); + + double value = function.evaluate(point); + assertEquals(gvalue, value, 0); + } + + @Test + public void testNaNValue() throws InterruptedException, OptimizationException { + final Rocket rocket = new Rocket(); + final Simulation simulation = new Simulation(rocket); + + final double p1 = 0.4; + final double p2 = 0.7; + final double ddist = -0.43; + final Value dref = new Value(0.33, Unit.NOUNIT2); + final double pvalue = 9.81; + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(modifier1).modify(simulation, p1); + oneOf(modifier2).modify(simulation, p2); + oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); + oneOf(parameter).computeValue(simulation); will(returnValue(pvalue)); + oneOf(parameter).getUnitGroup(); will(returnValue(UnitGroup.UNITS_NONE)); + oneOf(goal).getMinimizationParameter(pvalue); will(returnValue(Double.NaN)); + }}); + // @formatter:on + + + RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, + parameter, goal, domain, modifier1, modifier2) { + @Override + Simulation newSimulationInstance(Simulation sim) { + return sim; + } + }; + + + double value = function.evaluate(new Point(p1, p2)); + assertEquals(Double.MAX_VALUE, value, 0); + } + + + @Test + public void testOutsideDomain() throws InterruptedException, OptimizationException { + final Rocket rocket = new Rocket(); + final Simulation simulation = new Simulation(rocket); + + final double p1 = 0.4; + final double p2 = 0.7; + final double ddist = 0.98; + final Value dref = new Value(ddist, Unit.NOUNIT2); + final Point point = new Point(p1, p2); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(modifier1).modify(simulation, p1); + oneOf(modifier2).modify(simulation, p2); + oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); + oneOf(modifier1).getCurrentSIValue(simulation); will(returnValue(0.2)); + oneOf(modifier1).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); + oneOf(modifier2).getCurrentSIValue(simulation); will(returnValue(0.3)); + oneOf(modifier2).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); + oneOf(listener).evaluated(point, new Value[] { + new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()), + new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit()) + }, dref, null, 1.98E200); + }}); + // @formatter:on + + + RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, + parameter, goal, domain, modifier1, modifier2) { + @Override + Simulation newSimulationInstance(Simulation sim) { + return sim; + } + }; + function.addRocketOptimizationListener(listener); + + double value = function.evaluate(new Point(p1, p2)); + assertTrue(value > 1e100); + } + + @Test + public void testOutsideDomain2() throws InterruptedException, OptimizationException { + final Rocket rocket = new Rocket(); + final Simulation simulation = new Simulation(rocket); + + final double p1 = 0.4; + final double p2 = 0.7; + final double ddist = Double.NaN; + final Value dref = new Value(0.33, Unit.NOUNIT2); + + // @formatter:off + context.checking(new Expectations() {{ + oneOf(modifier1).modify(simulation, p1); + oneOf(modifier2).modify(simulation, p2); + oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); + }}); + // @formatter:on + + + RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, + parameter, goal, domain, modifier1, modifier2) { + @Override + Simulation newSimulationInstance(Simulation sim) { + return sim; + } + }; + + double value = function.evaluate(new Point(p1, p2)); + assertEquals(Double.MAX_VALUE, value, 0); + } + + + @Test + public void testNewSimulationInstance() { + final Rocket rocket = new Rocket(); + rocket.setName("Foobar"); + final Simulation simulation = new Simulation(rocket); + simulation.setName("MySim"); + + RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, + parameter, goal, domain, modifier1, modifier2); + + Simulation sim = function.newSimulationInstance(simulation); + assertFalse(simulation == sim); + assertEquals("MySim", sim.getName()); + assertFalse(rocket == sim.getRocket()); + assertEquals("Foobar", sim.getRocket().getName()); + } + +} diff --git a/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java b/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java new file mode 100644 index 00000000..deacacf4 --- /dev/null +++ b/core/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java @@ -0,0 +1,102 @@ +package net.sf.openrocket.optimization.rocketoptimization.modifiers; + +import static net.sf.openrocket.util.MathUtil.EPSILON; +import static org.junit.Assert.assertEquals; +import net.sf.openrocket.document.Simulation; +import net.sf.openrocket.optimization.general.OptimizationException; +import net.sf.openrocket.rocketcomponent.Rocket; +import net.sf.openrocket.unit.UnitGroup; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestGenericModifier { + + private TestValue value; + private GenericModifier gm; + private Simulation sim; + + @Before + public void setup() { + value = new TestValue(); + sim = new Simulation(new Rocket()); + + Object related = new Object(); + + gm = new GenericModifier("Test modifier", "Description", related, + UnitGroup.UNITS_NONE, 2.0, TestValue.class, "value") { + @Override + protected TestValue getModifiedObject(Simulation simulation) { + Assert.assertTrue(simulation == sim); + return value; + } + }; + + gm.setMinValue(0.5); + gm.setMaxValue(5.5); + } + + @Test + public void testGetCurrentValue() throws OptimizationException { + value.d = 1.0; + assertEquals(2.0, gm.getCurrentSIValue(sim), EPSILON); + value.d = 2.0; + assertEquals(4.0, gm.getCurrentSIValue(sim), EPSILON); + } + + @Test + public void testGetCurrentScaledValue() throws OptimizationException { + value.d = 0.0; + assertEquals(-0.1, gm.getCurrentScaledValue(sim), EPSILON); + value.d = 1.0; + assertEquals(0.3, gm.getCurrentScaledValue(sim), EPSILON); + value.d = 2.0; + assertEquals(0.7, gm.getCurrentScaledValue(sim), EPSILON); + value.d = 3.0; + assertEquals(1.1, gm.getCurrentScaledValue(sim), EPSILON); + } + + @Test + public void testModify() throws OptimizationException { + value.d = 0.0; + gm.modify(sim, -0.5); + assertEquals(-1.0, value.d, EPSILON); + + gm.modify(sim, 0.0); + assertEquals(0.25, value.d, EPSILON); + + gm.modify(sim, 0.5); + assertEquals(1.5, value.d, EPSILON); + + gm.modify(sim, 1.0); + assertEquals(2.75, value.d, EPSILON); + + gm.modify(sim, 1.5); + assertEquals(4.0, value.d, EPSILON); + } + + public void testSingularRange() throws OptimizationException { + gm.setMinValue(1.0); + gm.setMaxValue(1.0); + value.d = 0.5; + assertEquals(0.0, gm.getCurrentScaledValue(sim), EPSILON); + value.d = 1.0; + assertEquals(0.5, gm.getCurrentScaledValue(sim), EPSILON); + value.d = 1.00001; + assertEquals(1.0, gm.getCurrentScaledValue(sim), EPSILON); + } + + public class TestValue { + private double d; + + public double getValue() { + return d; + } + + public void setValue(double value) { + this.d = value; + } + } + +} diff --git a/core/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java b/core/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java new file mode 100644 index 00000000..fb231dc0 --- /dev/null +++ b/core/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java @@ -0,0 +1,147 @@ +package net.sf.openrocket.rocketcomponent; + +import static org.junit.Assert.*; + +import java.lang.reflect.Method; +import java.util.Iterator; +import java.util.regex.Pattern; + +import net.sf.openrocket.util.BugException; + +public class ComponentCompare { + + private static final Pattern GETTER_PATTERN = Pattern.compile("^(is|get)[A-Z].*+"); + + private static final String[] IGNORED_METHODS = { + "getClass", "getChildCount", "getChildren", "getNextComponent", "getID", + "getPreviousComponent", "getParent", "getRocket", "getRoot", "getStage", + "getStageNumber", "getComponentName", + // Rocket specific methods: + "getModID", "getMassModID", "getAerodynamicModID", "getTreeModID", "getFunctionalModID", + "getMotorConfigurationIDs", "getDefaultConfiguration" + }; + + + /** + * Check whether the two components are equal. Two components are considered + * equal if they are of the same type and all of their getXXX() and isXXX() methods + * return equal values. + * + * @param c1 the first component to compare. + * @param c2 the second component to compare. + */ + public static void assertEquality(RocketComponent c1, RocketComponent c2) { + assertEquals(c1.getClass(), c2.getClass()); + + // Same class + similar == equal + assertSimilarity(c1, c2); + } + + + + public static void assertDeepEquality(RocketComponent c1, RocketComponent c2) { + assertEquality(c1, c2); + + Iterator i1 = c1.getChildren().iterator(); + Iterator i2 = c2.getChildren().iterator(); + while (i1.hasNext()) { + assertTrue("iterator continues", i2.hasNext()); + RocketComponent comp1 = i1.next(); + RocketComponent comp2 = i2.next(); + assertDeepEquality(comp1, comp2); + } + assertFalse("iterator end", i2.hasNext()); + } + + + + public static void assertDeepSimilarity(RocketComponent c1, RocketComponent c2, + boolean allowNameDifference) { + assertSimilarity(c1, c2, allowNameDifference); + + Iterator i1 = c1.getChildren().iterator(); + Iterator i2 = c2.getChildren().iterator(); + while (i1.hasNext()) { + assertTrue("iterator continues", i2.hasNext()); + RocketComponent comp1 = i1.next(); + RocketComponent comp2 = i2.next(); + assertDeepSimilarity(comp1, comp2, allowNameDifference); + } + assertFalse("iterator end", i2.hasNext()); + } + + + + /** + * Check whether the two components are similar. Two components are similar + * if each of the getXXX and isXXX methods that both object types have return + * equal values. This does not check whether the two components are of the same type. + * + * @param c1 the first component. + * @param c2 the second component. + */ + public static void assertSimilarity(RocketComponent c1, RocketComponent c2) { + assertSimilarity(c1, c2, false); + } + + /** + * Check whether the two components are similar, allowing a name difference. + * + * @param c1 the first component. + * @param c2 the second component. + * @param allowNameDifference whether to allow the components to have different names. + */ + public static void assertSimilarity(RocketComponent c1, RocketComponent c2, + boolean allowNameDifference) { + Class class1 = c1.getClass(); + Class class2 = c2.getClass(); + + mainloop: for (Method m1 : class1.getMethods()) { + // Check for getter method + String name = m1.getName(); + if (!GETTER_PATTERN.matcher(name).matches()) + continue; + + // Ignore methods that take parameters + if (m1.getParameterTypes().length != 0) + continue; + + // Ignore specific getters + for (String ignore : IGNORED_METHODS) { + if (name.equals(ignore)) + continue mainloop; + } + if (allowNameDifference && name.equals("getName")) + continue; + + + // Check for method in other class + Method m2; + try { + m2 = class2.getMethod(name); + } catch (NoSuchMethodException e) { + continue; + } + + // System.out.println("Testing results of method " + name); + + // Run the methods + Object result1, result2; + try { + result1 = m1.invoke(c1); + result2 = m2.invoke(c2); + } catch (Exception e) { + throw new BugException("Error executing method " + name, e); + } + + if (result1 != null && result2 != null && + result1.getClass().isArray() && result2.getClass().isArray()) { + assertArrayEquals("Comparing result of method " + name, + (Object[]) result1, (Object[]) result2); + } else { + assertEquals("Comparing result of method " + name, result1, result2); + } + } + } + +} diff --git a/core/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java b/core/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java new file mode 100644 index 00000000..46c8f21d --- /dev/null +++ b/core/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java @@ -0,0 +1,135 @@ +package net.sf.openrocket.rocketcomponent; + +import static org.junit.Assert.*; + +import java.awt.Color; +import java.util.Iterator; + +import net.sf.openrocket.gui.util.ColorConversion; +import net.sf.openrocket.util.Coordinate; + +import org.junit.Test; + +public class ComponentCompareTest { + + @Test + public void testComponentEquality() { + + System.out.println("TEST CLASSPATH: " + System.getProperty("java.class.path")); + + Rocket r1 = net.sf.openrocket.util.TestRockets.makeBigBlue(); + Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue(); + + Iterator i1 = r1.iterator(true); + Iterator i2 = r2.iterator(true); + while (i1.hasNext()) { + assertTrue(i2.hasNext()); + + RocketComponent c1 = i1.next(); + RocketComponent c2 = i2.next(); + + ComponentCompare.assertEquality(c1, c2); + ComponentCompare.assertSimilarity(c1, c2); + } + assertFalse(i2.hasNext()); + + + ComponentCompare.assertDeepEquality(r1, r2); + ComponentCompare.assertDeepSimilarity(r1, r2, false); + + + r1.setColor(ColorConversion.fromAwtColor(Color.YELLOW)); + try { + ComponentCompare.assertEquality(r1, r2); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + + + i1 = r1.iterator(true); + i2 = r2.iterator(true); + boolean finsetfound = false; + while (i1.hasNext()) { + RocketComponent c1 = i1.next(); + RocketComponent c2 = i2.next(); + + if (c1 instanceof FinSet) { + finsetfound = true; + FinSet f1 = (FinSet)c1; + f1.setTabHeight(0.001); + + try { + ComponentCompare.assertEquality(c1, c2); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + } + } + assertTrue(finsetfound); + } + + + @Test + public void testComponentSimilarity() throws IllegalFinPointException { + FinSet trap = new TrapezoidFinSet( + 5, // fins + 5.0, // root + 3.0, // tip + 0.0, // sweep + 2.0); // height + FinSet free = new FreeformFinSet(new Coordinate[] { + new Coordinate(0,0), + new Coordinate(0,2), + new Coordinate(3,2), + new Coordinate(5,0) + }); + free.setFinCount(5); + + ComponentCompare.assertSimilarity(trap, free, true); + + try { + ComponentCompare.assertSimilarity(trap, free); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + + free.setName(trap.getName()); + ComponentCompare.assertSimilarity(trap, free); + + try { + ComponentCompare.assertEquality(trap, free); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + + + BodyTube t1 = new BodyTube(); + BodyTube t2 = new BodyTube(); + t1.addChild(free); + t2.addChild(trap); + + ComponentCompare.assertDeepSimilarity(t1, t2, false); + + try { + ComponentCompare.assertDeepEquality(t1, t2); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + + t1.addChild(new TrapezoidFinSet()); + + try { + ComponentCompare.assertDeepSimilarity(t1, t2, true); + fail(); + } catch (AssertionError e) { + // Correct behavior + } + + } + +} diff --git a/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java new file mode 100644 index 00000000..abec65ce --- /dev/null +++ b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java @@ -0,0 +1,116 @@ +package net.sf.openrocket.rocketcomponent; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; + +import net.sf.openrocket.gui.util.ColorConversion; +import net.sf.openrocket.material.Material; +import net.sf.openrocket.material.Material.Type; +import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish; +import net.sf.openrocket.rocketcomponent.FinSet.CrossSection; +import net.sf.openrocket.rocketcomponent.FinSet.TabRelativePosition; +import net.sf.openrocket.rocketcomponent.RocketComponent.Position; +import net.sf.openrocket.util.LineStyle; +import net.sf.openrocket.util.BaseTestCase.BaseTestCase; + +import org.junit.Test; + +public class FinSetTest extends BaseTestCase { + + + @Test + public void testFreeformConvert() { + testFreeformConvert(new TrapezoidFinSet()); + testFreeformConvert(new EllipticalFinSet()); + testFreeformConvert(new FreeformFinSet()); + } + + + private void testFreeformConvert(FinSet fin) { + FreeformFinSet converted; + Material mat = Material.newMaterial(Type.BULK, "foo", 0.1, true); + + fin.setBaseRotation(1.1); + fin.setCantAngle(0.001); + fin.setCGOverridden(true); + fin.setColor(ColorConversion.fromAwtColor(Color.YELLOW)); + fin.setComment("cmt"); + fin.setCrossSection(CrossSection.ROUNDED); + fin.setFinCount(5); + fin.setFinish(Finish.ROUGH); + fin.setLineStyle(LineStyle.DASHDOT); + fin.setMassOverridden(true); + fin.setMaterial(mat); + fin.setOverrideCGX(0.012); + fin.setOverrideMass(0.0123); + fin.setOverrideSubcomponents(true); + fin.setPositionValue(0.1); + fin.setRelativePosition(Position.ABSOLUTE); + fin.setTabHeight(0.01); + fin.setTabLength(0.02); + fin.setTabRelativePosition(TabRelativePosition.END); + fin.setTabShift(0.015); + fin.setThickness(0.005); + + + converted = FreeformFinSet.convertFinSet((FinSet) fin.copy()); + + ComponentCompare.assertSimilarity(fin, converted, true); + + assertEquals(converted.getComponentName(), converted.getName()); + + + // Create test rocket + Rocket rocket = new Rocket(); + Stage stage = new Stage(); + BodyTube body = new BodyTube(); + + rocket.addChild(stage); + stage.addChild(body); + body.addChild(fin); + + Listener l1 = new Listener("l1"); + rocket.addComponentChangeListener(l1); + + fin.setName("Custom name"); + assertTrue(l1.changed); + assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype); + + + // Create copy + RocketComponent rocketcopy = rocket.copy(); + + Listener l2 = new Listener("l2"); + rocketcopy.addComponentChangeListener(l2); + + FinSet fincopy = (FinSet) rocketcopy.getChild(0).getChild(0).getChild(0); + FreeformFinSet.convertFinSet(fincopy); + + assertTrue(l2.changed); + assertEquals(ComponentChangeEvent.TREE_CHANGE, + l2.changetype & ComponentChangeEvent.TREE_CHANGE); + + } + + + private static class Listener implements ComponentChangeListener { + private boolean changed = false; + private int changetype = 0; + private final String name; + + public Listener(String name) { + this.name = name; + } + + @Override + public void componentChanged(ComponentChangeEvent e) { + assertFalse("Ensuring listener " + name + " has not been called.", changed); + changed = true; + changetype = e.getType(); + } + } + +} diff --git a/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java b/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java new file mode 100644 index 00000000..16b5ca5d --- /dev/null +++ b/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java @@ -0,0 +1,23 @@ +package net.sf.openrocket.rocketcomponent; + +import net.sf.openrocket.util.BaseTestCase.BaseTestCase; + +import org.junit.Test; + +public class RocketTest extends BaseTestCase { + + @Test + public void testCopyFrom() { + Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu(); + Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue(); + + Rocket copy = (Rocket) r2.copy(); + + ComponentCompare.assertDeepEquality(r2, copy); + + r1.copyFrom(copy); + + ComponentCompare.assertDeepEquality(r1, r2); + } + +} diff --git a/core/test/net/sf/openrocket/simplerocket.ork b/core/test/net/sf/openrocket/simplerocket.ork new file mode 100644 index 00000000..453cdec9 Binary files /dev/null and b/core/test/net/sf/openrocket/simplerocket.ork differ diff --git a/core/test/net/sf/openrocket/unit/ValueTest.java b/core/test/net/sf/openrocket/unit/ValueTest.java new file mode 100644 index 00000000..9440c4d0 --- /dev/null +++ b/core/test/net/sf/openrocket/unit/ValueTest.java @@ -0,0 +1,43 @@ +package net.sf.openrocket.unit; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ValueTest { + + @Test + public void testValues() { + Value v1, v2; + + v1 = new Value(273.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); + v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("C")); + + assertTrue(v1.compareTo(v2) > 0); + assertTrue(v2.compareTo(v1) < 0); + assertTrue(v1.compareTo(v1) == 0); + assertTrue(v2.compareTo(v2) == 0); + + v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("K")); + assertTrue(v1.compareTo(v2) > 0); + assertTrue(v2.compareTo(v1) < 0); + assertEquals("283 K", v2.toString()); + + v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); + assertTrue(v1.compareTo(v2) < 0); + assertTrue(v2.compareTo(v1) > 0); + + + v1 = new Value(Double.NaN, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); + assertTrue(v1.compareTo(v2) > 0); + assertTrue(v2.compareTo(v1) < 0); + + v2 = new Value(Double.NaN, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); + assertTrue(v1.compareTo(v2) == 0); + assertTrue(v1.compareTo(v2) == 0); + assertEquals("N/A", v1.toString()); + assertEquals("N/A", v2.toString()); + + } + +} diff --git a/core/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java b/core/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java new file mode 100644 index 00000000..c5d1feb1 --- /dev/null +++ b/core/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java @@ -0,0 +1,16 @@ +package net.sf.openrocket.util.BaseTestCase; + +import net.sf.openrocket.gui.util.SwingPreferences; +import net.sf.openrocket.startup.Application; + +import org.junit.BeforeClass; + +public class BaseTestCase { + + @BeforeClass + public static void setUpApplication () { + + Application.setPreferences( new SwingPreferences() ); + + } +} diff --git a/core/test/net/sf/openrocket/util/CoordinateTest.java b/core/test/net/sf/openrocket/util/CoordinateTest.java new file mode 100644 index 00000000..0c74a3a1 --- /dev/null +++ b/core/test/net/sf/openrocket/util/CoordinateTest.java @@ -0,0 +1,64 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CoordinateTest { + + private static final double EPS = 0.0000000001; + + @Test + public void coordinateTest() { + + Coordinate x = new Coordinate(1,1,1,1); + Coordinate y = new Coordinate(1,2,3,4); + + assertCoordinateEquals(new Coordinate(2,1,1,1), x.setX(2)); + assertCoordinateEquals(new Coordinate(1,2,1,1), x.setY(2)); + assertCoordinateEquals(new Coordinate(1,1,2,1), x.setZ(2)); + assertCoordinateEquals(new Coordinate(1,1,1,2), x.setWeight(2)); + assertCoordinateEquals(new Coordinate(2,3,4,1), x.setXYZ(y).add(1,1,1)); + + assertFalse(x.isNaN()); + assertTrue(x.setX(Double.NaN).isNaN()); + assertTrue(Coordinate.NaN.isNaN()); + + assertTrue(x.isWeighted()); + assertFalse(x.setWeight(0).isWeighted()); + + + assertCoordinateEquals(x, x.add(Coordinate.NUL)); + assertCoordinateEquals(new Coordinate(2,3,4,5), x.add(y)); + assertCoordinateEquals(new Coordinate(2,3,4,1), x.add(1,2,3)); + assertCoordinateEquals(new Coordinate(2,3,4,5), x.add(1,2,3,4)); + + assertCoordinateEquals(new Coordinate(0,-1,-2,1), x.sub(y)); + assertCoordinateEquals(new Coordinate(0,-1,-2,1), x.sub(1,2,3)); + + assertCoordinateEquals(new Coordinate(2,4,6,8), y.multiply(2)); + + assertEquals(1+2+3, y.dot(x), EPS); + assertEquals(1+2+3, x.dot(y), EPS); + assertEquals(1+2+3, Coordinate.dot(x,y), EPS); + assertEquals(x.dot(x), x.length2(), EPS); + assertEquals(y.dot(y), y.length2(), EPS); + assertEquals(Math.sqrt(1+4+9), y.length(), EPS); + assertEquals(1, y.normalize().length(), EPS); + + assertCoordinateEquals(new Coordinate(1.75,1.75,1.75,4), + new Coordinate(1,1,1,1).average(new Coordinate(2,2,2,3))); + assertCoordinateEquals(new Coordinate(1,1,1,1), + new Coordinate(1,1,1,1).average(new Coordinate(2,2,2,0))); + assertCoordinateEquals(new Coordinate(1.5,1.5,1.5,0), + new Coordinate(1,1,1,0).average(new Coordinate(2,2,2,0))); + + } + + + private void assertCoordinateEquals(Coordinate a, Coordinate b) { + assertEquals(a, b); + assertEquals(a.weight, b.weight, EPS); + } + +} diff --git a/core/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java b/core/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java new file mode 100644 index 00000000..29efe41c --- /dev/null +++ b/core/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java @@ -0,0 +1,158 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class GeodeticComputationStrategyTest { + + @Test + public void testSpericalAddCoordinate() { + + double arcmin = (1.0 / 60.0); + double arcsec = (1.0 / (60.0 * 60.0)); + + double lat1 = 50.0 + 3 * arcmin + 59 * arcsec; + double lon1 = -1.0 * (5 + 42 * arcmin + 53 * arcsec); //W + + double lat2 = 58 + 38 * arcmin + 38 * arcsec; + double lon2 = -1.0 * (3 + 4 * arcmin + 12 * arcsec); + + double range = 968.9 * 1000.0; + double bearing = (9.0 + 7 * arcmin + 11 * arcsec) * (Math.PI / 180.0); + + Coordinate coord = new Coordinate(range * Math.sin(bearing), range * Math.cos(bearing), 1000.0); + WorldCoordinate wc = new WorldCoordinate(lat1, lon1, 0.0); + wc = GeodeticComputationStrategy.SPHERICAL.addCoordinate(wc, coord); + + System.out.println(wc.getLatitudeDeg()); + System.out.println(lat2); + + System.out.println(wc.getLongitudeDeg()); + System.out.println(lon2); + + assertEquals(lat2, wc.getLatitudeDeg(), 0.001); + assertEquals(lon2, wc.getLongitudeDeg(), 0.001); + assertEquals(1000.0, wc.getAltitude(), 0.0); + } + + + @Test + public void testAddCoordinates() { + + double min = 1 / 60.0; + double sec = 1 / 3600.0; + + + // Test zero movement + System.out.println("\nTesting zero movement"); + testAddCoordinate(50.0, 20.0, 0, 123, 50.0, 20.0, false); + + + /* + * These example values have been computed using the calculator at + * http://www.movable-type.co.uk/scripts/latlong.html + */ + + // Long distance NE over England, crosses Greenwich meridian + // 50 03N 005 42W to 58 38N 003 04E is 1109km at 027 16'07" + System.out.println("\nTesting 1109km NE over England"); + testAddCoordinate(50 + 3 * min, -5 - 42 * min, 1109000, 27 + 16 * min + 7 * sec, 58 + 38 * min, 3 + 4 * min, false); + + // SW over Brazil + // -10N -60E to -11N -61E is 155.9km at 224 25'34" + System.out.println("\nTesting 155km SW over Brazil"); + testAddCoordinate(-10, -60, 155900, 224 + 25 * min + 34 * sec, -11, -61, true); + + // NW over the 180 meridian + // 63N -179E to 63 01N 179E is 100.9km at 271 56'34" + System.out.println("\nTesting 100km NW over 180 meridian"); + testAddCoordinate(63, -179, 100900, 271 + 56 * min + 34 * sec, 63 + 1 * min, 179, true); + + // NE near the north pole + // 89 50N 0E to 89 45N 175E is 46.29 km at 003 00'01" + System.out.println("\nTesting 46km NE near north pole"); + testAddCoordinate(89 + 50 * min, 0, 46290, 3 + 0 * min + 1 * sec, 89 + 45 * min, 175, false); + + // S directly over south pole + // -89 50N 12E to -89 45N 192E is 46.33km at 180 00'00" + System.out.println("\nTesting 46km directly over south pole "); + testAddCoordinate(-89 - 50 * min, 12, 46330, 180, -89 - 45 * min, -168, false); + + } + + private void testAddCoordinate(double initialLatitude, double initialLongitude, double distance, double bearing, + double finalLatitude, double finalLongitude, boolean testFlat) { + + double tolerance; + + bearing = Math.toRadians(bearing); + + // positive X is EAST, positive Y is NORTH + double deltaX = distance * Math.sin(bearing); + double deltaY = distance * Math.cos(bearing); + + Coordinate coord = new Coordinate(deltaX, deltaY, 1000.0); + WorldCoordinate wc = new WorldCoordinate(initialLatitude, initialLongitude, 0.0); + + // Test SPHERICAL + tolerance = 0.0015 * distance / 111325; + System.out.println("\nSpherical tolerance: " + tolerance); + WorldCoordinate result = GeodeticComputationStrategy.SPHERICAL.addCoordinate(wc, coord); + + System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); + System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); + assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); + assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); + assertEquals(1000.0, result.getAltitude(), 0.0); + + + // Test WGS84 + /* + * Note: Since the example values are computed using a spherical earth approximation, + * the WGS84 method will have significantly larger errors. A tolerance of 1% accommodates + * all cases except the NE flight near the north pole, where the ellipsoidal effect is + * the greatest. + */ + tolerance = 0.04 * distance / 111325; + System.out.println("\nWGS84 tolerance: " + tolerance); + result = GeodeticComputationStrategy.WGS84.addCoordinate(wc, coord); + + System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); + System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); + assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); + assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); + assertEquals(1000.0, result.getAltitude(), 0.0); + + + // Test FLAT + if (testFlat) { + tolerance = 0.02 * distance / 111325; + System.out.println("\nFlat tolerance: " + tolerance); + result = GeodeticComputationStrategy.FLAT.addCoordinate(wc, coord); + + System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); + System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); + assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); + assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); + assertEquals(1000.0, result.getAltitude(), 0.0); + + } + + } + + + + @Test + public void testSpericalGetCoriolisAcceleration() { + + // For positive latitude and rotational velocity, a movement due east results in an acceleration due south + Coordinate velocity = new Coordinate(-1000, 0, 0); + WorldCoordinate wc = new WorldCoordinate(45, 0, 0); + double north_accel = GeodeticComputationStrategy.SPHERICAL.getCoriolisAcceleration(wc, velocity).y; + System.out.println("North accel " + north_accel); + assertTrue(north_accel < 0.0); + + } + +} diff --git a/core/test/net/sf/openrocket/util/MathUtilTest.java b/core/test/net/sf/openrocket/util/MathUtilTest.java new file mode 100644 index 00000000..8b79aeca --- /dev/null +++ b/core/test/net/sf/openrocket/util/MathUtilTest.java @@ -0,0 +1,219 @@ +package net.sf.openrocket.util; + +import static java.lang.Double.NaN; +import static java.lang.Math.PI; +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class MathUtilTest { + + public static final double EPS = 0.00000000001; + + @Test + public void miscMathTest() { + + assertEquals(PI * PI, MathUtil.pow2(PI), EPS); + assertEquals(PI * PI * PI, MathUtil.pow3(PI), EPS); + assertEquals(PI * PI * PI * PI, MathUtil.pow4(PI), EPS); + + assertEquals(1.0, MathUtil.clamp(0.9999, 1.0, 2.0), 0); + assertEquals(1.23, MathUtil.clamp(1.23, 1.0, 2.0), 0); + assertEquals(2.0, MathUtil.clamp(2 + EPS / 100, 1.0, 2.0), 0); + + assertEquals(1.0f, MathUtil.clamp(0.9999f, 1.0f, 2.0f), 0); + assertEquals(1.23f, MathUtil.clamp(1.23f, 1.0f, 2.0f), 0); + assertEquals(2.0f, MathUtil.clamp(2.0001f, 1.0f, 2.0f), 0); + + assertEquals(1, MathUtil.clamp(-3, 1, 5)); + assertEquals(3, MathUtil.clamp(3, 1, 5)); + assertEquals(5, MathUtil.clamp(6, 1, 5)); + + assertEquals(-1.0, MathUtil.sign(Double.NEGATIVE_INFINITY), EPS); + assertEquals(-1.0, MathUtil.sign(-100), EPS); + assertEquals(-1.0, MathUtil.sign(Math.nextAfter(0.0, -1.0)), EPS); + assertEquals(1.0, MathUtil.sign(Math.nextUp(0.0)), EPS); + assertEquals(1.0, MathUtil.sign(100), EPS); + assertEquals(1.0, MathUtil.sign(Double.POSITIVE_INFINITY), EPS); + } + + @Test + public void hypotTest() { + + for (int i = 0; i < 10000; i++) { + double x = Math.random() * 100 - 50; + double y = Math.random() * i - i / 2; + double z = Math.hypot(x, y); + assertEquals(z, MathUtil.hypot(x, y), EPS); + } + + } + + @Test + public void reduceTest() { + + for (int i = -1000; i < 1000; i++) { + double angle = Math.random() * 2 * PI; + double shift = angle + i * 2 * PI; + assertEquals(angle, MathUtil.reduce360(shift), EPS); + } + + for (int i = -1000; i < 1000; i++) { + double angle = Math.random() * 2 * PI - PI; + double shift = angle + i * 2 * PI; + assertEquals(angle, MathUtil.reduce180(shift), EPS); + } + + } + + @Test + public void minmaxTest() { + assertEquals(1.0, MathUtil.min(1.0, Math.nextUp(1.0)), 0); + assertEquals(1.0, MathUtil.min(1.0, Double.POSITIVE_INFINITY), 0); + assertEquals(1.0, MathUtil.min(NaN, 1.0), 0); + assertEquals(1.0, MathUtil.min(1.0, NaN), 0); + assertEquals(NaN, MathUtil.min(NaN, NaN), 0); + + assertEquals(Math.nextUp(1.0), MathUtil.max(1.0, Math.nextUp(1.0)), 0); + assertEquals(Double.POSITIVE_INFINITY, MathUtil.max(1.0, Double.POSITIVE_INFINITY), 0); + assertEquals(1.0, MathUtil.max(NaN, 1.0), 0); + assertEquals(1.0, MathUtil.max(1.0, NaN), 0); + assertEquals(NaN, MathUtil.max(NaN, NaN), 0); + + assertEquals(1.0, MathUtil.min(1.0, 2.0, 3.0), 0); + assertEquals(1.0, MathUtil.min(1.0, NaN, NaN), 0); + assertEquals(1.0, MathUtil.min(NaN, 1.0, NaN), 0); + assertEquals(1.0, MathUtil.min(NaN, NaN, 1.0), 0); + assertEquals(1.0, MathUtil.min(2.0, NaN, 1.0), 0); + assertEquals(1.0, MathUtil.min(1.0, 2.0, NaN), 0); + assertEquals(1.0, MathUtil.min(NaN, 2.0, 1.0), 0); + + assertEquals(3.0, MathUtil.max(1.0, 3.0, 2.0), 0); + assertEquals(1.0, MathUtil.max(1.0, NaN, NaN), 0); + assertEquals(1.0, MathUtil.max(NaN, 1.0, NaN), 0); + assertEquals(1.0, MathUtil.max(NaN, NaN, 1.0), 0); + assertEquals(2.0, MathUtil.max(2.0, NaN, 1.0), 0); + assertEquals(2.0, MathUtil.max(1.0, 2.0, NaN), 0); + assertEquals(2.0, MathUtil.max(NaN, 2.0, 1.0), 0); + + assertEquals(1.0, MathUtil.min(1.0, 2.0, 3.0, 4.0), 0); + assertEquals(1.0, MathUtil.min(1.0, NaN, NaN, NaN), 0); + assertEquals(1.0, MathUtil.min(NaN, 1.0, NaN, NaN), 0); + assertEquals(1.0, MathUtil.min(NaN, NaN, 1.0, NaN), 0); + assertEquals(1.0, MathUtil.min(2.0, NaN, 1.0, NaN), 0); + assertEquals(1.0, MathUtil.min(2.0, NaN, NaN, 1.0), 0); + assertEquals(1.0, MathUtil.min(1.0, 2.0, NaN, 3.0), 0); + assertEquals(1.0, MathUtil.min(NaN, 2.0, 3.0, 1.0), 0); + + } + + @Test + public void mapTest() { + assertEquals(1.0, MathUtil.map(1.0, 0.0, 5.0, -1.0, 9.0), EPS); + assertEquals(7.0, MathUtil.map(1.0, 5.0, 0.0, -1.0, 9.0), EPS); + assertEquals(7.0, MathUtil.map(1.0, 0.0, 5.0, 9.0, -1.0), EPS); + assertEquals(6.0, MathUtil.map(6.0, 0.0, 5.0, Math.nextUp(6.0), 6.0), EPS); + assertEquals(6.0, MathUtil.map(6.0, 0.0, 0.0, Math.nextUp(6.0), 6.0), EPS); + try { + MathUtil.map(6.0, 1.0, Math.nextUp(1.0), 1.0, 2.0); + fail("Should not be reached."); + } catch (IllegalArgumentException normal) { + } + + assertEquals(7.0, MathUtil.map(Math.nextUp(1.0), 0.0, 5.0, 9.0, -1.0), EPS); + } + + + @Test + public void mapCoordinateTest() { + assertEquals(new Coordinate(0.8, 2.0, 1.6, 4.0), + MathUtil.map(1.0, 0.0, 5.0, new Coordinate(0, 1, 2, 3), new Coordinate(4, 6, 0, 8))); + } + + + @Test + public void equalsTest() { + assertTrue(MathUtil.equals(1.0, 1.0 + MathUtil.EPSILON / 3)); + assertFalse(MathUtil.equals(1.0, 1.0 + MathUtil.EPSILON * 2)); + assertTrue(MathUtil.equals(-1.0, -1.0 + MathUtil.EPSILON / 3)); + assertFalse(MathUtil.equals(-1.0, -1.0 + MathUtil.EPSILON * 2)); + + for (double zero : new double[] { 0.0, MathUtil.EPSILON / 10, -MathUtil.EPSILON / 10 }) { + + assertTrue(MathUtil.equals(zero, MathUtil.EPSILON / 3)); + assertTrue(MathUtil.equals(zero, -MathUtil.EPSILON / 3)); + assertFalse(MathUtil.equals(zero, MathUtil.EPSILON * 2)); + assertFalse(MathUtil.equals(zero, -MathUtil.EPSILON * 2)); + + assertTrue(MathUtil.equals(MathUtil.EPSILON / 3, zero)); + assertTrue(MathUtil.equals(-MathUtil.EPSILON / 3, zero)); + assertFalse(MathUtil.equals(MathUtil.EPSILON * 2, zero)); + assertFalse(MathUtil.equals(-MathUtil.EPSILON * 2, zero)); + + } + + for (double value : new double[] { PI * 1e20, -PI * 1e20 }) { + assertTrue("value=" + value, MathUtil.equals(value, value + 1)); + assertTrue("value=" + value, MathUtil.equals(value, Math.nextUp(value))); + assertTrue("value=" + value, MathUtil.equals(value, value * (1 + MathUtil.EPSILON))); + } + + assertFalse(MathUtil.equals(NaN, 0.0)); + assertFalse(MathUtil.equals(0.0, NaN)); + assertFalse(MathUtil.equals(NaN, NaN)); + } + + @Test + public void testAverageStddev() { + List ints = new ArrayList(); + List doubles = new ArrayList(); + + ints.add(3); + ints.add(4); + ints.add(7); + ints.add(5); + + doubles.add(3.4); + doubles.add(2.9); + doubles.add(7.5); + doubles.add(5.43); + doubles.add(2.8); + doubles.add(6.6); + + assertEquals(4.75, MathUtil.average(ints), EPS); + assertEquals(1.707825127659933, MathUtil.stddev(ints), EPS); + assertEquals(4.771666666666667, MathUtil.average(doubles), EPS); + assertEquals(2.024454659078999, MathUtil.stddev(doubles), EPS); + } + + @Test + public void testMedian() { + List ints = new ArrayList(); + List doubles = new ArrayList(); + + ints.add(3); + ints.add(4); + ints.add(7); + ints.add(5); + + doubles.add(3.4); + doubles.add(2.9); + doubles.add(7.5); + doubles.add(5.43); + doubles.add(2.8); + doubles.add(6.6); + + assertEquals(4.5, MathUtil.median(ints), EPS); + assertEquals(4.415, MathUtil.median(doubles), EPS); + + ints.add(9); + doubles.add(10.0); + + assertEquals(5, MathUtil.median(ints), EPS); + assertEquals(5.43, MathUtil.median(doubles), EPS); + } + +} diff --git a/core/test/net/sf/openrocket/util/MutableTest.java b/core/test/net/sf/openrocket/util/MutableTest.java new file mode 100644 index 00000000..dfc02209 --- /dev/null +++ b/core/test/net/sf/openrocket/util/MutableTest.java @@ -0,0 +1,56 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; +import net.sf.openrocket.logging.TraceException; + +import org.junit.Test; + +public class MutableTest { + + @Test + public void testMutable() { + Mutable m = new Mutable(); + Throwable t = null; + + m.check(); + m.check(); + assertTrue(m.isMutable()); + + m.immute(); + + try { + m.check(); + fail(); + } catch (IllegalStateException e) { + // Success + t = e.getCause(); + assertTrue(t instanceof TraceException); + } + + m.immute(); + + try { + m.check(); + fail(); + } catch (IllegalStateException e) { + // Success + assertTrue(e.getCause() == t); + } + } + + + @Test + public void testClone() { + Mutable m1 = new Mutable(); + Mutable m2 = m1.clone(); + + assertTrue(m1.isMutable()); + assertTrue(m2.isMutable()); + + m1.immute(); + + assertFalse(m1.isMutable()); + assertTrue(m2.isMutable()); + } + +} diff --git a/core/test/net/sf/openrocket/util/ReflectionTest.java b/core/test/net/sf/openrocket/util/ReflectionTest.java new file mode 100644 index 00000000..9f7c10ed --- /dev/null +++ b/core/test/net/sf/openrocket/util/ReflectionTest.java @@ -0,0 +1,50 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import org.junit.Test; + +public class ReflectionTest { + + @Test + public void textHandleInvocationTargetException() { + Throwable cause = null; + + try { + cause = new InvocationTargetException(null); + Reflection.handleWrappedException((InvocationTargetException)cause); + fail(); + } catch (BugException e) { + assertTrue(cause == e.getCause()); + } + + try { + cause = new IllegalStateException("Test"); + Reflection.handleWrappedException(new InvocationTargetException(cause)); + fail(); + } catch (IllegalStateException e) { + assertTrue(cause == e); + } + + try { + cause = new AbstractMethodError(); + Reflection.handleWrappedException(new InvocationTargetException(cause)); + fail(); + } catch (AbstractMethodError e) { + assertTrue(cause == e); + } + + try { + cause = new IOException(); + Reflection.handleWrappedException(new InvocationTargetException(cause)); + fail(); + } catch (BugException e) { + assertTrue(cause == e.getCause()); + } + + } + +} diff --git a/core/test/net/sf/openrocket/util/Rotation2DTest.java b/core/test/net/sf/openrocket/util/Rotation2DTest.java new file mode 100644 index 00000000..6cc6d91f --- /dev/null +++ b/core/test/net/sf/openrocket/util/Rotation2DTest.java @@ -0,0 +1,31 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class Rotation2DTest { + + @Test + public void rotationTest() { + + double rot60 = 0.5; + double rot30 = Math.sqrt(3)/2; + + Coordinate x = new Coordinate(1,1,0); + Coordinate y = new Coordinate(0,1,1); + + Rotation2D rot = new Rotation2D(Math.PI/3); // 60 deg + + assertEquals(new Coordinate(rot60, 1, -rot30), rot.rotateY(x)); + assertEquals(new Coordinate(rot60, 1, rot30), rot.invRotateY(x)); + + assertEquals(new Coordinate(1, rot60, rot30), rot.rotateX(x)); + assertEquals(new Coordinate(1, rot60, -rot30), rot.invRotateX(x)); + + assertEquals(new Coordinate(-rot30, rot60, 1), rot.rotateZ(y)); + assertEquals(new Coordinate(rot30, rot60, 1), rot.invRotateZ(y)); + + } + +} diff --git a/core/test/net/sf/openrocket/util/TestMutex.java b/core/test/net/sf/openrocket/util/TestMutex.java new file mode 100644 index 00000000..94d5a9f5 --- /dev/null +++ b/core/test/net/sf/openrocket/util/TestMutex.java @@ -0,0 +1,175 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class TestMutex { + + @Before + public void setup() { + System.setProperty("openrocket.debug.safetycheck", "true"); + } + + @Test + public void testSingleLocking() { + SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); + + // Test single locking + assertNull(m.lockingThread); + m.verify(); + m.lock("here"); + assertNotNull(m.lockingThread); + assertTrue(m.unlock("here")); + + } + + @Test + public void testDoubleLocking() { + SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); + + // Test double locking + m.verify(); + m.lock("foobar"); + m.verify(); + m.lock("bazqux"); + m.verify(); + assertTrue(m.unlock("bazqux")); + m.verify(); + assertTrue(m.unlock("foobar")); + m.verify(); + } + + @Test + public void testDoubleUnlocking() { + SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); + // Mark error reported to not init exception handler + SafetyMutex.ConcreteSafetyMutex.errorReported = true; + + m.lock("here"); + assertTrue(m.unlock("here")); + assertFalse(m.unlock("here")); + } + + + + private volatile int testState = 0; + private volatile String failure = null; + + @Test(timeout = 1000) + public void testThreadingErrors() { + final SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); + + // Initialize and start the thread + Thread thread = new Thread() { + @Override + public void run() { + try { + + // Test locking a locked mutex + waitFor(1); + try { + m.lock("in thread one"); + failure = "Succeeded in locking a mutex locked by a different thread"; + return; + } catch (ConcurrencyException e) { + // OK + } + + // Test unlocking a mutex locked by a different thread + if (m.unlock("in thread two")) { + failure = "Succeeded in unlocking a mutex locked by a different thread"; + return; + } + + // Test verifying a locked mutex that already has an error + try { + m.verify(); + failure = "Succeeded in verifying a mutex locked by a different thread"; + return; + } catch (ConcurrencyException e) { + // OK + } + + // Test locking a mutex after it's been unlocked + testState = 2; + waitFor(3); + m.lock("in thread three"); + m.verify(); + + // Wait for other side to test + testState = 4; + waitFor(5); + + // Exit code + testState = 6; + + } catch (Exception e) { + failure = "Exception occurred in thread: " + e; + return; + } + + } + }; + thread.setDaemon(true); + thread.start(); + + m.lock("one"); + testState = 1; + + waitFor(2); + assertNull("Thread error: " + failure, failure); + + m.verify(); + m.unlock("one"); + testState = 3; + + waitFor(4); + assertNull("Thread error: " + failure, failure); + + try { + m.lock("two"); + fail("Succeeded in locking a locked mutex in main thread"); + } catch (ConcurrencyException e) { + // OK + } + + // Test unlocking a mutex locked by a different thread + assertFalse(m.unlock("here")); + + try { + m.verify(); + fail("Succeeded in verifying a locked mutex in main thread"); + } catch (ConcurrencyException e) { + // OK + } + + testState = 5; + waitFor(6); + assertNull("Thread error: " + failure, failure); + } + + private void waitFor(int state) { + while (testState != state && failure == null) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + } + } + + + public void testBogusMutex() { + SafetyMutex m = new SafetyMutex.BogusSafetyMutex(); + m.lock("foo"); + m.lock("bar"); + m.lock("baz"); + m.verify(); + m.unlock("a"); + m.unlock(null); + m.unlock(""); + m.unlock("c"); + } + +} diff --git a/core/test/net/sf/openrocket/util/TextUtilTest.java b/core/test/net/sf/openrocket/util/TextUtilTest.java new file mode 100644 index 00000000..8ac8319d --- /dev/null +++ b/core/test/net/sf/openrocket/util/TextUtilTest.java @@ -0,0 +1,258 @@ +package net.sf.openrocket.util; + +import static java.lang.Math.PI; +import static org.junit.Assert.assertEquals; + +import java.util.Random; + +import org.junit.Test; + +public class TextUtilTest { + + @Test + public void testHexString() { + assertEquals("", TextUtil.hexString(new byte[0])); + assertEquals("00", TextUtil.hexString(new byte[] { 0x00 })); + assertEquals("ff", TextUtil.hexString(new byte[] { (byte) 0xff })); + + for (int i = 0; i <= 0xff; i++) { + assertEquals(String.format("%02x", i), TextUtil.hexString(new byte[] { (byte) i })); + } + + assertEquals("0f1e2d3c4b5a6978", TextUtil.hexString(new byte[] { + 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78 + })); + + Random rnd = new Random(); + for (int count = 0; count < 10; count++) { + int n = rnd.nextInt(100); + byte[] bytes = new byte[n]; + rnd.nextBytes(bytes); + StringBuilder sb = new StringBuilder(); + for (byte b : bytes) { + sb.append(String.format("%02x", b & 0xFF)); + } + assertEquals(sb.toString(), TextUtil.hexString(bytes)); + } + } + + @Test + public void specialCaseTest() { + assertEquals("NaN", TextUtil.doubleToString(Double.NaN)); + assertEquals("Inf", TextUtil.doubleToString(Double.POSITIVE_INFINITY)); + assertEquals("-Inf", TextUtil.doubleToString(Double.NEGATIVE_INFINITY)); + assertEquals("0", TextUtil.doubleToString(0.0)); + assertEquals("0", TextUtil.doubleToString(MathUtil.EPSILON / 3)); + assertEquals("0", TextUtil.doubleToString(-MathUtil.EPSILON / 3)); + } + + @Test + public void longTest() { + + assertEquals("3.1416e-5", TextUtil.doubleToString(PI * 1e-5)); + assertEquals("3.1416e-4", TextUtil.doubleToString(PI * 1e-4)); + assertEquals("0.0031416", TextUtil.doubleToString(PI * 1e-3)); + assertEquals("0.031416", TextUtil.doubleToString(PI * 1e-2)); + assertEquals("0.31416", TextUtil.doubleToString(PI * 1e-1)); + assertEquals("3.1416", TextUtil.doubleToString(PI)); + assertEquals("31.416", TextUtil.doubleToString(PI * 1e1)); + assertEquals("314.16", TextUtil.doubleToString(PI * 1e2)); + assertEquals("3141.6", TextUtil.doubleToString(PI * 1e3)); + assertEquals("31416", TextUtil.doubleToString(PI * 1e4)); + assertEquals("314159", TextUtil.doubleToString(PI * 1e5)); + assertEquals("3141593", TextUtil.doubleToString(PI * 1e6)); + assertEquals("31415927", TextUtil.doubleToString(PI * 1e7)); + assertEquals("3.1416e8", TextUtil.doubleToString(PI * 1e8)); + assertEquals("3.1416e9", TextUtil.doubleToString(PI * 1e9)); + assertEquals("3.1416e10", TextUtil.doubleToString(PI * 1e10)); + + assertEquals("-3.1416e-5", TextUtil.doubleToString(-PI * 1e-5)); + assertEquals("-3.1416e-4", TextUtil.doubleToString(-PI * 1e-4)); + assertEquals("-0.0031416", TextUtil.doubleToString(-PI * 1e-3)); + assertEquals("-0.031416", TextUtil.doubleToString(-PI * 1e-2)); + assertEquals("-0.31416", TextUtil.doubleToString(-PI * 1e-1)); + assertEquals("-3.1416", TextUtil.doubleToString(-PI)); + assertEquals("-31.416", TextUtil.doubleToString(-PI * 1e1)); + assertEquals("-314.16", TextUtil.doubleToString(-PI * 1e2)); + assertEquals("-3141.6", TextUtil.doubleToString(-PI * 1e3)); + assertEquals("-31416", TextUtil.doubleToString(-PI * 1e4)); + assertEquals("-314159", TextUtil.doubleToString(-PI * 1e5)); + assertEquals("-3141593", TextUtil.doubleToString(-PI * 1e6)); + assertEquals("-31415927", TextUtil.doubleToString(-PI * 1e7)); + assertEquals("-3.1416e8", TextUtil.doubleToString(-PI * 1e8)); + assertEquals("-3.1416e9", TextUtil.doubleToString(-PI * 1e9)); + assertEquals("-3.1416e10", TextUtil.doubleToString(-PI * 1e10)); + + } + + @Test + public void shortTest() { + double p = 3.1; + assertEquals("3.1e-5", TextUtil.doubleToString(p * 1e-5)); + assertEquals("3.1e-4", TextUtil.doubleToString(p * 1e-4)); + assertEquals("0.0031", TextUtil.doubleToString(p * 1e-3)); + assertEquals("0.031", TextUtil.doubleToString(p * 1e-2)); + assertEquals("0.31", TextUtil.doubleToString(p * 1e-1)); + assertEquals("3.1", TextUtil.doubleToString(p)); + assertEquals("31", TextUtil.doubleToString(p * 1e1)); + assertEquals("310", TextUtil.doubleToString(p * 1e2)); + assertEquals("3100", TextUtil.doubleToString(p * 1e3)); + assertEquals("31000", TextUtil.doubleToString(p * 1e4)); + assertEquals("3.1e5", TextUtil.doubleToString(p * 1e5)); + assertEquals("3.1e6", TextUtil.doubleToString(p * 1e6)); + assertEquals("3.1e7", TextUtil.doubleToString(p * 1e7)); + assertEquals("3.1e8", TextUtil.doubleToString(p * 1e8)); + assertEquals("3.1e9", TextUtil.doubleToString(p * 1e9)); + assertEquals("3.1e10", TextUtil.doubleToString(p * 1e10)); + + assertEquals("-3.1e-5", TextUtil.doubleToString(-p * 1e-5)); + assertEquals("-3.1e-4", TextUtil.doubleToString(-p * 1e-4)); + assertEquals("-0.0031", TextUtil.doubleToString(-p * 1e-3)); + assertEquals("-0.031", TextUtil.doubleToString(-p * 1e-2)); + assertEquals("-0.31", TextUtil.doubleToString(-p * 1e-1)); + assertEquals("-3.1", TextUtil.doubleToString(-p)); + assertEquals("-31", TextUtil.doubleToString(-p * 1e1)); + assertEquals("-310", TextUtil.doubleToString(-p * 1e2)); + assertEquals("-3100", TextUtil.doubleToString(-p * 1e3)); + assertEquals("-31000", TextUtil.doubleToString(-p * 1e4)); + assertEquals("-3.1e5", TextUtil.doubleToString(-p * 1e5)); + assertEquals("-3.1e6", TextUtil.doubleToString(-p * 1e6)); + assertEquals("-3.1e7", TextUtil.doubleToString(-p * 1e7)); + assertEquals("-3.1e8", TextUtil.doubleToString(-p * 1e8)); + assertEquals("-3.1e9", TextUtil.doubleToString(-p * 1e9)); + assertEquals("-3.1e10", TextUtil.doubleToString(-p * 1e10)); + + p = 3; + assertEquals("3e-5", TextUtil.doubleToString(p * 1e-5)); + assertEquals("3e-4", TextUtil.doubleToString(p * 1e-4)); + assertEquals("3e-3", TextUtil.doubleToString(p * 1e-3)); + assertEquals("0.03", TextUtil.doubleToString(p * 1e-2)); + assertEquals("0.3", TextUtil.doubleToString(p * 1e-1)); + assertEquals("3", TextUtil.doubleToString(p)); + assertEquals("30", TextUtil.doubleToString(p * 1e1)); + assertEquals("300", TextUtil.doubleToString(p * 1e2)); + assertEquals("3e3", TextUtil.doubleToString(p * 1e3)); + assertEquals("3e4", TextUtil.doubleToString(p * 1e4)); + assertEquals("3e5", TextUtil.doubleToString(p * 1e5)); + assertEquals("3e6", TextUtil.doubleToString(p * 1e6)); + assertEquals("3e7", TextUtil.doubleToString(p * 1e7)); + assertEquals("3e8", TextUtil.doubleToString(p * 1e8)); + assertEquals("3e9", TextUtil.doubleToString(p * 1e9)); + assertEquals("3e10", TextUtil.doubleToString(p * 1e10)); + + assertEquals("-3e-5", TextUtil.doubleToString(-p * 1e-5)); + assertEquals("-3e-4", TextUtil.doubleToString(-p * 1e-4)); + assertEquals("-3e-3", TextUtil.doubleToString(-p * 1e-3)); + assertEquals("-0.03", TextUtil.doubleToString(-p * 1e-2)); + assertEquals("-0.3", TextUtil.doubleToString(-p * 1e-1)); + assertEquals("-3", TextUtil.doubleToString(-p)); + assertEquals("-30", TextUtil.doubleToString(-p * 1e1)); + assertEquals("-300", TextUtil.doubleToString(-p * 1e2)); + assertEquals("-3e3", TextUtil.doubleToString(-p * 1e3)); + assertEquals("-3e4", TextUtil.doubleToString(-p * 1e4)); + assertEquals("-3e5", TextUtil.doubleToString(-p * 1e5)); + assertEquals("-3e6", TextUtil.doubleToString(-p * 1e6)); + assertEquals("-3e7", TextUtil.doubleToString(-p * 1e7)); + assertEquals("-3e8", TextUtil.doubleToString(-p * 1e8)); + assertEquals("-3e9", TextUtil.doubleToString(-p * 1e9)); + assertEquals("-3e10", TextUtil.doubleToString(-p * 1e10)); + + } + + @Test + public void roundingTest() { + + assertEquals("1.001", TextUtil.doubleToString(1.00096)); + + + /* + * Not testing with 1.00015 because it might be changed during number formatting + * calculations. Its rounding is basically arbitrary anyway. + */ + + assertEquals("1.0002e-5", TextUtil.doubleToString(1.0001500001e-5)); + assertEquals("1.0001e-5", TextUtil.doubleToString(1.0001499999e-5)); + assertEquals("1.0002e-4", TextUtil.doubleToString(1.0001500001e-4)); + assertEquals("1.0001e-4", TextUtil.doubleToString(1.0001499999e-4)); + assertEquals("0.0010002", TextUtil.doubleToString(1.0001500001e-3)); + assertEquals("0.0010001", TextUtil.doubleToString(1.0001499999e-3)); + assertEquals("0.010002", TextUtil.doubleToString(1.0001500001e-2)); + assertEquals("0.010001", TextUtil.doubleToString(1.0001499999e-2)); + assertEquals("0.10002", TextUtil.doubleToString(1.0001500001e-1)); + assertEquals("0.10001", TextUtil.doubleToString(1.0001499999e-1)); + assertEquals("1.0002", TextUtil.doubleToString(1.0001500001)); + assertEquals("1.0001", TextUtil.doubleToString(1.0001499999)); + assertEquals("10.002", TextUtil.doubleToString(1.0001500001e1)); + assertEquals("10.001", TextUtil.doubleToString(1.0001499999e1)); + assertEquals("100.02", TextUtil.doubleToString(1.0001500001e2)); + assertEquals("100.01", TextUtil.doubleToString(1.0001499999e2)); + assertEquals("1000.2", TextUtil.doubleToString(1.0001500001e3)); + assertEquals("1000.1", TextUtil.doubleToString(1.0001499999e3)); + assertEquals("10002", TextUtil.doubleToString(1.0001500001e4)); + assertEquals("10001", TextUtil.doubleToString(1.0001499999e4)); + assertEquals("100012", TextUtil.doubleToString(1.00011500001e5)); + assertEquals("100011", TextUtil.doubleToString(1.00011499999e5)); + assertEquals("1000112", TextUtil.doubleToString(1.000111500001e6)); + assertEquals("1000111", TextUtil.doubleToString(1.000111499999e6)); + assertEquals("10001112", TextUtil.doubleToString(1.0001111500001e7)); + assertEquals("10001111", TextUtil.doubleToString(1.0001111499999e7)); + assertEquals("1.0002e8", TextUtil.doubleToString(1.0001500001e8)); + assertEquals("1.0001e8", TextUtil.doubleToString(1.0001499999e8)); + assertEquals("1.0002e9", TextUtil.doubleToString(1.0001500001e9)); + assertEquals("1.0001e9", TextUtil.doubleToString(1.0001499999e9)); + assertEquals("1.0002e10", TextUtil.doubleToString(1.0001500001e10)); + assertEquals("1.0001e10", TextUtil.doubleToString(1.0001499999e10)); + + + assertEquals("-1.0002e-5", TextUtil.doubleToString(-1.0001500001e-5)); + assertEquals("-1.0001e-5", TextUtil.doubleToString(-1.0001499999e-5)); + assertEquals("-1.0002e-4", TextUtil.doubleToString(-1.0001500001e-4)); + assertEquals("-1.0001e-4", TextUtil.doubleToString(-1.0001499999e-4)); + assertEquals("-0.0010002", TextUtil.doubleToString(-1.0001500001e-3)); + assertEquals("-0.0010001", TextUtil.doubleToString(-1.0001499999e-3)); + assertEquals("-0.010002", TextUtil.doubleToString(-1.0001500001e-2)); + assertEquals("-0.010001", TextUtil.doubleToString(-1.0001499999e-2)); + assertEquals("-0.10002", TextUtil.doubleToString(-1.0001500001e-1)); + assertEquals("-0.10001", TextUtil.doubleToString(-1.0001499999e-1)); + assertEquals("-1.0002", TextUtil.doubleToString(-1.0001500001)); + assertEquals("-1.0001", TextUtil.doubleToString(-1.0001499999)); + assertEquals("-10.002", TextUtil.doubleToString(-1.0001500001e1)); + assertEquals("-10.001", TextUtil.doubleToString(-1.0001499999e1)); + assertEquals("-100.02", TextUtil.doubleToString(-1.0001500001e2)); + assertEquals("-100.01", TextUtil.doubleToString(-1.0001499999e2)); + assertEquals("-1000.2", TextUtil.doubleToString(-1.0001500001e3)); + assertEquals("-1000.1", TextUtil.doubleToString(-1.0001499999e3)); + assertEquals("-10002", TextUtil.doubleToString(-1.0001500001e4)); + assertEquals("-10001", TextUtil.doubleToString(-1.0001499999e4)); + assertEquals("-100012", TextUtil.doubleToString(-1.00011500001e5)); + assertEquals("-100011", TextUtil.doubleToString(-1.00011499999e5)); + assertEquals("-1000112", TextUtil.doubleToString(-1.000111500001e6)); + assertEquals("-1000111", TextUtil.doubleToString(-1.000111499999e6)); + assertEquals("-10001112", TextUtil.doubleToString(-1.0001111500001e7)); + assertEquals("-10001111", TextUtil.doubleToString(-1.0001111499999e7)); + assertEquals("-1.0002e8", TextUtil.doubleToString(-1.0001500001e8)); + assertEquals("-1.0001e8", TextUtil.doubleToString(-1.0001499999e8)); + assertEquals("-1.0002e9", TextUtil.doubleToString(-1.0001500001e9)); + assertEquals("-1.0001e9", TextUtil.doubleToString(-1.0001499999e9)); + assertEquals("-1.0002e10", TextUtil.doubleToString(-1.0001500001e10)); + assertEquals("-1.0001e10", TextUtil.doubleToString(-1.0001499999e10)); + + } + + + @Test + public void randomTest() { + for (int i = 0; i < 10000; i++) { + double orig = Math.random(); + double result; + double expected = Math.rint(orig * 100000) / 100000.0; + + if (orig < 0.1) + continue; + String s = TextUtil.doubleToString(orig); + result = Double.parseDouble(s); + assertEquals(expected, result, 0.00000001); + } + } + +} diff --git a/core/test/net/sf/openrocket/util/UniqueIDTest.java b/core/test/net/sf/openrocket/util/UniqueIDTest.java new file mode 100644 index 00000000..c77da324 --- /dev/null +++ b/core/test/net/sf/openrocket/util/UniqueIDTest.java @@ -0,0 +1,29 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class UniqueIDTest { + + @Test + public void integerTest() { + + int n = UniqueID.next(); + assertTrue(n > 0); + assertEquals(n+1, UniqueID.next()); + assertEquals(n+2, UniqueID.next()); + assertEquals(n+3, UniqueID.next()); + + } + + + @Test + public void stringTest() { + String id = UniqueID.uuid(); + assertNotNull(id); + assertNotSame(id, UniqueID.uuid()); + assertNotSame(id, UniqueID.uuid()); + } + +} diff --git a/core/test/net/sf/openrocket/util/WorldCoordinateTest.java b/core/test/net/sf/openrocket/util/WorldCoordinateTest.java new file mode 100644 index 00000000..ce67dc11 --- /dev/null +++ b/core/test/net/sf/openrocket/util/WorldCoordinateTest.java @@ -0,0 +1,47 @@ +package net.sf.openrocket.util; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class WorldCoordinateTest { + + private static final double EPS = 1e-10; + + @Test + public void testConstructor() { + WorldCoordinate wc; + + wc = new WorldCoordinate(10, 15, 130); + assertEquals(10, wc.getLatitudeDeg(), EPS); + assertEquals(15, wc.getLongitudeDeg(), EPS); + assertEquals(130, wc.getAltitude(), 0); + + wc = new WorldCoordinate(100, 190, 13000); + assertEquals(90, wc.getLatitudeDeg(), EPS); + assertEquals(-170, wc.getLongitudeDeg(), EPS); + assertEquals(13000, wc.getAltitude(), 0); + + wc = new WorldCoordinate(-100, -200, -13000); + assertEquals(-90, wc.getLatitudeDeg(), EPS); + assertEquals(160, wc.getLongitudeDeg(), EPS); + assertEquals(-13000, wc.getAltitude(), 0); + } + + @Test + public void testGetLatitude() { + WorldCoordinate wc; + wc = new WorldCoordinate(10, 15, 130); + assertEquals(10, wc.getLatitudeDeg(), EPS); + assertEquals(Math.toRadians(10), wc.getLatitudeRad(), EPS); + } + + @Test + public void testGetLongitude() { + WorldCoordinate wc; + wc = new WorldCoordinate(10, 15, 130); + assertEquals(15, wc.getLongitudeDeg(), EPS); + assertEquals(Math.toRadians(15), wc.getLongitudeRad(), EPS); + } + +} diff --git a/test/net/sf/openrocket/Estes_A8.rse b/test/net/sf/openrocket/Estes_A8.rse deleted file mode 100644 index 1098ffe1..00000000 --- a/test/net/sf/openrocket/Estes_A8.rse +++ /dev/null @@ -1,40 +0,0 @@ - - - -Estes A8 RASP.ENG file made from NAR published data -File produced October 3, 2000 -The total impulse, peak thrust, average thrust and burn time are -the same as the averaged static test data on the NAR web site in -the certification file. The curve drawn with these data points is as -close to the certification curve as can be with such a limited -number of points (32) allowed with wRASP up to v1.6. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/net/sf/openrocket/IntegrationTest.java b/test/net/sf/openrocket/IntegrationTest.java deleted file mode 100644 index af73af34..00000000 --- a/test/net/sf/openrocket/IntegrationTest.java +++ /dev/null @@ -1,325 +0,0 @@ -package net.sf.openrocket; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.awt.event.ActionEvent; -import java.io.IOException; -import java.io.InputStream; - -import javax.swing.Action; - -import net.sf.openrocket.aerodynamics.AerodynamicCalculator; -import net.sf.openrocket.aerodynamics.BarrowmanCalculator; -import net.sf.openrocket.aerodynamics.FlightConditions; -import net.sf.openrocket.database.ThrustCurveMotorSetDatabase; -import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.document.Simulation; -import net.sf.openrocket.file.GeneralRocketLoader; -import net.sf.openrocket.file.RocketLoadException; -import net.sf.openrocket.file.motor.GeneralMotorLoader; -import net.sf.openrocket.gui.main.UndoRedoAction; -import net.sf.openrocket.l10n.ResourceBundleTranslator; -import net.sf.openrocket.masscalc.BasicMassCalculator; -import net.sf.openrocket.masscalc.MassCalculator; -import net.sf.openrocket.masscalc.MassCalculator.MassCalcType; -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.ThrustCurveMotor; -import net.sf.openrocket.rocketcomponent.Configuration; -import net.sf.openrocket.rocketcomponent.EngineBlock; -import net.sf.openrocket.rocketcomponent.MassComponent; -import net.sf.openrocket.rocketcomponent.NoseCone; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.simulation.FlightDataType; -import net.sf.openrocket.simulation.exception.SimulationException; -import net.sf.openrocket.startup.Application; -import net.sf.openrocket.util.Coordinate; -import net.sf.openrocket.util.BaseTestCase.BaseTestCase; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * This class contains various integration tests that simulate user actions that - * might be performed. - */ -public class IntegrationTest extends BaseTestCase { - - private OpenRocketDocument document; - private Action undoAction, redoAction; - - private AerodynamicCalculator aeroCalc = new BarrowmanCalculator(); - private MassCalculator massCalc = new BasicMassCalculator(); - private Configuration config; - private FlightConditions conditions; - - - @BeforeClass - public static void initialize() { - ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(false) { - @Override - protected void loadMotors() { - GeneralMotorLoader loader = new GeneralMotorLoader(); - InputStream is = this.getClass().getResourceAsStream("Estes_A8.rse"); - assertNotNull("Problem in unit test, cannot find Estes_A8.rse", is); - try { - for (Motor m : loader.load(is, "Estes_A8.rse")) { - addMotor((ThrustCurveMotor) m); - } - is.close(); - } catch (IOException e) { - e.printStackTrace(); - fail("IOException: " + e); - } - } - }; - db.startLoading(); - assertEquals(1, db.getMotorSets().size()); - Application.setMotorSetDatabase(db); - Application.setBaseTranslator(new ResourceBundleTranslator("l10n.messages")); - } - - /** - * Tests loading a rocket design, modifying it, simulating it and the undo/redo - * mechanism in various combinations. - */ - @Test - public void test1() throws RocketLoadException, IOException, SimulationException { - System.setProperty("openrocket.unittest", "true"); - - // Load the rocket - GeneralRocketLoader loader = new GeneralRocketLoader(); - InputStream is = this.getClass().getResourceAsStream("simplerocket.ork"); - assertNotNull("Problem in unit test, cannot find simplerocket.ork", is); - document = loader.load(is); - is.close(); - - undoAction = UndoRedoAction.newUndoAction(document ); - redoAction = UndoRedoAction.newRedoAction(document); - config = document.getSimulation(0).getConfiguration(); - conditions = new FlightConditions(config); - - - // Test undo state - checkUndoState(null, null); - - - // Compute cg+cp + altitude - checkCgCp(0.248, 0.0645, 0.320, 12.0); - checkAlt(48.2); - - - // Mass modification - document.addUndoPosition("Modify mass"); - checkUndoState(null, null); - massComponent().setComponentMass(0.01); - checkUndoState("Modify mass", null); - - - // Check cg+cp + altitude - checkCgCp(0.230, 0.0745, 0.320, 12.0); - checkAlt(37.2); - - - // Non-change - document.addUndoPosition("No change"); - checkUndoState("Modify mass", null); - - - // Non-funcitonal change - document.addUndoPosition("Name change"); - checkUndoState("Modify mass", null); - massComponent().setName("Foobar component"); - checkUndoState("Name change", null); - - - // Check cg+cp - checkCgCp(0.230, 0.0745, 0.320, 12.0); - - - // Aerodynamic modification - document.addUndoPosition("Remove component"); - checkUndoState("Name change", null); - document.getRocket().getChild(0).removeChild(0); - checkUndoState("Remove component", null); - - - // Check cg+cp + altitude - checkCgCp(0.163, 0.0613, 0.275, 9.95); - checkAlt(45.0); - - - // Undo "Remove component" change - undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertTrue(document.getRocket().getChild(0).getChild(0) instanceof NoseCone); - checkUndoState("Name change", "Remove component"); - - - // Check cg+cp + altitude - checkCgCp(0.230, 0.0745, 0.320, 12.0); - checkAlt(37.2); - - - // Undo "Name change" change - undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertEquals("Extra mass", massComponent().getName()); - checkUndoState("Modify mass", "Name change"); - - - // Check cg+cp - checkCgCp(0.230, 0.0745, 0.320, 12.0); - - - // Undo "Modify mass" change - undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertEquals(0, massComponent().getComponentMass(), 0); - checkUndoState(null, "Modify mass"); - - - // Check cg+cp + altitude - checkCgCp(0.248, 0.0645, 0.320, 12.0); - checkAlt(48.2); - - - // Redo "Modify mass" change - redoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertEquals(0.010, massComponent().getComponentMass(), 0.00001); - checkUndoState("Modify mass", "Name change"); - - - // Check cg+cp + altitude - checkCgCp(0.230, 0.0745, 0.320, 12.0); - checkAlt(37.2); - - - // Mass modification - document.addUndoPosition("Modify mass2"); - checkUndoState("Modify mass", "Name change"); - massComponent().setComponentMass(0.015); - checkUndoState("Modify mass2", null); - - - // Check cg+cp + altitude - checkCgCp(0.223, 0.0795, 0.320, 12.0); - checkAlt(32.7); - - - // Perform component movement - document.startUndo("Move component"); - document.getRocket().freeze(); - RocketComponent bodytube = document.getRocket().getChild(0).getChild(1); - RocketComponent innertube = bodytube.getChild(2); - RocketComponent engineblock = innertube.getChild(0); - assertTrue(innertube.removeChild(engineblock)); - bodytube.addChild(engineblock, 0); - checkUndoState("Modify mass2", null); - document.getRocket().thaw(); - checkUndoState("Move component", null); - document.stopUndo(); - - - // Check cg+cp + altitude - checkCgCp(0.221, 0.0797, 0.320, 12.0); - checkAlt(32.7); - - - // Modify mass without setting undo description - massComponent().setComponentMass(0.020); - checkUndoState("Modify mass2", null); - - - // Check cg+cp + altitude - checkCgCp(0.215, 0.0847, 0.320, 12.0); - checkAlt(29.0); - - - // Undo "Modify mass2" change - undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertEquals(0.015, massComponent().getComponentMass(), 0.0000001); - checkUndoState("Move component", "Modify mass2"); - - - // Check cg+cp + altitude - checkCgCp(0.221, 0.0797, 0.320, 12.0); - checkAlt(32.7); - - - // Undo "Move component" change - undoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertTrue(document.getRocket().getChild(0).getChild(1).getChild(2).getChild(0) instanceof EngineBlock); - checkUndoState("Modify mass2", "Move component"); - - - // Check cg+cp + altitude - checkCgCp(0.223, 0.0795, 0.320, 12.0); - checkAlt(32.7); - - - // Redo "Move component" change - redoAction.actionPerformed(new ActionEvent(this, 0, "foo")); - assertTrue(document.getRocket().getChild(0).getChild(1).getChild(0) instanceof EngineBlock); - checkUndoState("Move component", "Modify mass2"); - - - // Check cg+cp + altitude - checkCgCp(0.221, 0.0797, 0.320, 12.0); - checkAlt(32.7); - - - } - - private String massComponentID = null; - - private MassComponent massComponent() { - if (massComponentID == null) { - massComponentID = document.getRocket().getChild(0).getChild(1).getChild(0).getID(); - } - return (MassComponent) document.getRocket().findComponent(massComponentID); - } - - - private void checkUndoState(String undoDesc, String redoDesc) { - if (undoDesc == null) { - assertEquals("Undo", undoAction.getValue(Action.NAME)); - assertFalse(undoAction.isEnabled()); - } else { - assertEquals("Undo (" + undoDesc + ")", undoAction.getValue(Action.NAME)); - assertTrue(undoAction.isEnabled()); - } - if (redoDesc == null) { - assertEquals("Redo", redoAction.getValue(Action.NAME)); - assertFalse(redoAction.isEnabled()); - } else { - assertEquals("Redo (" + redoDesc + ")", redoAction.getValue(Action.NAME)); - assertTrue(redoAction.isEnabled()); - } - } - - - private void checkCgCp(double cgx, double mass, double cpx, double cna) { - Coordinate cg, cp; - - cg = massCalc.getCG(config, MassCalcType.LAUNCH_MASS); - assertEquals(cgx, cg.x, 0.001); - assertEquals(mass, cg.weight, 0.0005); - - cp = aeroCalc.getWorstCP(config, conditions, null); - assertEquals(cpx, cp.x, 0.001); - assertEquals(cna, cp.weight, 0.1); - } - - - private void checkAlt(double expected) throws SimulationException { - Simulation simulation = document.getSimulation(0); - double actual; - - // Simulate + check altitude - simulation.simulate(); - actual = simulation.getSimulatedData().getBranch(0).getMaximum(FlightDataType.TYPE_ALTITUDE); - assertEquals(expected, actual, 0.5); - } - -} diff --git a/test/net/sf/openrocket/arch/TestSystemInfo.java b/test/net/sf/openrocket/arch/TestSystemInfo.java deleted file mode 100644 index 80c65584..00000000 --- a/test/net/sf/openrocket/arch/TestSystemInfo.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.sf.openrocket.arch; - -import static org.junit.Assert.assertEquals; - -import java.io.File; - -import org.junit.Test; - -/* - * Note: These tests have not been tested on Windows, they might fail there - * due to a different directory separator character. - */ -public class TestSystemInfo { - - private String osname; - private String userhome; - - - public void setup() { - this.osname = System.getProperty("os.name"); - this.userhome = System.getProperty("user.home"); - } - - public void tearDown() { - System.setProperty("os.name", this.osname); - System.setProperty("user.home", this.userhome); - } - - @Test - public void testWindows() { - setup(); - - System.setProperty("os.name", "Windows Me"); - System.setProperty("user.home", "C:/Users/my user"); - assertEquals(SystemInfo.Platform.WINDOWS, SystemInfo.getPlatform()); - if (System.getenv("APPDATA") != null) { - assertEquals(new File(System.getenv("APPDATA") + "/OpenRocket/"), SystemInfo.getUserApplicationDirectory()); - } else { - assertEquals(new File("C:/Users/my user/OpenRocket/"), SystemInfo.getUserApplicationDirectory()); - } - - tearDown(); - } - - @Test - public void testMacOS() { - setup(); - - System.setProperty("os.name", "Mac OS X"); - System.setProperty("user.home", "/Users/My User"); - assertEquals(SystemInfo.Platform.MAC_OS, SystemInfo.getPlatform()); - assertEquals(new File("/Users/My User/Library/Application Support/OpenRocket/"), - SystemInfo.getUserApplicationDirectory()); - - tearDown(); - } - - @Test - public void testUnix() { - setup(); - - System.setProperty("user.home", "/home/myuser"); - for (String os : new String[] { "Linux", "Solaris", "Foobar" }) { - System.setProperty("os.name", os); - - assertEquals(SystemInfo.Platform.UNIX, SystemInfo.getPlatform()); - assertEquals(new File("/home/myuser/.openrocket"), SystemInfo.getUserApplicationDirectory()); - } - - tearDown(); - } - -} diff --git a/test/net/sf/openrocket/communication/BugReportTest.java b/test/net/sf/openrocket/communication/BugReportTest.java deleted file mode 100644 index e178ec7f..00000000 --- a/test/net/sf/openrocket/communication/BugReportTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.sf.openrocket.communication; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; - -import net.sf.openrocket.util.BuildProperties; - -import org.junit.Test; - - -public class BugReportTest { - - private HttpURLConnectionMock setup() { - HttpURLConnectionMock connection = new HttpURLConnectionMock(); - Communicator.setConnectionSource(new ConnectionSourceStub(connection)); - - connection.setUseCaches(true); - return connection; - } - - private void check(HttpURLConnectionMock connection) { - assertEquals(Communicator.BUG_REPORT_URL, connection.getTrueUrl()); - assertTrue(connection.getConnectTimeout() > 0); - assertEquals(BuildProperties.getVersion(), connection.getRequestProperty("X-OpenRocket-Version")); - assertTrue(connection.getInstanceFollowRedirects()); - assertEquals("POST", connection.getRequestMethod()); - assertFalse(connection.getUseCaches()); - } - - - @Test - public void testBugReportSuccess() throws IOException { - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(Communicator.BUG_REPORT_RESPONSE_CODE); - - String message = - "MyMessage\n"+ - "is important\n"+ - "h\u00e4h?"; - - BugReporter.sendBugReport(message); - - check(connection); - - String msg = connection.getOutputStreamString(); - assertTrue(msg.indexOf("version=" + BuildProperties.getVersion()) >= 0); - assertTrue(msg.indexOf(Communicator.encode(message)) >= 0); - } - - - @Test - public void testBugReportFailure() throws IOException { - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(200); - - String message = - "MyMessage\n"+ - "is important\n"+ - "h\u00e4h?"; - - try { - BugReporter.sendBugReport(message); - fail("Exception did not occur"); - } catch (IOException e) { - // Success - } - - check(connection); - } - -} diff --git a/test/net/sf/openrocket/communication/ConnectionSourceStub.java b/test/net/sf/openrocket/communication/ConnectionSourceStub.java deleted file mode 100644 index 4cd5470b..00000000 --- a/test/net/sf/openrocket/communication/ConnectionSourceStub.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.sf.openrocket.communication; - -import java.io.IOException; -import java.net.HttpURLConnection; - -public class ConnectionSourceStub implements ConnectionSource { - - private final HttpURLConnection connection; - - public ConnectionSourceStub(HttpURLConnection connection) { - this.connection = connection; - } - - @Override - public HttpURLConnection getConnection(String url) throws IOException { - if (connection instanceof HttpURLConnectionMock) { - ((HttpURLConnectionMock)connection).setTrueUrl(url); - } - return connection; - } - -} diff --git a/test/net/sf/openrocket/communication/HttpURLConnectionMock.java b/test/net/sf/openrocket/communication/HttpURLConnectionMock.java deleted file mode 100644 index ab5c48ab..00000000 --- a/test/net/sf/openrocket/communication/HttpURLConnectionMock.java +++ /dev/null @@ -1,550 +0,0 @@ -package net.sf.openrocket.communication; - - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.net.URL; -import java.security.Permission; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.openrocket.util.BugException; - -public class HttpURLConnectionMock extends HttpURLConnection { - - private static final URL MOCK_URL; - static { - try { - MOCK_URL = new URL("http://localhost/"); - } catch (MalformedURLException e) { - throw new BugException(e); - } - } - - private volatile boolean instanceFollowRedirects = false; - private volatile String requestMethod = ""; - private volatile int responseCode; - private Map requestProperties = new HashMap(); - private volatile int connectTimeout = -1; - private volatile String contentEncoding = ""; - - private volatile boolean doInput = false; - private volatile boolean doOutput = false; - - private volatile byte[] content = null; - private volatile String contentType = null; - private volatile boolean useCaches = false; - - - private volatile InputStream inputStream = null; - private volatile ByteArrayOutputStream outputStream = null; - - private volatile String trueUrl = null; - - - private volatile boolean connected = false; - private volatile int connectionDelay = 0; - - private volatile boolean failed = false; - - - - - public HttpURLConnectionMock() { - super(MOCK_URL); - } - - public HttpURLConnectionMock(URL u) { - super(u); - } - - - - public String getTrueUrl() { - return trueUrl; - } - - public void setTrueUrl(String url) { - assertNull(this.trueUrl); - this.trueUrl = url; - } - - - public boolean hasFailed() { - return failed; - } - - - public void setConnectionDelay(int delay) { - this.connectionDelay = delay; - } - - - - @Override - public void connect() { - if (!connected) { - try { - Thread.sleep(connectionDelay); - } catch (InterruptedException e) { - } - connected = true; - } - } - - @Override - public void disconnect() { - - } - - @Override - public boolean usingProxy() { - return false; - } - - - - - @Override - public boolean getInstanceFollowRedirects() { - return this.instanceFollowRedirects; - } - - @Override - public void setInstanceFollowRedirects(boolean followRedirects) { - assertFalse(connected); - this.instanceFollowRedirects = followRedirects; - } - - @Override - public String getRequestMethod() { - return this.requestMethod; - } - - @Override - public void setRequestMethod(String method) throws ProtocolException { - assertFalse(connected); - this.requestMethod = method; - } - - @Override - public int getResponseCode() throws IOException { - connect(); - return this.responseCode; - } - - public void setResponseCode(int code) { - this.responseCode = code; - } - - - @Override - public void addRequestProperty(String key, String value) { - assertFalse(connected); - assertFalse(this.requestProperties.containsKey(key.toLowerCase())); - this.requestProperties.put(key.toLowerCase(), value); - } - - - @Override - public void setRequestProperty(String key, String value) { - assertFalse(connected); - this.requestProperties.put(key.toLowerCase(), value); - } - - - @Override - public String getRequestProperty(String key) { - return this.requestProperties.get(key.toLowerCase()); - } - - - @Override - public int getConnectTimeout() { - return this.connectTimeout; - } - - @Override - public void setConnectTimeout(int timeout) { - assertFalse(connected); - this.connectTimeout = timeout; - } - - - - @Override - public String getContentEncoding() { - connect(); - return this.contentEncoding; - } - - public void setContentEncoding(String encoding) { - this.contentEncoding = encoding; - } - - - - @Override - public int getContentLength() { - connect(); - if (content == null) - return 0; - return content.length; - } - - public void setContent(byte[] content) { - this.content = content; - } - - public void setContent(String content) { - try { - this.content = content.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - fail("UTF-8"); - } - } - - - @Override - public String getContentType() { - connect(); - return this.contentType; - } - - public void setContentType(String type) { - this.contentType = type; - } - - - - @Override - public boolean getDoInput() { - return this.doInput; - } - - - @Override - public void setDoInput(boolean doinput) { - assertFalse(connected); - this.doInput = doinput; - } - - - @Override - public boolean getDoOutput() { - return this.doOutput; - } - - - @Override - public void setDoOutput(boolean dooutput) { - assertFalse(connected); - this.doOutput = dooutput; - } - - - @Override - public InputStream getInputStream() throws IOException { - assertTrue(doInput); - assertNull(inputStream); - assertNotNull(content); - - connect(); - inputStream = new ByteArrayInputStream(content); - return inputStream; - } - - - @Override - public OutputStream getOutputStream() throws IOException { - assertTrue(doOutput); - assertNull(outputStream); - outputStream = new ByteArrayOutputStream(); - return outputStream; - } - - public byte[] getOutputStreamData() { - return outputStream.toByteArray(); - } - - public String getOutputStreamString() { - try { - return outputStream.toString("UTF-8"); - } catch (UnsupportedEncodingException e) { - fail("UTF-8"); - return null; - } - } - - - - @Override - public void setUseCaches(boolean usecaches) { - assertFalse(connected); - this.useCaches = usecaches; - } - - - - @Override - public boolean getUseCaches() { - return this.useCaches; - } - - - - - - - - - private void assertNull(Object o) { - try { - org.junit.Assert.assertNull(o); - } catch (AssertionError e) { - failed = true; - throw e; - } - } - - private void assertNotNull(Object o) { - try { - org.junit.Assert.assertNotNull(o); - } catch (AssertionError e) { - failed = true; - throw e; - } - } - - private void assertTrue(boolean o) { - try { - org.junit.Assert.assertTrue(o); - } catch (AssertionError e) { - failed = true; - throw e; - } - } - - private void assertFalse(boolean o) { - try { - org.junit.Assert.assertFalse(o); - } catch (AssertionError e) { - failed = true; - throw e; - } - } - - private void fail(String msg) { - failed = true; - org.junit.Assert.fail(msg); - } - - - - - - - - - - - - - - - - - - - @Override - public InputStream getErrorStream() { - throw new UnsupportedOperationException(); - } - - - - @Override - public String getHeaderField(int n) { - throw new UnsupportedOperationException(); - } - - - - @Override - public long getHeaderFieldDate(String name, long Default) { - throw new UnsupportedOperationException(); - } - - - - @Override - public String getHeaderFieldKey(int n) { - throw new UnsupportedOperationException(); - } - - - @Override - public Permission getPermission() throws IOException { - throw new UnsupportedOperationException(); - } - - - @Override - public String getResponseMessage() throws IOException { - throw new UnsupportedOperationException(); - } - - - - @Override - public void setChunkedStreamingMode(int chunklen) { - throw new UnsupportedOperationException(); - } - - - - @Override - public void setFixedLengthStreamingMode(int contentLength) { - throw new UnsupportedOperationException(); - } - - - - - - @Override - public boolean getAllowUserInteraction() { - throw new UnsupportedOperationException(); - } - - - - @Override - public Object getContent() throws IOException { - throw new UnsupportedOperationException(); - } - - - - @SuppressWarnings("unchecked") - @Override - public Object getContent(Class[] classes) throws IOException { - throw new UnsupportedOperationException(); - } - - - @Override - public long getDate() { - throw new UnsupportedOperationException(); - } - - - - @Override - public boolean getDefaultUseCaches() { - throw new UnsupportedOperationException(); - } - - - @Override - public long getExpiration() { - throw new UnsupportedOperationException(); - } - - - - @Override - public String getHeaderField(String name) { - throw new UnsupportedOperationException(); - } - - - - @Override - public int getHeaderFieldInt(String name, int Default) { - throw new UnsupportedOperationException(); - } - - - - @Override - public Map> getHeaderFields() { - throw new UnsupportedOperationException(); - } - - - - @Override - public long getIfModifiedSince() { - throw new UnsupportedOperationException(); - } - - - @Override - public long getLastModified() { - throw new UnsupportedOperationException(); - } - - @Override - public int getReadTimeout() { - throw new UnsupportedOperationException(); - } - - - - @Override - public Map> getRequestProperties() { - throw new UnsupportedOperationException(); - } - - - @Override - public URL getURL() { - throw new UnsupportedOperationException(); - } - - - - @Override - public void setAllowUserInteraction(boolean allowuserinteraction) { - throw new UnsupportedOperationException(); - } - - @Override - public void setDefaultUseCaches(boolean defaultusecaches) { - throw new UnsupportedOperationException(); - } - - - @Override - public void setIfModifiedSince(long ifmodifiedsince) { - throw new UnsupportedOperationException(); - } - - - @Override - public void setReadTimeout(int timeout) { - throw new UnsupportedOperationException(); - } - - - - - - @Override - public String toString() { - throw new UnsupportedOperationException(); - } - - - - -} diff --git a/test/net/sf/openrocket/communication/UpdateInfoTest.java b/test/net/sf/openrocket/communication/UpdateInfoTest.java deleted file mode 100644 index d09db759..00000000 --- a/test/net/sf/openrocket/communication/UpdateInfoTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package net.sf.openrocket.communication; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import net.sf.openrocket.util.BuildProperties; -import net.sf.openrocket.util.ComparablePair; -import net.sf.openrocket.util.BaseTestCase.BaseTestCase; - -import org.junit.Test; - -public class UpdateInfoTest extends BaseTestCase { - - /** The connection delay */ - private static final int DELAY = 100; - - /** How much long does the test allow it to take */ - private static final int ALLOWANCE = 2000; - - - private HttpURLConnectionMock setup() { - HttpURLConnectionMock connection = new HttpURLConnectionMock(); - Communicator.setConnectionSource(new ConnectionSourceStub(connection)); - - connection.setConnectionDelay(DELAY); - connection.setUseCaches(true); - connection.setContentType("text/plain"); - return connection; - } - - private void check(HttpURLConnectionMock connection) { - assertEquals(Communicator.UPDATE_INFO_URL + "?version=" + BuildProperties.getVersion(), - connection.getTrueUrl()); - assertTrue(connection.getConnectTimeout() > 0); - assertEquals(BuildProperties.getVersion() + "+" + BuildProperties.getBuildSource(), - connection.getRequestProperty("X-OpenRocket-Version")); - assertNotNull(connection.getRequestProperty("X-OpenRocket-Country")); - assertNotNull(connection.getRequestProperty("X-OpenRocket-ID")); - assertNotNull(connection.getRequestProperty("X-OpenRocket-OS")); - assertNotNull(connection.getRequestProperty("X-OpenRocket-Java")); - assertTrue(connection.getInstanceFollowRedirects()); - assertEquals("GET", connection.getRequestMethod()); - assertFalse(connection.getUseCaches()); - } - - - @Test - public void testUpdateAvailable() throws IOException { - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); - - String content = - "Version: 6.6.6pre A \n" + - "Extra: information\n" + - "100:hundred\n" + - "50: m\u00e4 \n\n" + - "1: one\n" + - "-2: none"; - connection.setContent(content); - - UpdateInfoRetriever retriever = new UpdateInfoRetriever(); - retriever.start(); - - // Info is null while processing - assertNull(retriever.getUpdateInfo()); - - waitfor(retriever); - assertFalse(connection.hasFailed()); - - UpdateInfo info = retriever.getUpdateInfo(); - assertNotNull(info); - - check(connection); - - assertEquals("6.6.6pre A", info.getLatestVersion()); - - List> updates = info.getUpdates(); - assertEquals(3, updates.size()); - Collections.sort(updates); - assertEquals(1, (int)updates.get(0).getU()); - assertEquals("one", updates.get(0).getV()); - assertEquals(50, (int)updates.get(1).getU()); - assertEquals("m\u00e4", updates.get(1).getV()); - assertEquals(100, (int)updates.get(2).getU()); - assertEquals("hundred", updates.get(2).getV()); - } - - - - - @Test - public void testUpdateNotAvailable() throws IOException { - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_NO_UPDATE_CODE); - - String content = - "Version: 6.6.6pre A \n" + - "Extra: information\n" + - "100:hundred\n" + - "50: m\u00e4 \n\n" + - "1: one\n" + - "-2: none"; - connection.setContent(content); - - UpdateInfoRetriever retriever = new UpdateInfoRetriever(); - retriever.start(); - - // Info is null while processing - assertNull(retriever.getUpdateInfo()); - - waitfor(retriever); - assertFalse(connection.hasFailed()); - - UpdateInfo info = retriever.getUpdateInfo(); - assertNotNull(info); - - check(connection); - - assertEquals(BuildProperties.getVersion(), info.getLatestVersion()); - assertEquals(0, info.getUpdates().size()); - } - - - - @Test - public void testInvalidResponses() { - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(404); - connection.setContent("Version: 1.2.3"); - - UpdateInfoRetriever retriever = new UpdateInfoRetriever(); - retriever.start(); - assertNull(retriever.getUpdateInfo()); - waitfor(retriever); - assertFalse(connection.hasFailed()); - assertNull(retriever.getUpdateInfo()); - check(connection); - - - connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); - connection.setContentType("text/xml"); - - retriever = new UpdateInfoRetriever(); - retriever.start(); - assertNull(retriever.getUpdateInfo()); - waitfor(retriever); - assertFalse(connection.hasFailed()); - assertNull(retriever.getUpdateInfo()); - check(connection); - - - - connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); - String content = - "100:hundred\n" + - "50: m\u00e4 \n\n" + - "1: one\n"; - connection.setContent(content); - - retriever = new UpdateInfoRetriever(); - retriever.start(); - assertNull(retriever.getUpdateInfo()); - waitfor(retriever); - assertFalse(connection.hasFailed()); - assertNull(retriever.getUpdateInfo()); - check(connection); - - - connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); - connection.setContent(new byte[0]); - - retriever = new UpdateInfoRetriever(); - retriever.start(); - assertNull(retriever.getUpdateInfo()); - waitfor(retriever); - assertFalse(connection.hasFailed()); - assertNull(retriever.getUpdateInfo()); - check(connection); - - } - - @Test - public void testRandomInputData() { - - Random rnd = new Random(); - for (int i=0; i<10; i++) { - int size = (int) ((1 + 0.3 * rnd.nextGaussian()) * Math.pow(i, 6)); - byte[] buf = new byte[size]; - rnd.nextBytes(buf); - - HttpURLConnectionMock connection = setup(); - connection.setResponseCode(Communicator.UPDATE_INFO_UPDATE_AVAILABLE); - connection.setContent(buf); - - UpdateInfoRetriever retriever = new UpdateInfoRetriever(); - retriever.start(); - assertNull(retriever.getUpdateInfo()); - waitfor(retriever); - assertFalse(connection.hasFailed()); - assertNull(retriever.getUpdateInfo()); - check(connection); - } - - } - - - - private void waitfor(UpdateInfoRetriever retriever) { - long t = System.currentTimeMillis(); - - while (retriever.isRunning()) { - if (System.currentTimeMillis() >= t+ALLOWANCE) { - fail("retriever took too long to respond"); - } - - try { - Thread.sleep(10); - } catch (InterruptedException e) { } - } - - System.out.println("Waiting took " + (System.currentTimeMillis()-t) + " ms"); - } - -} diff --git a/test/net/sf/openrocket/database/MotorSetDatabaseTest.java b/test/net/sf/openrocket/database/MotorSetDatabaseTest.java deleted file mode 100644 index 33ced0c8..00000000 --- a/test/net/sf/openrocket/database/MotorSetDatabaseTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.sf.openrocket.database; - -import static org.junit.Assert.*; - -import java.util.List; - -import net.sf.openrocket.motor.Manufacturer; -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.ThrustCurveMotor; -import net.sf.openrocket.util.Coordinate; - -import org.junit.Test; - - -public class MotorSetDatabaseTest { - - @Test - public void testMotorLoading() { - - ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(true) { - @Override - protected void loadMotors() { - try { - Thread.sleep(200); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - 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})); - 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})); - 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})); - } - }; - - assertFalse(db.isLoaded()); - db.startLoading(); - assertFalse(db.isLoaded()); - List list = db.getMotorSets(); - assertTrue(db.isLoaded()); - - assertEquals(2, list.size()); - assertEquals(1, list.get(0).getMotors().size()); - assertEquals(1, list.get(1).getMotors().size()); - assertEquals("Bar", list.get(0).getMotors().get(0).getDesignation()); - assertEquals("Foo", list.get(1).getMotors().get(0).getDesignation()); - } - -} diff --git a/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java b/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java deleted file mode 100644 index 56e30b2d..00000000 --- a/test/net/sf/openrocket/database/ThrustCurveMotorSetTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package net.sf.openrocket.database; - -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.Collections; - -import net.sf.openrocket.motor.Manufacturer; -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.ThrustCurveMotor; -import net.sf.openrocket.util.Coordinate; - -import org.junit.Test; - -public class ThrustCurveMotorSetTest { - - - private static final ThrustCurveMotor motor1 = new ThrustCurveMotor( - 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}); - - 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}); - - 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}); - - 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}); - - - @Test - public void testSimplifyDesignation() { - assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("J115")); - assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation(" J115 ")); - assertEquals("H115", ThrustCurveMotorSet.simplifyDesignation("241H115-KS")); - assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("384 J115")); - assertEquals("J115", ThrustCurveMotorSet.simplifyDesignation("384-J115")); - assertEquals("A2", ThrustCurveMotorSet.simplifyDesignation("A2T")); - assertEquals("1/2A2T", ThrustCurveMotorSet.simplifyDesignation("1/2A2T")); - assertEquals("Micro Maxx II", ThrustCurveMotorSet.simplifyDesignation("Micro Maxx II")); - } - - @Test - public void testAdding() { - ThrustCurveMotorSet set = new ThrustCurveMotorSet(); - - // Test empty set - assertNull(set.getManufacturer()); - assertEquals(0, set.getMotors().size()); - - // Add motor1 - assertTrue(set.matches(motor1)); - set.addMotor(motor1); - assertEquals(motor1.getManufacturer(), set.getManufacturer()); - assertEquals(motor1.getDesignation(), set.getDesignation()); - assertEquals(Motor.Type.UNKNOWN, set.getType()); - assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); - assertEquals(motor1.getLength(), set.getLength(), 0.00001); - assertEquals(1, set.getMotors().size()); - assertEquals(motor1, set.getMotors().get(0)); - assertEquals(Collections.emptyList(), set.getDelays()); - - // Add motor1 again - assertTrue(set.matches(motor1)); - set.addMotor(motor1); - assertEquals(motor1.getManufacturer(), set.getManufacturer()); - assertEquals(motor1.getDesignation(), set.getDesignation()); - assertEquals(Motor.Type.UNKNOWN, set.getType()); - assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); - assertEquals(motor1.getLength(), set.getLength(), 0.00001); - assertEquals(1, set.getMotors().size()); - assertEquals(motor1, set.getMotors().get(0)); - assertEquals(Collections.emptyList(), set.getDelays()); - - // Add motor2 - assertTrue(set.matches(motor2)); - set.addMotor(motor2); - assertEquals(motor1.getManufacturer(), set.getManufacturer()); - assertEquals(motor3.getDesignation(), set.getDesignation()); - assertEquals(Motor.Type.SINGLE, set.getType()); - assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); - assertEquals(motor1.getLength(), set.getLength(), 0.00001); - assertEquals(2, set.getMotors().size()); - assertEquals(motor2, set.getMotors().get(0)); - assertEquals(motor1, set.getMotors().get(1)); - assertEquals(Arrays.asList(5.0), set.getDelays()); - - // Add motor3 - assertTrue(set.matches(motor3)); - set.addMotor(motor3); - assertEquals(motor1.getManufacturer(), set.getManufacturer()); - assertEquals(motor3.getDesignation(), set.getDesignation()); - assertEquals(Motor.Type.SINGLE, set.getType()); - assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001); - assertEquals(motor1.getLength(), set.getLength(), 0.00001); - assertEquals(3, set.getMotors().size()); - assertEquals(motor3, set.getMotors().get(0)); - assertEquals(motor2, set.getMotors().get(1)); - assertEquals(motor1, set.getMotors().get(2)); - assertEquals(Arrays.asList(0.0, 5.0, Motor.PLUGGED), set.getDelays()); - - // Test that adding motor4 fails - assertFalse(set.matches(motor4)); - try { - set.addMotor(motor4); - fail("Did not throw exception"); - } catch (IllegalArgumentException e) { - } - } - -} diff --git a/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java b/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java deleted file mode 100644 index dce14861..00000000 --- a/test/net/sf/openrocket/file/iterator/TestDirectoryIterator.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.sf.openrocket.file.iterator; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; - -import org.junit.Test; - -public class TestDirectoryIterator { - - @Test - public void testDirectoryIterator() throws IOException { - DirectoryIterator iterator = new DirectoryIterator(new File("test/net/sf/openrocket/file"), new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().matches("^Test(Directory|File)Iterator.java"); - } - }, true); - - while (iterator.hasNext()) { - System.out.println("" + iterator.next()); - } - - } -} diff --git a/test/net/sf/openrocket/file/iterator/TestFileIterator.java b/test/net/sf/openrocket/file/iterator/TestFileIterator.java deleted file mode 100644 index c3e424ee..00000000 --- a/test/net/sf/openrocket/file/iterator/TestFileIterator.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.sf.openrocket.file.iterator; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import net.sf.openrocket.util.Pair; - -import org.junit.Test; - -public class TestFileIterator { - - @Test - public void testFileIterator() { - final Pair one = new Pair("one", new ByteArrayInputStream(new byte[] { 1 })); - final Pair two = new Pair("two", new ByteArrayInputStream(new byte[] { 2 })); - - FileIterator iterator = new FileIterator() { - private int count = 0; - - @Override - protected Pair findNext() { - count++; - switch (count) { - case 1: - return one; - case 2: - return two; - default: - return null; - } - } - }; - - assertTrue(iterator.hasNext()); - assertEquals(one, iterator.next()); - assertEquals(two, iterator.next()); - assertFalse(iterator.hasNext()); - } -} diff --git a/test/net/sf/openrocket/file/motor/TestMotorLoader.java b/test/net/sf/openrocket/file/motor/TestMotorLoader.java deleted file mode 100644 index 8200310a..00000000 --- a/test/net/sf/openrocket/file/motor/TestMotorLoader.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.sf.openrocket.file.motor; - -import static org.junit.Assert.*; - -import java.io.IOException; -import java.io.InputStream; -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; - -public class TestMotorLoader { - - @Test - public void testGeneralMotorLoader() throws IOException { - MotorLoader loader = new GeneralMotorLoader(); - - test(loader, "test1.eng", "c056cf25df6751f7bb8a94bc4f64750f"); - test(loader, "test2.rse", "b2fe203ee319ae28b9ccdad26a8f21de"); - test(loader, "test.zip", "b2fe203ee319ae28b9ccdad26a8f21de", "c056cf25df6751f7bb8a94bc4f64750f"); - - } - - @Test - public void testRASPMotorLoader() throws IOException { - test(new RASPMotorLoader(), "test1.eng", "c056cf25df6751f7bb8a94bc4f64750f"); - } - - @Test - public void testRocksimMotorLoader() throws IOException { - test(new RockSimMotorLoader(), "test2.rse", "b2fe203ee319ae28b9ccdad26a8f21de"); - } - - @Test - public void testZipMotorLoader() throws IOException { - test(new ZipFileMotorLoader(), "test.zip", "b2fe203ee319ae28b9ccdad26a8f21de", "c056cf25df6751f7bb8a94bc4f64750f"); - } - - - private void test(MotorLoader loader, String file, String... digests) throws IOException { - List motors; - - InputStream is = this.getClass().getResourceAsStream(file); - assertNotNull("File " + file + " not found", is); - motors = loader.load(is, file); - is.close(); - assertEquals(digests.length, motors.size()); - - String[] d = new String[digests.length]; - for (int i = 0; i < motors.size(); i++) { - d[i] = MotorDigest.digestMotor((ThrustCurveMotor) motors.get(i)); - } - - Arrays.sort(digests); - Arrays.sort(d); - assertTrue(Arrays.equals(d, digests)); - } - -} diff --git a/test/net/sf/openrocket/file/motor/test.txt b/test/net/sf/openrocket/file/motor/test.txt deleted file mode 100644 index 4b43be8f..00000000 --- a/test/net/sf/openrocket/file/motor/test.txt +++ /dev/null @@ -1 +0,0 @@ -boo bah diff --git a/test/net/sf/openrocket/file/motor/test.zip b/test/net/sf/openrocket/file/motor/test.zip deleted file mode 100644 index eeb5ef7c..00000000 Binary files a/test/net/sf/openrocket/file/motor/test.zip and /dev/null differ diff --git a/test/net/sf/openrocket/file/motor/test1.eng b/test/net/sf/openrocket/file/motor/test1.eng deleted file mode 100644 index 06dc100e..00000000 --- a/test/net/sf/openrocket/file/motor/test1.eng +++ /dev/null @@ -1,24 +0,0 @@ -D10 18 70 7 0.009800000000000001 0.0259 AT - 0.0070 23.0 - 0.018 25.0 - 0.027 20.25 - 0.066 20.25 - 0.073 18.5 - 0.094 20.25 - 0.112 20.75 - 0.137 19.75 - 0.163 21.5 - 0.202 20.75 - 0.231 20.75 - 0.254 22.75 - 0.27 20.75 - 0.504 20.0 - 0.536 18.25 - 0.607 17.0 - 0.687 14.75 - 0.751 14.25 - 0.84 11.25 - 0.998 8.25 - 1.024 8.25 - 1.248 2.5 - 1.385 0.0 diff --git a/test/net/sf/openrocket/file/motor/test2.rse b/test/net/sf/openrocket/file/motor/test2.rse deleted file mode 100644 index a77408f8..00000000 --- a/test/net/sf/openrocket/file/motor/test2.rse +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java b/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java deleted file mode 100644 index 7feb8d23..00000000 --- a/test/net/sf/openrocket/file/rocksim/export/RocksimDocumentDTOTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.sf.openrocket.file.rocksim.export; - -import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.file.rocksim.importt.RocksimLoader; -import net.sf.openrocket.file.rocksim.importt.RocksimLoaderTest; -import net.sf.openrocket.file.rocksim.importt.RocksimTestBase; -import org.junit.Assert; -import org.junit.Test; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import java.io.File; -import java.io.FileWriter; -import java.io.StringWriter; - -/** - */ -public class RocksimDocumentDTOTest extends RocksimTestBase { - - @Test - public void testDTO() throws Exception { - JAXBContext binder = JAXBContext.newInstance(RocksimDocumentDTO.class); - Marshaller marshaller = binder.createMarshaller(); - marshaller.setProperty("jaxb.fragment", Boolean.TRUE); - - NoseConeDTO noseCone = new NoseConeDTO(); - noseCone.setBaseDia(10d); - noseCone.setCalcCG(1.3d); - - StageDTO stage1 = new StageDTO(); - stage1.addExternalPart(noseCone); - - RocketDesignDTO design2 = new RocketDesignDTO(); - design2.setName("Test"); - design2.setStage3(stage1); - - RocksimDesignDTO design = new RocksimDesignDTO(); - design.setDesign(design2); - RocksimDocumentDTO message = new RocksimDocumentDTO(); - message.setDesign(design); - - - StringWriter stringWriter = new StringWriter(); - marshaller.marshal(message, stringWriter); - - String response = stringWriter.toString(); - - System.err.println(response); - } - - @Test - public void testRoundTrip() throws Exception { - OpenRocketDocument ord = RocksimLoaderTest.loadRocksimRocket3(new RocksimLoader()); - - Assert.assertNotNull(ord); - String result = new RocksimSaver().marshalToRocksim(ord); - -// System.err.println(result); - - File output = new File("rt.rkt"); - FileWriter fw = new FileWriter(output); - fw.write(result); - fw.flush(); - fw.close(); - } -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java deleted file mode 100644 index b69a3bd9..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/BodyTubeHandlerTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * BodyTubeHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.ExternalComponent; -import net.sf.openrocket.rocketcomponent.Stage; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; - -/** - * BodyTubeHandler Tester. - * - */ -public class BodyTubeHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testConstructor() throws Exception { - - try { - new BodyTubeHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - Stage stage = new Stage(); - BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); - BodyTube component = (BodyTube) getField(handler, "bodyTube"); - assertContains(component, stage.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new BodyTubeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); - Assert.assertNotNull(new BodyTubeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); - } - - /** - * - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testCloseElement() throws Exception { - Stage stage = new Stage(); - BodyTubeHandler handler = new BodyTubeHandler(stage, new WarningSet()); - BodyTube component = (BodyTube) getField(handler, "bodyTube"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ID", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("IsMotorMount", attributes, "1", warnings); - Assert.assertTrue(component.isMotorMount()); - handler.closeElement("IsMotorMount", attributes, "0", warnings); - Assert.assertFalse(component.isMotorMount()); - handler.closeElement("IsMotorMount", attributes, "foo", warnings); - Assert.assertFalse(component.isMotorMount()); - - handler.closeElement("EngineOverhang", attributes, "-1", warnings); - Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("FinishCode", attributes, "-1", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "100", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new BodyTubeHandler(new Stage(), new WarningSet()).getComponent() instanceof BodyTube); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new BodyTubeHandler(new Stage(), new WarningSet()).getMaterialType()); - } - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java deleted file mode 100644 index 503654bc..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/FinSetHandlerTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * FinSetHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -import junit.framework.TestCase; -import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.rocketcomponent.BodyTube; -import net.sf.openrocket.rocketcomponent.EllipticalFinSet; -import net.sf.openrocket.rocketcomponent.FinSet; -import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; -import net.sf.openrocket.util.Coordinate; - -import java.lang.reflect.Method; -import java.util.HashMap; - -/** - * FinSetHandler Tester. - * - */ -public class FinSetHandlerTest extends TestCase { - - /** - * Method: asOpenRocket(WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testAsOpenRocket() throws Exception { - - FinSetHandler dto = new FinSetHandler(new BodyTube()); - - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - dto.closeElement("Name", attributes, "The name", warnings); - dto.closeElement("ShapeCode", attributes, "0", warnings); - dto.closeElement("Xb", attributes, "2", warnings); - dto.closeElement("FinCount", attributes, "4", warnings); - dto.closeElement("RootChord", attributes, "10", warnings); - dto.closeElement("TipChord", attributes, "11", warnings); - dto.closeElement("SemiSpan", attributes, "12", warnings); - dto.closeElement("MidChordLen", attributes, "13", warnings); - dto.closeElement("SweepDistance", attributes, "14", warnings); - dto.closeElement("Thickness", attributes, "200", warnings); - dto.closeElement("TipShapeCode", attributes, "1", warnings); - dto.closeElement("TabLength", attributes, "400", warnings); - dto.closeElement("TabDepth", attributes, "500", warnings); - dto.closeElement("TabOffset", attributes, "30", warnings); - dto.closeElement("RadialAngle", attributes, ".123", warnings); - dto.closeElement("PointList", attributes, "20,0|2,2|0,0", warnings); - dto.closeElement("LocationMode", attributes, "0", warnings); - - WarningSet set = new WarningSet(); - FinSet fins = dto.asOpenRocket(set); - assertNotNull(fins); - assertEquals(0, set.size()); - - assertEquals("The name", fins.getName()); - assertTrue(fins instanceof TrapezoidFinSet); - assertEquals(4, fins.getFinCount()); - - assertEquals(0.012d, ((TrapezoidFinSet) fins).getHeight()); - assertEquals(0.012d, fins.getSpan()); - - assertEquals(0.2d, fins.getThickness()); - assertEquals(0.4d, fins.getTabLength()); - assertEquals(0.5d, fins.getTabHeight()); - assertEquals(0.03d, fins.getTabShift()); - assertEquals(.123d, fins.getBaseRotation()); - - dto.closeElement("ShapeCode", attributes, "1", warnings); - fins = dto.asOpenRocket(set); - assertNotNull(fins); - assertEquals(0, set.size()); - - assertEquals("The name", fins.getName()); - assertTrue(fins instanceof EllipticalFinSet); - assertEquals(4, fins.getFinCount()); - - assertEquals(0.2d, fins.getThickness()); - assertEquals(0.4d, fins.getTabLength()); - assertEquals(0.5d, fins.getTabHeight()); - assertEquals(0.03d, fins.getTabShift()); - assertEquals(.123d, fins.getBaseRotation()); - } - - - /** - * Method: toCoordinates(String pointList) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testToCoordinates() throws Exception { - FinSetHandler holder = new FinSetHandler(new BodyTube()); - Method method = FinSetHandler.class.getDeclaredMethod("toCoordinates", String.class, WarningSet.class); - method.setAccessible(true); - - WarningSet warnings = new WarningSet(); - //Null finlist - String finlist = null; - Coordinate[] result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(0 == result.length); - - //Empty string finlist - finlist = ""; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(0 == result.length); - - //Invalid finlist (only x coordinate) - finlist = "10.0"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(0 == result.length); - assertEquals(1, warnings.size()); - warnings.clear(); - - //Invalid finlist (non-numeric character) - finlist = "10.0,asdf"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(0 == result.length); - assertEquals(1, warnings.size()); - warnings.clear(); - - //Invalid finlist (all delimiters) - finlist = "||||||"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(0 == result.length); - assertEquals(0, warnings.size()); - warnings.clear(); - - //One point finlist - from a parsing view it's valid; from a practical view it may not be, but that's outside - //the scope of this test case - finlist = "10.0,5.0"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(1 == result.length); - assertEquals(0, warnings.size()); - warnings.clear(); - - //Two point finlist - from a parsing view it's valid; from a practical view it may not be, but that's outside - //the scope of this test case - finlist = "10.0,5.0|3.3,4.4"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(2 == result.length); - assertEquals(0, warnings.size()); - warnings.clear(); - - //Normal four point finlist. - finlist = "518.16,0|517.494,37.2145|1.31261,6.77283|0,0|"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(4 == result.length); - assertEquals(new Coordinate(0,0), result[0]); - assertEquals(0, warnings.size()); - warnings.clear(); - - //Normal four point finlist with spaces. - finlist = "518.16 , 0 | 517.494 , 37.2145 | 1.31261,6.77283|0,0|"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(4 == result.length); - assertEquals(new Coordinate(0,0), result[0]); - assertEquals(new Coordinate(.51816,0), result[3]); - assertEquals(0, warnings.size()); - warnings.clear(); - - //Reversed Normal four point finlist. - finlist = "0,0|1.31261,6.77283|517.494,37.2145|518.16,0|"; - result = (Coordinate[])method.invoke(holder, finlist, warnings); - assertNotNull(result); - assertTrue(4 == result.length); - assertEquals(new Coordinate(0,0), result[0]); - assertEquals(new Coordinate(.51816,0), result[3]); - assertEquals(0, warnings.size()); - warnings.clear(); - - } -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java deleted file mode 100644 index fa070ce7..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/InnerBodyTubeHandlerTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * InnerBodyTubeHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.InnerTube; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import org.junit.Assert; - -import java.util.HashMap; - -/** - * InnerBodyTubeHandler Tester. - * - */ -public class InnerBodyTubeHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new InnerBodyTubeHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); - InnerTube component = (InnerTube) getField(handler, "bodyTube"); - assertContains(component, tube.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - Assert.assertNotNull(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).openElement("AttachedParts", null, null)); - } - - /** - * - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); - InnerTube component = (InnerTube) getField(handler, "bodyTube"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("OD", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ID", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("IsMotorMount", attributes, "1", warnings); - Assert.assertTrue(component.isMotorMount()); - handler.closeElement("IsMotorMount", attributes, "0", warnings); - Assert.assertFalse(component.isMotorMount()); - handler.closeElement("IsMotorMount", attributes, "foo", warnings); - Assert.assertFalse(component.isMotorMount()); - - handler.closeElement("EngineOverhang", attributes, "-1", warnings); - Assert.assertEquals(-1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); - handler.closeElement("EngineOverhang", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - InnerBodyTubeHandler handler = new InnerBodyTubeHandler(tube, new WarningSet()); - InnerTube component = (InnerTube) getField(handler, "bodyTube"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new InnerBodyTubeHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java deleted file mode 100644 index 503ce805..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/LaunchLugHandlerTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * LaunchLugHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.ExternalComponent; -import net.sf.openrocket.rocketcomponent.LaunchLug; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import org.junit.Assert; - -import java.util.HashMap; - -/** - * LaunchLugHandler Tester. - * - */ -public class LaunchLugHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new LaunchLugHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); - LaunchLug component = (LaunchLug) getField(handler, "lug"); - assertContains(component, tube.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new LaunchLugHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - } - - /** - * - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); - LaunchLug component = (LaunchLug) getField(handler, "lug"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getOuterRadius(), 0.001); - handler.closeElement("OD", attributes, "0", warnings); - Assert.assertEquals(0d, component.getOuterRadius(), 0.001); - handler.closeElement("OD", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001); - handler.closeElement("OD", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ID", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("FinishCode", attributes, "-1", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "100", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - LaunchLugHandler handler = new LaunchLugHandler(tube, new WarningSet()); - LaunchLug component = (LaunchLug) getField(handler, "lug"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new LaunchLugHandler(new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new LaunchLugHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } - - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java deleted file mode 100644 index e5360a12..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/MassObjectHandlerTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * MassObjectHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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 org.junit.Assert; - -import java.util.HashMap; - -/** - * MassObjectHandler Tester. - * - */ -public class MassObjectHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new MassObjectHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); - MassComponent component = (MassComponent) getField(handler, "mass"); - assertContains(component, tube.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new MassObjectHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - } - - /** - * - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - BodyTube tube = new BodyTube(); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); - MassComponent component = (MassComponent) getField(handler, "mass"); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH) - , component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / (MassObjectHandler.MASS_LEN_FUDGE_FACTOR * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH) - , component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("KnownMass", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getComponentMass(), 0.001); - handler.closeElement("KnownMass", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS, component.getComponentMass(), 0.001); - handler.closeElement("KnownMass", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - MassObjectHandler handler = new MassObjectHandler(tube, new WarningSet()); - MassComponent component = (MassComponent) getField(handler, "mass"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new MassObjectHandler(new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new MassObjectHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java deleted file mode 100644 index 593434c4..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/NoseConeHandlerTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * NoseConeHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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 org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; - -/** - * NoseConeHandler Tester. - * - */ -public class NoseConeHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testConstructor() throws Exception { - - try { - new NoseConeHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - Stage stage = new Stage(); - NoseConeHandler handler = new NoseConeHandler(stage, new WarningSet()); - NoseCone component = (NoseCone) getField(handler, "noseCone"); - assertContains(component, stage.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new NoseConeHandler(new Stage(), new WarningSet()).openElement(null, null, null)); - Assert.assertNotNull(new NoseConeHandler(new Stage(), new WarningSet()).openElement("AttachedParts", null, null)); - } - - /** - * - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testCloseElement() throws Exception { - - Stage stage = new Stage(); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - NoseConeHandler handler = new NoseConeHandler(stage, warnings); - NoseCone component = (NoseCone) getField(handler, "noseCone"); - - handler.closeElement("ShapeCode", attributes, "0", warnings); - Assert.assertEquals(Transition.Shape.CONICAL, component.getType()); - handler.closeElement("ShapeCode", attributes, "1", warnings); - Assert.assertEquals(Transition.Shape.OGIVE, component.getType()); - handler.closeElement("ShapeCode", attributes, "17", warnings); - Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default - handler.closeElement("ShapeCode", attributes, "foo", warnings); - Assert.assertNotNull(component.getType()); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("BaseDia", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftRadius(), 0.001); - handler.closeElement("BaseDia", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001); - handler.closeElement("BaseDia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - - final double aft = 100d; - component.setAftRadius(aft); - - handler.closeElement("ConstructionType", attributes, "0", warnings); - component.setAftShoulderRadius(1.1d); - handler.closeElement("WallThickness", attributes, "-1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001); - Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "100", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(aft, component.getThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "foo", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ConstructionType", attributes, "1", warnings); - component.setAftShoulderRadius(1.1d); - handler.closeElement("WallThickness", attributes, "-1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(0d, component.getThickness(), 0.001); - Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "1.1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001); - Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001); - - handler.closeElement("ShoulderLen", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001); - handler.closeElement("ShoulderLen", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); - handler.closeElement("ShoulderLen", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); - handler.closeElement("ShoulderLen", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ShoulderOD", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001); - handler.closeElement("ShoulderOD", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001); - handler.closeElement("ShoulderOD", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - component.setType(Transition.Shape.HAACK); - handler.closeElement("ShapeParameter", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getShapeParameter(), 0.001); - handler.closeElement("ShapeParameter", attributes, "100", warnings); - Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001); - handler.closeElement("ShapeParameter", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.", - warnings.iterator().next().toString()); - - warnings.clear(); - - component.setType(Transition.Shape.CONICAL); - component.setShapeParameter(0d); - handler.closeElement("ShapeParameter", attributes, "100", warnings); - Assert.assertEquals(0d, component.getShapeParameter(), 0.001); - - handler.closeElement("FinishCode", attributes, "-1", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "100", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - - handler.closeElement("Material", attributes, "Some Material", warnings); - handler.endHandler("NoseCone", attributes, null, warnings); - Assert.assertTrue(component.getMaterial().getName().contains("Some Material")); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new NoseConeHandler(new Stage(), new WarningSet()).getComponent() instanceof NoseCone); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new NoseConeHandler(new Stage(), new WarningSet()).getMaterialType()); - } -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java deleted file mode 100644 index 20ab19fb..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/ParachuteHandlerTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * ParachuteHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.Parachute; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import org.junit.Assert; - -import java.util.HashMap; - -/** - * ParachuteHandler Tester. - */ -public class ParachuteHandlerTest extends RocksimTestBase { - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new ParachuteHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - } - - /** - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - - BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); - Parachute component = (Parachute) getField(handler, "chute"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - - handler.closeElement("DragCoefficient", attributes, "0.94", warnings); - Assert.assertEquals(0.94d, component.getCD(), 0.001); - handler.closeElement("DragCoefficient", attributes, "-0.94", warnings); - Assert.assertEquals(-0.94d, component.getCD(), 0.001); - handler.closeElement("DragCoefficient", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Dia", attributes, "-1", warnings); - Assert.assertEquals(-1d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001); - handler.closeElement("Dia", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getDiameter(), 0.001); - handler.closeElement("Dia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ShroudLineCount", attributes, "-1", warnings); - Assert.assertEquals(0, component.getLineCount()); - handler.closeElement("ShroudLineCount", attributes, "10", warnings); - Assert.assertEquals(10, component.getLineCount()); - handler.closeElement("ShroudLineCount", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ShroudLineLen", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLineLength(), 0.001); - handler.closeElement("ShroudLineLen", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLineLength(), 0.001); - handler.closeElement("ShroudLineLen", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - } - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new ParachuteHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); - Parachute component = (Parachute) getField(handler, "chute"); - assertContains(component, tube.getChildren()); - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); - Parachute component = (Parachute) getField(handler, "chute"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new ParachuteHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Parachute); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.SURFACE, new ParachuteHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } - - /** - * Method: endHandler() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testEndHandler() throws Exception { - BodyTube tube = new BodyTube(); - ParachuteHandler handler = new ParachuteHandler(tube, new WarningSet()); - Parachute component = (Parachute) getField(handler, "chute"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("Xb", attributes, "-10", warnings); - handler.closeElement("LocationMode", attributes, "1", warnings); - handler.endHandler("Parachute", attributes, null, warnings); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - Assert.assertEquals(component.getPositionValue(), -10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); - - handler.closeElement("Xb", attributes, "-10", warnings); - handler.closeElement("LocationMode", attributes, "2", warnings); - handler.endHandler("Parachute", attributes, null, warnings); - Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition()); - Assert.assertEquals(component.getPositionValue(), 10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); - } -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/PodFins.rkt b/test/net/sf/openrocket/file/rocksim/importt/PodFins.rkt deleted file mode 100644 index a137008f..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/PodFins.rkt +++ /dev/null @@ -1,605 +0,0 @@ - - 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/importt/RingHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/RingHandlerTest.java deleted file mode 100644 index af64a820..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/RingHandlerTest.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * RingHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.Bulkhead; -import net.sf.openrocket.rocketcomponent.CenteringRing; -import net.sf.openrocket.rocketcomponent.EngineBlock; -import net.sf.openrocket.rocketcomponent.RingComponent; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.rocketcomponent.TubeCoupler; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; - -/** - * RingHandler Tester. - */ -public class RingHandlerTest extends RocksimTestBase { - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new RingHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - } - - /** - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - CenteringRing component = (CenteringRing) getField(handler, "ring"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "0", warnings); - Assert.assertEquals(0d, component.getOuterRadius(), 0.001); - handler.closeElement("OD", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getOuterRadius(), 0.001); - handler.closeElement("OD", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ID", attributes, "0", warnings); - Assert.assertEquals(0d, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "75", warnings); - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getInnerRadius(), 0.001); - handler.closeElement("ID", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - } - - /** - * Test a bulkhead. - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testBulkhead() throws Exception { - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - CenteringRing component = (CenteringRing) getField(handler, "ring"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "75", warnings); - handler.closeElement("ID", attributes, "0", warnings); - handler.closeElement("Len", attributes, "10", warnings); - handler.closeElement("Name", attributes, "Test Name", warnings); - handler.closeElement("KnownMass", attributes, "109.9", warnings); - handler.closeElement("UsageCode", attributes, "1", warnings); - handler.closeElement("UseKnownCG", attributes, "1", warnings); - handler.endHandler("", attributes, "", warnings); - - Assert.assertEquals(1, tube.getChildren().size()); - RingComponent child = (RingComponent)tube.getChild(0); - - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); - Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); - Assert.assertEquals("Test Name", child.getName()); - Assert.assertEquals(109.9/1000, child.getMass(), 0.001); - Assert.assertEquals(0, child.getPositionValue(), 0.0); - Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); - Assert.assertTrue(child instanceof Bulkhead); - - } - - /** - * Test a tube coupler. - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testTubeCoupler() throws Exception { - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "75", warnings); - handler.closeElement("ID", attributes, "70", warnings); - handler.closeElement("Len", attributes, "10", warnings); - handler.closeElement("Name", attributes, "Test Name", warnings); - handler.closeElement("KnownMass", attributes, "109.9", warnings); - handler.closeElement("UsageCode", attributes, "4", warnings); - handler.closeElement("UseKnownCG", attributes, "1", warnings); - handler.endHandler("", attributes, "", warnings); - - Assert.assertEquals(1, tube.getChildren().size()); - RingComponent child = (RingComponent)tube.getChild(0); - Assert.assertTrue(child instanceof TubeCoupler); - - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); - Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); - Assert.assertEquals("Test Name", child.getName()); - Assert.assertEquals(109.9/1000, child.getMass(), 0.001); - Assert.assertEquals(0, child.getPositionValue(), 0.0); - Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); - } - - /** - * Test a engine block. - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testEngineBlock() throws Exception { - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "75", warnings); - handler.closeElement("ID", attributes, "70", warnings); - handler.closeElement("Len", attributes, "10", warnings); - handler.closeElement("Name", attributes, "Test Name", warnings); - handler.closeElement("KnownMass", attributes, "109.9", warnings); - handler.closeElement("UsageCode", attributes, "2", warnings); - handler.closeElement("KnownCG", attributes, "4", warnings); - handler.closeElement("UseKnownCG", attributes, "1", warnings); - handler.endHandler("", attributes, "", warnings); - - Assert.assertEquals(1, tube.getChildren().size()); - RingComponent child = (RingComponent)tube.getChild(0); - Assert.assertTrue(child instanceof EngineBlock); - - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); - Assert.assertEquals(70d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); - Assert.assertEquals("Test Name", child.getName()); - Assert.assertEquals(109.9/1000, child.getMass(), 0.001); - Assert.assertEquals(0, child.getPositionValue(), 0.0); - Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); - Assert.assertEquals(4d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getCG().x, 0.000001); - - } - - /** - * Test a centering ring - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testRing() throws Exception { - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("OD", attributes, "75", warnings); - handler.closeElement("ID", attributes, "0", warnings); - handler.closeElement("Len", attributes, "10", warnings); - handler.closeElement("Name", attributes, "Test Name", warnings); - handler.closeElement("KnownMass", attributes, "109.9", warnings); - handler.closeElement("UsageCode", attributes, "0", warnings); - handler.closeElement("UseKnownCG", attributes, "1", warnings); - handler.endHandler("", attributes, "", warnings); - - Assert.assertEquals(1, tube.getChildren().size()); - RingComponent child = (RingComponent)tube.getChild(0); - - Assert.assertEquals(75d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getOuterRadius(), 0.001); - Assert.assertEquals(0d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, child.getInnerRadius(), 0.001); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, child.getLength(), 0.001); - Assert.assertEquals("Test Name", child.getName()); - Assert.assertEquals(109.9/1000, child.getMass(), 0.001); - Assert.assertEquals(0, child.getPositionValue(), 0.0); - Assert.assertEquals(RocketComponent.Position.TOP, child.getRelativePosition()); - Assert.assertTrue(child instanceof CenteringRing); - } - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new RingHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - CenteringRing component = (CenteringRing) getField(handler, "ring"); - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - RingHandler handler = new RingHandler(tube, new WarningSet()); - CenteringRing component = (CenteringRing) getField(handler, "ring"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new RingHandler(new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new RingHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } - - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java deleted file mode 100644 index 0eb1d625..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/RocksimContentHandlerTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * RocksimContentHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -import org.junit.Assert; - -/** - * RocksimContentHandler Tester. - * - */ -public class RocksimContentHandlerTest { - - /** - * - * Method: getDocument() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetDocument() throws Exception { - RocksimContentHandler handler = new RocksimContentHandler(); - Assert.assertNotNull(handler.getDocument()); - } - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java b/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java deleted file mode 100644 index 92a0eea3..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * RocksimLoaderTest.java - * - */ -package net.sf.openrocket.file.rocksim.importt; - -import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.file.RocketLoadException; -import net.sf.openrocket.rocketcomponent.BodyTube; -import net.sf.openrocket.rocketcomponent.LaunchLug; -import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.Stage; -import org.junit.Assert; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * RocksimLoader Tester. - */ -public class RocksimLoaderTest { - - /** - * 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. - */ - @org.junit.Test - public void testFinsOnInnerTube() throws Exception { - RocksimLoader loader = new RocksimLoader(); - InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt"); - Assert.assertNotNull("Could not open PodFins.rkt", stream); - try { - OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream)); - Assert.assertNotNull(doc); - Rocket rocket = doc.getRocket(); - Assert.assertNotNull(rocket); - } catch (IllegalStateException ise) { - Assert.fail(ise.getMessage()); - } - Assert.assertTrue(loader.getWarnings().size() == 2); - } - - /** - * Method: loadFromStream(InputStream source) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testLoadFromStream() throws Exception { - RocksimLoader loader = new RocksimLoader(); - //Stupid single stage rocket - OpenRocketDocument doc = loadRocksimRocket(loader); - InputStream stream; - - Assert.assertNotNull(doc); - Rocket rocket = doc.getRocket(); - Assert.assertNotNull(rocket); - Assert.assertEquals("FooBar Test", doc.getRocket().getName()); - Assert.assertTrue(loader.getWarnings().isEmpty()); - - stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt"); - Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream); - doc = loader.loadFromStream(new BufferedInputStream(stream)); - - Assert.assertNotNull(doc); - rocket = doc.getRocket(); - Assert.assertNotNull(rocket); - - //Do some simple asserts; the important thing here is just validating that the mass and cg were - //not overridden for each stage. - Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName()); - Assert.assertEquals(1, loader.getWarnings().size()); - Assert.assertEquals(3, rocket.getStageCount()); - Stage stage1 = (Stage) rocket.getChild(0); - Assert.assertFalse(stage1.isMassOverridden()); - Assert.assertFalse(stage1.isCGOverridden()); - Stage stage2 = (Stage) rocket.getChild(1); - Assert.assertFalse(stage2.isMassOverridden()); - Assert.assertFalse(stage2.isCGOverridden()); - Stage stage3 = (Stage) rocket.getChild(2); - Assert.assertFalse(stage3.isMassOverridden()); - Assert.assertFalse(stage3.isCGOverridden()); - - stream = this.getClass().getResourceAsStream("rocksimTestRocket3.rkt"); - Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream); - doc = loader.loadFromStream(new BufferedInputStream(stream)); - - Assert.assertNotNull(doc); - rocket = doc.getRocket(); - Assert.assertNotNull(rocket); - Assert.assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName()); - Assert.assertEquals(3, rocket.getStageCount()); - stage1 = (Stage) rocket.getChild(0); - stage2 = (Stage) rocket.getChild(1); - stage3 = (Stage) rocket.getChild(2); - - //Do some 1st level and simple asserts; the idea here is to not do a deep validation as that - //should have been covered elsewhere. Assert that the stage overrides are correct. - Assert.assertEquals(2, stage1.getChildCount()); - Assert.assertEquals("Nose cone", stage1.getChild(0).getName()); - Assert.assertEquals("Body tube", stage1.getChild(1).getName()); - Assert.assertTrue(stage1.isMassOverridden()); - Assert.assertEquals(0.185d, stage1.getOverrideMass(), 0.001); - Assert.assertTrue(stage1.isCGOverridden()); - Assert.assertEquals(0.3d, stage1.getOverrideCG().x, 0.001); - Assert.assertEquals(4, loader.getWarnings().size()); - - Assert.assertEquals(1, stage2.getChildCount()); - Assert.assertEquals("2nd Stage Tube", stage2.getChild(0).getName()); - Assert.assertTrue(stage2.isMassOverridden()); - Assert.assertEquals(0.21d, stage2.getOverrideMass(), 0.001); - Assert.assertTrue(stage2.isCGOverridden()); - Assert.assertEquals(0.4d, stage2.getOverrideCG().x, 0.001); - - BodyTube bt = (BodyTube) stage2.getChild(0); - LaunchLug ll = (LaunchLug) bt.getChild(6); - Assert.assertEquals(1.22d, ll.getRadialDirection(), 0.001); - - Assert.assertEquals(2, stage3.getChildCount()); - Assert.assertEquals("Transition", stage3.getChild(0).getName()); - Assert.assertEquals("Body tube", stage3.getChild(1).getName()); - Assert.assertTrue(stage2.isMassOverridden()); - Assert.assertEquals(0.33d, stage3.getOverrideMass(), 0.001); - Assert.assertTrue(stage2.isCGOverridden()); - Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001); - } - - public static OpenRocketDocument loadRocksimRocket(RocksimLoader theLoader) throws IOException, RocketLoadException { - InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket1.rkt"); - try { - Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream); - return theLoader.loadFromStream(new BufferedInputStream(stream)); - } finally { - stream.close(); - } - } - - public static OpenRocketDocument loadRocksimRocket3(RocksimLoader theLoader) throws IOException, RocketLoadException { - InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket3.rkt"); - try { - Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream); - return theLoader.loadFromStream(new BufferedInputStream(stream)); - } finally { - stream.close(); - } - } - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java b/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java deleted file mode 100644 index 14b2494d..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/RocksimTestBase.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * BaseRocksimTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -import net.sf.openrocket.gui.util.SwingPreferences; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.startup.Application; -import org.junit.Assert; -import org.junit.Before; - -import java.lang.reflect.Field; -import java.util.List; - -/** - * A base class for the Rocksim tests. Includes code from the junitx.addons project. - */ -public abstract class RocksimTestBase { - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - @Before - public void setUp() throws Exception { - Application.setPreferences( new SwingPreferences() ); - } - - - public void assertContains(RocketComponent child, List components) { - Assert.assertTrue("Components did not contain child", components.contains(child)); - } - - /** - * Returns the value of the field on the specified object. The name - * parameter is a String specifying the simple name of the - * desired field.

- * - * The object is first searched for any matching field. If no matching - * field is found, the superclasses are recursively searched. - * - * @exception NoSuchFieldException if a field with the specified name is - * not found. - */ - public static Object getField(Object object, - String name) - throws NoSuchFieldException { - if (object == null) { - throw new IllegalArgumentException("Invalid null object argument"); - } - for (Class cls = object.getClass(); cls != null; cls = cls.getSuperclass()) { - try { - Field field = cls.getDeclaredField(name); - field.setAccessible(true); - return field.get(object); - } catch (Exception ex) { - /* in case of an exception, we will throw a new - * NoSuchFieldException object */ - ; - } - } - throw new NoSuchFieldException("Could get value for field " + - object.getClass().getName() + "." + name); - } - - /** - * Returns the value of the field on the specified class. The name - * parameter is a String specifying the simple name of the - * desired field.

- * - * The class is first searched for any matching field. If no matching - * field is found, the superclasses are recursively searched. - * - * @exception NoSuchFieldException if a field with the specified name is - * not found. - */ - public static Object getField(Class cls, - String name) - throws NoSuchFieldException { - if (cls == null) { - throw new IllegalArgumentException("Invalid null cls argument"); - } - Class base = cls; - while (base != null) { - try { - Field field = base.getDeclaredField(name); - field.setAccessible(true); - return field.get(base); - } catch (Exception ex) { - /* in case of an exception, we will throw a new - * NoSuchFieldException object */ - ; - } - base = base.getSuperclass(); - } - throw new NoSuchFieldException("Could get value for static field " + - cls.getName() + "." + name); - } - - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java deleted file mode 100644 index a1dea0aa..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/StreamerHandlerTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * StreamerHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.RocketComponent; -import net.sf.openrocket.rocketcomponent.Streamer; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; - -/** - * StreamerHandler Tester. - */ -public class StreamerHandlerTest extends RocksimTestBase { - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new StreamerHandler(new BodyTube(), new WarningSet()).openElement(null, null, null)); - } - - /** - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testCloseElement() throws Exception { - - BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); - Streamer component = (Streamer) getField(handler, "streamer"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("Width", attributes, "0", warnings); - Assert.assertEquals(0d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001); - handler.closeElement("Width", attributes, "10", warnings); - Assert.assertEquals(10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripWidth(), 0.001); - handler.closeElement("Width", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getStripLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getStripLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - - handler.closeElement("DragCoefficient", attributes, "0.94", warnings); - Assert.assertEquals(0.94d, component.getCD(), 0.001); - handler.closeElement("DragCoefficient", attributes, "-0.94", warnings); - Assert.assertEquals(-0.94d, component.getCD(), 0.001); - handler.closeElement("DragCoefficient", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - } - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testConstructor() throws Exception { - - try { - new StreamerHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); - Streamer component = (Streamer) getField(handler, "streamer"); - assertContains(component, tube.getChildren()); - } - - /** - * Method: setRelativePosition(RocketComponent.Position position) - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testSetRelativePosition() throws Exception { - BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); - Streamer component = (Streamer) getField(handler, "streamer"); - handler.setRelativePosition(RocketComponent.Position.ABSOLUTE); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new StreamerHandler(new BodyTube(), new WarningSet()).getComponent() instanceof Streamer); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.SURFACE, new StreamerHandler(new BodyTube(), new WarningSet()).getMaterialType()); - } - - /** - * Method: endHandler() - * - * @throws Exception thrown if something goes awry - */ - @Test - public void testEndHandler() throws Exception { - BodyTube tube = new BodyTube(); - StreamerHandler handler = new StreamerHandler(tube, new WarningSet()); - Streamer component = (Streamer) getField(handler, "streamer"); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - handler.closeElement("Xb", attributes, "-10", warnings); - handler.closeElement("LocationMode", attributes, "1", warnings); - handler.endHandler("Streamer", attributes, null, warnings); - Assert.assertEquals(RocketComponent.Position.ABSOLUTE, component.getRelativePosition()); - Assert.assertEquals(component.getPositionValue(), -10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); - - handler.closeElement("Xb", attributes, "-10", warnings); - handler.closeElement("LocationMode", attributes, "2", warnings); - handler.endHandler("Streamer", attributes, null, warnings); - Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition()); - Assert.assertEquals(component.getPositionValue(), 10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001); - - handler.closeElement("Thickness", attributes, "0.02", warnings); - Assert.assertEquals(0.01848, handler.computeDensity(RocksimDensityType.ROCKSIM_BULK, 924d), 0.001); - - //Test Density Type 0 (Bulk) - handler.closeElement("Density", attributes, "924.0", warnings); - handler.closeElement("DensityType", attributes, "0", warnings); - handler.endHandler("Streamer", attributes, null, warnings); - Assert.assertEquals(0.01848d, component.getMaterial().getDensity(), 0.001); - - //Test Density Type 1 (Surface) - handler.closeElement("Density", attributes, "0.006685", warnings); - handler.closeElement("DensityType", attributes, "1", warnings); - handler.endHandler("Streamer", attributes, null, warnings); - Assert.assertTrue(Math.abs(0.06685d - component.getMaterial().getDensity()) < 0.00001); - - //Test Density Type 2 (Line) - handler.closeElement("Density", attributes, "0.223225", warnings); - handler.closeElement("DensityType", attributes, "2", warnings); - handler.closeElement("Len", attributes, "3810.", warnings); - handler.closeElement("Width", attributes, "203.2", warnings); - handler.endHandler("Streamer", attributes, null, warnings); - - Assert.assertEquals(1.728190092, component.getMass(), 0.001); - - } - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java b/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java deleted file mode 100644 index cea3a07f..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/TransitionHandlerTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * TransitionHandlerTest.java - */ -package net.sf.openrocket.file.rocksim.importt; - -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.Stage; -import net.sf.openrocket.rocketcomponent.Transition; -import org.junit.Assert; - -import java.util.HashMap; - -/** - * TransitionHandler Tester. - */ -public class TransitionHandlerTest extends RocksimTestBase { - - /** - * Method: constructor - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testConstructor() throws Exception { - - try { - new TransitionHandler(null, new WarningSet()); - Assert.fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException iae) { - //success - } - - Stage stage = new Stage(); - TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); - Transition component = (Transition) getField(handler, "transition"); - assertContains(component, stage.getChildren()); - } - - /** - * Method: openElement(String element, HashMap attributes, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testOpenElement() throws Exception { - Assert.assertEquals(PlainTextHandler.INSTANCE, new TransitionHandler(new Stage(), new WarningSet()).openElement(null, null, null)); - } - - /** - * Method: closeElement(String element, HashMap attributes, String content, WarningSet warnings) - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testCloseElement() throws Exception { - - Stage stage = new Stage(); - HashMap attributes = new HashMap(); - WarningSet warnings = new WarningSet(); - - TransitionHandler handler = new TransitionHandler(stage, new WarningSet()); - Transition component = (Transition) getField(handler, "transition"); - - handler.closeElement("ShapeCode", attributes, "0", warnings); - Assert.assertEquals(Transition.Shape.CONICAL, component.getType()); - handler.closeElement("ShapeCode", attributes, "1", warnings); - Assert.assertEquals(Transition.Shape.OGIVE, component.getType()); - handler.closeElement("ShapeCode", attributes, "17", warnings); - Assert.assertEquals(RocksimNoseConeCode.PARABOLIC.asOpenRocket(), component.getType()); //test of default - handler.closeElement("ShapeCode", attributes, "foo", warnings); - Assert.assertNotNull(component.getType()); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Len", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getLength(), 0.001); - handler.closeElement("Len", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("FrontDia", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getForeRadius(), 0.001); - handler.closeElement("FrontDia", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeRadius(), 0.001); - handler.closeElement("FrontDia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("RearDia", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftRadius(), 0.001); - handler.closeElement("RearDia", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftRadius(), 0.001); - handler.closeElement("RearDia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - final double aft = 100d; - component.setAftRadius(aft); - - handler.closeElement("ConstructionType", attributes, "0", warnings); - component.setAftShoulderRadius(1.1d); - component.setForeShoulderRadius(1.1d); - handler.closeElement("WallThickness", attributes, "-1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(component.getAftRadius(), component.getThickness(), 0.001); - Assert.assertEquals(component.getAftShoulderThickness(), component.getAftShoulderThickness(), 0.001); - Assert.assertEquals(component.getForeShoulderThickness(), component.getForeShoulderThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "100", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(aft, component.getThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "foo", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("ConstructionType", attributes, "1", warnings); - component.setAftShoulderRadius(1.1d); - component.setForeShoulderRadius(1.1d); - handler.closeElement("WallThickness", attributes, "-1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(0d, component.getThickness(), 0.001); - Assert.assertEquals(0d, component.getAftShoulderThickness(), 0.001); - Assert.assertEquals(0d, component.getForeShoulderThickness(), 0.001); - handler.closeElement("WallThickness", attributes, "1.1", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getThickness(), 0.001); - Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderThickness(), 0.001); - Assert.assertEquals(1.1d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderThickness(), 0.001); - - - handler.closeElement("FrontShoulderLen", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getForeShoulderLength(), 0.001); - handler.closeElement("FrontShoulderLen", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001); - handler.closeElement("FrontShoulderLen", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getForeShoulderLength(), 0.001); - handler.closeElement("FrontShoulderLen", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("RearShoulderLen", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftShoulderLength(), 0.001); - handler.closeElement("RearShoulderLen", attributes, "10", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); - handler.closeElement("RearShoulderLen", attributes, "10.0", warnings); - Assert.assertEquals(10d / RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, component.getAftShoulderLength(), 0.001); - handler.closeElement("RearShoulderLen", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("FrontShoulderDia", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getForeShoulderRadius(), 0.001); - handler.closeElement("FrontShoulderDia", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getForeShoulderRadius(), 0.001); - handler.closeElement("FrontShoulderDia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("RearShoulderDia", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getAftShoulderRadius(), 0.001); - handler.closeElement("RearShoulderDia", attributes, "100", warnings); - Assert.assertEquals(100d / RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS, component.getAftShoulderRadius(), 0.001); - handler.closeElement("RearShoulderDia", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - component.setType(Transition.Shape.HAACK); - handler.closeElement("ShapeParameter", attributes, "-1", warnings); - Assert.assertEquals(0d, component.getShapeParameter(), 0.001); - handler.closeElement("ShapeParameter", attributes, "100", warnings); - Assert.assertEquals(Transition.Shape.HAACK.maxParameter(), component.getShapeParameter(), 0.001); - handler.closeElement("ShapeParameter", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - Assert.assertEquals("Could not convert ShapeParameter value of foo. It is expected to be a number.", - warnings.iterator().next().toString()); - - warnings.clear(); - - component.setType(Transition.Shape.CONICAL); - component.setShapeParameter(0d); - handler.closeElement("ShapeParameter", attributes, "100", warnings); - Assert.assertEquals(0d, component.getShapeParameter(), 0.001); - - handler.closeElement("FinishCode", attributes, "-1", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "100", warnings); - Assert.assertEquals(ExternalComponent.Finish.NORMAL, component.getFinish()); - handler.closeElement("FinishCode", attributes, "foo", warnings); - Assert.assertEquals(1, warnings.size()); - warnings.clear(); - - handler.closeElement("Name", attributes, "Test Name", warnings); - Assert.assertEquals("Test Name", component.getName()); - - handler.closeElement("Material", attributes, "Some Material", warnings); - handler.endHandler("Transition", attributes, null, warnings); - Assert.assertTrue(component.getMaterial().getName().contains("Some Material")); - } - - /** - * Method: getComponent() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetComponent() throws Exception { - Assert.assertTrue(new TransitionHandler(new Stage(), new WarningSet()).getComponent() instanceof Transition); - } - - /** - * Method: getMaterialType() - * - * @throws Exception thrown if something goes awry - */ - @org.junit.Test - public void testGetMaterialType() throws Exception { - Assert.assertEquals(Material.Type.BULK, new TransitionHandler(new Stage(), new WarningSet()).getMaterialType()); - } - - -} diff --git a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt b/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt deleted file mode 100644 index 79f7b003..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket1.rkt +++ /dev/null @@ -1,743 +0,0 @@ - -3 - - - FooBar Test -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 -11 -1 -0 -0,1215.49,0,0 -0,35.9506,0,0 -0,1226.38,0,0 -0,47.5027,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 -424.688 -66.04 -1417.95 -1332.23 -0. -1417.95 -0,66.04,0,0 -0,1332.23,0,0 - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,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.1 -1049.21 -Polystyrene PS -Nose cone -65.3999 -1 -0. -126.438 -348.443 -0.0356487 -0.0356487 -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 -2 -0 -0 -0 -blue -2. -0.264319 -2. -0.264319 -1 -0 -8 -0 -0. -396.875 -57.15 -0 -0 -1 -58.3997 -2.159 -0. -53.1012 -66.675 -0. -0. - - - - -Estes -0. -1121.29 -Paper -Body tube -0. -0 -0. -10.636 -180.34 -0.0748306 -0.0748306 -0. -0 -EST 3090 -BT-80 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -3 -1 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -463.55 -66.04 -65.786 -360.68 -0 -0 -0. -0.5 -0. -0. -0 -0 - - - - -BalsaMachining.com -0. -128.148 -Balsa -Transition -0. -0 -0. -39.355 -37.0332 -0.0096001 -0.0096001 -0. -0 -TA7080 -Transition T70 to T80 2 in long -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.92852 -0.848729 --0.92852 -0.848729 -1 -0 -8 -0 -824.23 -66.04 -53.34 -50.8 -0 -35.56 -35.56 -0 -0. -55.118 -53.34 -0. -0 -0. -264.12 -213.32 - - - - -Estes -0. -1121.29 -Paper -Body tube -0. -0 -0. -44.449 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -8 -1 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -875.03 -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 -260.35 -153.85 -155.575 -0.0339112 -0.101734 -0. -0 -FIN-A-01 -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 -9 -0 -0 -0 -blue -34.8792 -1.26026 -46.4312 -1.26026 -1 -0 -8 -0 -1135.38 -3 -184.15 -0. -184.15 -264.956 -282.575 -1.5875 -0 -0 -0 -0. -0. -0. -1 -0.990003 -0. -89.5773 -26.8071 -0. -0. -0. - - - - -Estes -0. -1121.29 -Paper -Body tube -0. -0 -0. -13.008 -228.6 -0. -0. -0. -0 -EST 3086 -BT-50 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -11 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -875.03 -24.7904 -24.13 -457.2 -0 -1 -24. -12.7 -0. -0. -1 -0 - - - - - - - - - - - - - - - - - - - - -445.129 -68.7587 -76.6476 -10.8263 -4.765 -1 -33.4284 -405.535 -2 -8.06125 -4 -6.06125 -22.4787 -8.06125 -1.35915 -65.9349 -1.0686 -76.5426 -4.01173 -172.076 -0. -0. -0 -1828.8 -0 -0. -0 -0.0523599 -0. -0. -770.314 -43. -0. -70. -7.22222 -304.8 -0. -0 -3 -1.34112 -3.53162 -2 -0.01 -0.02 -0 -5 -0. -0.1 -1 -0. -0 -3 -300. -2000. -1 -5.99999 -0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -2 -0.99 -2000. -1500. -2 -0.98 -1 -0. -0 -0.08 -1 -0. -1 -0. -1 -0. -1. -1. -0. -0 -0 -3600. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -0. -[E6-2] -15.4098 -0. -0. -0.25875 -5.69125 -0.11125 -10 -1 -800. -0 -Earth -Standard earth condistions. -4.078 --172.076 -0. -56.537 --3.38254 --56.4357 -0. -0,0,8.06125,0,0 --1,-1,-1,-1,-1 -0,0,0,0,0 -32,32,32,32,32 -1. -1 -0.233111 -0.739954 -0.0208295 -0.000194272 -{b33e529e-1ada-4524-9885-7382d7cf4d64} - - -0 -0 -0. -0. -0 -0. -0. -0. -0. --1 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 - - - - -0 -0 -0. -0. -0 -0. -0. -0. -0. --1 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 -0,0,0 - - - - - - - - - - -1 -E6 -0. -Apogee -0.50038 -0. -5 -2. -0. -0. - - - - - - - diff --git a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt b/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt deleted file mode 100644 index 39b3411b..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket2.rkt +++ /dev/null @@ -1,1583 +0,0 @@ - -3 - - -Three Stage Everything Included Rocket -1 -1 -1 -0.75 -0.8 -0.81 -0.95 -0.95 -3 -0. -0. -0. -0. -0. -0. -0. -0. -1 -914.4 -0 -0 -0 -1 -0 -1 -25 -7 -0 -0,29.6333,326.159,887.03 -0,2,4.93008,33.0782 -0,29.6333,384.174,883.929 -0,2,6.91103,47.1184 -0,0,0,0 -0,0,0,0 -0 -3 -0 -3 -0. -0. -0 -0 -0 -0 -0 -0 -0 -0 -0. -10. -10. -10. -10. -0 -0 -0 -10. -0.15 -black -339.43 -66.3 -2104.53 -2104.53 -0. -1150.33 -0,66.3,66.3,66.3 -0,296.8,954.2,2104.53 - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - - - -Aerospace Speciality Products -0. -128.148 -Balsa -Nose cone -0. -0 -0. -42.0747 -75.3029 -0.0152945 -0.0152945 -0. -0 -BNC80S - -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.0296333 -2. -0.0296333 -1 -0 -8 -0 -0. -88.9 -66.3 -0 -3 -0 -38.1 -0. -0. -64.3 -0. -0. -0. - - -Custom -20. -0. -Custom -Clay -17.8 -1 -17.8 -0. -0. -0. -0. -0. -0 -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 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -17.8 -0 -0. - - - - -Apogee -0. -1121.29 -Paper -Attachment Rod -0. -0 -6.1 -2.47301 -78.85 -0.00684683 -0.00684683 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -3 -1 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -6.1 -13.82 -13.16 -157.7 -0 -0 -0. -0.5 -0. -0. -1 -0 - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Plate -0. -0 -78.9 -7.86272 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -4 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -85. -66. -13.82 -3.17 -0 -0 -0 - - - - -Custom -0. -1400. -Carbon Fiber -Sleeve -0. -0 -0. -17.5527 -13.85 -0. -0. -0. -0 -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 -2 -blue -0. -0. -0. -0. -1 -0 -8 -0 -136.1 -27.7 -13.82 -27.7 -0 -3 -0 - - - - -LOC Precision -170. -0.006685 -Rip stop nylon -Nose Cone Parachute -0. -1 -142.6 -15.8812 -34.5417 -0. -0. -0. -1 -LP-50 -50 In. 16 lines -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 -6 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -148.7 -414.5 -0. -15 -16 -0.05 -1350. -1 -0.00032972 -Carpet String (Apogee 29500) -0.95 - - - - - - - - -Estes -15. -1121.29 -Paper -Body tube -100. -1 -0. -5.80486 -100. -0.0414942 -0.0414942 -0. -0 -EST 3090 -BT-80 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -7 -1 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -88.9 -66.04 -65.79 -200. -0 -0 -0. -0.5 -0. -0. -0 -0 - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -190.2 -7.65502 -1.59 -0. -0. -0. -0 -LOC CR-2.56-0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -8 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -279.1 -65.02 -25.4 -3.18 -0 -0 -0 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -165. -7.62626 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -9 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -253.9 -65. -25.4 -3.17 -0 -0 -0 - - - - -Public Missiles Ltd. -0. -958.705 -Kraft phenolic -Body tube -0. -0 -137.9 -9.8818 -35. -0. -0. -0. -0 -KS-1.1 -KwikSwitch MMT 29mm -0. --1.58371 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -10 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -226.8 -32.26 -29.21 -70. -0 -1 -29. -0.5 -0. -0. -1 -0 - - - - - - - - -Estes -0. -1121.29 -Paper -2nd Stage Tube -0. -0 -0. -10.4685 -180.34 -0.0748306 -0.0748306 -0. -0 -EST 3090 -BT-80 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -11 -1 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -288.9 -66.04 -65.79 -360.68 -0 -0 -0. -0.5 -0. -0. -0 -0 - - -LOC Precision -15.025 -1121.29 -Paper -Tube coupler -0. -1 --10. -20.465 -35.45 -0. -0. -0. -0 -TC-2.56 -Tube Coupler -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 -12 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -278.9 -65.79 -63.25 -70.9 -0 -4 -1 - - - - -Custom -40. -0. -Custom -Electronics -138.3 -1 -138.3 -0. -0. -0. -0. -0. -0 -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 -13 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -427.2 -0 -0. - - - - -Quest -0. -128.148 -Balsa -Fin set -0. -0 -228.6 -1.32269 -19.05 -0.0028791 -0.0086373 -0. -0 -Payloader One -Fin -0. -0.0830777 -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 -14 -0 -0 -0 -blue -2.93008 -0.52856 -5.49629 -0.52856 -1 -0 -8 -0 -517.5 -3 -38.1 -24.9 -45.7 -45.7 -6.6 -2.39 -0 -0 -2 -0. -0. -0. -1 -0.139993 -0. -54.2741 -2.83538 -0.653543 -0. -0. - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -302. -7.65502 -1.59 -0. -0. -0. -0 -LOC CR-2.56-0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -15 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -590.9 -65.02 -25.4 -3.18 -0 -0 -0 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -335.5 -7.62626 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -16 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -624.4 -65. -25.4 -3.17 -0 -0 -0 - - - - -Public Missiles Ltd. -0. -958.705 -Kraft phenolic -Body tube -0. -0 -587.4 -9.8818 -35. -0. -0. -0. -0 -KS-1.1 -KwikSwitch MMT 29mm -0. --1.58371 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -17 -1 -0 -1 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -587.4 -32.26 -29.21 -70. -0 -1 -29. -0.5 -0. -0. -1 -0 - - -Semroc -0. -1121.29 -Paper -Engine block -0. -0 -0. -2.69315 -2.39 -0. -0. -0. -0 -TB-7 -Thrust Block -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 -18 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -587.4 -29.21 -14.61 -4.78 -0 -2 -1 - - - - - - - - - - -BalsaMachining.com -0. -128.148 -Balsa -Transition -0. -0 -0. -8.62096 -25.1578 -0.00986655 -0.00986655 -0. -0 -TA6080 -Transition T60 to T80 2.25 in long -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 -19 -0 -0 -0 -blue --1.20451 -0.675971 --1.20451 -0.675971 -1 -0 -8 -0 -649.58 -66.04 -41.4 -57.15 -0 -20. -38.1 -1 -3. -64.77 -41.38 -0. -0 -0. -153.172 -96.022 - - - - -LOC/Precision -0. -1121.29 -Paper -Body tube -0. -0 -0. -33.5306 -209.2 -0.0604643 -0.0604643 -0. -0 -LOC BT-2.14 -Airframe tube -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -20 -1 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -706.73 -46. -45. -418.4 -0 -0 -0. -0.5 -0. -0. -0 -0 - - -Quest -0. -1121.29 -Paper -Elliptical Fins -0. -0 -69.7 -36.2048 -46. -0.00676907 -0.0203072 -0. -0 -0. --0.519061 -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 -21 -0 -0 -0 -blue -3.64017 -0.802926 -6.19583 -0.802926 -1 -0 -8 -0 -776.43 -3 -92. -46. -46.9 -46.9 -33.49 -3.18 -1 -0 -0 -0. -0. -0. -1 -0.349066 -0. -43.8444 -3.30201 -0.5 -0. -0. - - - - -Public Missiles -0. -1905.24 -G10 fiberglass -Custom Fins -0. -0 -241.7 -256.292 -78.9922 -0.0355266 -0.10658 -0. -0 -FIN-C-02 -Fins -0. -0.357967 -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 -22 -0 -0 -0 -blue -25.7124 -0.996591 -34.6308 -0.996926 -1 -0 -8 -0 -948.43 -3 -152.4 -83.83 -146.72 -146.81 -39.42 -2.38 -2 -0 -2 -101.6 -10.6 -35.6 -1 -0. -0. -89.2598 -19.9941 -0.550066 -0. -0. -121.07 -83.8257 -152.4,0|126.202,146.715|36.455,146.715|0,0| -0,0,0,0,0,0,0 -10,10,10,10,10,10,10 -0,0,0,0,0,0,0 -0.5,10,0.5,0.5,0.00018939,0.001,1 -0.25,5,0.1,0.1,0.00018939,0.001,1 -0,0,0,0,0,0,0 -10,10,10,10,10,10,10 -0,0,0,0,0,0,0 -0.5,10,0.5,0.5,0.00018939,0.001,1 -0.25,5,0.1,0.1,0.00018939,0.001,1 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -379.5 -2.55395 -1.59 -0. -0. -0. -0 -LOC FCR-1.52-1.14 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -23 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -1086.23 -45. -24.79 -3.18 -0 -0 -1 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -272. -2.55395 -1.59 -0. -0. -0. -0 -LOC FCR-1.52-1.14 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -24 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -978.73 -45. -24.79 -3.18 -0 -0 -1 - - - - -Estes -0. -1121.29 -Paper -Body tube -0. -0 -259.7 -5.22902 -91.95 -0. -0. -0. -0 -EST 3086 -BT-50 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -25 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -966.43 -24.79 -24.13 -183.9 -0 -1 -24. -0.5 -0. -0. -1 -0 - - - - - - - - - - - - - - - - - diff --git a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt b/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt deleted file mode 100644 index df1788c2..00000000 --- a/test/net/sf/openrocket/file/rocksim/importt/rocksimTestRocket3.rkt +++ /dev/null @@ -1,1961 +0,0 @@ - -3 - - -Three Stage Everything Included Rocket - Override Total Mass/CG -1 -1 -1 -0.75 -0.8 -0.81 -0.95 -0.95 -3 -185. -210. -330. -0. -0. -300. -400. -500. -1 -914.4 -0 -0 -0 -1 -0 -1 -32 -7 -0 -0,29.6333,327.236,966.855 -0,2,4.95647,83.562 -0,29.6333,385.082,953.76 -0,2,6.95476,97.0629 -0,0,0,0 -0,0,0,0 -0 -3 -0 -3 -0. -0. -0 -0 -0 -0 -0 -0 -0 -0 -0. -10. -10. -10. -10. -0 -0 -0 -10. -0.15 -black -334.83 -66. -2155.23 -2155.23 -0. -1150.33 -0,66,66,66 -0,347.5,1004.9,2155.23 - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - - - -Aerospace Speciality Products -0. -128.148 -Balsa -Nose cone -0. -0 -0. -42.6368 -76.0242 -0.0152192 -0.0152192 -0. -0 -BNC80S - -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 -1 -0 -0 -blue -2. -0.0296333 -2. -0.0296333 -1 -0 -8 -0 -0. -88.9 -66. -0 -3 -0 -38.1 -0. -0. -65.9 -0. -0. -0. - - -Custom -20. -0. -Custom -Clay -17.8 -1 -17.8 -0. -0. -0. -0. -0. -0 -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 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -17.8 -0 -0. - - - - -Apogee -0. -1121.29 -Paper -Attachment Rod -0. -0 -6.1 -2.47301 -78.85 -0.00684683 -0.00684683 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -3 -1 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -6.1 -13.82 -13.16 -157.7 -0 -0 -0. -0.5 -0. -0. -1 -0 - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Plate -0. -0 -78.9 -7.86272 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -4 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -85. -66. -13.82 -3.17 -0 -0 -0 - - - - -Custom -0. -1400. -Carbon Fiber -Sleeve -0. -0 -0. -17.5527 -13.85 -0. -0. -0. -0 -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 -2 -blue -0. -0. -0. -0. -1 -0 -8 -0 -136.1 -27.7 -13.82 -27.7 -0 -3 -0 - - - - -LOC Precision -170. -0.006685 -Rip stop nylon -Nose Cone Parachute -0. -1 -142.6 -15.8812 -34.5417 -0. -0. -0. -1 -LP-50 -50 In. 16 lines -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 -6 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -148.7 -414.5 -0. -15 -16 -0.05 -1350. -1 -0.00032972 -Carpet String (Apogee 29500) -0.95 - - - - - - - - -Estes -15. -1121.29 -Paper -Body tube -100. -1 -0. -5.805 -100. -0.0414942 -0.0414942 -0. -0 -EST 3090 -BT-80 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -7 -1 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -88.9 -66. -65.79 -200. -0 -0 -0. -0.5 -0. -0. -0 -0 - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -190.2 -7.65502 -1.59 -0. -0. -0. -0 -LOC CR-2.56-0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -8 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -279.1 -65.02 -25.4 -3.18 -0 -0 -0 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -165. -7.62626 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -9 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -253.9 -65. -25.4 -3.17 -0 -0 -0 - - - - -Public Missiles Ltd. -0. -958.705 -Kraft phenolic -Body tube -0. -0 -137.9 -9.8818 -35. -0. -0. -0. -0 -KS-1.1 -KwikSwitch MMT 29mm -0. --1.58371 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -10 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -226.8 -32.26 -29.21 -70. -0 -1 -29. -0.5 -0. -0. -1 -0 - - - - -Apogee -0. -1121.29 -Paper -Launch lug -0. -0 -77.2 -1.11942 -38.1 -0.00374518 -0.00199411 -0. -0 -13056 - -37.185 -3.14 -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 -26 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -166.1 -8.33 -7.26 -76.2 -0 - - - - -Custom -0. -0. -Pod -0. -0 -200. -0. -0. -0. -0. -0. -0 -36.175 --1.50735 -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 -29 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -288.9 -1 -1 -1 - - -Apogee -0. -958.705 -Kraft phenolic -Body tube -0. -0 -0. -0.400397 -29.3 -0.00116902 -0.00116902 -0. -0 -9601 -6 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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -30 -0 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -288.9 -6.35 -5.59 -58.6 -0 -0 -0. -0.5 -0. -0. -0 -0 - - - - - - - - - - -Estes -0. -1121.29 -Paper -2nd Stage Tube -0. -0 -0. -10.468 -180.34 -0.0748306 -0.0748306 -0. -0 -EST 3090 -BT-80 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -11 -0 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -288.9 -66. -65.79 -360.68 -0 -0 -0. -0.5 -0. -0. -0 -0 - - -LOC Precision -15.025 -1121.29 -Paper -Tube coupler -0. -1 --10. -20.465 -35.45 -0. -0. -0. -0 -TC-2.56 -Tube Coupler -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 -12 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -278.9 -65.79 -63.25 -70.9 -0 -4 -1 - - - - -Custom -40. -0. -Custom -Electronics -138.3 -1 -138.3 -0. -0. -0. -0. -0. -0 -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 -13 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -427.2 -0 -0. - - - - -Quest -0. -128.148 -Balsa -Fin set -0. -0 -228.6 -1.32269 -19.05 -0.0028791 -0.0086373 -0. -0 -Payloader One -Fin -0. -0.0830777 -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 -14 -0 -0 -0 -blue -2.95647 -0.52856 -5.54523 -0.52856 -1 -0 -8 -0 -517.5 -3 -38.1 -24.9 -45.7 -45.7 -6.6 -2.39 -0 -0 -2 -0. -0. -0. -1 -0.139993 -0. -54.2541 -2.86063 -0.653543 -0. -0. - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -302. -7.65502 -1.59 -0. -0. -0. -0 -LOC CR-2.56-0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -15 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -590.9 -65.02 -25.4 -3.18 -0 -0 -0 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -335.5 -7.62626 -1.585 -0. -0. -0. -0 -LOC CR-2.56-(2)0.95 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -16 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -624.4 -65. -25.4 -3.17 -0 -0 -0 - - - - -Public Missiles Ltd. -0. -958.705 -Kraft phenolic -Body tube -0. -0 -587.4 -9.8818 -35. -0. -0. -0. -0 -KS-1.1 -KwikSwitch MMT 29mm -0. --1.58371 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -17 -0 -0 -1 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -587.4 -32.26 -29.21 -70. -0 -1 -29. -0.5 -0. -0. -1 -0 - - -Semroc -0. -1121.29 -Paper -Engine block -0. -0 -0. -2.69315 -2.39 -0. -0. -0. -0 -TB-7 -Thrust Block -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 -18 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -587.4 -29.21 -14.61 -4.78 -0 -2 -1 - - - - - - -Apogee -0. -1121.29 -Paper -Launch lug -0. -0 -265.8 -1.11942 -38.1 -0.00374518 -0.00199411 -0. -0 -13056 - -37.185 -1.22 -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 -27 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -554.7 -8.33 -7.26 -76.2 -0 - - - - - - - - -BalsaMachining.com -0. -128.148 -Balsa -Transition -0. -0 -0. -8.61936 -25.1551 -0.0098623 -0.0098623 -0. -0 -TA6080 -Transition T60 to T80 2.25 in long -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 -19 -0 -0 -0 -blue --1.213 -0.675973 --1.213 -0.675973 -1 -0 -8 -0 -649.58 -66. -41.4 -57.15 -0 -20. -38.1 -1 -3. -64.77 -41.38 -0. -0 -0. -153.339 -96.1895 - - - - -LOC/Precision -0. -1121.29 -Paper -Body tube -0. -0 -0. -0. -nan. -0.0544179 -0.0544179 -0. -0 -LOC BT-2.14 -Airframe tube -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -20 -0 -0 -0 -rgb(54,250,21) -0. -0. -0. -0. -1 -0 -8 -0 -706.73 -41.4 -41. -418.4 -0 -0 -0. -0.5 -0. -0. -0 -0 - - -Quest -0. -1121.29 -Paper -Elliptical Fins -0. -0 -69.7 -36.2048 -46. -0.00676907 -0.0203072 -0. -0 -0. --0.519061 -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 -21 -0 -0 -0 -blue -3.61024 -0.802926 -6.03948 -0.802926 -1 -0 -8 -0 -776.43 -3 -92. -46. -46.9 -46.9 -33.49 -3.18 -1 -0 -0 -0. -0. -0. -1 -0.349066 -0. -41.5444 -3.21868 -0.5 -0. -0. - - - - -Public Missiles -0. -1905.24 -G10 fiberglass -Custom Fins -0. -0 -241.7 -256.292 -78.9922 -0.0355266 -0.10658 -0. -0 -FIN-C-02 -Fins -0. -0.357967 -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 -22 -0 -0 -0 -blue -25.7037 -0.996526 -34.1865 -0.996822 -1 -0 -8 -0 -948.43 -3 -152.4 -84.53 -146.72 -146.81 -39.07 -2.38 -2 -0 -2 -101.6 -10.6 -35.6 -1 -0. -0. -87.0529 -19.7376 -0.554659 -0. -0. -121.39 -84.5261 -152.4,0|126.202,146.715|36.455,146.715|0,0| -0,0,0,0,0,0,0 -10,10,10,10,10,10,10 -0,0,0,0,0,0,0 -0.5,10,0.5,0.5,0.00018939,0.001,1 -0.25,5,0.1,0.1,0.00018939,0.001,1 -0,0,0,0,0,0,0 -10,10,10,10,10,10,10 -0,0,0,0,0,0,0 -0.5,10,0.5,0.5,0.00018939,0.001,1 -0.25,5,0.1,0.1,0.00018939,0.001,1 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -379.5 -1.99074 -1.59 -0. -0. -0. -0 -LOC FCR-1.52-1.14 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -23 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -1086.23 -41.4 -24.79 -3.18 -0 -0 -1 - - - - -LOC Precision -0. -724.996 -Aircraft plywood (LOC) -Centering ring -0. -0 -272. -1.99074 -1.59 -0. -0. -0. -0 -LOC FCR-1.52-1.14 -Centering Ring -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -24 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -978.73 -41.4 -24.79 -3.18 -0 -0 -1 - - - - -Estes -0. -1121.29 -Paper -Body tube -0. -0 -259.7 -5.22902 -91.95 -0. -0. -0. -0 -EST 3086 -BT-50 -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. -rgb(0,0,250) -rgb(0,0,250) -rgb(255,255,255) -1 -25 -0 -0 -0 -rgb(0,0,250) -0. -0. -0. -0. -1 -0 -8 -0 -966.43 -24.79 -24.13 -183.9 -0 -1 -24. -0.5 -0. -0. -1 -0 - - - - -Custom -0. -1121.29 -Paper -Tube fins -0. -0 -0. -12.6878 -24.79 -0.0688063 -0.0688063 -0. -0 -35.395 -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 -28 -0 -0 -0 -blue -10.866 -0.707815 -10.866 -0.707815 -1 -0 -8 -0 -706.73 -24.79 -24.13 -49.58 -0 -9 -0.715549 -9 - - - - -Custom -0. -688.794 -Cardboard -Ringtail -0. -0 -0. -2.93707 -10. -0.00474229 -0.00444249 -0. -0 -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 -31 -0 -0 -2 -rgb(255,9,18) -39.6386 -1.10463 -39.6386 -1.10463 -1 -0 -8 -0 -1105.13 -3 -20. -20. -7.495 -7.495 -0. -3. -0 -0 -0 -0. -0. -0. -1 -0. -0. -0. -0. -0. -0. -0. -56.39 -55.37 -20. -1121.29 -0 -Paper - - - - -Apogee -0. -1309. -Mylar -Streamer -0. -0 -149.4 -5.67514 -50.8 -0. -0. -0. -0 -29006 - -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 -32 -0 -0 -0 -blue -0. -0. -0. -0. -1 -0 -8 -0 -856.13 -1422.4 -101.6 -0.03 -1 -0.127 -0 -1 - - - - - - - - - - - - - - - - - diff --git a/test/net/sf/openrocket/gui/TestGUI.java b/test/net/sf/openrocket/gui/TestGUI.java deleted file mode 100644 index 6e05aabb..00000000 --- a/test/net/sf/openrocket/gui/TestGUI.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.sf.openrocket.gui; - -import org.junit.Test; - -public class TestGUI { - - @Test - public void test() { - // No-op - } - -} diff --git a/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java b/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java deleted file mode 100644 index e45693bc..00000000 --- a/test/net/sf/openrocket/gui/configdialog/FinSetConfigTest.java +++ /dev/null @@ -1,257 +0,0 @@ -package net.sf.openrocket.gui.configdialog; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import net.sf.openrocket.gui.adaptors.DoubleModel; -import net.sf.openrocket.rocketcomponent.BodyTube; -import net.sf.openrocket.rocketcomponent.CenteringRing; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.util.BaseTestCase.BaseTestCase; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class FinSetConfigTest extends BaseTestCase { - - static Method method; - - @BeforeClass - public static void classSetup() throws Exception { - method = FinSetConfig.class.getDeclaredMethod("computeFinTabLength", List.class, Double.class, Double.class, DoubleModel.class, RocketComponent.class); - Assert.assertNotNull(method); - method.setAccessible(true); - } - - /** - * Test no centering rings. - * - * @throws Exception - */ - @Test - public void testComputeFinTabLength() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - RocketComponent parent = new BodyTube(); - - Double result = (Double)method.invoke(null, rings, 10d, 11d, dm, parent); - Assert.assertEquals(0.0001, 11d, result.doubleValue()); - result = (Double)method.invoke(null, null, 10d, 11d, dm, parent); - Assert.assertEquals(11d, result.doubleValue(), 0.0001); - } - - /** - * Test 2 rings both ahead of the fin. - */ - @Test - public void testCompute2LeadingRings() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - RocketComponent parent = new BodyTube(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setLength(0.004); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setPositionValue(0.43); - CenteringRing ring2 = new CenteringRing(); - ring2.setLength(0.004); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setPositionValue(0.45); - rings.add(ring1); - rings.add(ring2); - parent.addChild(ring1); - parent.addChild(ring2); - - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.01, result.doubleValue(), 0.0001); - - } - - /** - * Test one ring, ahead of the fin. - */ - @Test - public void testCompute1Ring() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setLength(0.004); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setPositionValue(0.43); - rings.add(ring1); - - RocketComponent parent = new BodyTube(); - parent.addChild(ring1); - - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.01, result.doubleValue(), 0.0001); - } - - /** - * Test one ring ahead of the fin, one ring within the root chord. - */ - @Test - public void testComputeOneLeadingOneRingWithinRoot() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setLength(0.004); - ring1.setPositionValue(0.43); - CenteringRing ring2 = new CenteringRing(); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setLength(0.004); - ring2.setPositionValue(0.45); - rings.add(ring1); - rings.add(ring2); - - RocketComponent parent = new BodyTube(1d, 0.01); - parent.addChild(ring1); - parent.addChild(ring2); - - Double result = (Double)method.invoke(null, rings, 0.45d, 0.01, dm, parent); - Assert.assertEquals(0.01 - 0.004, result.doubleValue(), 0.0001); - } - - /** - * Test one ring ahead of the fin, one ring beyond the root chord. - */ - @Test - public void testComputeOneLeadingOneTrailingRing() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setLength(0.004); - ring1.setPositionValue(0.43); - CenteringRing ring2 = new CenteringRing(); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setLength(0.004); - ring2.setPositionValue(0.48); - rings.add(ring1); - rings.add(ring2); - - RocketComponent parent = new BodyTube(); - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, ring1); - Assert.assertEquals(0.01, result.doubleValue(), 0.0001); - } - - /** - * Test one ring within the root chord, another ring beyond the root chord. - */ - @Test - public void testComputeOneWithinRootOneTrailingRing() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setLength(0.004); - ring1.setPositionValue(0.4701); - CenteringRing ring2 = new CenteringRing(); - ring2.setLength(0.004); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setPositionValue(0.48); - rings.add(ring1); - rings.add(ring2); - RocketComponent parent = new BodyTube(1.0d, 0.1d); - parent.addChild(ring1); - parent.addChild(ring2); - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.0059, result.doubleValue(), 0.0001); - } - - /** - * Test both rings within the root chord. - */ - @Test - public void testBothRingsWithinRootChord() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - RocketComponent parent = new BodyTube(1.0000d, 0.1d); - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setLength(0.004); - ring1.setPositionValue(0.4701); - parent.addChild(ring1); - CenteringRing ring2 = new CenteringRing(); - ring2.setLength(0.004); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setPositionValue(0.4750); - parent.addChild(ring2); - rings.add(ring1); - rings.add(ring2); - - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.0009, result.doubleValue(), 0.0002); - } - - - /** - * Test both rings beyond the root chord. - */ - @Test - public void testBothRingsBeyondRootChord() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.TOP); - ring1.setLength(0.004); - ring1.setPositionValue(0.48); - CenteringRing ring2 = new CenteringRing(); - ring2.setRelativePosition(RocketComponent.Position.TOP); - ring2.setLength(0.004); - ring2.setPositionValue(0.49); - rings.add(ring1); - rings.add(ring2); - RocketComponent parent = new BodyTube(1.0d, 0.1d); - parent.addChild(ring1); - parent.addChild(ring2); - - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.0, result.doubleValue(), 0.0001); - } - - /** - * Test both rings within the root chord - the top ring has an adjacent ring (so 3 rings total). - */ - @Test - public void test3RingsWithinRootChord() throws Exception { - DoubleModel dm = new DoubleModel(1d); - List rings = new ArrayList(); - - CenteringRing ring1 = new CenteringRing(); - ring1.setRelativePosition(RocketComponent.Position.ABSOLUTE); - ring1.setLength(0.004); - ring1.setPositionValue(0.47); - CenteringRing ring2 = new CenteringRing(); - ring2.setRelativePosition(RocketComponent.Position.ABSOLUTE); - ring2.setLength(0.004); - ring2.setPositionValue(0.4702); - CenteringRing ring3 = new CenteringRing(); - ring3.setRelativePosition(RocketComponent.Position.ABSOLUTE); - ring3.setLength(0.004); - ring3.setPositionValue(0.4770); - rings.add(ring1); - rings.add(ring2); - rings.add(ring3); - BodyTube parent = new BodyTube(1.0d, 0.1d); - parent.setPositionValue(0); - parent.addChild(ring1); - parent.addChild(ring2); - parent.addChild(ring3); - - Double result = (Double)method.invoke(null, rings, 0.47d, 0.01, dm, parent); - Assert.assertEquals(0.0028, result.doubleValue(), 0.0001); - } - -} diff --git a/test/net/sf/openrocket/gui/print/TestPaperSize.java b/test/net/sf/openrocket/gui/print/TestPaperSize.java deleted file mode 100644 index 82677cdc..00000000 --- a/test/net/sf/openrocket/gui/print/TestPaperSize.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.sf.openrocket.gui.print; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class TestPaperSize { - - @Test - public void testGetDefaultForCountry() { - assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("US")); - assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("cA")); - assertEquals(PaperSize.LETTER, PaperSize.getDefaultForCountry("mx")); - - assertEquals(PaperSize.A4, PaperSize.getDefaultForCountry("FI")); - assertEquals(PaperSize.A4, PaperSize.getDefaultForCountry("xy")); - - assertNull(PaperSize.getDefaultForCountry("FIN")); - assertNull(PaperSize.getDefaultForCountry("a")); - assertNull(PaperSize.getDefaultForCountry("A4")); - assertNull(PaperSize.getDefaultForCountry(null)); - } - - @Test - public void testGetSizeFromString() { - assertEquals(PaperSize.LETTER, PaperSize.getSizeFromString("Letter")); - assertEquals(PaperSize.LEGAL, PaperSize.getSizeFromString(" legal\t")); - assertEquals(PaperSize.A4, PaperSize.getSizeFromString(" A4\n")); - assertEquals(PaperSize.A3, PaperSize.getSizeFromString("A3")); - - assertNull(PaperSize.getSizeFromString("#A4")); - assertNull(PaperSize.getSizeFromString("")); - assertNull(PaperSize.getSizeFromString(null)); - } - -} diff --git a/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java b/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java deleted file mode 100644 index 94909b0c..00000000 --- a/test/net/sf/openrocket/l10n/TestClassBasedTranslator.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.sf.openrocket.l10n; - -import static org.junit.Assert.*; - -import java.util.MissingResourceException; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.auto.Mock; -import org.jmock.integration.junit4.JMock; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.Test; -import org.junit.runner.RunWith; - - -@RunWith(JMock.class) -public class TestClassBasedTranslator { - Mockery context = new JUnit4Mockery(); - - @Mock - Translator translator; - - @Test - public void testClassName() { - ClassBasedTranslator cbt = new ClassBasedTranslator(null, 0); - assertEquals("TestClassBasedTranslator", cbt.getClassName()); - - cbt = new ClassBasedTranslator(null, "foobar"); - assertEquals("foobar", cbt.getClassName()); - } - - @Test - public void testGetWithClassName() { - ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(returnValue("foobar")); - }}); - // @formatter:on - - assertEquals("foobar", cbt.get("fake.key")); - } - - - @Test - public void testGetWithoutClassName() { - ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); - oneOf(translator).get("fake.key"); will(returnValue("barbaz")); - }}); - // @formatter:on - - assertEquals("barbaz", cbt.get("fake.key")); - } - - - @Test - public void testMissing() { - ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(translator).get("TestClassBasedTranslator.fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); - oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); - }}); - // @formatter:on - - try { - fail("Returned: " + cbt.get("fake.key")); - } catch (MissingResourceException e) { - assertEquals("Neither key 'TestClassBasedTranslator.fake.key' nor 'fake.key' could be found", e.getMessage()); - } - - } -} diff --git a/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java b/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java deleted file mode 100644 index 153b921f..00000000 --- a/test/net/sf/openrocket/l10n/TestExceptionSuppressingTranslator.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.sf.openrocket.l10n; - -import static org.junit.Assert.*; - -import java.util.MissingResourceException; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.auto.Mock; -import org.jmock.integration.junit4.JMock; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(JMock.class) -public class TestExceptionSuppressingTranslator { - Mockery context = new JUnit4Mockery(); - - @Mock - Translator translator; - - @Test - public void testSuccessful() { - ExceptionSuppressingTranslator est = new ExceptionSuppressingTranslator(translator); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(translator).get("fake.key"); will(returnValue("foobar")); - }}); - // @formatter:on - - assertEquals("foobar", est.get("fake.key")); - } - - - @Test - public void testFailure() { - ExceptionSuppressingTranslator est = new ExceptionSuppressingTranslator(translator); - - assertFalse("Prerequisite failed", ExceptionSuppressingTranslator.errorReported); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); - oneOf(translator).get("fake.key"); will(throwException(new MissingResourceException("a", "b", "c"))); - oneOf(translator).get("fake.key2"); will(throwException(new MissingResourceException("a", "b", "c"))); - }}); - // @formatter:on - - // Test first failure - assertEquals("fake.key", est.get("fake.key")); - assertTrue(ExceptionSuppressingTranslator.errorReported); - - // Test second failure - assertEquals("fake.key", est.get("fake.key")); - assertTrue(ExceptionSuppressingTranslator.errorReported); - - // Test failure with other key - assertEquals("fake.key2", est.get("fake.key2")); - assertTrue(ExceptionSuppressingTranslator.errorReported); - } - - -} diff --git a/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java b/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java deleted file mode 100644 index db7dbfc7..00000000 --- a/test/net/sf/openrocket/l10n/TestResourceBundleTranslator.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.sf.openrocket.l10n; - -import static org.junit.Assert.*; - -import java.util.Locale; -import java.util.MissingResourceException; - -import org.junit.Test; - -public class TestResourceBundleTranslator { - - @Test - public void testSuccessfulUS() { - ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.US); - assertEquals("messages.properties", trans.get("debug.currentFile")); - } - - @Test - public void testSuccessfulFR() { - ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.FRENCH); - assertEquals("messages_fr.properties", trans.get("debug.currentFile")); - } - - @Test - public void testFailure() { - ResourceBundleTranslator trans = new ResourceBundleTranslator("l10n.messages", Locale.US); - try { - fail("Returned: " + trans.get("missing")); - } catch (MissingResourceException e) { - // Expected - } - } - -} diff --git a/test/net/sf/openrocket/logging/CyclicBufferTest.java b/test/net/sf/openrocket/logging/CyclicBufferTest.java deleted file mode 100644 index c7672178..00000000 --- a/test/net/sf/openrocket/logging/CyclicBufferTest.java +++ /dev/null @@ -1,162 +0,0 @@ -package net.sf.openrocket.logging; - -import static org.junit.Assert.*; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Random; - -import org.junit.Test; - - -public class CyclicBufferTest { - - @Test - public void testBasic() { - CyclicBuffer buffer = new CyclicBuffer(5); - LinkedList correct = new LinkedList(); - - Random rnd = new Random(); - for (int i=0; i<50; i++) { - int n = rnd.nextInt(); - buffer.add(n); - correct.add(n); - if (correct.size() > 5) - correct.remove(); - assertEquals(correct, buffer.asList()); - } - } - - @Test - public void testComplex() { - CyclicBuffer buffer = new CyclicBuffer(5); - - testContents(buffer); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.offer(1); - testContents(buffer, 1); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.add(2); - testContents(buffer, 1, 2); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.add(3); - testContents(buffer, 1, 2, 3); - assertEquals(0, buffer.getOverwriteCount()); - - assertEquals(1, (int)buffer.remove()); - testContents(buffer, 2, 3); - assertEquals(0, buffer.getOverwriteCount()); - - assertEquals(2, (int)buffer.peek()); - testContents(buffer, 2, 3); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.offer(-2); - testContents(buffer, 2, 3, -2); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.offer(-3); - testContents(buffer, 2, 3, -2, -3); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.offer(-4); - testContents(buffer, 2, 3, -2, -3, -4); - assertEquals(0, buffer.getOverwriteCount()); - - buffer.offer(5); - testContents(buffer, 3, -2, -3, -4, 5); - assertEquals(1, buffer.getOverwriteCount()); - - buffer.offer(6); - testContents(buffer, -2, -3, -4, 5, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(-2, (int)buffer.peek()); - testContents(buffer, -2, -3, -4, 5, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(-2, (int)buffer.remove()); - testContents(buffer, -3, -4, 5, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(-3, (int)buffer.remove()); - testContents(buffer, -4, 5, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(-4, (int)buffer.poll()); - testContents(buffer, 5, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(5, (int)buffer.remove()); - testContents(buffer, 6); - assertEquals(2, buffer.getOverwriteCount()); - - assertEquals(6, (int)buffer.poll()); - testContents(buffer); - assertEquals(2, buffer.getOverwriteCount()); - - assertNull(buffer.peek()); - assertNull(buffer.poll()); - testContents(buffer); - assertEquals(2, buffer.getOverwriteCount()); - } - - - @Test - public void testRandom() { - CyclicBuffer buffer = new CyclicBuffer(4); - LinkedList correct = new LinkedList(); - - Random rnd = new Random(); - for (int i=0; i<500; i++) { - - if (rnd.nextBoolean()) { - int n = rnd.nextInt(); - buffer.add(n); - correct.add(n); - if (correct.size() > 4) - correct.remove(); - } else { - Integer n = buffer.poll(); - if (correct.size() > 0) { - assertEquals(correct.remove(), n); - } else { - assertNull(n); - } - } - - assertEquals(correct, buffer.asList()); - } - } - - - private void testContents(CyclicBuffer buffer, int ... values) { - - // Test using iterator - Iterator iterator = buffer.iterator(); - for (int v: values) { - assertTrue(iterator.hasNext()); - assertEquals(v, (int)iterator.next()); - } - assertFalse(iterator.hasNext()); - try { - iterator.next(); - fail(); - } catch (NoSuchElementException ignore) { } - - // Test using list - List list = buffer.asList(); - assertEquals("List: " + list, values.length, list.size()); - for (int i=0; i list = logger.getLogs(); - assertEquals(16, list.size()); - - assertEquals("user 1", list.get(0).getMessage()); - assertEquals("warn 1", list.get(1).getMessage()); - assertEquals("user 2", list.get(2).getMessage()); - assertEquals("===== 2 INFO lines removed =====", list.get(3).getMessage()); - assertEquals("info 3", list.get(4).getMessage()); - assertEquals("error 1", list.get(5).getMessage()); - assertEquals("===== 4 DEBUG lines removed =====", list.get(6).getMessage()); - assertEquals("debug 5", list.get(7).getMessage()); - assertEquals("warn 2", list.get(8).getMessage()); - assertEquals("debug 6", list.get(9).getMessage()); - assertEquals("user 3", list.get(10).getMessage()); - assertEquals("info 4", list.get(11).getMessage()); - assertEquals("debug 7", list.get(12).getMessage()); - assertEquals("info 5", list.get(13).getMessage()); - assertEquals("debug 8", list.get(14).getMessage()); - assertEquals("info 6", list.get(15).getMessage()); - - } - -} diff --git a/test/net/sf/openrocket/logging/LogLevelTest.java b/test/net/sf/openrocket/logging/LogLevelTest.java deleted file mode 100644 index 63c77012..00000000 --- a/test/net/sf/openrocket/logging/LogLevelTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.sf.openrocket.logging; - -import static net.sf.openrocket.logging.LogLevel.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -public class LogLevelTest { - - @Test - public void testLevels() { - assertTrue(DEBUG.atLeast(DEBUG)); - assertFalse(DEBUG.atLeast(INFO)); - assertTrue(ERROR.atLeast(WARN)); - - assertTrue(ERROR.moreThan(WARN)); - assertFalse(ERROR.moreThan(ERROR)); - - assertEquals(5, LENGTH); - } - -} diff --git a/test/net/sf/openrocket/logging/LoggingTest.java b/test/net/sf/openrocket/logging/LoggingTest.java deleted file mode 100644 index 39e4777d..00000000 --- a/test/net/sf/openrocket/logging/LoggingTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.sf.openrocket.logging; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Test; - -public class LoggingTest { - - @Test - public void testLoggers() { - // Ensure a sane stack trace - actualTest(); - } - - private void actualTest() { - BufferLogger log3 = new BufferLogger(3); - BufferLogger log4 = new BufferLogger(4); - - DelegatorLogger delegator = new DelegatorLogger(); - delegator.addLogger(log3); - delegator.addLogger(log4); - - delegator.debug("one"); - delegator.debug("two"); - delegator.info("three"); - delegator.warn(1, "four"); - delegator.error("five"); - - List logs = log4.getLogs(); - assertEquals(4, logs.size()); - assertTrue(logs.get(0).toString(), logs.get(0).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +DEBUG \\(-\\) two")); - assertTrue(logs.get(1).toString(), logs.get(1).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +INFO \\(LoggingTest.java:[0-9]+\\) three")); - assertTrue(logs.get(2).toString(), logs.get(2).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +WARN \\(LoggingTest.java:[0-9]+ LoggingTest.java:[0-9]+\\) four")); - assertTrue(logs.get(3).toString(), logs.get(3).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +ERROR \\(LoggingTest.java:[0-9]+\\) five")); - - logs = log3.getLogs(); - assertEquals(3, logs.size()); - assertTrue(logs.get(0).toString(), logs.get(0).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +INFO \\(LoggingTest.java:[0-9]+\\) three")); - assertTrue(logs.get(1).toString(), logs.get(1).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +WARN \\(LoggingTest.java:[0-9]+ LoggingTest.java:[0-9]+\\) four")); - assertTrue(logs.get(2).toString(), logs.get(2).toString().matches( - " *[0-9]+ +[0-9]+\\.[0-9]+ +ERROR \\(LoggingTest.java:[0-9]+\\) five")); - - } - - public static void main(String[] args) { - PrintStreamLogger logger = new PrintStreamLogger(); - - logger.debug("a debug message"); - logger.info("an info message"); - logger.warn("a warning message"); - logger.error("an error message"); - - logger.debug(4, "Debugging"); - } -} diff --git a/test/net/sf/openrocket/logging/TraceExceptionTest.java b/test/net/sf/openrocket/logging/TraceExceptionTest.java deleted file mode 100644 index 72f3c13a..00000000 --- a/test/net/sf/openrocket/logging/TraceExceptionTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package net.sf.openrocket.logging; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class TraceExceptionTest { - - private TraceException getViaAccess() { - - /* - * The SubClass test bases on the fact that getViaAccess method is defined on a row number < 20 - * and the return statement is on a row number > 20. - * - * The JRE sometimes adds an additional "access$NNN" method call between the calls with the - * row number equal to the method definition line. - * - * - * - * - * - * - * - */ - - return new TraceException(0, 1); - } - - - @Test - public void testBasic() { - TraceException trace = new TraceException(); - assertMatch("\\(TraceExceptionTest.java:[2-9][0-9]\\)", trace); - } - - - @Test - public void testOneLevelUp() { - // @formatter:off - these need to be on the same line number - TraceException trace = getOneLevelUp(); TraceException ref = new TraceException(); - // @formatter:on - assertEquals(ref.getMessage(), trace.getMessage()); - } - - private TraceException getOneLevelUp() { - return new TraceException(1); - } - - - @Test - public void testTwoLevels() { - TraceException trace = getTwoLevels(); - assertMatch("\\(TraceExceptionTest.java:[2-9][0-9] TraceExceptionTest.java:[2-9][0-9]\\)", trace); - } - - private TraceException getTwoLevels() { - return new TraceException(0, 1); - } - - - @Test - public void testViaSubclass() { - /* - * This tests that TraceException.getMessage ignores the synthetic "access$0" method calls. - */ - - TraceException trace = new SubClass().getTrace(); - assertMatch("\\(TraceExceptionTest.java:[2-9][0-9] TraceExceptionTest.java:[2-9][0-9]\\)", trace); - } - - private class SubClass { - private TraceException getTrace() { - return getViaAccess(); - } - } - - - - - - private void assertMatch(String regex, TraceException trace) { - boolean match = trace.getMessage().matches(regex); - if (!match) { - trace.printStackTrace(); - assertTrue("Was: " + trace.getMessage(), match); - } - } - -} diff --git a/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java b/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java deleted file mode 100644 index a0aea634..00000000 --- a/test/net/sf/openrocket/models/gravity/WGSGravityModelTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.sf.openrocket.models.gravity; - -import static org.junit.Assert.assertEquals; -import net.sf.openrocket.util.WorldCoordinate; - -import org.junit.Test; - - -public class WGSGravityModelTest { - - private WGSGravityModel model = new WGSGravityModel(); - - @Test - public void testSurfaceGravity() { - // Equator - test(0, 0, 0, 9.780); - // Mid-latitude - test(45, 0, 0, 9.806); - // Mid-latitude - test(45, 99, 0, 9.806); - // South pole - test(-90, 0, 0, 9.832); - } - - @Test - public void testAltitudeEffect() { - test(45, 0, -100, 9.806); - test(45, 0, 0, 9.806); - test(45, 0, 10, 9.806); - test(45, 0, 100, 9.806); - test(45, 0, 1000, 9.803); - test(45, 0, 10000, 9.775); - test(45, 0, 100000, 9.505); - } - - private void test(double lat, double lon, double alt, double g) { - WorldCoordinate wc = new WorldCoordinate(lat, lon, alt); - assertEquals(g, model.getGravity(wc), 0.001); - assertEquals(g, model.getGravity(wc), 0.001); - } - -} diff --git a/test/net/sf/openrocket/motor/ManufacturerTest.java b/test/net/sf/openrocket/motor/ManufacturerTest.java deleted file mode 100644 index 6870c5f2..00000000 --- a/test/net/sf/openrocket/motor/ManufacturerTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.sf.openrocket.motor; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ManufacturerTest { - - @Test - public void testExisting() { - - Manufacturer m1, m2, m3, m4, m5; - - m1 = Manufacturer.getManufacturer("aerotech"); - m2 = Manufacturer.getManufacturer("a "); - m3 = Manufacturer.getManufacturer("-isp-"); - m4 = Manufacturer.getManufacturer("at/rcs"); - m5 = Manufacturer.getManufacturer("e"); - - assertTrue(m1 == m2); - assertTrue(m1 == m3); - assertTrue(m1 == m4); - assertFalse(m1 == m5); - - } - - @Test - public void testNew() { - - Manufacturer m1, m2, m3; - - m1 = Manufacturer.getManufacturer("Unknown"); - m2 = Manufacturer.getManufacturer(" Unknown/ "); - m3 = Manufacturer.getManufacturer("Unknown/a"); - - assertEquals(m1.getDisplayName(), "Unknown"); - assertEquals(m2.getDisplayName(), "Unknown"); - assertTrue(m1 == m2); - - assertEquals(m3.getDisplayName(), "Unknown/a"); - assertFalse(m1 == m3); - - } - - @Test - public void testSimpleName() { - - Manufacturer m1, m2, m3, m4; - - m1 = Manufacturer.getManufacturer("cs"); - m2 = Manufacturer.getManufacturer("Cesaroni Technology"); - m3 = Manufacturer.getManufacturer("Cesaroni Technology Inc"); - m4 = Manufacturer.getManufacturer("Cesaroni Technology Inc."); - - assertEquals(m1.getDisplayName(), "Cesaroni Technology Inc."); - assertEquals(m1.toString(), "Cesaroni Technology Inc."); - assertEquals(m1.getSimpleName(), "Cesaroni Technology"); - - assertTrue(m1 == m2); - assertTrue(m1 == m3); - assertTrue(m1 == m4); - - } - - @Test - public void testMatches() { - - Manufacturer m1; - - m1 = Manufacturer.getManufacturer("aerotech"); - - assertTrue(m1.matches("a")); - assertTrue(m1.matches("a/")); - assertTrue(m1.matches("a/rcs")); - assertTrue(m1.matches("a/rms")); - assertTrue(m1.matches("aerotech ...-/%#_!")); - assertTrue(m1.matches(" .isp/")); - - assertFalse(m1.matches("aero/tech")); - assertFalse(m1.matches("aero.tech")); - assertFalse(m1.matches("aero_tech")); - assertFalse(m1.matches("aero tech")); - } - -} diff --git a/test/net/sf/openrocket/motor/MotorDigestTest.java b/test/net/sf/openrocket/motor/MotorDigestTest.java deleted file mode 100644 index 916ab12c..00000000 --- a/test/net/sf/openrocket/motor/MotorDigestTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.sf.openrocket.motor; - -import static org.junit.Assert.assertEquals; - -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import net.sf.openrocket.motor.MotorDigest.DataType; -import net.sf.openrocket.util.TextUtil; - -import org.junit.Test; - - -public class MotorDigestTest { - - private static final double[] timeArray = { - 0.0, 0.123456789, 0.4115, Math.nextAfter(Math.nextAfter(1.4445, 0), 0) - }; - - private static final double[] massArray = { - 0.54321, 0.43211 - }; - - private static final double[] thrustArray = { - 0.0, 0.2345678, 9999.3335, 0.0 - }; - - private static final int[] intData = { - // Time (ms) - 0, 4, 0, 123, 412, 1445, - // Mass specific (0.1g) - 1, 2, 5432, 4321, - // Thrust (mN) - 5, 4, 0, 235, 9999334, 0 - }; - - - @Test - public void testMotorDigest() throws NoSuchAlgorithmException { - - MessageDigest correct = MessageDigest.getInstance("MD5"); - for (int value: intData) { - correct.update((byte) ((value >>> 24) & 0xFF)); - correct.update((byte) ((value >>> 16) & 0xFF)); - correct.update((byte) ((value >>> 8) & 0xFF)); - correct.update((byte) (value & 0xFF)); - } - - MotorDigest motor = new MotorDigest(); - motor.update(DataType.TIME_ARRAY, timeArray); - motor.update(DataType.MASS_SPECIFIC, massArray); - motor.update(DataType.FORCE_PER_TIME, thrustArray); - - - assertEquals(TextUtil.hexString(correct.digest()), motor.getDigest()); - } - - - @Test - public void testCommentDigest() throws NoSuchAlgorithmException, UnsupportedEncodingException { - - assertEquals(md5("Hello world!"), MotorDigest.digestComment("Hello world! ")); - assertEquals(md5("Hello world!"), MotorDigest.digestComment("\nHello\tworld!\n\r")); - assertEquals(md5("Hello world!"), MotorDigest.digestComment("Hello\r\r\r\nworld!")); - assertEquals(md5("Hello\u00e4 world!"), MotorDigest.digestComment("Hello\u00e4\r\r\nworld!")); - - } - - - private static String md5(String source) - throws NoSuchAlgorithmException, UnsupportedEncodingException { - MessageDigest digest = MessageDigest.getInstance("MD5"); - return TextUtil.hexString(digest.digest(source.getBytes("UTF-8"))); - } -} diff --git a/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java b/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java deleted file mode 100644 index 7ca43d71..00000000 --- a/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.sf.openrocket.motor; - -import static org.junit.Assert.assertEquals; -import net.sf.openrocket.util.Coordinate; -import net.sf.openrocket.util.Inertia; - -import org.junit.Test; - -public class ThrustCurveMotorTest { - - private final double EPS = 0.000001; - - private final double radius = 0.025; - private final double length = 0.10; - private final double longitudinal = Inertia.filledCylinderLongitudinal(radius, length); - private final double rotational = Inertia.filledCylinderRotational(radius); - - private final ThrustCurveMotor motor = - new ThrustCurveMotor(Manufacturer.getManufacturer("foo"), - "X6", "Description of X6", Motor.Type.RELOAD, - new double[] {0, 2, Motor.PLUGGED}, radius*2, length, - new double[] {0, 1, 3, 4}, // time - new double[] {0, 2, 3, 0}, // thrust - new Coordinate[] { - new Coordinate(0.02,0,0,0.05), - new Coordinate(0.02,0,0,0.05), - new Coordinate(0.02,0,0,0.05), - new Coordinate(0.03,0,0,0.03) - }); - - @Test - public void testMotorData() { - - assertEquals("X6", motor.getDesignation()); - assertEquals("X6-5", motor.getDesignation(5.0)); - assertEquals("Description of X6", motor.getDescription()); - assertEquals(Motor.Type.RELOAD, motor.getMotorType()); - - } - - @Test - public void testInstance() { - MotorInstance instance = motor.getInstance(); - - verify(instance, 0, 0.05, 0.02); - instance.step(0.0, 0, null); - verify(instance, 0, 0.05, 0.02); - instance.step(0.5, 0, null); - verify(instance, 0.5, 0.05, 0.02); - instance.step(1.5, 0, null); - verify(instance, (1.5 + 2.125)/2, 0.05, 0.02); - instance.step(2.5, 0, null); - verify(instance, (2.125 + 2.875)/2, 0.05, 0.02); - instance.step(3.0, 0, null); - verify(instance, (2+3.0/4 + 3)/2, 0.05, 0.02); - instance.step(3.5, 0, null); - verify(instance, (1.5 + 3)/2, 0.045, 0.0225); - instance.step(4.5, 0, null); - // mass and cg is simply average of the end points - verify(instance, 1.5/4, 0.035, 0.0275); - instance.step(5.0, 0, null); - verify(instance, 0, 0.03, 0.03); - } - - private void verify(MotorInstance instance, double thrust, double mass, double cgx) { - assertEquals("Testing thrust", thrust, instance.getThrust(), EPS); - assertEquals("Testing mass", mass, instance.getCG().weight, EPS); - assertEquals("Testing cg x", cgx, instance.getCG().x, EPS); - assertEquals("Testing longitudinal inertia", mass*longitudinal, instance.getLongitudinalInertia(), EPS); - assertEquals("Testing rotational inertia", mass*rotational, instance.getRotationalInertia(), EPS); - } - - -} diff --git a/test/net/sf/openrocket/optimization/TestSearchPattern.java b/test/net/sf/openrocket/optimization/TestSearchPattern.java deleted file mode 100644 index fcb618b8..00000000 --- a/test/net/sf/openrocket/optimization/TestSearchPattern.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.sf.openrocket.optimization; - -import static org.junit.Assert.*; - -import java.util.List; - -import net.sf.openrocket.optimization.general.Point; -import net.sf.openrocket.optimization.general.multidim.SearchPattern; - -import org.junit.Test; - -public class TestSearchPattern { - - @Test - public void testRegularSimplex() { - for (int dim = 1; dim < 20; dim++) { - List points = SearchPattern.regularSimplex(dim); - assertEquals(dim, points.size()); - - for (int i = 0; i < dim; i++) { - // Test dot product - for (int j = i + 1; j < dim; j++) { - double[] x = points.get(i).asArray(); - double[] y = points.get(j).asArray(); - double dot = 0; - for (int k = 0; k < dim; k++) { - dot += x[k] * y[k]; - } - assertEquals(0.5, dot, 0.000000001); - } - - // Test positive coordinates - for (int j = 0; j < dim; j++) { - assertTrue(points.get(i).get(j) >= 0); - } - - // Test length - assertEquals(1.0, points.get(i).length(), 0.000000001); - } - } - } - -} diff --git a/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java b/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java deleted file mode 100644 index 48cc648b..00000000 --- a/test/net/sf/openrocket/optimization/rocketoptimization/TestRocketOptimizationFunction.java +++ /dev/null @@ -1,212 +0,0 @@ -package net.sf.openrocket.optimization.rocketoptimization; - -import static org.junit.Assert.*; -import net.sf.openrocket.document.Simulation; -import net.sf.openrocket.optimization.general.OptimizationException; -import net.sf.openrocket.optimization.general.Point; -import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.unit.Unit; -import net.sf.openrocket.unit.UnitGroup; -import net.sf.openrocket.unit.Value; -import net.sf.openrocket.util.Pair; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.auto.Mock; -import org.jmock.integration.junit4.JMock; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.Test; -import org.junit.runner.RunWith; - - -@RunWith(JMock.class) -public class TestRocketOptimizationFunction { - Mockery context = new JUnit4Mockery(); - - @Mock - OptimizableParameter parameter; - @Mock - OptimizationGoal goal; - @Mock - SimulationDomain domain; - @Mock - SimulationModifier modifier1; - @Mock - SimulationModifier modifier2; - @Mock - RocketOptimizationListener listener; - - @Test - public void testNormalEvaluation() throws InterruptedException, OptimizationException { - final Rocket rocket = new Rocket(); - final Simulation simulation = new Simulation(rocket); - - final double p1 = 0.4; - final double p2 = 0.7; - final double ddist = -0.43; - final Value dref = new Value(ddist, Unit.NOUNIT2); - final double pvalue = 9.81; - final Value pvalueValue = new Value(9.81, Unit.NOUNIT2); - final double gvalue = 8.81; - final Point point = new Point(p1, p2); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(modifier1).modify(simulation, p1); - oneOf(modifier2).modify(simulation, p2); - oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); - oneOf(parameter).computeValue(simulation); will(returnValue(pvalue)); - oneOf(parameter).getUnitGroup(); will(returnValue(UnitGroup.UNITS_NONE)); - oneOf(goal).getMinimizationParameter(pvalue); will(returnValue(gvalue)); - oneOf(modifier1).getCurrentSIValue(simulation); will(returnValue(0.2)); - oneOf(modifier1).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); - oneOf(modifier2).getCurrentSIValue(simulation); will(returnValue(0.3)); - oneOf(modifier2).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); - oneOf(listener).evaluated(point, new Value[] { - new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()), - new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit()) - }, dref, pvalueValue, gvalue); - }}); - // @formatter:on - - RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, - parameter, goal, domain, modifier1, modifier2) { - @Override - Simulation newSimulationInstance(Simulation sim) { - return sim; - } - }; - function.addRocketOptimizationListener(listener); - - double value = function.evaluate(point); - assertEquals(gvalue, value, 0); - } - - @Test - public void testNaNValue() throws InterruptedException, OptimizationException { - final Rocket rocket = new Rocket(); - final Simulation simulation = new Simulation(rocket); - - final double p1 = 0.4; - final double p2 = 0.7; - final double ddist = -0.43; - final Value dref = new Value(0.33, Unit.NOUNIT2); - final double pvalue = 9.81; - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(modifier1).modify(simulation, p1); - oneOf(modifier2).modify(simulation, p2); - oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); - oneOf(parameter).computeValue(simulation); will(returnValue(pvalue)); - oneOf(parameter).getUnitGroup(); will(returnValue(UnitGroup.UNITS_NONE)); - oneOf(goal).getMinimizationParameter(pvalue); will(returnValue(Double.NaN)); - }}); - // @formatter:on - - - RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, - parameter, goal, domain, modifier1, modifier2) { - @Override - Simulation newSimulationInstance(Simulation sim) { - return sim; - } - }; - - - double value = function.evaluate(new Point(p1, p2)); - assertEquals(Double.MAX_VALUE, value, 0); - } - - - @Test - public void testOutsideDomain() throws InterruptedException, OptimizationException { - final Rocket rocket = new Rocket(); - final Simulation simulation = new Simulation(rocket); - - final double p1 = 0.4; - final double p2 = 0.7; - final double ddist = 0.98; - final Value dref = new Value(ddist, Unit.NOUNIT2); - final Point point = new Point(p1, p2); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(modifier1).modify(simulation, p1); - oneOf(modifier2).modify(simulation, p2); - oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); - oneOf(modifier1).getCurrentSIValue(simulation); will(returnValue(0.2)); - oneOf(modifier1).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); - oneOf(modifier2).getCurrentSIValue(simulation); will(returnValue(0.3)); - oneOf(modifier2).getUnitGroup(); will(returnValue(UnitGroup.UNITS_LENGTH)); - oneOf(listener).evaluated(point, new Value[] { - new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()), - new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit()) - }, dref, null, 1.98E200); - }}); - // @formatter:on - - - RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, - parameter, goal, domain, modifier1, modifier2) { - @Override - Simulation newSimulationInstance(Simulation sim) { - return sim; - } - }; - function.addRocketOptimizationListener(listener); - - double value = function.evaluate(new Point(p1, p2)); - assertTrue(value > 1e100); - } - - @Test - public void testOutsideDomain2() throws InterruptedException, OptimizationException { - final Rocket rocket = new Rocket(); - final Simulation simulation = new Simulation(rocket); - - final double p1 = 0.4; - final double p2 = 0.7; - final double ddist = Double.NaN; - final Value dref = new Value(0.33, Unit.NOUNIT2); - - // @formatter:off - context.checking(new Expectations() {{ - oneOf(modifier1).modify(simulation, p1); - oneOf(modifier2).modify(simulation, p2); - oneOf(domain).getDistanceToDomain(simulation); will(returnValue(new Pair(ddist, dref))); - }}); - // @formatter:on - - - RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, - parameter, goal, domain, modifier1, modifier2) { - @Override - Simulation newSimulationInstance(Simulation sim) { - return sim; - } - }; - - double value = function.evaluate(new Point(p1, p2)); - assertEquals(Double.MAX_VALUE, value, 0); - } - - - @Test - public void testNewSimulationInstance() { - final Rocket rocket = new Rocket(); - rocket.setName("Foobar"); - final Simulation simulation = new Simulation(rocket); - simulation.setName("MySim"); - - RocketOptimizationFunction function = new RocketOptimizationFunction(simulation, - parameter, goal, domain, modifier1, modifier2); - - Simulation sim = function.newSimulationInstance(simulation); - assertFalse(simulation == sim); - assertEquals("MySim", sim.getName()); - assertFalse(rocket == sim.getRocket()); - assertEquals("Foobar", sim.getRocket().getName()); - } - -} diff --git a/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java b/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java deleted file mode 100644 index deacacf4..00000000 --- a/test/net/sf/openrocket/optimization/rocketoptimization/modifiers/TestGenericModifier.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.sf.openrocket.optimization.rocketoptimization.modifiers; - -import static net.sf.openrocket.util.MathUtil.EPSILON; -import static org.junit.Assert.assertEquals; -import net.sf.openrocket.document.Simulation; -import net.sf.openrocket.optimization.general.OptimizationException; -import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.unit.UnitGroup; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class TestGenericModifier { - - private TestValue value; - private GenericModifier gm; - private Simulation sim; - - @Before - public void setup() { - value = new TestValue(); - sim = new Simulation(new Rocket()); - - Object related = new Object(); - - gm = new GenericModifier("Test modifier", "Description", related, - UnitGroup.UNITS_NONE, 2.0, TestValue.class, "value") { - @Override - protected TestValue getModifiedObject(Simulation simulation) { - Assert.assertTrue(simulation == sim); - return value; - } - }; - - gm.setMinValue(0.5); - gm.setMaxValue(5.5); - } - - @Test - public void testGetCurrentValue() throws OptimizationException { - value.d = 1.0; - assertEquals(2.0, gm.getCurrentSIValue(sim), EPSILON); - value.d = 2.0; - assertEquals(4.0, gm.getCurrentSIValue(sim), EPSILON); - } - - @Test - public void testGetCurrentScaledValue() throws OptimizationException { - value.d = 0.0; - assertEquals(-0.1, gm.getCurrentScaledValue(sim), EPSILON); - value.d = 1.0; - assertEquals(0.3, gm.getCurrentScaledValue(sim), EPSILON); - value.d = 2.0; - assertEquals(0.7, gm.getCurrentScaledValue(sim), EPSILON); - value.d = 3.0; - assertEquals(1.1, gm.getCurrentScaledValue(sim), EPSILON); - } - - @Test - public void testModify() throws OptimizationException { - value.d = 0.0; - gm.modify(sim, -0.5); - assertEquals(-1.0, value.d, EPSILON); - - gm.modify(sim, 0.0); - assertEquals(0.25, value.d, EPSILON); - - gm.modify(sim, 0.5); - assertEquals(1.5, value.d, EPSILON); - - gm.modify(sim, 1.0); - assertEquals(2.75, value.d, EPSILON); - - gm.modify(sim, 1.5); - assertEquals(4.0, value.d, EPSILON); - } - - public void testSingularRange() throws OptimizationException { - gm.setMinValue(1.0); - gm.setMaxValue(1.0); - value.d = 0.5; - assertEquals(0.0, gm.getCurrentScaledValue(sim), EPSILON); - value.d = 1.0; - assertEquals(0.5, gm.getCurrentScaledValue(sim), EPSILON); - value.d = 1.00001; - assertEquals(1.0, gm.getCurrentScaledValue(sim), EPSILON); - } - - public class TestValue { - private double d; - - public double getValue() { - return d; - } - - public void setValue(double value) { - this.d = value; - } - } - -} diff --git a/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java b/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java deleted file mode 100644 index fb231dc0..00000000 --- a/test/net/sf/openrocket/rocketcomponent/ComponentCompare.java +++ /dev/null @@ -1,147 +0,0 @@ -package net.sf.openrocket.rocketcomponent; - -import static org.junit.Assert.*; - -import java.lang.reflect.Method; -import java.util.Iterator; -import java.util.regex.Pattern; - -import net.sf.openrocket.util.BugException; - -public class ComponentCompare { - - private static final Pattern GETTER_PATTERN = Pattern.compile("^(is|get)[A-Z].*+"); - - private static final String[] IGNORED_METHODS = { - "getClass", "getChildCount", "getChildren", "getNextComponent", "getID", - "getPreviousComponent", "getParent", "getRocket", "getRoot", "getStage", - "getStageNumber", "getComponentName", - // Rocket specific methods: - "getModID", "getMassModID", "getAerodynamicModID", "getTreeModID", "getFunctionalModID", - "getMotorConfigurationIDs", "getDefaultConfiguration" - }; - - - /** - * Check whether the two components are equal. Two components are considered - * equal if they are of the same type and all of their getXXX() and isXXX() methods - * return equal values. - * - * @param c1 the first component to compare. - * @param c2 the second component to compare. - */ - public static void assertEquality(RocketComponent c1, RocketComponent c2) { - assertEquals(c1.getClass(), c2.getClass()); - - // Same class + similar == equal - assertSimilarity(c1, c2); - } - - - - public static void assertDeepEquality(RocketComponent c1, RocketComponent c2) { - assertEquality(c1, c2); - - Iterator i1 = c1.getChildren().iterator(); - Iterator i2 = c2.getChildren().iterator(); - while (i1.hasNext()) { - assertTrue("iterator continues", i2.hasNext()); - RocketComponent comp1 = i1.next(); - RocketComponent comp2 = i2.next(); - assertDeepEquality(comp1, comp2); - } - assertFalse("iterator end", i2.hasNext()); - } - - - - public static void assertDeepSimilarity(RocketComponent c1, RocketComponent c2, - boolean allowNameDifference) { - assertSimilarity(c1, c2, allowNameDifference); - - Iterator i1 = c1.getChildren().iterator(); - Iterator i2 = c2.getChildren().iterator(); - while (i1.hasNext()) { - assertTrue("iterator continues", i2.hasNext()); - RocketComponent comp1 = i1.next(); - RocketComponent comp2 = i2.next(); - assertDeepSimilarity(comp1, comp2, allowNameDifference); - } - assertFalse("iterator end", i2.hasNext()); - } - - - - /** - * Check whether the two components are similar. Two components are similar - * if each of the getXXX and isXXX methods that both object types have return - * equal values. This does not check whether the two components are of the same type. - * - * @param c1 the first component. - * @param c2 the second component. - */ - public static void assertSimilarity(RocketComponent c1, RocketComponent c2) { - assertSimilarity(c1, c2, false); - } - - /** - * Check whether the two components are similar, allowing a name difference. - * - * @param c1 the first component. - * @param c2 the second component. - * @param allowNameDifference whether to allow the components to have different names. - */ - public static void assertSimilarity(RocketComponent c1, RocketComponent c2, - boolean allowNameDifference) { - Class class1 = c1.getClass(); - Class class2 = c2.getClass(); - - mainloop: for (Method m1 : class1.getMethods()) { - // Check for getter method - String name = m1.getName(); - if (!GETTER_PATTERN.matcher(name).matches()) - continue; - - // Ignore methods that take parameters - if (m1.getParameterTypes().length != 0) - continue; - - // Ignore specific getters - for (String ignore : IGNORED_METHODS) { - if (name.equals(ignore)) - continue mainloop; - } - if (allowNameDifference && name.equals("getName")) - continue; - - - // Check for method in other class - Method m2; - try { - m2 = class2.getMethod(name); - } catch (NoSuchMethodException e) { - continue; - } - - // System.out.println("Testing results of method " + name); - - // Run the methods - Object result1, result2; - try { - result1 = m1.invoke(c1); - result2 = m2.invoke(c2); - } catch (Exception e) { - throw new BugException("Error executing method " + name, e); - } - - if (result1 != null && result2 != null && - result1.getClass().isArray() && result2.getClass().isArray()) { - assertArrayEquals("Comparing result of method " + name, - (Object[]) result1, (Object[]) result2); - } else { - assertEquals("Comparing result of method " + name, result1, result2); - } - } - } - -} diff --git a/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java b/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java deleted file mode 100644 index 46c8f21d..00000000 --- a/test/net/sf/openrocket/rocketcomponent/ComponentCompareTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package net.sf.openrocket.rocketcomponent; - -import static org.junit.Assert.*; - -import java.awt.Color; -import java.util.Iterator; - -import net.sf.openrocket.gui.util.ColorConversion; -import net.sf.openrocket.util.Coordinate; - -import org.junit.Test; - -public class ComponentCompareTest { - - @Test - public void testComponentEquality() { - - System.out.println("TEST CLASSPATH: " + System.getProperty("java.class.path")); - - Rocket r1 = net.sf.openrocket.util.TestRockets.makeBigBlue(); - Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue(); - - Iterator i1 = r1.iterator(true); - Iterator i2 = r2.iterator(true); - while (i1.hasNext()) { - assertTrue(i2.hasNext()); - - RocketComponent c1 = i1.next(); - RocketComponent c2 = i2.next(); - - ComponentCompare.assertEquality(c1, c2); - ComponentCompare.assertSimilarity(c1, c2); - } - assertFalse(i2.hasNext()); - - - ComponentCompare.assertDeepEquality(r1, r2); - ComponentCompare.assertDeepSimilarity(r1, r2, false); - - - r1.setColor(ColorConversion.fromAwtColor(Color.YELLOW)); - try { - ComponentCompare.assertEquality(r1, r2); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - - - i1 = r1.iterator(true); - i2 = r2.iterator(true); - boolean finsetfound = false; - while (i1.hasNext()) { - RocketComponent c1 = i1.next(); - RocketComponent c2 = i2.next(); - - if (c1 instanceof FinSet) { - finsetfound = true; - FinSet f1 = (FinSet)c1; - f1.setTabHeight(0.001); - - try { - ComponentCompare.assertEquality(c1, c2); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - } - } - assertTrue(finsetfound); - } - - - @Test - public void testComponentSimilarity() throws IllegalFinPointException { - FinSet trap = new TrapezoidFinSet( - 5, // fins - 5.0, // root - 3.0, // tip - 0.0, // sweep - 2.0); // height - FinSet free = new FreeformFinSet(new Coordinate[] { - new Coordinate(0,0), - new Coordinate(0,2), - new Coordinate(3,2), - new Coordinate(5,0) - }); - free.setFinCount(5); - - ComponentCompare.assertSimilarity(trap, free, true); - - try { - ComponentCompare.assertSimilarity(trap, free); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - - free.setName(trap.getName()); - ComponentCompare.assertSimilarity(trap, free); - - try { - ComponentCompare.assertEquality(trap, free); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - - - BodyTube t1 = new BodyTube(); - BodyTube t2 = new BodyTube(); - t1.addChild(free); - t2.addChild(trap); - - ComponentCompare.assertDeepSimilarity(t1, t2, false); - - try { - ComponentCompare.assertDeepEquality(t1, t2); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - - t1.addChild(new TrapezoidFinSet()); - - try { - ComponentCompare.assertDeepSimilarity(t1, t2, true); - fail(); - } catch (AssertionError e) { - // Correct behavior - } - - } - -} diff --git a/test/net/sf/openrocket/rocketcomponent/FinSetTest.java b/test/net/sf/openrocket/rocketcomponent/FinSetTest.java deleted file mode 100644 index abec65ce..00000000 --- a/test/net/sf/openrocket/rocketcomponent/FinSetTest.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.sf.openrocket.rocketcomponent; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.awt.Color; - -import net.sf.openrocket.gui.util.ColorConversion; -import net.sf.openrocket.material.Material; -import net.sf.openrocket.material.Material.Type; -import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish; -import net.sf.openrocket.rocketcomponent.FinSet.CrossSection; -import net.sf.openrocket.rocketcomponent.FinSet.TabRelativePosition; -import net.sf.openrocket.rocketcomponent.RocketComponent.Position; -import net.sf.openrocket.util.LineStyle; -import net.sf.openrocket.util.BaseTestCase.BaseTestCase; - -import org.junit.Test; - -public class FinSetTest extends BaseTestCase { - - - @Test - public void testFreeformConvert() { - testFreeformConvert(new TrapezoidFinSet()); - testFreeformConvert(new EllipticalFinSet()); - testFreeformConvert(new FreeformFinSet()); - } - - - private void testFreeformConvert(FinSet fin) { - FreeformFinSet converted; - Material mat = Material.newMaterial(Type.BULK, "foo", 0.1, true); - - fin.setBaseRotation(1.1); - fin.setCantAngle(0.001); - fin.setCGOverridden(true); - fin.setColor(ColorConversion.fromAwtColor(Color.YELLOW)); - fin.setComment("cmt"); - fin.setCrossSection(CrossSection.ROUNDED); - fin.setFinCount(5); - fin.setFinish(Finish.ROUGH); - fin.setLineStyle(LineStyle.DASHDOT); - fin.setMassOverridden(true); - fin.setMaterial(mat); - fin.setOverrideCGX(0.012); - fin.setOverrideMass(0.0123); - fin.setOverrideSubcomponents(true); - fin.setPositionValue(0.1); - fin.setRelativePosition(Position.ABSOLUTE); - fin.setTabHeight(0.01); - fin.setTabLength(0.02); - fin.setTabRelativePosition(TabRelativePosition.END); - fin.setTabShift(0.015); - fin.setThickness(0.005); - - - converted = FreeformFinSet.convertFinSet((FinSet) fin.copy()); - - ComponentCompare.assertSimilarity(fin, converted, true); - - assertEquals(converted.getComponentName(), converted.getName()); - - - // Create test rocket - Rocket rocket = new Rocket(); - Stage stage = new Stage(); - BodyTube body = new BodyTube(); - - rocket.addChild(stage); - stage.addChild(body); - body.addChild(fin); - - Listener l1 = new Listener("l1"); - rocket.addComponentChangeListener(l1); - - fin.setName("Custom name"); - assertTrue(l1.changed); - assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype); - - - // Create copy - RocketComponent rocketcopy = rocket.copy(); - - Listener l2 = new Listener("l2"); - rocketcopy.addComponentChangeListener(l2); - - FinSet fincopy = (FinSet) rocketcopy.getChild(0).getChild(0).getChild(0); - FreeformFinSet.convertFinSet(fincopy); - - assertTrue(l2.changed); - assertEquals(ComponentChangeEvent.TREE_CHANGE, - l2.changetype & ComponentChangeEvent.TREE_CHANGE); - - } - - - private static class Listener implements ComponentChangeListener { - private boolean changed = false; - private int changetype = 0; - private final String name; - - public Listener(String name) { - this.name = name; - } - - @Override - public void componentChanged(ComponentChangeEvent e) { - assertFalse("Ensuring listener " + name + " has not been called.", changed); - changed = true; - changetype = e.getType(); - } - } - -} diff --git a/test/net/sf/openrocket/rocketcomponent/RocketTest.java b/test/net/sf/openrocket/rocketcomponent/RocketTest.java deleted file mode 100644 index 16b5ca5d..00000000 --- a/test/net/sf/openrocket/rocketcomponent/RocketTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.sf.openrocket.rocketcomponent; - -import net.sf.openrocket.util.BaseTestCase.BaseTestCase; - -import org.junit.Test; - -public class RocketTest extends BaseTestCase { - - @Test - public void testCopyFrom() { - Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu(); - Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue(); - - Rocket copy = (Rocket) r2.copy(); - - ComponentCompare.assertDeepEquality(r2, copy); - - r1.copyFrom(copy); - - ComponentCompare.assertDeepEquality(r1, r2); - } - -} diff --git a/test/net/sf/openrocket/simplerocket.ork b/test/net/sf/openrocket/simplerocket.ork deleted file mode 100644 index 453cdec9..00000000 Binary files a/test/net/sf/openrocket/simplerocket.ork and /dev/null differ diff --git a/test/net/sf/openrocket/unit/ValueTest.java b/test/net/sf/openrocket/unit/ValueTest.java deleted file mode 100644 index 9440c4d0..00000000 --- a/test/net/sf/openrocket/unit/ValueTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.sf.openrocket.unit; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ValueTest { - - @Test - public void testValues() { - Value v1, v2; - - v1 = new Value(273.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); - v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("C")); - - assertTrue(v1.compareTo(v2) > 0); - assertTrue(v2.compareTo(v1) < 0); - assertTrue(v1.compareTo(v1) == 0); - assertTrue(v2.compareTo(v2) == 0); - - v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("K")); - assertTrue(v1.compareTo(v2) > 0); - assertTrue(v2.compareTo(v1) < 0); - assertEquals("283 K", v2.toString()); - - v2 = new Value(283.15, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); - assertTrue(v1.compareTo(v2) < 0); - assertTrue(v2.compareTo(v1) > 0); - - - v1 = new Value(Double.NaN, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); - assertTrue(v1.compareTo(v2) > 0); - assertTrue(v2.compareTo(v1) < 0); - - v2 = new Value(Double.NaN, UnitGroup.UNITS_TEMPERATURE.findApproximate("F")); - assertTrue(v1.compareTo(v2) == 0); - assertTrue(v1.compareTo(v2) == 0); - assertEquals("N/A", v1.toString()); - assertEquals("N/A", v2.toString()); - - } - -} diff --git a/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java b/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java deleted file mode 100644 index c5d1feb1..00000000 --- a/test/net/sf/openrocket/util/BaseTestCase/BaseTestCase.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.sf.openrocket.util.BaseTestCase; - -import net.sf.openrocket.gui.util.SwingPreferences; -import net.sf.openrocket.startup.Application; - -import org.junit.BeforeClass; - -public class BaseTestCase { - - @BeforeClass - public static void setUpApplication () { - - Application.setPreferences( new SwingPreferences() ); - - } -} diff --git a/test/net/sf/openrocket/util/CoordinateTest.java b/test/net/sf/openrocket/util/CoordinateTest.java deleted file mode 100644 index 0c74a3a1..00000000 --- a/test/net/sf/openrocket/util/CoordinateTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class CoordinateTest { - - private static final double EPS = 0.0000000001; - - @Test - public void coordinateTest() { - - Coordinate x = new Coordinate(1,1,1,1); - Coordinate y = new Coordinate(1,2,3,4); - - assertCoordinateEquals(new Coordinate(2,1,1,1), x.setX(2)); - assertCoordinateEquals(new Coordinate(1,2,1,1), x.setY(2)); - assertCoordinateEquals(new Coordinate(1,1,2,1), x.setZ(2)); - assertCoordinateEquals(new Coordinate(1,1,1,2), x.setWeight(2)); - assertCoordinateEquals(new Coordinate(2,3,4,1), x.setXYZ(y).add(1,1,1)); - - assertFalse(x.isNaN()); - assertTrue(x.setX(Double.NaN).isNaN()); - assertTrue(Coordinate.NaN.isNaN()); - - assertTrue(x.isWeighted()); - assertFalse(x.setWeight(0).isWeighted()); - - - assertCoordinateEquals(x, x.add(Coordinate.NUL)); - assertCoordinateEquals(new Coordinate(2,3,4,5), x.add(y)); - assertCoordinateEquals(new Coordinate(2,3,4,1), x.add(1,2,3)); - assertCoordinateEquals(new Coordinate(2,3,4,5), x.add(1,2,3,4)); - - assertCoordinateEquals(new Coordinate(0,-1,-2,1), x.sub(y)); - assertCoordinateEquals(new Coordinate(0,-1,-2,1), x.sub(1,2,3)); - - assertCoordinateEquals(new Coordinate(2,4,6,8), y.multiply(2)); - - assertEquals(1+2+3, y.dot(x), EPS); - assertEquals(1+2+3, x.dot(y), EPS); - assertEquals(1+2+3, Coordinate.dot(x,y), EPS); - assertEquals(x.dot(x), x.length2(), EPS); - assertEquals(y.dot(y), y.length2(), EPS); - assertEquals(Math.sqrt(1+4+9), y.length(), EPS); - assertEquals(1, y.normalize().length(), EPS); - - assertCoordinateEquals(new Coordinate(1.75,1.75,1.75,4), - new Coordinate(1,1,1,1).average(new Coordinate(2,2,2,3))); - assertCoordinateEquals(new Coordinate(1,1,1,1), - new Coordinate(1,1,1,1).average(new Coordinate(2,2,2,0))); - assertCoordinateEquals(new Coordinate(1.5,1.5,1.5,0), - new Coordinate(1,1,1,0).average(new Coordinate(2,2,2,0))); - - } - - - private void assertCoordinateEquals(Coordinate a, Coordinate b) { - assertEquals(a, b); - assertEquals(a.weight, b.weight, EPS); - } - -} diff --git a/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java b/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java deleted file mode 100644 index 29efe41c..00000000 --- a/test/net/sf/openrocket/util/GeodeticComputationStrategyTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class GeodeticComputationStrategyTest { - - @Test - public void testSpericalAddCoordinate() { - - double arcmin = (1.0 / 60.0); - double arcsec = (1.0 / (60.0 * 60.0)); - - double lat1 = 50.0 + 3 * arcmin + 59 * arcsec; - double lon1 = -1.0 * (5 + 42 * arcmin + 53 * arcsec); //W - - double lat2 = 58 + 38 * arcmin + 38 * arcsec; - double lon2 = -1.0 * (3 + 4 * arcmin + 12 * arcsec); - - double range = 968.9 * 1000.0; - double bearing = (9.0 + 7 * arcmin + 11 * arcsec) * (Math.PI / 180.0); - - Coordinate coord = new Coordinate(range * Math.sin(bearing), range * Math.cos(bearing), 1000.0); - WorldCoordinate wc = new WorldCoordinate(lat1, lon1, 0.0); - wc = GeodeticComputationStrategy.SPHERICAL.addCoordinate(wc, coord); - - System.out.println(wc.getLatitudeDeg()); - System.out.println(lat2); - - System.out.println(wc.getLongitudeDeg()); - System.out.println(lon2); - - assertEquals(lat2, wc.getLatitudeDeg(), 0.001); - assertEquals(lon2, wc.getLongitudeDeg(), 0.001); - assertEquals(1000.0, wc.getAltitude(), 0.0); - } - - - @Test - public void testAddCoordinates() { - - double min = 1 / 60.0; - double sec = 1 / 3600.0; - - - // Test zero movement - System.out.println("\nTesting zero movement"); - testAddCoordinate(50.0, 20.0, 0, 123, 50.0, 20.0, false); - - - /* - * These example values have been computed using the calculator at - * http://www.movable-type.co.uk/scripts/latlong.html - */ - - // Long distance NE over England, crosses Greenwich meridian - // 50 03N 005 42W to 58 38N 003 04E is 1109km at 027 16'07" - System.out.println("\nTesting 1109km NE over England"); - testAddCoordinate(50 + 3 * min, -5 - 42 * min, 1109000, 27 + 16 * min + 7 * sec, 58 + 38 * min, 3 + 4 * min, false); - - // SW over Brazil - // -10N -60E to -11N -61E is 155.9km at 224 25'34" - System.out.println("\nTesting 155km SW over Brazil"); - testAddCoordinate(-10, -60, 155900, 224 + 25 * min + 34 * sec, -11, -61, true); - - // NW over the 180 meridian - // 63N -179E to 63 01N 179E is 100.9km at 271 56'34" - System.out.println("\nTesting 100km NW over 180 meridian"); - testAddCoordinate(63, -179, 100900, 271 + 56 * min + 34 * sec, 63 + 1 * min, 179, true); - - // NE near the north pole - // 89 50N 0E to 89 45N 175E is 46.29 km at 003 00'01" - System.out.println("\nTesting 46km NE near north pole"); - testAddCoordinate(89 + 50 * min, 0, 46290, 3 + 0 * min + 1 * sec, 89 + 45 * min, 175, false); - - // S directly over south pole - // -89 50N 12E to -89 45N 192E is 46.33km at 180 00'00" - System.out.println("\nTesting 46km directly over south pole "); - testAddCoordinate(-89 - 50 * min, 12, 46330, 180, -89 - 45 * min, -168, false); - - } - - private void testAddCoordinate(double initialLatitude, double initialLongitude, double distance, double bearing, - double finalLatitude, double finalLongitude, boolean testFlat) { - - double tolerance; - - bearing = Math.toRadians(bearing); - - // positive X is EAST, positive Y is NORTH - double deltaX = distance * Math.sin(bearing); - double deltaY = distance * Math.cos(bearing); - - Coordinate coord = new Coordinate(deltaX, deltaY, 1000.0); - WorldCoordinate wc = new WorldCoordinate(initialLatitude, initialLongitude, 0.0); - - // Test SPHERICAL - tolerance = 0.0015 * distance / 111325; - System.out.println("\nSpherical tolerance: " + tolerance); - WorldCoordinate result = GeodeticComputationStrategy.SPHERICAL.addCoordinate(wc, coord); - - System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); - System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); - assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); - assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); - assertEquals(1000.0, result.getAltitude(), 0.0); - - - // Test WGS84 - /* - * Note: Since the example values are computed using a spherical earth approximation, - * the WGS84 method will have significantly larger errors. A tolerance of 1% accommodates - * all cases except the NE flight near the north pole, where the ellipsoidal effect is - * the greatest. - */ - tolerance = 0.04 * distance / 111325; - System.out.println("\nWGS84 tolerance: " + tolerance); - result = GeodeticComputationStrategy.WGS84.addCoordinate(wc, coord); - - System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); - System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); - assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); - assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); - assertEquals(1000.0, result.getAltitude(), 0.0); - - - // Test FLAT - if (testFlat) { - tolerance = 0.02 * distance / 111325; - System.out.println("\nFlat tolerance: " + tolerance); - result = GeodeticComputationStrategy.FLAT.addCoordinate(wc, coord); - - System.out.println("Difference Lat: " + Math.abs(finalLatitude - result.getLatitudeDeg())); - System.out.println("Difference Lon: " + Math.abs(finalLongitude - result.getLongitudeDeg())); - assertEquals(finalLatitude, result.getLatitudeDeg(), tolerance); - assertEquals(finalLongitude, result.getLongitudeDeg(), tolerance); - assertEquals(1000.0, result.getAltitude(), 0.0); - - } - - } - - - - @Test - public void testSpericalGetCoriolisAcceleration() { - - // For positive latitude and rotational velocity, a movement due east results in an acceleration due south - Coordinate velocity = new Coordinate(-1000, 0, 0); - WorldCoordinate wc = new WorldCoordinate(45, 0, 0); - double north_accel = GeodeticComputationStrategy.SPHERICAL.getCoriolisAcceleration(wc, velocity).y; - System.out.println("North accel " + north_accel); - assertTrue(north_accel < 0.0); - - } - -} diff --git a/test/net/sf/openrocket/util/MathUtilTest.java b/test/net/sf/openrocket/util/MathUtilTest.java deleted file mode 100644 index 8b79aeca..00000000 --- a/test/net/sf/openrocket/util/MathUtilTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package net.sf.openrocket.util; - -import static java.lang.Double.NaN; -import static java.lang.Math.PI; -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class MathUtilTest { - - public static final double EPS = 0.00000000001; - - @Test - public void miscMathTest() { - - assertEquals(PI * PI, MathUtil.pow2(PI), EPS); - assertEquals(PI * PI * PI, MathUtil.pow3(PI), EPS); - assertEquals(PI * PI * PI * PI, MathUtil.pow4(PI), EPS); - - assertEquals(1.0, MathUtil.clamp(0.9999, 1.0, 2.0), 0); - assertEquals(1.23, MathUtil.clamp(1.23, 1.0, 2.0), 0); - assertEquals(2.0, MathUtil.clamp(2 + EPS / 100, 1.0, 2.0), 0); - - assertEquals(1.0f, MathUtil.clamp(0.9999f, 1.0f, 2.0f), 0); - assertEquals(1.23f, MathUtil.clamp(1.23f, 1.0f, 2.0f), 0); - assertEquals(2.0f, MathUtil.clamp(2.0001f, 1.0f, 2.0f), 0); - - assertEquals(1, MathUtil.clamp(-3, 1, 5)); - assertEquals(3, MathUtil.clamp(3, 1, 5)); - assertEquals(5, MathUtil.clamp(6, 1, 5)); - - assertEquals(-1.0, MathUtil.sign(Double.NEGATIVE_INFINITY), EPS); - assertEquals(-1.0, MathUtil.sign(-100), EPS); - assertEquals(-1.0, MathUtil.sign(Math.nextAfter(0.0, -1.0)), EPS); - assertEquals(1.0, MathUtil.sign(Math.nextUp(0.0)), EPS); - assertEquals(1.0, MathUtil.sign(100), EPS); - assertEquals(1.0, MathUtil.sign(Double.POSITIVE_INFINITY), EPS); - } - - @Test - public void hypotTest() { - - for (int i = 0; i < 10000; i++) { - double x = Math.random() * 100 - 50; - double y = Math.random() * i - i / 2; - double z = Math.hypot(x, y); - assertEquals(z, MathUtil.hypot(x, y), EPS); - } - - } - - @Test - public void reduceTest() { - - for (int i = -1000; i < 1000; i++) { - double angle = Math.random() * 2 * PI; - double shift = angle + i * 2 * PI; - assertEquals(angle, MathUtil.reduce360(shift), EPS); - } - - for (int i = -1000; i < 1000; i++) { - double angle = Math.random() * 2 * PI - PI; - double shift = angle + i * 2 * PI; - assertEquals(angle, MathUtil.reduce180(shift), EPS); - } - - } - - @Test - public void minmaxTest() { - assertEquals(1.0, MathUtil.min(1.0, Math.nextUp(1.0)), 0); - assertEquals(1.0, MathUtil.min(1.0, Double.POSITIVE_INFINITY), 0); - assertEquals(1.0, MathUtil.min(NaN, 1.0), 0); - assertEquals(1.0, MathUtil.min(1.0, NaN), 0); - assertEquals(NaN, MathUtil.min(NaN, NaN), 0); - - assertEquals(Math.nextUp(1.0), MathUtil.max(1.0, Math.nextUp(1.0)), 0); - assertEquals(Double.POSITIVE_INFINITY, MathUtil.max(1.0, Double.POSITIVE_INFINITY), 0); - assertEquals(1.0, MathUtil.max(NaN, 1.0), 0); - assertEquals(1.0, MathUtil.max(1.0, NaN), 0); - assertEquals(NaN, MathUtil.max(NaN, NaN), 0); - - assertEquals(1.0, MathUtil.min(1.0, 2.0, 3.0), 0); - assertEquals(1.0, MathUtil.min(1.0, NaN, NaN), 0); - assertEquals(1.0, MathUtil.min(NaN, 1.0, NaN), 0); - assertEquals(1.0, MathUtil.min(NaN, NaN, 1.0), 0); - assertEquals(1.0, MathUtil.min(2.0, NaN, 1.0), 0); - assertEquals(1.0, MathUtil.min(1.0, 2.0, NaN), 0); - assertEquals(1.0, MathUtil.min(NaN, 2.0, 1.0), 0); - - assertEquals(3.0, MathUtil.max(1.0, 3.0, 2.0), 0); - assertEquals(1.0, MathUtil.max(1.0, NaN, NaN), 0); - assertEquals(1.0, MathUtil.max(NaN, 1.0, NaN), 0); - assertEquals(1.0, MathUtil.max(NaN, NaN, 1.0), 0); - assertEquals(2.0, MathUtil.max(2.0, NaN, 1.0), 0); - assertEquals(2.0, MathUtil.max(1.0, 2.0, NaN), 0); - assertEquals(2.0, MathUtil.max(NaN, 2.0, 1.0), 0); - - assertEquals(1.0, MathUtil.min(1.0, 2.0, 3.0, 4.0), 0); - assertEquals(1.0, MathUtil.min(1.0, NaN, NaN, NaN), 0); - assertEquals(1.0, MathUtil.min(NaN, 1.0, NaN, NaN), 0); - assertEquals(1.0, MathUtil.min(NaN, NaN, 1.0, NaN), 0); - assertEquals(1.0, MathUtil.min(2.0, NaN, 1.0, NaN), 0); - assertEquals(1.0, MathUtil.min(2.0, NaN, NaN, 1.0), 0); - assertEquals(1.0, MathUtil.min(1.0, 2.0, NaN, 3.0), 0); - assertEquals(1.0, MathUtil.min(NaN, 2.0, 3.0, 1.0), 0); - - } - - @Test - public void mapTest() { - assertEquals(1.0, MathUtil.map(1.0, 0.0, 5.0, -1.0, 9.0), EPS); - assertEquals(7.0, MathUtil.map(1.0, 5.0, 0.0, -1.0, 9.0), EPS); - assertEquals(7.0, MathUtil.map(1.0, 0.0, 5.0, 9.0, -1.0), EPS); - assertEquals(6.0, MathUtil.map(6.0, 0.0, 5.0, Math.nextUp(6.0), 6.0), EPS); - assertEquals(6.0, MathUtil.map(6.0, 0.0, 0.0, Math.nextUp(6.0), 6.0), EPS); - try { - MathUtil.map(6.0, 1.0, Math.nextUp(1.0), 1.0, 2.0); - fail("Should not be reached."); - } catch (IllegalArgumentException normal) { - } - - assertEquals(7.0, MathUtil.map(Math.nextUp(1.0), 0.0, 5.0, 9.0, -1.0), EPS); - } - - - @Test - public void mapCoordinateTest() { - assertEquals(new Coordinate(0.8, 2.0, 1.6, 4.0), - MathUtil.map(1.0, 0.0, 5.0, new Coordinate(0, 1, 2, 3), new Coordinate(4, 6, 0, 8))); - } - - - @Test - public void equalsTest() { - assertTrue(MathUtil.equals(1.0, 1.0 + MathUtil.EPSILON / 3)); - assertFalse(MathUtil.equals(1.0, 1.0 + MathUtil.EPSILON * 2)); - assertTrue(MathUtil.equals(-1.0, -1.0 + MathUtil.EPSILON / 3)); - assertFalse(MathUtil.equals(-1.0, -1.0 + MathUtil.EPSILON * 2)); - - for (double zero : new double[] { 0.0, MathUtil.EPSILON / 10, -MathUtil.EPSILON / 10 }) { - - assertTrue(MathUtil.equals(zero, MathUtil.EPSILON / 3)); - assertTrue(MathUtil.equals(zero, -MathUtil.EPSILON / 3)); - assertFalse(MathUtil.equals(zero, MathUtil.EPSILON * 2)); - assertFalse(MathUtil.equals(zero, -MathUtil.EPSILON * 2)); - - assertTrue(MathUtil.equals(MathUtil.EPSILON / 3, zero)); - assertTrue(MathUtil.equals(-MathUtil.EPSILON / 3, zero)); - assertFalse(MathUtil.equals(MathUtil.EPSILON * 2, zero)); - assertFalse(MathUtil.equals(-MathUtil.EPSILON * 2, zero)); - - } - - for (double value : new double[] { PI * 1e20, -PI * 1e20 }) { - assertTrue("value=" + value, MathUtil.equals(value, value + 1)); - assertTrue("value=" + value, MathUtil.equals(value, Math.nextUp(value))); - assertTrue("value=" + value, MathUtil.equals(value, value * (1 + MathUtil.EPSILON))); - } - - assertFalse(MathUtil.equals(NaN, 0.0)); - assertFalse(MathUtil.equals(0.0, NaN)); - assertFalse(MathUtil.equals(NaN, NaN)); - } - - @Test - public void testAverageStddev() { - List ints = new ArrayList(); - List doubles = new ArrayList(); - - ints.add(3); - ints.add(4); - ints.add(7); - ints.add(5); - - doubles.add(3.4); - doubles.add(2.9); - doubles.add(7.5); - doubles.add(5.43); - doubles.add(2.8); - doubles.add(6.6); - - assertEquals(4.75, MathUtil.average(ints), EPS); - assertEquals(1.707825127659933, MathUtil.stddev(ints), EPS); - assertEquals(4.771666666666667, MathUtil.average(doubles), EPS); - assertEquals(2.024454659078999, MathUtil.stddev(doubles), EPS); - } - - @Test - public void testMedian() { - List ints = new ArrayList(); - List doubles = new ArrayList(); - - ints.add(3); - ints.add(4); - ints.add(7); - ints.add(5); - - doubles.add(3.4); - doubles.add(2.9); - doubles.add(7.5); - doubles.add(5.43); - doubles.add(2.8); - doubles.add(6.6); - - assertEquals(4.5, MathUtil.median(ints), EPS); - assertEquals(4.415, MathUtil.median(doubles), EPS); - - ints.add(9); - doubles.add(10.0); - - assertEquals(5, MathUtil.median(ints), EPS); - assertEquals(5.43, MathUtil.median(doubles), EPS); - } - -} diff --git a/test/net/sf/openrocket/util/MutableTest.java b/test/net/sf/openrocket/util/MutableTest.java deleted file mode 100644 index dfc02209..00000000 --- a/test/net/sf/openrocket/util/MutableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; -import net.sf.openrocket.logging.TraceException; - -import org.junit.Test; - -public class MutableTest { - - @Test - public void testMutable() { - Mutable m = new Mutable(); - Throwable t = null; - - m.check(); - m.check(); - assertTrue(m.isMutable()); - - m.immute(); - - try { - m.check(); - fail(); - } catch (IllegalStateException e) { - // Success - t = e.getCause(); - assertTrue(t instanceof TraceException); - } - - m.immute(); - - try { - m.check(); - fail(); - } catch (IllegalStateException e) { - // Success - assertTrue(e.getCause() == t); - } - } - - - @Test - public void testClone() { - Mutable m1 = new Mutable(); - Mutable m2 = m1.clone(); - - assertTrue(m1.isMutable()); - assertTrue(m2.isMutable()); - - m1.immute(); - - assertFalse(m1.isMutable()); - assertTrue(m2.isMutable()); - } - -} diff --git a/test/net/sf/openrocket/util/ReflectionTest.java b/test/net/sf/openrocket/util/ReflectionTest.java deleted file mode 100644 index 9f7c10ed..00000000 --- a/test/net/sf/openrocket/util/ReflectionTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.junit.Test; - -public class ReflectionTest { - - @Test - public void textHandleInvocationTargetException() { - Throwable cause = null; - - try { - cause = new InvocationTargetException(null); - Reflection.handleWrappedException((InvocationTargetException)cause); - fail(); - } catch (BugException e) { - assertTrue(cause == e.getCause()); - } - - try { - cause = new IllegalStateException("Test"); - Reflection.handleWrappedException(new InvocationTargetException(cause)); - fail(); - } catch (IllegalStateException e) { - assertTrue(cause == e); - } - - try { - cause = new AbstractMethodError(); - Reflection.handleWrappedException(new InvocationTargetException(cause)); - fail(); - } catch (AbstractMethodError e) { - assertTrue(cause == e); - } - - try { - cause = new IOException(); - Reflection.handleWrappedException(new InvocationTargetException(cause)); - fail(); - } catch (BugException e) { - assertTrue(cause == e.getCause()); - } - - } - -} diff --git a/test/net/sf/openrocket/util/Rotation2DTest.java b/test/net/sf/openrocket/util/Rotation2DTest.java deleted file mode 100644 index 6cc6d91f..00000000 --- a/test/net/sf/openrocket/util/Rotation2DTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class Rotation2DTest { - - @Test - public void rotationTest() { - - double rot60 = 0.5; - double rot30 = Math.sqrt(3)/2; - - Coordinate x = new Coordinate(1,1,0); - Coordinate y = new Coordinate(0,1,1); - - Rotation2D rot = new Rotation2D(Math.PI/3); // 60 deg - - assertEquals(new Coordinate(rot60, 1, -rot30), rot.rotateY(x)); - assertEquals(new Coordinate(rot60, 1, rot30), rot.invRotateY(x)); - - assertEquals(new Coordinate(1, rot60, rot30), rot.rotateX(x)); - assertEquals(new Coordinate(1, rot60, -rot30), rot.invRotateX(x)); - - assertEquals(new Coordinate(-rot30, rot60, 1), rot.rotateZ(y)); - assertEquals(new Coordinate(rot30, rot60, 1), rot.invRotateZ(y)); - - } - -} diff --git a/test/net/sf/openrocket/util/TestMutex.java b/test/net/sf/openrocket/util/TestMutex.java deleted file mode 100644 index 94d5a9f5..00000000 --- a/test/net/sf/openrocket/util/TestMutex.java +++ /dev/null @@ -1,175 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -public class TestMutex { - - @Before - public void setup() { - System.setProperty("openrocket.debug.safetycheck", "true"); - } - - @Test - public void testSingleLocking() { - SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); - - // Test single locking - assertNull(m.lockingThread); - m.verify(); - m.lock("here"); - assertNotNull(m.lockingThread); - assertTrue(m.unlock("here")); - - } - - @Test - public void testDoubleLocking() { - SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); - - // Test double locking - m.verify(); - m.lock("foobar"); - m.verify(); - m.lock("bazqux"); - m.verify(); - assertTrue(m.unlock("bazqux")); - m.verify(); - assertTrue(m.unlock("foobar")); - m.verify(); - } - - @Test - public void testDoubleUnlocking() { - SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); - // Mark error reported to not init exception handler - SafetyMutex.ConcreteSafetyMutex.errorReported = true; - - m.lock("here"); - assertTrue(m.unlock("here")); - assertFalse(m.unlock("here")); - } - - - - private volatile int testState = 0; - private volatile String failure = null; - - @Test(timeout = 1000) - public void testThreadingErrors() { - final SafetyMutex.ConcreteSafetyMutex m = new SafetyMutex.ConcreteSafetyMutex(); - - // Initialize and start the thread - Thread thread = new Thread() { - @Override - public void run() { - try { - - // Test locking a locked mutex - waitFor(1); - try { - m.lock("in thread one"); - failure = "Succeeded in locking a mutex locked by a different thread"; - return; - } catch (ConcurrencyException e) { - // OK - } - - // Test unlocking a mutex locked by a different thread - if (m.unlock("in thread two")) { - failure = "Succeeded in unlocking a mutex locked by a different thread"; - return; - } - - // Test verifying a locked mutex that already has an error - try { - m.verify(); - failure = "Succeeded in verifying a mutex locked by a different thread"; - return; - } catch (ConcurrencyException e) { - // OK - } - - // Test locking a mutex after it's been unlocked - testState = 2; - waitFor(3); - m.lock("in thread three"); - m.verify(); - - // Wait for other side to test - testState = 4; - waitFor(5); - - // Exit code - testState = 6; - - } catch (Exception e) { - failure = "Exception occurred in thread: " + e; - return; - } - - } - }; - thread.setDaemon(true); - thread.start(); - - m.lock("one"); - testState = 1; - - waitFor(2); - assertNull("Thread error: " + failure, failure); - - m.verify(); - m.unlock("one"); - testState = 3; - - waitFor(4); - assertNull("Thread error: " + failure, failure); - - try { - m.lock("two"); - fail("Succeeded in locking a locked mutex in main thread"); - } catch (ConcurrencyException e) { - // OK - } - - // Test unlocking a mutex locked by a different thread - assertFalse(m.unlock("here")); - - try { - m.verify(); - fail("Succeeded in verifying a locked mutex in main thread"); - } catch (ConcurrencyException e) { - // OK - } - - testState = 5; - waitFor(6); - assertNull("Thread error: " + failure, failure); - } - - private void waitFor(int state) { - while (testState != state && failure == null) { - try { - Thread.sleep(1); - } catch (InterruptedException e) { - } - } - } - - - public void testBogusMutex() { - SafetyMutex m = new SafetyMutex.BogusSafetyMutex(); - m.lock("foo"); - m.lock("bar"); - m.lock("baz"); - m.verify(); - m.unlock("a"); - m.unlock(null); - m.unlock(""); - m.unlock("c"); - } - -} diff --git a/test/net/sf/openrocket/util/TextUtilTest.java b/test/net/sf/openrocket/util/TextUtilTest.java deleted file mode 100644 index 8ac8319d..00000000 --- a/test/net/sf/openrocket/util/TextUtilTest.java +++ /dev/null @@ -1,258 +0,0 @@ -package net.sf.openrocket.util; - -import static java.lang.Math.PI; -import static org.junit.Assert.assertEquals; - -import java.util.Random; - -import org.junit.Test; - -public class TextUtilTest { - - @Test - public void testHexString() { - assertEquals("", TextUtil.hexString(new byte[0])); - assertEquals("00", TextUtil.hexString(new byte[] { 0x00 })); - assertEquals("ff", TextUtil.hexString(new byte[] { (byte) 0xff })); - - for (int i = 0; i <= 0xff; i++) { - assertEquals(String.format("%02x", i), TextUtil.hexString(new byte[] { (byte) i })); - } - - assertEquals("0f1e2d3c4b5a6978", TextUtil.hexString(new byte[] { - 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78 - })); - - Random rnd = new Random(); - for (int count = 0; count < 10; count++) { - int n = rnd.nextInt(100); - byte[] bytes = new byte[n]; - rnd.nextBytes(bytes); - StringBuilder sb = new StringBuilder(); - for (byte b : bytes) { - sb.append(String.format("%02x", b & 0xFF)); - } - assertEquals(sb.toString(), TextUtil.hexString(bytes)); - } - } - - @Test - public void specialCaseTest() { - assertEquals("NaN", TextUtil.doubleToString(Double.NaN)); - assertEquals("Inf", TextUtil.doubleToString(Double.POSITIVE_INFINITY)); - assertEquals("-Inf", TextUtil.doubleToString(Double.NEGATIVE_INFINITY)); - assertEquals("0", TextUtil.doubleToString(0.0)); - assertEquals("0", TextUtil.doubleToString(MathUtil.EPSILON / 3)); - assertEquals("0", TextUtil.doubleToString(-MathUtil.EPSILON / 3)); - } - - @Test - public void longTest() { - - assertEquals("3.1416e-5", TextUtil.doubleToString(PI * 1e-5)); - assertEquals("3.1416e-4", TextUtil.doubleToString(PI * 1e-4)); - assertEquals("0.0031416", TextUtil.doubleToString(PI * 1e-3)); - assertEquals("0.031416", TextUtil.doubleToString(PI * 1e-2)); - assertEquals("0.31416", TextUtil.doubleToString(PI * 1e-1)); - assertEquals("3.1416", TextUtil.doubleToString(PI)); - assertEquals("31.416", TextUtil.doubleToString(PI * 1e1)); - assertEquals("314.16", TextUtil.doubleToString(PI * 1e2)); - assertEquals("3141.6", TextUtil.doubleToString(PI * 1e3)); - assertEquals("31416", TextUtil.doubleToString(PI * 1e4)); - assertEquals("314159", TextUtil.doubleToString(PI * 1e5)); - assertEquals("3141593", TextUtil.doubleToString(PI * 1e6)); - assertEquals("31415927", TextUtil.doubleToString(PI * 1e7)); - assertEquals("3.1416e8", TextUtil.doubleToString(PI * 1e8)); - assertEquals("3.1416e9", TextUtil.doubleToString(PI * 1e9)); - assertEquals("3.1416e10", TextUtil.doubleToString(PI * 1e10)); - - assertEquals("-3.1416e-5", TextUtil.doubleToString(-PI * 1e-5)); - assertEquals("-3.1416e-4", TextUtil.doubleToString(-PI * 1e-4)); - assertEquals("-0.0031416", TextUtil.doubleToString(-PI * 1e-3)); - assertEquals("-0.031416", TextUtil.doubleToString(-PI * 1e-2)); - assertEquals("-0.31416", TextUtil.doubleToString(-PI * 1e-1)); - assertEquals("-3.1416", TextUtil.doubleToString(-PI)); - assertEquals("-31.416", TextUtil.doubleToString(-PI * 1e1)); - assertEquals("-314.16", TextUtil.doubleToString(-PI * 1e2)); - assertEquals("-3141.6", TextUtil.doubleToString(-PI * 1e3)); - assertEquals("-31416", TextUtil.doubleToString(-PI * 1e4)); - assertEquals("-314159", TextUtil.doubleToString(-PI * 1e5)); - assertEquals("-3141593", TextUtil.doubleToString(-PI * 1e6)); - assertEquals("-31415927", TextUtil.doubleToString(-PI * 1e7)); - assertEquals("-3.1416e8", TextUtil.doubleToString(-PI * 1e8)); - assertEquals("-3.1416e9", TextUtil.doubleToString(-PI * 1e9)); - assertEquals("-3.1416e10", TextUtil.doubleToString(-PI * 1e10)); - - } - - @Test - public void shortTest() { - double p = 3.1; - assertEquals("3.1e-5", TextUtil.doubleToString(p * 1e-5)); - assertEquals("3.1e-4", TextUtil.doubleToString(p * 1e-4)); - assertEquals("0.0031", TextUtil.doubleToString(p * 1e-3)); - assertEquals("0.031", TextUtil.doubleToString(p * 1e-2)); - assertEquals("0.31", TextUtil.doubleToString(p * 1e-1)); - assertEquals("3.1", TextUtil.doubleToString(p)); - assertEquals("31", TextUtil.doubleToString(p * 1e1)); - assertEquals("310", TextUtil.doubleToString(p * 1e2)); - assertEquals("3100", TextUtil.doubleToString(p * 1e3)); - assertEquals("31000", TextUtil.doubleToString(p * 1e4)); - assertEquals("3.1e5", TextUtil.doubleToString(p * 1e5)); - assertEquals("3.1e6", TextUtil.doubleToString(p * 1e6)); - assertEquals("3.1e7", TextUtil.doubleToString(p * 1e7)); - assertEquals("3.1e8", TextUtil.doubleToString(p * 1e8)); - assertEquals("3.1e9", TextUtil.doubleToString(p * 1e9)); - assertEquals("3.1e10", TextUtil.doubleToString(p * 1e10)); - - assertEquals("-3.1e-5", TextUtil.doubleToString(-p * 1e-5)); - assertEquals("-3.1e-4", TextUtil.doubleToString(-p * 1e-4)); - assertEquals("-0.0031", TextUtil.doubleToString(-p * 1e-3)); - assertEquals("-0.031", TextUtil.doubleToString(-p * 1e-2)); - assertEquals("-0.31", TextUtil.doubleToString(-p * 1e-1)); - assertEquals("-3.1", TextUtil.doubleToString(-p)); - assertEquals("-31", TextUtil.doubleToString(-p * 1e1)); - assertEquals("-310", TextUtil.doubleToString(-p * 1e2)); - assertEquals("-3100", TextUtil.doubleToString(-p * 1e3)); - assertEquals("-31000", TextUtil.doubleToString(-p * 1e4)); - assertEquals("-3.1e5", TextUtil.doubleToString(-p * 1e5)); - assertEquals("-3.1e6", TextUtil.doubleToString(-p * 1e6)); - assertEquals("-3.1e7", TextUtil.doubleToString(-p * 1e7)); - assertEquals("-3.1e8", TextUtil.doubleToString(-p * 1e8)); - assertEquals("-3.1e9", TextUtil.doubleToString(-p * 1e9)); - assertEquals("-3.1e10", TextUtil.doubleToString(-p * 1e10)); - - p = 3; - assertEquals("3e-5", TextUtil.doubleToString(p * 1e-5)); - assertEquals("3e-4", TextUtil.doubleToString(p * 1e-4)); - assertEquals("3e-3", TextUtil.doubleToString(p * 1e-3)); - assertEquals("0.03", TextUtil.doubleToString(p * 1e-2)); - assertEquals("0.3", TextUtil.doubleToString(p * 1e-1)); - assertEquals("3", TextUtil.doubleToString(p)); - assertEquals("30", TextUtil.doubleToString(p * 1e1)); - assertEquals("300", TextUtil.doubleToString(p * 1e2)); - assertEquals("3e3", TextUtil.doubleToString(p * 1e3)); - assertEquals("3e4", TextUtil.doubleToString(p * 1e4)); - assertEquals("3e5", TextUtil.doubleToString(p * 1e5)); - assertEquals("3e6", TextUtil.doubleToString(p * 1e6)); - assertEquals("3e7", TextUtil.doubleToString(p * 1e7)); - assertEquals("3e8", TextUtil.doubleToString(p * 1e8)); - assertEquals("3e9", TextUtil.doubleToString(p * 1e9)); - assertEquals("3e10", TextUtil.doubleToString(p * 1e10)); - - assertEquals("-3e-5", TextUtil.doubleToString(-p * 1e-5)); - assertEquals("-3e-4", TextUtil.doubleToString(-p * 1e-4)); - assertEquals("-3e-3", TextUtil.doubleToString(-p * 1e-3)); - assertEquals("-0.03", TextUtil.doubleToString(-p * 1e-2)); - assertEquals("-0.3", TextUtil.doubleToString(-p * 1e-1)); - assertEquals("-3", TextUtil.doubleToString(-p)); - assertEquals("-30", TextUtil.doubleToString(-p * 1e1)); - assertEquals("-300", TextUtil.doubleToString(-p * 1e2)); - assertEquals("-3e3", TextUtil.doubleToString(-p * 1e3)); - assertEquals("-3e4", TextUtil.doubleToString(-p * 1e4)); - assertEquals("-3e5", TextUtil.doubleToString(-p * 1e5)); - assertEquals("-3e6", TextUtil.doubleToString(-p * 1e6)); - assertEquals("-3e7", TextUtil.doubleToString(-p * 1e7)); - assertEquals("-3e8", TextUtil.doubleToString(-p * 1e8)); - assertEquals("-3e9", TextUtil.doubleToString(-p * 1e9)); - assertEquals("-3e10", TextUtil.doubleToString(-p * 1e10)); - - } - - @Test - public void roundingTest() { - - assertEquals("1.001", TextUtil.doubleToString(1.00096)); - - - /* - * Not testing with 1.00015 because it might be changed during number formatting - * calculations. Its rounding is basically arbitrary anyway. - */ - - assertEquals("1.0002e-5", TextUtil.doubleToString(1.0001500001e-5)); - assertEquals("1.0001e-5", TextUtil.doubleToString(1.0001499999e-5)); - assertEquals("1.0002e-4", TextUtil.doubleToString(1.0001500001e-4)); - assertEquals("1.0001e-4", TextUtil.doubleToString(1.0001499999e-4)); - assertEquals("0.0010002", TextUtil.doubleToString(1.0001500001e-3)); - assertEquals("0.0010001", TextUtil.doubleToString(1.0001499999e-3)); - assertEquals("0.010002", TextUtil.doubleToString(1.0001500001e-2)); - assertEquals("0.010001", TextUtil.doubleToString(1.0001499999e-2)); - assertEquals("0.10002", TextUtil.doubleToString(1.0001500001e-1)); - assertEquals("0.10001", TextUtil.doubleToString(1.0001499999e-1)); - assertEquals("1.0002", TextUtil.doubleToString(1.0001500001)); - assertEquals("1.0001", TextUtil.doubleToString(1.0001499999)); - assertEquals("10.002", TextUtil.doubleToString(1.0001500001e1)); - assertEquals("10.001", TextUtil.doubleToString(1.0001499999e1)); - assertEquals("100.02", TextUtil.doubleToString(1.0001500001e2)); - assertEquals("100.01", TextUtil.doubleToString(1.0001499999e2)); - assertEquals("1000.2", TextUtil.doubleToString(1.0001500001e3)); - assertEquals("1000.1", TextUtil.doubleToString(1.0001499999e3)); - assertEquals("10002", TextUtil.doubleToString(1.0001500001e4)); - assertEquals("10001", TextUtil.doubleToString(1.0001499999e4)); - assertEquals("100012", TextUtil.doubleToString(1.00011500001e5)); - assertEquals("100011", TextUtil.doubleToString(1.00011499999e5)); - assertEquals("1000112", TextUtil.doubleToString(1.000111500001e6)); - assertEquals("1000111", TextUtil.doubleToString(1.000111499999e6)); - assertEquals("10001112", TextUtil.doubleToString(1.0001111500001e7)); - assertEquals("10001111", TextUtil.doubleToString(1.0001111499999e7)); - assertEquals("1.0002e8", TextUtil.doubleToString(1.0001500001e8)); - assertEquals("1.0001e8", TextUtil.doubleToString(1.0001499999e8)); - assertEquals("1.0002e9", TextUtil.doubleToString(1.0001500001e9)); - assertEquals("1.0001e9", TextUtil.doubleToString(1.0001499999e9)); - assertEquals("1.0002e10", TextUtil.doubleToString(1.0001500001e10)); - assertEquals("1.0001e10", TextUtil.doubleToString(1.0001499999e10)); - - - assertEquals("-1.0002e-5", TextUtil.doubleToString(-1.0001500001e-5)); - assertEquals("-1.0001e-5", TextUtil.doubleToString(-1.0001499999e-5)); - assertEquals("-1.0002e-4", TextUtil.doubleToString(-1.0001500001e-4)); - assertEquals("-1.0001e-4", TextUtil.doubleToString(-1.0001499999e-4)); - assertEquals("-0.0010002", TextUtil.doubleToString(-1.0001500001e-3)); - assertEquals("-0.0010001", TextUtil.doubleToString(-1.0001499999e-3)); - assertEquals("-0.010002", TextUtil.doubleToString(-1.0001500001e-2)); - assertEquals("-0.010001", TextUtil.doubleToString(-1.0001499999e-2)); - assertEquals("-0.10002", TextUtil.doubleToString(-1.0001500001e-1)); - assertEquals("-0.10001", TextUtil.doubleToString(-1.0001499999e-1)); - assertEquals("-1.0002", TextUtil.doubleToString(-1.0001500001)); - assertEquals("-1.0001", TextUtil.doubleToString(-1.0001499999)); - assertEquals("-10.002", TextUtil.doubleToString(-1.0001500001e1)); - assertEquals("-10.001", TextUtil.doubleToString(-1.0001499999e1)); - assertEquals("-100.02", TextUtil.doubleToString(-1.0001500001e2)); - assertEquals("-100.01", TextUtil.doubleToString(-1.0001499999e2)); - assertEquals("-1000.2", TextUtil.doubleToString(-1.0001500001e3)); - assertEquals("-1000.1", TextUtil.doubleToString(-1.0001499999e3)); - assertEquals("-10002", TextUtil.doubleToString(-1.0001500001e4)); - assertEquals("-10001", TextUtil.doubleToString(-1.0001499999e4)); - assertEquals("-100012", TextUtil.doubleToString(-1.00011500001e5)); - assertEquals("-100011", TextUtil.doubleToString(-1.00011499999e5)); - assertEquals("-1000112", TextUtil.doubleToString(-1.000111500001e6)); - assertEquals("-1000111", TextUtil.doubleToString(-1.000111499999e6)); - assertEquals("-10001112", TextUtil.doubleToString(-1.0001111500001e7)); - assertEquals("-10001111", TextUtil.doubleToString(-1.0001111499999e7)); - assertEquals("-1.0002e8", TextUtil.doubleToString(-1.0001500001e8)); - assertEquals("-1.0001e8", TextUtil.doubleToString(-1.0001499999e8)); - assertEquals("-1.0002e9", TextUtil.doubleToString(-1.0001500001e9)); - assertEquals("-1.0001e9", TextUtil.doubleToString(-1.0001499999e9)); - assertEquals("-1.0002e10", TextUtil.doubleToString(-1.0001500001e10)); - assertEquals("-1.0001e10", TextUtil.doubleToString(-1.0001499999e10)); - - } - - - @Test - public void randomTest() { - for (int i = 0; i < 10000; i++) { - double orig = Math.random(); - double result; - double expected = Math.rint(orig * 100000) / 100000.0; - - if (orig < 0.1) - continue; - String s = TextUtil.doubleToString(orig); - result = Double.parseDouble(s); - assertEquals(expected, result, 0.00000001); - } - } - -} diff --git a/test/net/sf/openrocket/util/UniqueIDTest.java b/test/net/sf/openrocket/util/UniqueIDTest.java deleted file mode 100644 index c77da324..00000000 --- a/test/net/sf/openrocket/util/UniqueIDTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class UniqueIDTest { - - @Test - public void integerTest() { - - int n = UniqueID.next(); - assertTrue(n > 0); - assertEquals(n+1, UniqueID.next()); - assertEquals(n+2, UniqueID.next()); - assertEquals(n+3, UniqueID.next()); - - } - - - @Test - public void stringTest() { - String id = UniqueID.uuid(); - assertNotNull(id); - assertNotSame(id, UniqueID.uuid()); - assertNotSame(id, UniqueID.uuid()); - } - -} diff --git a/test/net/sf/openrocket/util/WorldCoordinateTest.java b/test/net/sf/openrocket/util/WorldCoordinateTest.java deleted file mode 100644 index ce67dc11..00000000 --- a/test/net/sf/openrocket/util/WorldCoordinateTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.sf.openrocket.util; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class WorldCoordinateTest { - - private static final double EPS = 1e-10; - - @Test - public void testConstructor() { - WorldCoordinate wc; - - wc = new WorldCoordinate(10, 15, 130); - assertEquals(10, wc.getLatitudeDeg(), EPS); - assertEquals(15, wc.getLongitudeDeg(), EPS); - assertEquals(130, wc.getAltitude(), 0); - - wc = new WorldCoordinate(100, 190, 13000); - assertEquals(90, wc.getLatitudeDeg(), EPS); - assertEquals(-170, wc.getLongitudeDeg(), EPS); - assertEquals(13000, wc.getAltitude(), 0); - - wc = new WorldCoordinate(-100, -200, -13000); - assertEquals(-90, wc.getLatitudeDeg(), EPS); - assertEquals(160, wc.getLongitudeDeg(), EPS); - assertEquals(-13000, wc.getAltitude(), 0); - } - - @Test - public void testGetLatitude() { - WorldCoordinate wc; - wc = new WorldCoordinate(10, 15, 130); - assertEquals(10, wc.getLatitudeDeg(), EPS); - assertEquals(Math.toRadians(10), wc.getLatitudeRad(), EPS); - } - - @Test - public void testGetLongitude() { - WorldCoordinate wc; - wc = new WorldCoordinate(10, 15, 130); - assertEquals(15, wc.getLongitudeDeg(), EPS); - assertEquals(Math.toRadians(15), wc.getLongitudeRad(), EPS); - } - -}