• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the  "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 /*
19  * $Id$
20  */
21 
22 /*
23  *
24  * Datalet.java
25  *
26  */
27 package org.apache.qetest;
28 
29 import java.util.Hashtable;
30 
31 /**
32  * Minimal interface defining a datalet, a single set of data
33  * for a simple test case.
34  * <p>A Datalet defines a single group of data that a matching
35  * Testlet needs to execute it's simple test case.  Normally,
36  * Testlets and Datalets are matched.</p>
37  *
38  * <p>This makes creating data-driven tests simpler, by separating
39  * the test algorithm from the definition of the test data.  Note
40  * that logging what happened during the test is already separated
41  * out into the Logger interface.</p>
42  *
43  * <p>Normally Datalets will simply be collections of public members
44  * that can be written or read by anyone.  An enclosing test can
45  * simply create or load a number of Datalets and then pass them
46  * to a Testlet to execute the whole bunch of them.</p>
47  *
48  * <p>One way to look at a Datalet is basically an intelligent
49  * Properties / Hashtable / InputSource, designed for a
50  * specific set of data.  They can be loaded from a variety of
51  * inputs and will intelligently create the right kind of data
52  * that their corresponding Testlet is expecting.
53  * For example, and DOM-based InputSource Datalet might be
54  * loaded from a number of Strings denoting filenames or URLs.
55  * The Datalet would then know how to parse each of the files
56  * into a DOM, which a Testlet could then use directly.</p>
57  *
58  * <p>//@todo what metaphor is best? I.e. Should Datalets break OO
59  * paradigms and just have public members, or should they work more
60  * like a Hashtable with some Properties-like features thrown in?
61  * Or: what are the most important
62  * things to optimize: syntactic sugar-like simplicity for callers;
63  * more functionality for different datatypes; ease of use by
64  * inexperienced coders (perhaps testers who are just learning Java);
65  * ease of use by experienced coders?</p>
66  *
67  *
68  * <p>//@todo Should we add a getParameterInfo() method?</p>
69  * @author Shane_Curcuru@lotus.com
70  * @version $Id$
71  */
72 public interface Datalet
73 {
74 
75     /**
76      * Accesor method for a brief description of this Datalet.
77      *
78      * @return String describing the specific set of data
79      * this Datalet contains (can often be used as the description
80      * of any check() calls made from the Testlet).
81      */
getDescription()82     public abstract String getDescription();
83 
84 
85     /**
86      * Accesor method for a brief description of this Datalet.
87      * Datalets must have this as a read/write property, since many
88      * users will programmatically construct Datalets.
89      *
90      * @param s description to use for this Datalet.
91      */
setDescription(String s)92     public abstract void setDescription(String s);
93 
94 
95     /**
96      * Load fields of this Datalet from a Hashtable.
97      * Note many datalets might take in a Properties block
98      * instead for simple String-valued data.
99      *
100      * @param Hashtable to load; Datalet should attempt to fill
101      * in as many member variables as possible from this, leaving
102      * any non-specified variables null or some default; behavior
103      * if null is passed is undefined
104      */
load(Hashtable h)105     public abstract void load(Hashtable h);
106 
107 
108     /**
109      * Load fields of this Datalet from an array.
110      * This allows most Datalets to be initialized from a main()
111      * command line or the like.  For any String-valued types, or
112      * types that can easily be derived from a String, this makes
113      * running ad-hoc tests very easy.
114      *
115      * @param args array of Strings, as if from the command line;
116      * Datalet should attempt to fill in as many member variables
117      * as possible from this, defining the order itself, leaving
118      * any non-specified variables null or some default; behavior
119      * if null is passed is undefined
120      */
load(String[] args)121     public abstract void load(String[] args);
122 
123 }  // end of class Datalet
124 
125