Commit 5362669e authored by Luc Maisonobe's avatar Luc Maisonobe

Improved test coverage.

parent 6b660abd
......@@ -79,10 +79,10 @@ class JPLCelestialBody implements CelestialBody {
* this frame <strong>must</strong> be aligned with ICRF
*/
JPLCelestialBody(final String name, final String supportedNames,
final JPLEphemeridesLoader.EphemerisType generateType,
final JPLEphemeridesLoader.RawPVProvider rawPVProvider,
final double gm, final double scale,
final IAUPole iauPole, final Frame definingFrameAlignedWithICRF) {
final JPLEphemeridesLoader.EphemerisType generateType,
final JPLEphemeridesLoader.RawPVProvider rawPVProvider,
final double gm, final double scale,
final IAUPole iauPole, final Frame definingFrameAlignedWithICRF) {
this.name = name;
this.gm = gm;
this.scale = scale;
......
......@@ -160,12 +160,8 @@ public class NetworkCrawler implements DataProvider {
return loaded;
} catch (URISyntaxException use) {
throw new OrekitException(use, new DummyLocalizable(use.getMessage()));
} catch (IOException ioe) {
throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage()));
} catch (ParseException pe) {
throw new OrekitException(pe, new DummyLocalizable(pe.getMessage()));
} catch (URISyntaxException | IOException | ParseException e) {
throw new OrekitException(e, new DummyLocalizable(e.getMessage()));
}
}
......
......@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.channels.UnsupportedAddressTypeException;
import java.text.ParseException;
import java.util.Iterator;
import java.util.NoSuchElementException;
......@@ -144,7 +143,7 @@ public class ZipJarCrawler implements DataProvider {
try {
// open the raw data stream
Archive archive = null;;
Archive archive = null;
try {
if (file != null) {
archive = new Archive(new FileInputStream(file));
......@@ -289,19 +288,9 @@ public class ZipJarCrawler implements DataProvider {
/** {@inheritDoc} */
@Override
public EntryStream next() throws NoSuchElementException {
if (next == null) {
throw new NoSuchElementException();
}
return next;
}
/** {@inheritDoc} */
@Override
public void remove() {
// this part is never called
throw new UnsupportedAddressTypeException();
}
};
}
......
......@@ -44,8 +44,10 @@ public class IodGooding {
/** Normalizing constant for distances. */
private double R;
/** Normalizing constant for velocities. */
private double V;
/** Normalizing constant for duration. */
private double T;
......@@ -144,17 +146,16 @@ public class IodGooding {
final Vector3D lineOfSight1, final AbsoluteDate dateObs1,
final Vector3D lineOfSight2, final AbsoluteDate dateObs2,
final Vector3D lineOfSight3, final AbsoluteDate dateObs3,
final double rho1init, final double rho3init)
{
final double rho1init, final double rho3init) {
this.date1 = dateObs1;
// normalizeing coefficients
// normalizing coefficients
R = FastMath.max(rho1init, rho3init);
V = FastMath.sqrt(mu / R);
T = R / V;
// Initialize Lambert's problem solver for nondimensional units.
// Initialize Lambert's problem solver for non-dimensional units.
lambert = new IodLambert(1.);
this.vObserverPosition1 = O1.scalarMultiply(1. / R);
......@@ -489,8 +490,7 @@ public class IodGooding {
private Vector3D getPositionOnLoS2(final Vector3D E1, final double RO1,
final Vector3D E3, final double RO3,
final double T13, final double T12,
final double nRev, final boolean posigrade)
{
final double nRev, final boolean posigrade) {
final Vector3D P1 = vObserverPosition1.add(E1.scalarMultiply(RO1));
R1 = P1.getNorm();
......
......@@ -782,7 +782,7 @@ public class GenericTimeStampedCache<T extends TimeStamped> implements TimeStamp
if (!appended) {
throw new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_AFTER,
cache.get(cache.size() - 1).getData().getDate());
cache.get(cache.size() - 1).getData().getDate());
}
// evict excess data at start
......
......@@ -116,12 +116,10 @@ public class ImmutableTimeStampedCache<T extends TimeStamped>
// check index in in the range of the data
if (i < 0) {
throw new TimeStampedCacheException(
OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
throw new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
this.getEarliest().getDate());
} else if (i >= this.data.size()) {
throw new TimeStampedCacheException(
OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_AFTER,
throw new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_AFTER,
this.getLatest().getDate());
}
......
......@@ -83,7 +83,7 @@ public class AttitudesSequenceTest {
private static final long serialVersionUID = 1L;
public EventHandler.Action eventOccurred(final SpacecraftState s, final EclipseDetector d, final boolean increasing) {
setInEclipse(s.getDate(), !increasing);
return EventHandler.Action.CONTINUE;
return EventHandler.Action.RESET_STATE;
}
});
final EventDetector monitored = logger.monitorDetector(ed);
......@@ -95,7 +95,9 @@ public class AttitudesSequenceTest {
attitudesSequence.addSwitchingCondition(nightRestingLaw, dayObservationLaw,
monitored, true, false, 300.0,
AngularDerivativesFilter.USE_RRA, nightToDayHandler);
if (ed.g(new SpacecraftState(initialOrbit)) >= 0) {
SpacecraftState initialState = new SpacecraftState(initialOrbit);
initialState = initialState.addAdditionalState("fortyTwo", 42.0);
if (ed.g(initialState) >= 0) {
// initial position is in daytime
setInEclipse(initialDate, false);
attitudesSequence.resetActiveProvider(dayObservationLaw);
......@@ -182,16 +184,21 @@ public class AttitudesSequenceTest {
true, false, 10.0, AngularDerivativesFilter.USE_R, null);
attitudesSequence.resetActiveProvider(current);
SpacecraftState initialState = new SpacecraftState(initialOrbit);
initialState = initialState.addAdditionalState("fortyTwo", 42.0);
final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence,
Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20,
Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40,
Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
propagator.resetInitialState(initialState);
Assert.assertEquals(42.0, propagator.getInitialState().getAdditionalState("fortyTwo")[0], 1.0e-10);
// Register the switching events to the propagator
attitudesSequence.registerSwitchEvents(propagator);
SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(-10000.0));
Assert.assertEquals(42.0, finalState.getAdditionalState("fortyTwo")[0], 1.0e-10);
Assert.assertEquals(1, handler.dates.size());
Assert.assertEquals(-500.0, handler.dates.get(0).durationFrom(initialDate), 1.0e-3);
Assert.assertEquals(-490.0, finalState.getDate().durationFrom(initialDate), 1.0e-3);
......
......@@ -49,10 +49,9 @@ public class SpinStabilizedTest {
new TimeComponents(3, 25, 45.6789),
TimeScalesFactory.getTAI());
double rate = 2.0 * FastMath.PI / (12 * 60);
AttitudeProvider bbq =
new SpinStabilized(new CelestialBodyPointed(FramesFactory.getEME2000(), sun, Vector3D.PLUS_K,
Vector3D.PLUS_I, Vector3D.PLUS_K),
date, Vector3D.PLUS_K, rate);
AttitudeProvider cbp = new CelestialBodyPointed(FramesFactory.getEME2000(), sun, Vector3D.PLUS_K,
Vector3D.PLUS_I, Vector3D.PLUS_K);
SpinStabilized bbq = new SpinStabilized(cbp, date, Vector3D.PLUS_K, rate);
PVCoordinates pv =
new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0),
new Vector3D(0, 0, 3680.853673522056));
......@@ -63,6 +62,7 @@ public class SpinStabilizedTest {
Vector3D.angle(xDirection, sun.getPVCoordinates(date, FramesFactory.getEME2000()).getPosition()),
2.0e-15);
Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-6);
Assert.assertSame(cbp, bbq.getUnderlyingAttitudeProvider());
}
......
......@@ -96,6 +96,7 @@ public class YawCompensationTest {
Assert.assertEquals(0.0, observedDiff.getPosition().getNorm(), Utils.epsilonTest);
Assert.assertEquals(0.0, observedDiff.getVelocity().getNorm(), Utils.epsilonTest);
Assert.assertEquals(0.0, observedDiff.getAcceleration().getNorm(), Utils.epsilonTest);
Assert.assertSame(nadirLaw, yawCompensLaw.getUnderlyingAttitudeProvider());
}
......
......@@ -93,6 +93,7 @@ public class YawSteeringTest {
Assert.assertEquals(0.0, observedDiff.getPosition().getNorm(), Utils.epsilonTest);
Assert.assertEquals(0.0, observedDiff.getVelocity().getNorm(), Utils.epsilonTest);
Assert.assertEquals(0.0, observedDiff.getAcceleration().getNorm(), Utils.epsilonTest);
Assert.assertSame(nadirLaw, yawCompensLaw.getUnderlyingAttitudeProvider());
}
......
......@@ -18,7 +18,6 @@ package org.orekit.bodies;
import java.io.IOException;
import java.text.ParseException;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.junit.Assert;
......@@ -45,6 +44,7 @@ public class JPLEphemeridesLoaderTest {
JPLEphemeridesLoader.EphemerisType.SUN);
Assert.assertEquals(149597870691.0, loader.getLoadedAstronomicalUnit(), 0.1);
Assert.assertEquals(81.30056, loader.getLoadedEarthMoonMassRatio(), 1.0e-8);
Assert.assertTrue(Double.isNaN(loader.getLoadedConstant("not-a-constant")));
}
@Test
......@@ -143,7 +143,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testDerivative405() throws OrekitException, ParseException {
public void testDerivative405() throws OrekitException {
Utils.setDataRoot("regular-data/de405-ephemerides");
checkDerivative(JPLEphemeridesLoader.DEFAULT_DE_SUPPORTED_NAMES,
new AbsoluteDate(1969, 6, 25, TimeScalesFactory.getTT()),
......@@ -151,7 +151,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testDerivative406() throws OrekitException, ParseException {
public void testDerivative406() throws OrekitException {
Utils.setDataRoot("regular-data:regular-data/de406-ephemerides");
checkDerivative(JPLEphemeridesLoader.DEFAULT_DE_SUPPORTED_NAMES,
new AbsoluteDate(2964, 9, 26, TimeScalesFactory.getTT()),
......@@ -159,7 +159,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testDummyEarth() throws OrekitException, ParseException {
public void testDummyEarth() throws OrekitException {
Utils.setDataRoot("regular-data/de405-ephemerides");
JPLEphemeridesLoader loader =
new JPLEphemeridesLoader(JPLEphemeridesLoader.DEFAULT_DE_SUPPORTED_NAMES,
......@@ -175,7 +175,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testEndianness() throws OrekitException, ParseException {
public void testEndianness() throws OrekitException {
Utils.setDataRoot("inpop");
JPLEphemeridesLoader.EphemerisType type = JPLEphemeridesLoader.EphemerisType.MARS;
JPLEphemeridesLoader loaderInpopTCBBig =
......@@ -200,7 +200,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testInpopvsJPL() throws OrekitException, ParseException {
public void testInpopvsJPL() throws OrekitException {
Utils.setDataRoot("regular-data:inpop");
JPLEphemeridesLoader.EphemerisType type = JPLEphemeridesLoader.EphemerisType.MARS;
JPLEphemeridesLoader loaderDE405 =
......@@ -230,7 +230,7 @@ public class JPLEphemeridesLoaderTest {
}
@Test
public void testOverlappingEphemeridesData() throws OrekitException, IOException, ParseException {
public void testOverlappingEphemeridesData() throws OrekitException, IOException {
Utils.setDataRoot("overlapping-data/data.zip");
// the data root contains two ephemerides files (JPL DE 405), which overlap in the period
......@@ -263,7 +263,7 @@ public class JPLEphemeridesLoaderTest {
}
private void checkDerivative(String supportedNames, AbsoluteDate date, double maxChunkDuration)
throws OrekitException, ParseException {
throws OrekitException {
JPLEphemeridesLoader loader =
new JPLEphemeridesLoader(supportedNames, JPLEphemeridesLoader.EphemerisType.MERCURY);
CelestialBody body = loader.loadCelestialBody(CelestialBodyFactory.MERCURY);
......
......@@ -25,6 +25,9 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Before;
......@@ -76,6 +79,30 @@ public class FundamentalNutationArgumentsTest {
}
}
@Test
public void testEnum() throws NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
Class<?> e = null;
for (final Class<?> c : FundamentalNutationArguments.class.getDeclaredClasses()) {
if (c.getName().endsWith("FundamentalName")) {
e = c;
}
}
Method m = e.getDeclaredMethod("valueOf", String.class);
m.setAccessible(true);
for (String n : Arrays.asList("L", "L_PRIME", "F", "D", "OMEGA",
"L_ME", "L_VE", "L_E", "L_MA", "L_J", "L_SA", "L_U", "L_NE", "PA")) {
Assert.assertEquals(n, m.invoke(null, n).toString());
}
try {
m.invoke(null, "inexistent");
Assert.fail("an exception should have been thrown");
} catch (InvocationTargetException ite) {
Assert.assertTrue(ite.getCause() instanceof IllegalArgumentException);
}
}
@Test
public void testSerializationNoTidalCorrection() throws OrekitException, IOException, ClassNotFoundException {
IERSConventions conventions = IERSConventions.IERS_2010;
......
......@@ -62,12 +62,14 @@ public class NetworkCrawlerTest {
@Test
public void local() throws OrekitException {
CountingLoader crawler = new CountingLoader();
new NetworkCrawler(url("regular-data/UTC-TAI.history"),
NetworkCrawler nc = new NetworkCrawler(url("regular-data/UTC-TAI.history"),
url("regular-data/de405-ephemerides/unxp0000.405"),
url("regular-data/de405-ephemerides/unxp0001.405"),
url("regular-data/de406-ephemerides/unxp0000.406"),
url("regular-data/Earth-orientation-parameters/monthly/bulletinb_IAU2000-216.txt"),
url("no-data")).feed(Pattern.compile(".*"), crawler);
url("no-data"));
nc.setTimeout(20);
nc.feed(Pattern.compile(".*"), crawler);
Assert.assertEquals(6, crawler.getCount());
}
......
......@@ -576,6 +576,7 @@ public class PoissonSeriesParserTest {
// direct computation of derivatives
FieldBodiesElements<DerivativeStructure> elements = arguments.evaluateDerivative(date);
Assert.assertEquals(0.0, elements.getDate().durationFrom(date), 1.0e-15);
DerivativeStructure xDirect = xSeries.value(elements);
DerivativeStructure yDirect = ySeries.value(elements);
DerivativeStructure zDirect = zSeries.value(elements);
......
......@@ -16,6 +16,10 @@
*/
package org.orekit.data;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
......@@ -180,4 +184,28 @@ public class PolynomialParserTest {
Assert.assertEquals(FastMath.toRadians(5.98 / 3600000000.0), coefficients[5], 1.0e-14);
}
@Test
public void testEnum() throws NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
Class<?> e = null;
for (final Class<?> c : PolynomialParser.class.getDeclaredClasses()) {
if (c.getName().endsWith("Unit")) {
e = c;
}
}
Method m = e.getDeclaredMethod("valueOf", String.class);
m.setAccessible(true);
for (String n : Arrays.asList("RADIANS", "DEGREES", "ARC_SECONDS",
"MILLI_ARC_SECONDS", "MICRO_ARC_SECONDS", "NO_UNITS")) {
Assert.assertEquals(n, m.invoke(null, n).toString());
}
try {
m.invoke(null, "inexistent");
Assert.fail("an exception should have been thrown");
} catch (InvocationTargetException ite) {
Assert.assertTrue(ite.getCause() instanceof IllegalArgumentException);
}
}
}
/* Copyright 2002-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.errors;
import java.util.Locale;
import org.hipparchus.exception.MathRuntimeException;
import org.junit.Assert;
import org.junit.Test;
@Deprecated
public class PropagationExceptionTest {
@Test
public void testMessage() {
PropagationException e =
new PropagationException(OrekitMessages.NON_EXISTENT_HMS_TIME, 97, 98, 99);
Assert.assertEquals(OrekitMessages.NON_EXISTENT_HMS_TIME, e.getSpecifier());
Assert.assertEquals(3, e.getParts().length);
Assert.assertEquals(97, ((Integer) e.getParts()[0]).intValue());
Assert.assertEquals(98, ((Integer) e.getParts()[1]).intValue());
Assert.assertEquals(99, ((Integer) e.getParts()[2]).intValue());
Assert.assertTrue(e.getMessage().contains("98"));
Assert.assertEquals(e.getMessage(Locale.getDefault()), e.getLocalizedMessage());
Assert.assertEquals("heure inexistante 97:98:99", e.getMessage(Locale.FRENCH));
}
@Test
public void testUnwrapOrekitExceptionNeedsCreation() {
OrekitException base = new OrekitException(OrekitMessages.NON_EXISTENT_HMS_TIME, 97, 98, 99);
PropagationException unwraped = PropagationException.unwrap(base);
Assert.assertSame(base, unwraped.getCause());
}
@Test
public void testUnwrapOrekitExceptionSimpleExtraction() {
PropagationException base = new PropagationException(OrekitMessages.NON_EXISTENT_HMS_TIME, 97, 98, 99);
OrekitException intermediate = new OrekitException(base);
PropagationException unwraped = PropagationException.unwrap(intermediate);
Assert.assertNull(unwraped.getCause());
Assert.assertSame(base, unwraped);
}
@Test
public void testUnwrapMathRuntimeExceptionNeedsCreation() {
MathRuntimeException base = new MathRuntimeException(OrekitMessages.NON_EXISTENT_HMS_TIME, 97, 98, 99);
PropagationException unwraped = PropagationException.unwrap(base);
Assert.assertSame(base, unwraped.getCause());
}
@Test
public void testUnwrapMathRuntimeExceptionSimpleExtraction() {
PropagationException base = new PropagationException(OrekitMessages.NON_EXISTENT_HMS_TIME, 97, 98, 99);
MathRuntimeException intermediate = new MathRuntimeException(base, base.getSpecifier(), base.getParts());
PropagationException unwraped = PropagationException.unwrap(intermediate);
Assert.assertNull(unwraped.getCause());
Assert.assertSame(base, unwraped);
}
}
/* Copyright 2002-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.errors;
import java.util.Locale;
import org.hipparchus.exception.MathRuntimeException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.Utils;
import org.orekit.time.AbsoluteDate;
public class TimeStampedCacheExceptionTest {
@Test
public void testMessage() {
TimeStampedCacheException e =
new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
Assert.assertEquals(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE, e.getSpecifier());
Assert.assertEquals(1, e.getParts().length);
Assert.assertEquals(0, ((AbsoluteDate) e.getParts()[0]).durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH), 1.0e-10);
Assert.assertEquals(e.getMessage(Locale.getDefault()), e.getLocalizedMessage());
Assert.assertEquals("impossible de générer des données avant le 1858-11-16T23:59:27.816",
e.getMessage(Locale.FRENCH));
}
@Test
public void testCause() {
TimeStampedCacheException e =
new TimeStampedCacheException(new ArrayIndexOutOfBoundsException(),
OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
Assert.assertTrue(e.getCause() instanceof ArrayIndexOutOfBoundsException);
Assert.assertEquals(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE, e.getSpecifier());
Assert.assertEquals(1, e.getParts().length);
Assert.assertEquals(0, ((AbsoluteDate) e.getParts()[0]).durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH), 1.0e-10);
Assert.assertEquals(e.getMessage(Locale.getDefault()), e.getLocalizedMessage());
Assert.assertEquals("impossible de générer des données avant le 1858-11-16T23:59:27.816",
e.getMessage(Locale.FRENCH));
}
@Test
public void testUnwrapOrekitExceptionNeedsCreation() {
OrekitException base = new OrekitException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(base);
Assert.assertSame(base, unwraped.getCause());
}
@Test
public void testUnwrapOrekitExceptionSimpleExtraction() {
TimeStampedCacheException base = new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
OrekitException intermediate = new OrekitException(base);
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(intermediate);
Assert.assertNull(unwraped.getCause());
Assert.assertSame(base, unwraped);
}
@Test
public void testUnwrapMathRuntimeExceptionNeedsCreation() {
MathRuntimeException base = new MathRuntimeException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(base);
Assert.assertSame(base, unwraped.getCause());
}
@Test
public void testUnwrapMathRuntimeExceptionSimpleExtraction() {
TimeStampedCacheException base = new TimeStampedCacheException(OrekitMessages.UNABLE_TO_GENERATE_NEW_DATA_BEFORE,
AbsoluteDate.MODIFIED_JULIAN_EPOCH);
MathRuntimeException intermediate = new MathRuntimeException(base, base.getSpecifier(), base.getParts());
TimeStampedCacheException unwraped = TimeStampedCacheException.unwrap(intermediate);
Assert.assertNull(unwraped.getCause());
Assert.assertSame(base, unwraped);
}
@Before
public void setUp() throws OrekitException {
Utils.setDataRoot("regular-data");
}
}
......@@ -23,6 +23,7 @@ import java.util.Map;
import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.RotationConvention;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.orekit.Utils;
......@@ -228,6 +229,10 @@ public class EstimationTestUtils {
Assert.assertEquals(iterations, estimator.getIterationsCount());
Assert.assertEquals(evaluations, estimator.getEvaluationsCount());
Optimum optimum = estimator.getOptimum();
Assert.assertEquals(iterations, optimum.getIterations());
Assert.assertEquals(evaluations, optimum.getEvaluations());
int k = 0;
double sum = 0;
......
......@@ -19,9 +19,9 @@ import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
import org.orekit.time.AbsoluteDate;
/**
*
*
* Source: http://ccar.colorado.edu/asen5050/projects/projects_2012/kemble/gibbs_derivation.htm
*
*
* @author Joris Olympio
* @since 7.1
*
......@@ -32,22 +32,22 @@ public class IodGoodingTest {
public void testGooding() throws OrekitException
{
final Context context = EstimationTestUtils.eccentricContext();
final double mu = context.initialOrbit.getMu();
final Frame frame = context.initialOrbit.getFrame();
final NumericalPropagatorBuilder propagatorBuilder =
context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true,
1.0e-6, 60.0, 0.001);
// create perfect range measurements
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit,
propagatorBuilder);
final List<ObservedMeasurement<?>> measurements =
EstimationTestUtils.createMeasurements(propagator,
new PVMeasurementCreator(),
0.0, 1.0, 60.0);
0.0, 1.0, 60.0);
// measurement data 1
final int idMeasure1 = 0;
......@@ -57,12 +57,12 @@ public class IodGoodingTest {
.getPVCoordinates(date1, frame)
.getPosition();*/
final Vector3D position1 = new Vector3D(
measurements.get(idMeasure1).getObservedValue()[0],
measurements.get(idMeasure1).getObservedValue()[0],
measurements.get(idMeasure1).getObservedValue()[1],
measurements.get(idMeasure1).getObservedValue()[2]);
final double r1 = position1.getNorm();
final Vector3D lineOfSight1 = position1.normalize();
// measurement data 2
final int idMeasure2 = 20;
final AbsoluteDate date2 = measurements.get(idMeasure2).getDate();
......@@ -71,7 +71,7 @@ public class IodGoodingTest {
.getPVCoordinates(date2, frame)
.getPosition();*/
final Vector3D position2 = new Vector3D(
measurements.get(idMeasure2).getObservedValue()[0],
measurements.get(idMeasure2).getObservedValue()[0],
measurements.get(idMeasure2).getObservedValue()[1],
measurements.get(idMeasure2).getObservedValue()[2]);
final Vector3D lineOfSight2 = position2.normalize();
......@@ -84,11 +84,11 @@ public class IodGoodingTest {
.getPVCoordinates(date3, frame)
.getPosition();*/
final Vector3D position3 = new Vector3D(
measurements.get(idMeasure3).getObservedValue()[0],
measurements.get(idMeasure3).getObservedValue()[0],
measurements.get(idMeasure3).getObservedValue()[1],
measurements.get(idMeasure3).getObservedValue()[2]);
final double r3 = position3.getNorm();
final Vector3D lineOfSight3 = position3.normalize();
final Vector3D lineOfSight3 = position3.normalize();
// instantiate the IOD method
final IodGooding iod = new IodGooding(frame, mu);
......@@ -102,6 +102,11 @@ public class IodGoodingTest {
r1 * 1.0, r3 * 1.0);
Assert.assertEquals(orbit.getA(), context.initialOrbit.getA(), 1.0e-6 * context.initialOrbit.getA());
Assert.assertEquals(orbit.getE(), context.initialOrbit.getE(), 1.0e-6 * context.initialOrbit.getE());
Assert.assertEquals(orbit.getI(), context.initialOrbit.getI(), 1.0e-6