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 class
UnitTestCommon.ModDelete
Instance of Modifier specialized to delete lines matching a given Java regular expression of text before is is passed to compare().static interface
UnitTestCommon.Modifier
Provide an interface that allows for arbitrary modification of text before is is passed to compare().static class
UnitTestCommon.ModSuppress
Instance 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 void
bindstd()
static String
canonicalpath(String path)
Convert path to: 1.static String
canonjoin(String... pieces)
static String
canonjoin2(String prefix, String suffix)
protected static boolean
check(int code)
protected static boolean
check(int code, int[] ok)
protected boolean
checkServer(String candidate)
static void
clearDir(File dir, boolean clearsubdirs)
static String
compare(String tag, String baseline, String testresult)
static String
extractDatasetname(String urlorpath, String suffix)
String
getName()
String
getResourceDir()
String
getThreddsroot()
String
getTitle()
static boolean
hasDriveLetter(String path)
return true if this path appears to start with a windows drive letterprotected static String
ncdumpdata(NetcdfFile ncfile, String datasetname)
protected static String
ncdumpmetadata(NetcdfFile ncfile, String datasetname)
static NetcdfDataset
openDataset(String url)
static String[]
propertiesToArgs(String prefix, String... options)
static byte[]
readbinaryfile(InputStream stream)
static byte[]
readbinaryfile(String filename)
static String
readfile(String filename)
protected static String
rebuildpath(String[] pieces, int last)
static boolean
same(String tag, String baseline, String testresult)
void
setTitle(String title)
static String
shortenFileName(String text, String filename)
static boolean
similar(String tag, String baseline, String testresult, UnitTestCommon.Modifier mbaseline, UnitTestCommon.Modifier mtest)
static void
tag(String t)
protected void
unbindstd()
void
visual(String header, String captured)
void
visual(String header, String captured, char marker)
static void
writefile(String path, byte[] content)
static void
writefile(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 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(NetcdfFile ncfile, String datasetname) throws Exception
- Throws:
Exception
-
ncdumpdata
protected static String ncdumpdata(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)
-
-