ossj.common.tck
Class Util

java.lang.Object
  extended by ossj.common.tck.Util

public class Util
extends Object

Collection of useful methods & metadata

Version:

Field Summary
static PrintStream outputFile
          for log
 Random RANDOM
          used for random generator
 
Constructor Summary
Util()
          Creates new util
Util(boolean generic)
          Creates a new Util object.
 
Method Summary
static boolean contains(int[] a, int key)
           
static boolean contains(Object[] a, Object key)
           
static boolean containsDuplicates(Vector v, javax.oss.ManagedEntityKey key)
           
 javax.jms.QueueReceiver createQueueReceiver(String msgSelector)
          DOCUMENT ME!
 javax.jms.QueueSender createQueueSender()
          DOCUMENT ME!
 javax.jms.QueueSession createQueueSession()
          DOCUMENT ME!
 String[] deepCopy(String[] src)
          performs a deep copy on src
static String[] diff(String[] first, String[] second)
          gets first minus second i.e.
static int find(ArrayList list, javax.oss.ManagedEntityKey key)
           
static int find(javax.oss.ManagedEntityKey[] keys, javax.oss.ManagedEntityKey key)
           
static int find(Vector v, javax.oss.ManagedEntityKey key)
           
 ArrayList findImplementationOf(Class myInterface)
          DOCUMENT ME!
 ArrayList findInterfaceStartsWith(String s)
           
 Class getAttributeType(javax.oss.AttributeAccess mev, String name)
           
 long getEventTimeout()
           
 Vector getIllegalKeys(javax.oss.ManagedEntityValue mev)
           
static int[] getIllegalValue(int[] vals, int count)
          gets a value which is different from all input values and not null input array members must not be null
static String[] getIllegalValue(String[] vals, int count)
          gets a value which is different from all input values and not null input array members must not be null
 InitialContext getInitialContext()
           
 Hashtable getManagedEntityKeys(javax.oss.JVTSession jas)
           
static Object getMaxAsObject(Class cls)
           
static Object getMinAsObject(Class cls)
           
 String getProperty(String prop)
          DOCUMENT ME!
 String getQueueFactoryName()
           
 String getRequestQueueName()
           
 String getTopicFactoryName()
          return the name of the topic factory from the properties file
 String getTopicName()
          return the name of the topic from the properties file
 javax.jms.TopicSubscriber getTopicSubscriber()
           
 javax.jms.TopicSubscriber getTopicSubscriber(String msgSelector)
           
 long getTotalTimeout()
          The timeout to wait for all events
static String[] intersect(String[] first, String[] second)
           
static boolean isSameType(javax.oss.ManagedEntityValue first, javax.oss.ManagedEntityValue second)
           
static boolean isSubset(String[] subSet, String[] superSet)
           
 String isValidJndiName(String jndiName)
          Test if the given JNDI name follows: System/System1/ApplicationType/Common/Application/1-1;1-1;ReferenceImplementation/Comp/name or System/System1/ApplicationType/Common/Application/1-1;1-1;ReferenceImplementation/Resource/name
 void log(String s)
          DOCUMENT ME!
 void log(Throwable e)
          DOCUMENT ME!
static String makeCSList(Object[] items)
          makes a comma separated list of the items String representation
 Date randomDate()
           
 Object randomElement(Object[] a)
           
 javax.oss.AttributeAccess randomManagedEntityValueAtrributes(javax.oss.AttributeAccess mev)
          Creates a random value for the given ManagedEntityValue
 javax.oss.MultiValueList randomMultiValue(Class cls)
          DOCUMENT ME!
 String randomString()
           
 String[] randomSubset(String[] set)
           
 ArrayList randomSubsetNotEmpty(Object[] set)
           
 String[] randomSubsetNotEmpty(String[] set)
           
 Object randomValue(String name, javax.oss.AttributeAccess mev)
          Creates a random value for the given attribute name and ManagedEntityValue So far, Date and String are the only non primitve types supported.
 Object randomValueInstance(Class cls)
          DOCUMENT ME!
 void shuffle(Object[] a)
          shuffles the array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputFile

public static PrintStream outputFile
for log


RANDOM

public final Random RANDOM
used for random generator

Constructor Detail

Util

public Util()
     throws Exception
Creates new util

Throws:
Exception

Util

public Util(boolean generic)
     throws Exception
Creates a new Util object.

Parameters:
generic - DOCUMENT ME!
Throws:
Exception - DOCUMENT ME!
Method Detail

log

