Package ucar.unidata.util.test
Class UnitTestCommon
- java.lang.Object
-
- ucar.unidata.util.test.UnitTestCommon
-
public abstract class UnitTestCommon extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUnitTestCommon.ModDeleteInstance of Modifier specialized to delete lines matching a given Java regular expression of text before is is passed to compare().static interfaceUnitTestCommon.ModifierProvide an interface that allows for arbitrary modification of text before is is passed to compare().static classUnitTestCommon.ModSuppressInstance of Modifier specialized to delete named attributes.
-
Constructor Summary
Constructors Constructor Description UnitTestCommon()UnitTestCommon(String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbindstd()static Stringcanonicalpath(String path)Convert path to: 1.static Stringcanonjoin(String... pieces)static Stringcanonjoin2(String prefix, String suffix)protected static booleancheck(int code)protected static booleancheck(int code, int[] ok)protected booleancheckServer(String candidate)static voidclearDir(File dir, boolean clearsubdirs)static Stringcompare(String tag, String baseline, String testresult)static StringextractDatasetname(String urlorpath, String suffix)StringgetName()StringgetResourceDir()StringgetThreddsroot()StringgetTitle()static booleanhasDriveLetter(String path)return true if this path appears to start with a windows drive letterprotected static Stringncdumpdata(ucar.nc2.NetcdfFile ncfile, String datasetname)protected static Stringncdumpmetadata(ucar.nc2.NetcdfFile ncfile, String datasetname)static ucar.nc2.dataset.NetcdfDatasetopenDataset(String url)static String[]propertiesToArgs(String prefix, String... options)static byte[]readbinaryfile(InputStream stream)static byte[]readbinaryfile(String filename)static Stringreadfile(String filename)protected static Stringrebuildpath(String[] pieces, int last)static booleansame(String tag, String baseline, String testresult)voidsetTitle(String title)static StringshortenFileName(String text, String filename)static booleansimilar(String tag, String baseline, String testresult, UnitTestCommon.Modifier mbaseline, UnitTestCommon.Modifier mtest)static voidtag(String t)protected voidunbindstd()voidvisual(String header, String captured)voidvisual(String header, String captured, char marker)static voidwritefile(String path, byte[] content)static voidwritefile(String path, String content)
-
-
-
Field Detail
-
LOGSTDIO
public static boolean LOGSTDIO
-
DEBUG
public static final boolean DEBUG
- See Also:
- Constant Field Values
-
UTF8
public static final Charset UTF8
-
OKCODES
protected static final int[] OKCODES
-
log
protected static final org.slf4j.Logger log
-
threddsroot
protected static String threddsroot
-
title
protected String title
-
name
protected String name
-
DRIVELETTERS
public static final String DRIVELETTERS
-
-
Constructor Detail
-
UnitTestCommon
public UnitTestCommon()
-
UnitTestCommon
public UnitTestCommon(String name)
-
-
Method Detail
-
clearDir
public static void clearDir(File dir, boolean clearsubdirs)
-
setTitle
public void setTitle(String title)
-
getTitle
public String getTitle()
-
getThreddsroot
public String getThreddsroot()
-
getName
public String getName()
-
getResourceDir
public String getResourceDir()
-
similar
public static boolean similar(String tag, String baseline, String testresult, UnitTestCommon.Modifier mbaseline, UnitTestCommon.Modifier mtest)
-
checkServer
protected boolean checkServer(String candidate)
-
bindstd
protected void bindstd()
-
unbindstd
protected void unbindstd()
-
writefile
public static void writefile(String path, String content) throws IOException
- Throws:
IOException
-
writefile
public static void writefile(String path, byte[] content) throws IOException
- Throws:
IOException
-
readfile
public static String readfile(String filename) throws IOException
- Throws:
IOException
-
readbinaryfile
public static byte[] readbinaryfile(String filename) throws IOException
- Throws:
IOException
-
readbinaryfile
public static byte[] readbinaryfile(InputStream stream) throws IOException
- Throws:
IOException
-
openDataset
public static ucar.nc2.dataset.NetcdfDataset openDataset(String url) throws IOException
- Throws:
IOException
-
tag
public static void tag(String t)
-
canonicalpath
public static String canonicalpath(String path)
Convert path to: 1. use '/' consistently 2. remove any trailing '/' 3. trim blanks- Parameters:
path- convert this path- Returns:
- canonicalized version
-
hasDriveLetter
public static boolean hasDriveLetter(String path)
return true if this path appears to start with a windows drive letter- Parameters:
path-- Returns:
- true, if path has drive letter
-
ncdumpmetadata
protected static String ncdumpmetadata(ucar.nc2.NetcdfFile ncfile, String datasetname) throws Exception
- Throws:
Exception
-
ncdumpdata
protected static String ncdumpdata(ucar.nc2.NetcdfFile ncfile, String datasetname) throws Exception
- Throws:
Exception
-
propertiesToArgs
public static String[] propertiesToArgs(String prefix, String... options)
- Parameters:
prefix- - string to prefix all command line options: typically "--"options- - list of option names of interest- Returns:
- specified properties converted to command line form
-
check
protected static boolean check(int code)
-
check
protected static boolean check(int code, int[] ok)
-
-