2013-01-07 12:16:01 -06:00
|
|
|
/**
|
|
|
|
* This software was developed and / or modified by Raytheon Company,
|
|
|
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
|
|
*
|
|
|
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
|
|
* This software product contains export-restricted data whose
|
|
|
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
|
|
* to non-U.S. persons whether in the United States or abroad requires
|
|
|
|
* an export license or other authorization.
|
|
|
|
*
|
|
|
|
* Contractor Name: Raytheon Company
|
|
|
|
* Contractor Address: 6825 Pine Street, Suite 340
|
|
|
|
* Mail Stop B8
|
|
|
|
* Omaha, NE 68106
|
|
|
|
* 402.291.0100
|
|
|
|
*
|
|
|
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
|
|
* further licensing information.
|
|
|
|
**/
|
|
|
|
package dods.dap;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
2013-02-05 14:07:30 -06:00
|
|
|
import static org.junit.Assert.assertNotNull;
|
2013-01-07 12:16:01 -06:00
|
|
|
|
2013-02-05 14:07:30 -06:00
|
|
|
import java.io.ByteArrayInputStream;
|
2013-01-07 12:16:01 -06:00
|
|
|
import java.io.FileNotFoundException;
|
2013-02-05 14:07:30 -06:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.MalformedURLException;
|
2013-01-07 12:16:01 -06:00
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.raytheon.dods.DodsOriginalHttpConnectStrategy;
|
2013-02-05 14:07:30 -06:00
|
|
|
import com.raytheon.uf.common.util.TestUtil;
|
|
|
|
|
|
|
|
import dods.dap.parser.ParseException;
|
2013-01-07 12:16:01 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test {@link DConnect}.
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
*
|
|
|
|
* SOFTWARE HISTORY
|
|
|
|
*
|
|
|
|
* Date Ticket# Engineer Description
|
|
|
|
* ------------ ---------- ----------- --------------------------
|
2013-02-05 14:07:30 -06:00
|
|
|
* Jul 09, 2012 0634 djohnson Initial creation
|
|
|
|
* Feb 05, 2013 1543 djohnson Moved to tests project, add tests for reading dods files.
|
2013-01-07 12:16:01 -06:00
|
|
|
*
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @author djohnson
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
|
|
|
public class DConnectTest {
|
|
|
|
|
2013-02-05 14:07:30 -06:00
|
|
|
private class MockHttpConnectStrategy extends
|
|
|
|
DodsOriginalHttpConnectStrategy {
|
|
|
|
|
|
|
|
int connectionTimeout;
|
|
|
|
|
|
|
|
int socketTimeout;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setConnectionTimeout(int connectionTimeout) {
|
|
|
|
this.connectionTimeout = connectionTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setSocketTimeout(int socketTimeout) {
|
|
|
|
this.socketTimeout = socketTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-07 12:16:01 -06:00
|
|
|
@Test
|
|
|
|
public void testSystemPropertyTimeoutsAreSetOnHttpStrategy()
|
|
|
|
throws FileNotFoundException {
|
|
|
|
final int connectionTimeout = 10;
|
|
|
|
final int socketTimeout = 11;
|
|
|
|
|
|
|
|
System.setProperty(DConnect.DODS_CONNECTION_TIMEOUT_MILLISECONDS,
|
|
|
|
Integer.toString(connectionTimeout));
|
|
|
|
System.setProperty(DConnect.DODS_SOCKET_TIMEOUT_MILLISECONDS,
|
|
|
|
Integer.toString(socketTimeout));
|
|
|
|
|
|
|
|
MockHttpConnectStrategy mockHttpStrategy = new MockHttpConnectStrategy();
|
2013-02-05 14:07:30 -06:00
|
|
|
new DConnect("file://", null, null, true, mockHttpStrategy);
|
2013-01-07 12:16:01 -06:00
|
|
|
|
|
|
|
assertEquals(connectionTimeout, mockHttpStrategy.connectionTimeout);
|
|
|
|
assertEquals(socketTimeout, mockHttpStrategy.socketTimeout);
|
|
|
|
}
|
|
|
|
|
2013-02-05 14:07:30 -06:00
|
|
|
@Test
|
|
|
|
public void ableToReadCompressedFormat() throws MalformedURLException,
|
|
|
|
DDSException, IOException, ParseException, DODSException {
|
|
|
|
DConnect dconnect = new DConnect(new ByteArrayInputStream(
|
2013-02-05 15:32:26 -06:00
|
|
|
TestUtil.readResource(DConnectTest.class,
|
|
|
|
"/datadelivery/opendap/compressed_rap_dataset.dods")));
|
2013-02-05 14:07:30 -06:00
|
|
|
final DataDDS data = dconnect.getData(null);
|
2013-01-07 12:16:01 -06:00
|
|
|
|
2013-02-05 14:07:30 -06:00
|
|
|
assertNotNull(data);
|
|
|
|
}
|
2013-01-07 12:16:01 -06:00
|
|
|
|
2013-02-05 14:07:30 -06:00
|
|
|
@Test
|
|
|
|
public void ableToReadUncompressedFormat() throws MalformedURLException,
|
2013-02-05 15:32:26 -06:00
|
|
|
DDSException, IOException, ParseException, DODSException {
|
2013-02-05 14:07:30 -06:00
|
|
|
DConnect dconnect = new DConnect(new ByteArrayInputStream(
|
2013-02-05 15:32:26 -06:00
|
|
|
TestUtil.readResource(DConnectTest.class,
|
|
|
|
"/datadelivery/opendap/uncompressed_rap_dataset.dods")));
|
2013-02-05 14:07:30 -06:00
|
|
|
final DataDDS data = dconnect.getData(null);
|
|
|
|
|
|
|
|
assertNotNull(data);
|
2013-01-07 12:16:01 -06:00
|
|
|
}
|
|
|
|
}
|