public void log(String s)
DOCUMENT ME!

Parameters:
s - DOCUMENT ME!

log

public void log(Throwable e)
DOCUMENT ME!

Parameters:
e - DOCUMENT ME!

getEventTimeout

public long getEventTimeout()
Returns:
The timeout to wait for an event

getTotalTimeout

public long getTotalTimeout()
The timeout to wait for all events


getAttributeType

public Class getAttributeType(javax.oss.AttributeAccess mev,
                              String name)
                       throws Exception
Returns:
The type of the attribute. For indexed attributes, the element type is returned. If an attribute of that name doesn't exist, null is returned
Throws:
Exception

getInitialContext

public InitialContext getInitialContext()
                                 throws TCKException
Returns:
A new InitialContext for the server
Throws:
TCKException

getTopicFactoryName

public String getTopicFactoryName()
return the name of the topic factory from the properties file


getQueueFactoryName

public String getQueueFactoryName()

getRequestQueueName

public String getRequestQueueName()

getTopicName

public String getTopicName()
return the name of the topic from the properties file

Returns:
DOCUMENT ME!

isValidJndiName

public String isValidJndiName(String jndiName)
Test if the given JNDI name follows: System/System1/ApplicationType/Common/Application/1-1;1-1;ReferenceImplementation/Comp/name or System/System1/ApplicationType/Common/Application/1-1;1-1;ReferenceImplementation/Resource/name

Parameters:
name - the jndi name to test
Returns:
null if the name is valid or the text error found

getTopicSubscriber

public javax.jms.TopicSubscriber getTopicSubscriber()
                                             throws Exception
Returns:
A new TopicSubscriber on a new TopicConnection to the topic SysProps.TOPICNAME Messages sent by this connection are reeived
Throws:
Exception

getTopicSubscriber

public javax.jms.TopicSubscriber getTopicSubscriber(String msgSelector)
                                             throws TCKException
Parameters:
msgSelector - The selector for incoming messages
Returns:
A new TopicSubscriber on a new TopicConnection to the topic SysProps.TOPICNAME Messages sent by this connection are reeived
Throws:
TCKException

createQueueSession

public javax.jms.QueueSession createQueueSession()
                                          throws TCKException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
TCKException - DOCUMENT ME!

createQueueSender

public javax.jms.QueueSender createQueueSender()
                                        throws TCKException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
TCKException - DOCUMENT ME!

createQueueReceiver

public javax.jms.QueueReceiver createQueueReceiver(String msgSelector)
                                            throws TCKException
DOCUMENT ME!

Parameters:
msgSelector - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
TCKException - DOCUMENT ME!

intersect

public static String[] intersect(String[] first,
                                 String[] second)
Returns:
The intersection of first and second

isSubset

public static boolean isSubset(String[] subSet,
                               String[] superSet)
Parameters:
subSet - The subset
superSet - The superset
Returns:
true if both parameters are not null and subSet is subset of superSet

diff

public static String[] diff(String[] first,
                            String[] second)
gets first minus second i.e. all Strings of first which are not in second

Parameters:
first -
second -
Returns:
The difference of first and second

contains

public static boolean contains(Object[] a,
                               Object key)
                        throws IllegalArgumentException
Returns:
if a contains key nota bene:all buckets of a must not be null
Throws:
IllegalArgumentException - If an argument is null

contains

public static boolean contains(int[] a,
                               int key)
                        throws IllegalArgumentException
Parameters:
a -
key -
Returns:
if a contains key
Throws:
IllegalArgumentException - If an argument is null

find

public static int find(ArrayList list,
                       javax.oss.ManagedEntityKey key)
Parameters:
list - List of Keys
key - The Key to be looked for
Returns:
Index where key was found, -1 otherwise

find

public static int find(Vector v,
                       javax.oss.ManagedEntityKey key)
Parameters:
v - Vector of Keys
key - The Key to be looked for
Returns:
Index where key was found, -1 otherwise

find

public static int find(javax.oss.ManagedEntityKey[] keys,
                       javax.oss.ManagedEntityKey key)
Parameters:
list - List of Keys
key - The Key to be looked for
Returns:
Index where key was found, -1 otherwise

containsDuplicates

public static boolean containsDuplicates(Vector v,
                                         javax.oss.ManagedEntityKey key)
Parameters:
keys -
key -
Returns:
If the keys contains duplicates of key

makeCSList

public static String makeCSList(Object[] items)
makes a comma separated list of the items String representation

Parameters:
items - The items
Returns:
The comma separated list

