Issue #2208 moving edex unit tests to tests project
Change-Id: I9189ebd225df930d021855c19d338e74af800702 Former-commit-id:2103294b75
[formerly8d1e19f2df
] [formerly2103294b75
[formerly8d1e19f2df
] [formerly15fae243c9
[formerly 37c1d3c5b1a60260a537951c8a4bbceef4204029]]] Former-commit-id:15fae243c9
Former-commit-id:be35d04928
[formerlyfd38b63609
] Former-commit-id:52dfbc9f9f
This commit is contained in:
parent
b784aadcff
commit
820150deb3
58 changed files with 106 additions and 1315 deletions
|
@ -55,5 +55,3 @@ Require-Bundle: net.sf.ehcache,
|
|||
com.raytheon.uf.edex.core;visibility:=reexport,
|
||||
org.slf4j;bundle-version="1.7.5"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: junit.framework,
|
||||
org.junit
|
||||
|
|
|
@ -23,8 +23,6 @@ package com.raytheon.edex.test;
|
|||
import java.io.File;
|
||||
import java.lang.Thread.State;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.locking.ClusteredLockManager;
|
||||
|
||||
/**
|
||||
|
@ -74,7 +72,7 @@ public class TestLockManager {
|
|||
lockMgr.releaseLock(new File("/tmp/foo"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
// Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
// Test #2 Multi-thread
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
/**
|
||||
* 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 com.raytheon.edex.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* This unit test fails if there are absolute paths in .classpath.
|
||||
* Per http://awipscm/awips/ticket/425 eclipe's .classpath
|
||||
* should not have absolute paths in it.
|
||||
*
|
||||
* @author mgpayne
|
||||
*
|
||||
*/
|
||||
public class EclipseClasspathChecker extends TestCase
|
||||
{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testEclipseClassPath() throws SAXException, IOException,
|
||||
ParserConfigurationException
|
||||
{
|
||||
String fileName = ".classpath"; // file to parse...
|
||||
// fileName="demo.xml";
|
||||
MyHandler myHandler = new MyHandler();
|
||||
parseXmlFile(fileName, myHandler, false);
|
||||
}
|
||||
|
||||
class MyHandler extends DefaultHandler
|
||||
{
|
||||
public void startElement(String namespaceURI, String localName,
|
||||
String qName, Attributes atts)
|
||||
{
|
||||
// Get the number of attribute
|
||||
int length = atts.getLength();
|
||||
|
||||
// Process each attribute
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
// Get names and values for each attribute
|
||||
String name = atts.getQName(i);
|
||||
String value = atts.getValue(i);
|
||||
logdebug("Attribute " + name + "=" + value);
|
||||
if ("path".equalsIgnoreCase(name))
|
||||
{
|
||||
File file = new File(value);
|
||||
assertEquals(
|
||||
"Per http://awipscm/awips/ticket/425 must not contain absolute paths. But "
|
||||
+ value + " is an absolute path.", false,
|
||||
file.isAbsolute());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parses an XML file using a SAX parser.
|
||||
// If validating is true, the contents is validated against the DTD
|
||||
// specified in the file.
|
||||
public void parseXmlFile(String filename, DefaultHandler handler,
|
||||
boolean validating) throws SAXException, IOException,
|
||||
ParserConfigurationException
|
||||
{
|
||||
|
||||
// Create a builder factory
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
factory.setValidating(validating);
|
||||
|
||||
// Create the builder and parse the file
|
||||
factory.newSAXParser().parse(new File(filename), handler);
|
||||
|
||||
}
|
||||
|
||||
private void logdebug(String msg)
|
||||
{
|
||||
//System.out.println(msg);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/**
|
||||
* 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 com.raytheon.edex.util;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 10, 2009 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FileUtilTest {
|
||||
private static final String[] unmangled = { "Hour 0-240", "Yes/No",
|
||||
"N. America" };
|
||||
|
||||
private static final String[] mangled = { "Hour_CA0_CN240", "Yes_CPNo",
|
||||
"N_CO_CAAmerica" };
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.util.FileUtil#mangle(java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testMangle() {
|
||||
for (int i = 0; i < unmangled.length; i++) {
|
||||
String result = FileUtil.mangle(unmangled[i]);
|
||||
Assert.assertEquals(mangled[i], result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.util.FileUtil#unmangle(java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testUnmangle() {
|
||||
for (int i = 0; i < mangled.length; i++) {
|
||||
String result = FileUtil.unmangle(mangled[i]);
|
||||
Assert.assertEquals(unmangled[i], result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* 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 com.raytheon.edex.util;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* JUnit test case for the {@link com.raytheon.edex.util.Util} class.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 19Jun2007 345 MW Fegan Initial creation. Testing limited
|
||||
* to formatDate(float).
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mfegan
|
||||
* @version 1
|
||||
*/
|
||||
|
||||
public class TestUtil {
|
||||
private String pattern = "^\\d{4}-\\d{2}-\\d{2}_\\d{2}:\\d{2}:\\d{2}\\.\\d{1,3}$";
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.out.println("Setup");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
/**
|
||||
* Test method for {@link com.raytheon.edex.util.Util#formatDate(float)}.
|
||||
* Will error out if {@code formatDate(float)} throws an exception. Will
|
||||
* fail if the date is incorrectly formatted.
|
||||
*/
|
||||
@Test
|
||||
public void testFormatDate() {
|
||||
float time = Calendar.getInstance().getTimeInMillis()/1000;
|
||||
String result = Util.formatDate(time);
|
||||
assertTrue("Checking date format",result.matches(pattern));
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="testBin" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -12,4 +12,3 @@ Require-Bundle: meteolib.jni,
|
|||
Export-Package: com.raytheon.edex.meteoLib
|
||||
Bundle-ClassPath: .
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: org.junit
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<project basedir="." default="deploy" name="com.raytheon.edex.meteolib">
|
||||
<available file="../build.edex" property="build.dir.location" value="../build.edex"/>
|
||||
<available file="../../../../../build.edex" property="build.dir.location" value="../../../../../build.edex"/>
|
||||
|
||||
<import file="${build.dir.location}/basebuilds/component_deploy_base.xml" />
|
||||
|
||||
</project>
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* 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 com.raytheon.edex.meteoLib;
|
||||
|
||||
public class Test
|
||||
{
|
||||
// static{
|
||||
// System.load("libmeteoLib.so");
|
||||
// }
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//System.out.println("vp is : " + Controller.vp(283,1));
|
||||
System.out.println(System.getProperty("java.library.path"));
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -12,8 +12,7 @@ Import-Package: com.raytheon.edex.db.dao,
|
|||
com.raytheon.edex.esb,
|
||||
com.raytheon.edex.exception,
|
||||
com.raytheon.edex.plugin,
|
||||
org.apache.commons.logging,
|
||||
org.junit
|
||||
org.apache.commons.logging
|
||||
Require-Bundle: com.raytheon.uf.common.dataplugin.airep;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="testbin" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -67,8 +67,6 @@ Import-Package: com.raytheon.edex.db.dao,
|
|||
com.raytheon.uf.common.time.util,
|
||||
com.raytheon.uf.edex.activetable,
|
||||
com.raytheon.uf.edex.site,
|
||||
junit.framework,
|
||||
org.apache.commons.logging,
|
||||
org.hibernate,
|
||||
org.junit
|
||||
org.hibernate
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# Sample properties to initialise log4j
|
||||
log4j.rootCategory=DEBUG, stdout
|
||||
|
||||
# CONSOLE appender
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.stdout.layout.ConversionPattern=%-5p %d [%t] %c{2}: %m%n
|
||||
log4j.appender.stdout.layout.ConversionPattern=%-5p: %m%n
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -17,5 +17,4 @@ Export-Package: com.raytheon.edex.plugin.pirep,
|
|||
com.raytheon.edex.plugin.pirep.decoder
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: com.raytheon.uf.common.dataplugin.pirep,
|
||||
org.apache.commons.logging,
|
||||
org.junit
|
||||
org.apache.commons.logging
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -30,6 +30,5 @@ Import-Package: com.raytheon.edex.plugin.obs,
|
|||
com.raytheon.uf.common.dataplugin.sfcobs,
|
||||
com.raytheon.uf.common.dataplugin.text.request,
|
||||
com.raytheon.uf.common.ohd,
|
||||
org.apache.commons.logging,
|
||||
org.junit
|
||||
org.apache.commons.logging
|
||||
|
||||
|
|
|
@ -59,7 +59,5 @@ Import-Package: com.raytheon.edex.exception,
|
|||
com.raytheon.uf.common.serialization.comm,
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.common.util,
|
||||
junit.framework,
|
||||
org.junit
|
||||
com.raytheon.uf.common.util
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="testbin" path="tests"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -11,7 +11,6 @@ Export-Package: com.raytheon.uf.common.message,
|
|||
com.raytheon.uf.common.message.response
|
||||
Import-Package: com.raytheon.uf.common.serialization,
|
||||
com.raytheon.uf.common.serialization.annotations,
|
||||
org.apache.commons.lang,
|
||||
org.junit
|
||||
org.apache.commons.lang
|
||||
Require-Bundle: net.sf.cglib;bundle-version="2.1.3",
|
||||
com.raytheon.uf.common.status;bundle-version="1.11.11"
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<project basedir="." default="deploy" name="com.raytheon.uf.common.message">
|
||||
<available file="../build.edex" property="build.dir.location" value="../build.edex"/>
|
||||
<available file="../../../../../build.edex" property="build.dir.location" value="../../../../../build.edex"/>
|
||||
|
||||
<import file="${build.dir.location}/basebuilds/component_deploy_base.xml" />
|
||||
|
||||
</project>
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -18,4 +18,3 @@ Export-Package: com.raytheon.uf.common.serialization,
|
|||
com.raytheon.uf.common.serialization.annotations,
|
||||
com.raytheon.uf.common.serialization.thrift
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: org.junit
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<project basedir="." default="deploy" name="com.raytheon.uf.common.serialization">
|
||||
<available file="../build.edex" property="build.dir.location" value="../build.edex"/>
|
||||
<available file="../../../../../build.edex" property="build.dir.location" value="../../../../../build.edex"/>
|
||||
|
||||
<import file="${build.dir.location}/basebuilds/component_deploy_base.xml" />
|
||||
|
||||
</project>
|
|
@ -1,920 +0,0 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
|
||||
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
|
||||
import com.raytheon.uf.common.serialization.IDeserializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.ISerializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
||||
/**
|
||||
* Test the serialization capabilities
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 12, 2008 chammack Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TestSerialize {
|
||||
|
||||
@DynamicSerialize
|
||||
public static class Test {
|
||||
@DynamicSerializeElement
|
||||
private String _String;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int _int;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Integer _Integer;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float _float;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Float _Float;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private byte _byte;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Byte _Byte;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private long _long;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Long _Long;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private double _double;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Double _Double;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private short _short;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Short _Short;
|
||||
|
||||
/**
|
||||
* @return the _String
|
||||
*/
|
||||
public String get_String() {
|
||||
return _String;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* the _String to set
|
||||
*/
|
||||
public void set_String(String string) {
|
||||
_String = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _int
|
||||
*/
|
||||
public int get_int() {
|
||||
return _int;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _int
|
||||
* the _int to set
|
||||
*/
|
||||
public void set_int(int _int) {
|
||||
this._int = _int;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Integer
|
||||
*/
|
||||
public Integer get_Integer() {
|
||||
return _Integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer
|
||||
* the _Integer to set
|
||||
*/
|
||||
public void set_Integer(Integer integer) {
|
||||
_Integer = integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _float
|
||||
*/
|
||||
public float get_float() {
|
||||
return _float;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _float
|
||||
* the _float to set
|
||||
*/
|
||||
public void set_float(float _float) {
|
||||
this._float = _float;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Float
|
||||
*/
|
||||
public Float get_Float() {
|
||||
return _Float;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float1
|
||||
* the _Float to set
|
||||
*/
|
||||
public void set_Float(Float float1) {
|
||||
_Float = float1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _byte
|
||||
*/
|
||||
public byte get_byte() {
|
||||
return _byte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _byte
|
||||
* the _byte to set
|
||||
*/
|
||||
public void set_byte(byte _byte) {
|
||||
this._byte = _byte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Byte
|
||||
*/
|
||||
public Byte get_Byte() {
|
||||
return _Byte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param byte1
|
||||
* the _Byte to set
|
||||
*/
|
||||
public void set_Byte(Byte byte1) {
|
||||
_Byte = byte1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _long
|
||||
*/
|
||||
public long get_long() {
|
||||
return _long;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _long
|
||||
* the _long to set
|
||||
*/
|
||||
public void set_long(long _long) {
|
||||
this._long = _long;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Long
|
||||
*/
|
||||
public Long get_Long() {
|
||||
return _Long;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param long1
|
||||
* the _Long to set
|
||||
*/
|
||||
public void set_Long(Long long1) {
|
||||
_Long = long1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _double
|
||||
*/
|
||||
public double get_double() {
|
||||
return _double;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _double
|
||||
* the _double to set
|
||||
*/
|
||||
public void set_double(double _double) {
|
||||
this._double = _double;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Double
|
||||
*/
|
||||
public Double get_Double() {
|
||||
return _Double;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param double1
|
||||
* the _Double to set
|
||||
*/
|
||||
public void set_Double(Double double1) {
|
||||
_Double = double1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _short
|
||||
*/
|
||||
public short get_short() {
|
||||
return _short;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _short
|
||||
* the _short to set
|
||||
*/
|
||||
public void set_short(short _short) {
|
||||
this._short = _short;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _Short
|
||||
*/
|
||||
public Short get_Short() {
|
||||
return _Short;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param short1
|
||||
* the _Short to set
|
||||
*/
|
||||
public void set_Short(Short short1) {
|
||||
_Short = short1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class Test2 {
|
||||
@DynamicSerializeElement
|
||||
private String x;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int y;
|
||||
|
||||
/**
|
||||
* @return the x
|
||||
*/
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* the x to set
|
||||
*/
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param y
|
||||
* the y to set
|
||||
*/
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class TestContainer {
|
||||
@DynamicSerializeElement
|
||||
private float[] array;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Set<Float> set;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private List<Double> list;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private List<Test2> list2;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Map<String, Test2> map;
|
||||
|
||||
/**
|
||||
* @return the list
|
||||
*/
|
||||
public List<Double> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list
|
||||
* the list to set
|
||||
*/
|
||||
public void setList(List<Double> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list2
|
||||
*/
|
||||
public List<Test2> getList2() {
|
||||
return list2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list2
|
||||
* the list2 to set
|
||||
*/
|
||||
public void setList2(List<Test2> list2) {
|
||||
this.list2 = list2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map
|
||||
*/
|
||||
public Map<String, Test2> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param map
|
||||
* the map to set
|
||||
*/
|
||||
public void setMap(Map<String, Test2> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the array
|
||||
*/
|
||||
public float[] getArray() {
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foo
|
||||
* the array to set
|
||||
*/
|
||||
public void setArray(float[] array) {
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the set
|
||||
*/
|
||||
public Set<Float> getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param set
|
||||
* the set to set
|
||||
*/
|
||||
public void setSet(Set<Float> set) {
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class TestParent {
|
||||
@DynamicSerializeElement
|
||||
private AdapterObject adapterObject;
|
||||
|
||||
/**
|
||||
* @return the adapterObject
|
||||
*/
|
||||
public AdapterObject getAdapterObject() {
|
||||
return adapterObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parentString
|
||||
* the adapterObject to set
|
||||
*/
|
||||
public void setAdapterObject(AdapterObject adapterObject) {
|
||||
this.adapterObject = adapterObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class TestAdvancedCollection1 {
|
||||
@DynamicSerializeElement
|
||||
private LinkedHashMap<String, String> foo;
|
||||
|
||||
/**
|
||||
* @return the foo
|
||||
*/
|
||||
public LinkedHashMap<String, String> getFoo() {
|
||||
return foo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foo
|
||||
* the foo to set
|
||||
*/
|
||||
public void setFoo(LinkedHashMap<String, String> foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
@DynamicSerializeTypeAdapter(factory = TestAdapter.class)
|
||||
public static class AdapterObject {
|
||||
private String innerObject;
|
||||
|
||||
/**
|
||||
* @return the innerObject
|
||||
*/
|
||||
public String getInnerObject() {
|
||||
return innerObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param innerObject
|
||||
* the innerObject to set
|
||||
*/
|
||||
public void setInnerObject(String innerObject) {
|
||||
this.innerObject = innerObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TestAdapter implements
|
||||
ISerializationTypeAdapter<AdapterObject> {
|
||||
|
||||
@Override
|
||||
public AdapterObject deserialize(IDeserializationContext deserializer)
|
||||
throws SerializationException {
|
||||
String s = deserializer.readString();
|
||||
AdapterObject ao = new AdapterObject();
|
||||
ao.setInnerObject(s);
|
||||
return ao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ISerializationContext serializer,
|
||||
AdapterObject object) throws SerializationException {
|
||||
serializer.writeString(object.getInnerObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class TestChild extends TestParent {
|
||||
@DynamicSerializeElement
|
||||
private String childString;
|
||||
|
||||
/**
|
||||
* @return the childString
|
||||
*/
|
||||
public String getChildString() {
|
||||
return childString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param childString
|
||||
* the childString to set
|
||||
*/
|
||||
public void setChildString(String childString) {
|
||||
this.childString = childString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testBasicFunctionality() {
|
||||
Test inTest = new Test();
|
||||
inTest.set_byte((byte) 1);
|
||||
inTest.set_Byte(new Byte((byte) 2));
|
||||
inTest.set_double(2.1);
|
||||
inTest.set_Double(new Double(4.4));
|
||||
inTest.set_float(4.2f);
|
||||
inTest.set_Float(5.5f);
|
||||
inTest.set_int(8);
|
||||
inTest.set_Integer(new Integer(32));
|
||||
inTest.set_long(1000000L);
|
||||
inTest.set_Long(new Long(10000000000000L));
|
||||
inTest.set_short((short) 8);
|
||||
inTest.set_Short(new Short((short) 92));
|
||||
inTest.set_String("abcdefg");
|
||||
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
DynamicSerializationManager.inspect(inTest.getClass());
|
||||
byte[] bdata = null;
|
||||
try {
|
||||
bdata = dmgr.serialize(inTest);
|
||||
System.out.println("Serialized data of size: " + bdata.length);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
Test outTest = null;
|
||||
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bdata);
|
||||
outTest = (Test) dmgr.deserialize(bais);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
// Make sure somehow we didn't get the same exact objects
|
||||
Assert.assertNotSame(inTest, outTest);
|
||||
|
||||
// Verify results
|
||||
Assert.assertEquals(inTest.get_double(), outTest.get_double(), 0.0001);
|
||||
Assert.assertEquals(inTest.get_Double(), outTest.get_Double());
|
||||
|
||||
Assert.assertEquals(inTest.get_byte(), outTest.get_byte());
|
||||
Assert.assertEquals(inTest.get_Byte(), outTest.get_Byte());
|
||||
|
||||
Assert.assertEquals(inTest.get_float(), outTest.get_float(), 0.0001);
|
||||
Assert.assertEquals(inTest.get_Float(), outTest.get_Float());
|
||||
|
||||
Assert.assertEquals(inTest.get_int(), outTest.get_int());
|
||||
Assert.assertEquals(inTest.get_Integer(), outTest.get_Integer());
|
||||
|
||||
Assert.assertEquals(inTest.get_long(), outTest.get_long());
|
||||
Assert.assertEquals(inTest.get_Long(), outTest.get_Long());
|
||||
|
||||
Assert.assertEquals(inTest.get_short(), outTest.get_short());
|
||||
Assert.assertEquals(inTest.get_Short(), outTest.get_Short());
|
||||
|
||||
Assert.assertEquals(inTest.get_String(), outTest.get_String());
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testContainerFunctionality() {
|
||||
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
TestContainer inContainer = new TestContainer();
|
||||
|
||||
Test2 inTest2_1 = new Test2();
|
||||
inTest2_1.setX("hijklmnop");
|
||||
inTest2_1.setY(127);
|
||||
|
||||
Test2 inTest2_2 = new Test2();
|
||||
inTest2_2.setX("0123456");
|
||||
inTest2_2.setY(256);
|
||||
|
||||
float[] in = new float[614 * 428];
|
||||
for (int i = 0; i < in.length; i++) {
|
||||
in[i] = i;
|
||||
}
|
||||
|
||||
inContainer.setArray(in);
|
||||
|
||||
Set<Float> inFloatSet = new HashSet<Float>();
|
||||
inFloatSet.add(1.0f);
|
||||
inFloatSet.add(1.3f);
|
||||
inFloatSet.add(2.2f);
|
||||
inContainer.setSet(inFloatSet);
|
||||
|
||||
List<Double> inDoubleList = new ArrayList<Double>();
|
||||
inDoubleList.add(1.2);
|
||||
inDoubleList.add(0.5);
|
||||
inContainer.setList(inDoubleList);
|
||||
|
||||
List<Test2> inTest2List = new ArrayList<Test2>();
|
||||
inTest2List.add(inTest2_1);
|
||||
inTest2List.add(inTest2_2);
|
||||
inContainer.setList2(inTest2List);
|
||||
|
||||
Map<String, Test2> inMap = new HashMap<String, Test2>();
|
||||
inMap.put("abc", inTest2_1);
|
||||
inContainer.setMap(inMap);
|
||||
|
||||
DynamicSerializationManager.inspect(inContainer.getClass());
|
||||
byte[] bdata = null;
|
||||
try {
|
||||
bdata = dmgr.serialize(inContainer);
|
||||
System.out.println("Serialized data of size: " + bdata.length);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
TestContainer outContainer = null;
|
||||
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bdata);
|
||||
outContainer = (TestContainer) dmgr.deserialize(bais);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
// Make sure somehow we didn't get the same exact objects
|
||||
Assert.assertNotSame(inContainer, outContainer);
|
||||
Assert.assertNotSame(inContainer.getArray(), outContainer.getArray());
|
||||
|
||||
// Check the data came across okay
|
||||
Assert.assertEquals(inContainer.getArray().length,
|
||||
outContainer.getArray().length);
|
||||
for (int i = 0; i < inContainer.getArray().length; i++) {
|
||||
Assert.assertEquals(inContainer.getArray()[i],
|
||||
outContainer.getArray()[i], 0.0001);
|
||||
}
|
||||
|
||||
Assert.assertEquals(inContainer.getList().size(), outContainer
|
||||
.getList().size());
|
||||
for (int i = 0; i < inContainer.getList().size(); i++) {
|
||||
Assert.assertEquals(inContainer.getList().get(i), outContainer
|
||||
.getList().get(i));
|
||||
}
|
||||
|
||||
Assert.assertEquals(inContainer.getList2().size(), outContainer
|
||||
.getList2().size());
|
||||
for (int i = 0; i < inContainer.getList2().size(); i++) {
|
||||
|
||||
Assert.assertEquals(inContainer.getList2().get(i).getX(),
|
||||
outContainer.getList2().get(i).getX());
|
||||
Assert.assertEquals(inContainer.getList2().get(i).getY(),
|
||||
outContainer.getList2().get(i).getY());
|
||||
}
|
||||
|
||||
Assert.assertEquals(inContainer.getSet().size(), outContainer.getSet()
|
||||
.size());
|
||||
Iterator<Float> iterator1 = inContainer.getSet().iterator();
|
||||
Iterator<Float> iterator2 = outContainer.getSet().iterator();
|
||||
while (iterator1.hasNext()) {
|
||||
Assert.assertEquals(iterator1.next(), iterator2.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testInheritance() {
|
||||
TestChild tc = new TestChild();
|
||||
AdapterObject ao = new AdapterObject();
|
||||
ao.setInnerObject("parent");
|
||||
tc.setAdapterObject(ao);
|
||||
tc.setChildString("child");
|
||||
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
DynamicSerializationManager.inspect(tc.getClass());
|
||||
DynamicSerializationManager.inspect(AdapterObject.class);
|
||||
byte[] bdata = null;
|
||||
try {
|
||||
bdata = dmgr.serialize(tc);
|
||||
System.out.println("Serialized data of size: " + bdata.length);
|
||||
FileUtil.bytes2File(bdata, new File("/tmp/javaOut"));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
TestChild outTest = null;
|
||||
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bdata);
|
||||
outTest = (TestChild) dmgr.deserialize(bais);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
Assert.assertEquals(tc.getAdapterObject().getInnerObject(), outTest
|
||||
.getAdapterObject().getInnerObject());
|
||||
Assert.assertEquals(tc.getChildString(), outTest.getChildString());
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testAdvancedCollections() {
|
||||
TestAdvancedCollection1 coll = new TestAdvancedCollection1();
|
||||
|
||||
LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
|
||||
lhm.put("1", "one");
|
||||
lhm.put("2", "two");
|
||||
|
||||
coll.setFoo(lhm);
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
DynamicSerializationManager.inspect(coll.getClass());
|
||||
byte[] bdata = null;
|
||||
try {
|
||||
bdata = dmgr.serialize(coll);
|
||||
System.out.println("Serialized data of size: " + bdata.length);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
TestAdvancedCollection1 outTest = null;
|
||||
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bdata);
|
||||
outTest = (TestAdvancedCollection1) dmgr.deserialize(bais);
|
||||
System.out.println(outTest);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
Assert.assertEquals(LinkedHashMap.class, outTest.getFoo().getClass());
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class NullTester {
|
||||
@DynamicSerializeElement
|
||||
private Object[] objArr;
|
||||
|
||||
public Object[] getObjArr() {
|
||||
return objArr;
|
||||
}
|
||||
|
||||
public void setObjArr(Object[] objArr) {
|
||||
this.objArr = objArr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testNullsInArrays() {
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
DynamicSerializationManager.inspect(NullTester.class);
|
||||
|
||||
NullTester nt = new NullTester();
|
||||
Object[] obj = new Object[3];
|
||||
obj[0] = new String("test");
|
||||
obj[1] = null;
|
||||
obj[2] = new Integer(3);
|
||||
|
||||
nt.setObjArr(obj);
|
||||
|
||||
byte[] d = null;
|
||||
try {
|
||||
d = dmgr.serialize(nt);
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Object result = dmgr.deserialize(new ByteArrayInputStream(d));
|
||||
|
||||
Assert.assertTrue(result instanceof NullTester);
|
||||
Assert.assertTrue(((NullTester) result).getObjArr() != null);
|
||||
Assert.assertTrue(((NullTester) result).getObjArr() instanceof Object[]);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr()).length == obj.length);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr())[0]
|
||||
.equals(obj[0]));
|
||||
Assert.assertNull((((NullTester) result).getObjArr())[1]);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr())[2]
|
||||
.equals(obj[2]));
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testByteArrayInObjectArray() {
|
||||
DynamicSerializationManager dmgr = DynamicSerializationManager
|
||||
.getManager(SerializationType.Thrift);
|
||||
|
||||
DynamicSerializationManager.inspect(NullTester.class);
|
||||
|
||||
NullTester nt = new NullTester();
|
||||
Object[] obj = new Object[3];
|
||||
obj[0] = new String("test");
|
||||
obj[1] = null;
|
||||
obj[2] = new Integer(3);
|
||||
|
||||
nt.setObjArr(obj);
|
||||
|
||||
byte[] d = null;
|
||||
try {
|
||||
d = dmgr.serialize(nt);
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Object result = dmgr.deserialize(new ByteArrayInputStream(d));
|
||||
|
||||
Assert.assertTrue(result instanceof NullTester);
|
||||
Assert.assertTrue(((NullTester) result).getObjArr() != null);
|
||||
Assert.assertTrue(((NullTester) result).getObjArr() instanceof Object[]);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr()).length == obj.length);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr())[0]
|
||||
.equals(obj[0]));
|
||||
Assert.assertNull((((NullTester) result).getObjArr())[1]);
|
||||
Assert.assertTrue((((NullTester) result).getObjArr())[2]
|
||||
.equals(obj[2]));
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class DataURINotificationMessage implements
|
||||
ISerializableObject {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String[] dataURIs;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int[] ids;
|
||||
|
||||
/**
|
||||
* @return the dataURIs
|
||||
*/
|
||||
public String[] getDataURIs() {
|
||||
return dataURIs;
|
||||
}
|
||||
|
||||
public int[] getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ids
|
||||
* The ids to set
|
||||
*/
|
||||
public void setIds(int[] ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataURIs
|
||||
* the dataURIs to set
|
||||
*/
|
||||
public void setDataURIs(String[] dataURIs) {
|
||||
this.dataURIs = dataURIs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="test/bin" path="test/src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -16,4 +16,3 @@ Export-Package: com.raytheon.uf.common.util,
|
|||
com.raytheon.uf.common.util.mapping,
|
||||
com.raytheon.uf.common.util.registry,
|
||||
com.raytheon.uf.common.util.session
|
||||
Import-Package: org.junit
|
||||
|
|
|
@ -96,5 +96,16 @@
|
|||
<classpathentry kind="src" path="/com.raytheon.uf.common.archive"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.datadelivery.bandwidth.ncf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.thrift"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.gfe"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.gfe"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.python"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.airep"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.airep"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.message"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.shef"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.meteolib"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.obs"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.pirep"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.pirep"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -21,8 +21,11 @@ package com.raytheon.edex.meteoLib;
|
|||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class ControllerTest {
|
||||
static {
|
||||
System.loadLibrary("meteoLib");
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.airep;
|
||||
package com.raytheon.edex.plugin.airep.decoder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
|
@ -24,6 +24,7 @@ import java.util.Date;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints;
|
||||
|
@ -37,6 +38,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/19/2008 chammack Initial creation.
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,13 +46,16 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class TestTimeConstraints {
|
||||
|
||||
private static final int ONEHR = 60 * 60;
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#constraintTime(java.util.Date)}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#constraintTime(java.util.Date)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testConstraintTime() {
|
||||
|
@ -75,7 +80,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#anyConstraints()}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#anyConstraints()}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAnyConstraints() {
|
||||
|
@ -95,7 +101,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#equals(java.lang.Object)}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#equals(java.lang.Object)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsObject() {
|
||||
|
@ -113,7 +120,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#validTR(com.raytheon.uf.common.time.TimeRange)}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#validTR(com.raytheon.uf.common.time.TimeRange)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testValidTR() {
|
||||
|
@ -131,7 +139,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#constraintTimes(com.raytheon.uf.common.time.TimeRange)}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#constraintTimes(com.raytheon.uf.common.time.TimeRange)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testConstraintTimes() {
|
||||
|
@ -152,7 +161,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#toString()}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#toString()}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
|
@ -163,7 +173,8 @@ public class TestTimeConstraints {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#expandTRToQuantum(com.raytheon.uf.common.time.TimeRange)}.
|
||||
* {@link com.raytheon.uf.common.dataplugin.gfe.db.objects.TimeConstraints#expandTRToQuantum(com.raytheon.uf.common.time.TimeRange)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testExpandTRToQuantum() {
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleData;
|
||||
|
@ -38,6 +39,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 21, 2008 rbell Initial creation
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,6 +47,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class SampleDataTest {
|
||||
|
||||
private String testFileContents;
|
|
@ -37,8 +37,11 @@ import java.util.TimeZone;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class TestWCLWatchSrv {
|
||||
|
||||
private WclInfo wclInfoA;
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.pirep;
|
||||
package com.raytheon.edex.plugin.pirep;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.pirep;
|
||||
package com.raytheon.edex.plugin.pirep;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.pirep;
|
||||
package com.raytheon.edex.plugin.pirep;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.edex.transform.shef;
|
||||
package com.raytheon.edex.plugin.shef;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package test.edex.transform.shef;
|
||||
package com.raytheon.edex.plugin.shef;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -25,6 +25,7 @@ import java.util.Date;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
|
||||
|
@ -50,6 +51,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/03/2008 879 rbell Initial Creation.
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,6 +59,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class ScalarGridSliceTest {
|
||||
|
||||
private static final int HOUR = 3600;
|
|
@ -25,6 +25,7 @@ import java.util.Date;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
|
||||
|
@ -42,6 +43,8 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Op;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class VectorGridSliceTest {
|
||||
|
||||
private final float testFA1a[] = { 0.0f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f,
|
|
@ -18,16 +18,15 @@
|
|||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.utility;
|
||||
package com.raytheon.uf.common.localization;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* Test localization context
|
||||
|
@ -37,6 +36,7 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 19, 2007 chammack Initial Creation.
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,6 +44,8 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class LocalizationContextTest extends TestCase {
|
||||
|
||||
/**
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.edex.serialize;
|
||||
package com.raytheon.uf.common.serialization;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,13 +30,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
|
||||
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
|
||||
import com.raytheon.uf.common.serialization.IDeserializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -48,6 +44,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 12, 2008 chammack Initial creation
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,6 +52,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class TestSerialize {
|
||||
|
||||
@DynamicSerialize
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.edex.plugin.time;
|
||||
package com.raytheon.uf.common.time;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -27,8 +27,6 @@ import junit.framework.TestCase;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* Test case for TimeRange class based on AWIPS Common test case
|
||||
*
|
||||
|
@ -36,7 +34,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 19, 2007 chammack Initial Creation.
|
||||
* Jun 19, 2007 chammack Initial Creation.
|
||||
* Jul 25, 2013 2208 njensen Moved to tests project
|
||||
*
|
||||
* </pre>
|
||||
*
|
|
@ -19,12 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.util;
|
||||
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Tests for mangling/unmangling of file names
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -32,7 +31,9 @@ import org.junit.Test;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 26, 2011 randerso Initial creation
|
||||
* Oct 26, 2011 randerso Initial creation
|
||||
* Jul 25, 2013 2208 njensen Consolidated other tests
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,6 +43,36 @@ import org.junit.Test;
|
|||
|
||||
public class FileUtilTest {
|
||||
|
||||
private static final String[] unmangled = { "Hour 0-240", "Yes/No",
|
||||
"N. America" };
|
||||
|
||||
private static final String[] mangled = { "Hour_CA0_CN240", "Yes_CPNo",
|
||||
"N_CO_CAAmerica" };
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.util.FileUtil#mangle(java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testMangle() {
|
||||
for (int i = 0; i < unmangled.length; i++) {
|
||||
String result = FileUtil.mangle(unmangled[i]);
|
||||
Assert.assertEquals(mangled[i], result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.util.FileUtil#unmangle(java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testUnmangle() {
|
||||
for (int i = 0; i < mangled.length; i++) {
|
||||
String result = FileUtil.unmangle(mangled[i]);
|
||||
Assert.assertEquals(unmangled[i], result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link com.raytheon.uf.common.util.FileUtil#isMangled(java.lang.String)}.
|
||||
|
|
Loading…
Add table
Reference in a new issue