deepCopy

public String[] deepCopy(String[] src)
performs a deep copy on src

Parameters:
src - The source to be copied
Returns:
The deep copy

shuffle

public void shuffle(Object[] a)
             throws IllegalArgumentException
shuffles the array

Throws:
IllegalArgumentException - If a is null

randomSubset

public String[] randomSubset(String[] set)
Parameters:
set - The set of strings
Returns:
A random subset of set

randomSubsetNotEmpty

public String[] randomSubsetNotEmpty(String[] set)
Parameters:
set - The set of String
Returns:
A random subset of set

randomSubsetNotEmpty

public ArrayList randomSubsetNotEmpty(Object[] set)
Parameters:
set - The set
Returns:
A random subset of set

getMinAsObject

public static Object getMinAsObject(Class cls)
                             throws IllegalArgumentException
Parameters:
The - class to get the minimum from
Returns:
The minimum wrapped in the related java class
Throws:
IllegalArgumentException - If !cls.IsPrimitive()

getMaxAsObject

public static Object getMaxAsObject(Class cls)
                             throws IllegalArgumentException
Parameters:
The - class to get the maximum from
Returns:
The maximum wrapped in the related java class
Throws:
IllegalArgumentException - If !cls.IsPrimitive()

getIllegalValue

public static String[] getIllegalValue(String[] vals,
                                       int count)
                                throws IllegalArgumentException
gets a value which is different from all input values and not null input array members must not be null

Parameters:
vals - The values to be different from
count - The number of values to return
Returns:
The different values
Throws:
IllegalArgumentException

getIllegalValue

public static int[] getIllegalValue(int[] vals,
                                    int count)
                             throws IllegalArgumentException
gets a value which is different from all input values and not null input array members must not be null

Parameters:
vals - The values to be different from
count - The number of values to return
Returns:
The different values
Throws:
IllegalArgumentException

randomDate

public Date randomDate()
Returns:
A random Date

randomString

public String randomString()
Returns:
A random String which is not null

randomValue

public Object randomValue(String name,
                          javax.oss.AttributeAccess mev)
                   throws Exception
Creates a random value for the given attribute name and ManagedEntityValue So far, Date and String are the only non primitve types supported. Other non primitve type must be creatable via newInstance

Parameters:
name - The name of the attribute
mev - The ManagedEntityValue
Returns:
The randomly created value
Throws:
Exception

randomManagedEntityValueAtrributes

public javax.oss.AttributeAccess randomManagedEntityValueAtrributes(javax.oss.AttributeAccess mev)
                                                             throws Exception
Creates a random value for the given ManagedEntityValue

Parameters:
mev - The ManagedEntityValue
Returns:
The randomly created ManagedEntityValue
Throws:
Exception

randomMultiValue

public javax.oss.MultiValueList randomMultiValue(Class cls)
                                          throws Exception
DOCUMENT ME!

Parameters:
cls - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
Exception - DOCUMENT ME!

randomValueInstance

public Object randomValueInstance(Class cls)
                           throws Exception
DOCUMENT ME!

Parameters:
cls - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
Exception - DOCUMENT ME!

isSameType

public static boolean isSameType(javax.oss.ManagedEntityValue first,
                                 javax.oss.ManagedEntityValue second)
Parameters:
first -
second -
Returns:
If both MEVs are of the same type

getManagedEntityKeys

public Hashtable getManagedEntityKeys(javax.oss.JVTSession jas)
                               throws Exception
Returns:
A Hashtable containing a legal ( but removed ) Key per Type
Throws:
Exception

getIllegalKeys

public Vector getIllegalKeys(javax.oss.ManagedEntityValue mev)
                      throws Exception
Returns:
a Hashtable of Vector of illegal Keys per Type
Throws:
Exception

randomElement

public Object randomElement(Object[] a)
Parameters:
a - Array to select from
Returns:
Random element of the array. null if array is empty of null

getProperty

public String getProperty(String prop)
DOCUMENT ME!

Parameters:
prop - DOCUMENT ME!
Returns:
DOCUMENT ME!

findInterfaceStartsWith

public ArrayList findInterfaceStartsWith(String s)

findImplementationOf

public ArrayList findImplementationOf(Class myInterface)
DOCUMENT ME!

Parameters:
myInterface - DOCUMENT ME!
Returns:
DOCUMENT ME!


Copyright 2002-2006 The Members of the OSS through Java(TM) Initiative. All rights reserved. Use is subject to license terms.