Skip to main content

Missing Examples mentioned in the Architect's Guide

9 replies [Last post]
madridwitch
Offline
Joined: 2007-04-25

Hi.

First off, I'm not an ME developer, but I am a NetBeans and subversion user. I am trying to use JT Harness for testing of a java tool my team has written that analyzes telemetry signal processing data.

1. I have installed the source data for JT Harness in netbeans as a project. When I run main from the tool folder, the gui for JT Harness comes up, with nothing except JavaHelp and JavaTest Preferences. I suppose this is expected since there is no Test Suite and no examples folder with the download, but it would be nice if I could click on something in the gui and bring up a testsuite I have created.

2. Where can I get the examples mentioned in the Architect's Guide? The guide refers to an examples directory, i.e.:

...\examples\
javatest\
demoapi.jar API classes tested by the Demo TCK test suite
interviewDemo\ A self-documenting configuration interview demo
demotck The test suite used to run the interview demo
src The interview demo source files
simpleHTML\
demotck\ Demo test suite that uses HTML-based test descriptions
src\ Demo TCK configuration interview source files
simpleTags\
demotck\ Demo test suite that uses tag test descriptions
src\ Demo TCK configuration interview source files
sampleFiles\ Miscellaneous sample source files referred to
throughout this manual

These examples are not in the javatest.jar file nor with the source code.

Belinda

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexeyp
Offline
Joined: 2006-10-04

Hi Belinda

answering your questions in the reverse order.

#2 Examples, that are referred from JavaTest Architect's Guide are not
available in the open source repository. We are working to add
examples/tutorial there under appropriate license, should be ready in
few weeks.

For now let me please try to answer your questions and provide
assistance here. You can also look at examples, that are created fr ME
Framework at cqme.dev.java.net, check
https://cqme.dev.java.net/source/browse/cqme/trunk/samples/meframework/

MEF is a JT harness extension, its examples can be useful to understand the structure
of the JT harness test suite and how to create interview. Please note that these
examples use MEF-specific API.

#1 Launching JT under NetBeans

If you see only "File" and "Help" menus this may mean that JT harness
was not appropriately built and miss resource files.

If you build JT harness with NetBeans, please make sure to create
'A project with existing ant script' and use a build.xml that is in the
build directory. After that, launch JT harness with java -jar javatest.jar command.

Please note that you may need to have a separate NetBeans project for
the test suite.

Please let me know if this helps.

With best regards
Alexey

madridwitch
Offline
Joined: 2007-04-25

Hi, Alexey. Thanks for the response.

I was looking for the examples because I'm getting errors when I run MyTest.java from the Architect's Guide. The test does execute, but it fails with this error:

java.lang.NoClassDefFoundError: MyTest
Exception in thread "main"

I know my difficulty is in my directory structure and I looked at the directory structure for the ME framework and made my similar, but I still get the error.

I am using netbeans with a project named Test Harness. From the project level, this is what it looks like:

Test Harness
- tests
MyTest.java
- legal
legal.txt - src
- testharness
Main.java
- Libraries
javatest.jar
jhall.jar
JDK 1.6(Default)

Netbeans doesn't have the option to rename the Libraries directory, but I tried it with another folder named lib per the architect's instructions and still get the same thing.

My build ends up looking like this:

build
- classes
legal.txt
MyTest.class
- testharness
Main.class

My distribution folder:

dist
- lib
javatest.jar
jhall.jar
README.TXT
Test_Harness.jar

The Main.java is simply the Main that's created when a project is created in Netbeans and isn't being used right now.

This is what my testsuite.jtt looks like:

# Test Suite properties file for TAVS test suite
# with tag-style tests

name=TAVS Test Suite
id=1.0
tests=tests
finder=com.sun.javatest.finder.TagTestFinder
script=com.sun.javatest.lib.StdTestScript
interview=com.sun.javatest.interview.SimpleInterviewParameters
classpath=dist/lib/Test_Harness.jar

Can you or anyone else tell me what I'm doing wrong? If I can get this test to work properly with JT Harness, then I can begin writing my real tests to test our project software.

Thanks.

Belinda

alexeyp
Offline
Joined: 2006-10-04

Hi Belinda

I assume your testsuite structure is

/testsuite.jtt
/tests/MyTest.java
/dist/lib/Test_Harness.jar

and sequence of actions is:
- java -jar javatest.jar
- 'open test suite' - refer to the directory with testsuite.jtt
- created work directory
- in the Configuration Editor indicated 'How to run tests' - another process
- entered path for java vm on your machine

Seems that 'classpath' entry from testsuite.jtt is not automatically used for test execution, at least 'execute/messages' section of the test result states that java vm is called for test execution without -classpath parameter.

The problem can be fixed by adding javatest.jar and your Test_Harness.jar to the list of classpath entries in the 'Class Path' question of the Configuration Wizard

Please let me know if this helps.

Thank you
Alexey

madridwitch
Offline
Joined: 2007-04-25

Hi, Alexey.

I forgot to mention, in my previous email where I speak about my problems with getting the structure correct so that the test harness can find MyTest.class, it's the GUI I'm having problems with. If I run MYTest from netbeans as a standalone, then the JTHarness executes it and the test passes as it should, or fails as it should.

I'm still having problems getting the GUI to find my paths. I tried what you suggested. Right now what I have is, I've created a package com.sun.javatest (instead of the classes directory like the architect's guide suggests else NetBEANS builds a classes/classes folder). I copied Status.java and Test.java into this folder. This solved the problem of the GUI failing with a problem that it couldn't find the class Test.

The name of my test is TZero. You're right. If I don't add Test_Harness.jar to the classpath during the interview I get this:
java.lang.NoClassDefFoundError: TZero
Exception in thread "main"

So, I created another interview and added Test_Harness.jar via the Configuration Wizard and did a. However, now when I run the test, I get in execute/out 1:

java.lang.NoClassDefFoundError: Harness\dist\Test_Harness/jar
Exception in thread "main"

And in execute/Messages, I get this message:

command: com.sun.javatest.lib.ExecStdTestOtherJVMCmd C:\Program Files\Java\jdk1.6.0\bin\java.exe -classpath C:\svn_development\Test Harness\dist\Test_Harness.jar TZero

I don't understand why it's trying to find Test_Harness/jar

Below is the configuration interview that was created

#JavaTest Configuration Interview
#Tue May 01 17:01:48 MDT 2007
CHECKSUM=d3212ae0be02068
INTERVIEW=com.sun.javatest.interview.SimpleInterviewParameters
LOCALE=en_US
QUESTION=simple.tests.needTests
TESTSUITE=C\:\\svn_development\\Test Harness\\TavsTestSuite
WORKDIR=C\:\\svn_development\\Test Harness\\results\\results
simple.classPath=C\:\\svn_development\\Test Harness\\dist\\Test_Harness.jar\n
simple.cmdType=otherVM
simple.concurrency.concurrency=1
simple.desc=config
simple.excludeList.latestAutoCheck=No
simple.excludeList.latestAutoCheckInterval=7
simple.excludeList.latestAutoCheckMode=everyXDays
simple.excludeList.needExcludeList=No
simple.jvm=C\:\\Program Files\\Java\\jdk1.6.0\\bin\\java.exe
simple.keywords.keywords.mode=expr
simple.keywords.needKeywords=No
simple.name=config
simple.priorStatus.needStatus=No
simple.priorStatus.status=
simple.tests.needTests=No
simple.tests.tests=
simple.tests.treeOrFile=tree
simple.timeout.timeout=1

As you can see, everything points to Test_Harness.jar, unless Test_Harness/jar is merely a typo, but it looks like a legitimate message from the JVM.

Can you tell me what might be going on? Is this a bug or did I mess up somewhere?

Thanks.

Belinda

alexeyp
Offline
Joined: 2006-10-04

Hi Belinda

you describe interesting issue. The problem is because you have a whitespace in the classpath and this is not recognized by the harness:

C:\svn_development\[b]Test Harness[/b]\dist\Test_Harness.jar

because of this the dot before the 'jar' is treated as a dot in the name of the class and is converted to '/' by class loader.

To fix this please try to place your test suite to the directory, that does not contain witespaces on the path.

Please also add javatest.jar to the list of classpath entries in the config editor, this is a simple way to make test libraries (Test, Status etc) accessible.

With best regards
Alexey

madridwitch
Offline
Joined: 2007-04-25

I fixed the path problem as you suggested, Alexey, and renamed it Test_Harness. However, no matter what I do, and I have tried everything (even placing my class in the javatest.jar), I get this error and I can't get the JT harness to find my test class TZero. (However, the test does list under the files part of the GUI and everywhere else, it just can't seem to execute it.

java.lang.NoClassDefFoundError: TZero
Exception in thread "main"

I have tried adding the classpath to the Configuration editor, both my jar file and the javatest.jar file. I have even tried to point the class path directly to the TZero.class file under the classes directory in the build directory.

I have tried putting the classpath in the .jtt file as ../../dist/Test_Harness.jar.

I have even moved the Test_Harness.jar into the same directory where the .jtt file is located under classes in the build directory and changed the classpath in the .jtt file to just classpath=Test_Harness.jar.

I cannot get my test to execute because the JT Harness cannot find it.

This is what my .jtt file looks like after I removed the classpath property, which didn't seem to help. (If I did put the classpath to TZero, what would the relative classpath be to my test suite? My .jtt file is under Test_Harness/TavsTestSuite.

# Test Suite properties file for TAVS test suite
# with tag-style tests

name=Tavs 1.0 TestSuite
id=TavsTestSuite_1.0
tests=SignalOperatorTests
finder=com.sun.javatest.finder.TagTestFinder
script=com.sun.javatest.lib.StdTestScript
interview=com.sun.javatest.interview.SimpleInterviewParameters

Test_Harness/TavsTestSuite/SignalOperatorTests is where TZero.java is located.
Now TZero.java does show up under TestSuite Root in the left hand window of the Gui. This is what's displayed under the files tab of the GUI:

package SignalOperatorTests;
/*
* TZero.java
*
* Created on April 25, 2007, 2:44 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

import java.io.PrintWriter;
import com.sun.javatest.Status;
import com.sun.javatest.Test;

/** @test
* @executeClass TZero
* @sources TZero.java
* @author bagarci
**/

public class TZero implements Test {
public static void main(String[] args) {
PrintWriter err = new PrintWriter(System.err, true);
Test t = new TZero();
Status s = t.run(args, null, err);
s.exit();
}
public Status run(String[] args, PrintWriter log1, PrintWriter log2) {
Status result;
// your test code begins here ...
if (1 + 1 == 2)
result = Status.passed("OK");
else
result = Status.failed("Oops");
// your test code ends here ...
return result;
}
}

I'm at my wit's end of what to do here.

Belinda

alexeyp
Offline
Joined: 2006-10-04

Hi Belinda

please change

* @executeClass TZero
to
* @executeClass SignalOperatorTests.TZero

in TZero.java

The value of this parameter should be full-qualified name of the test class.

Please also make sure that both your classes and javatest.jar are on the classpath when test is executed. After this, it shold work and 'messages' sectoin of the test result should contain runnable command, something like:

/java/re/jdk/6.0/archive/fcs/binaries/linux-i586/bin/java -classpath
/home/lm153972/ws/tmp/ts/lib/javatest.jar:/home/lm153972/ws/tmp/ts/Test_Harness.jar
SignalOperatorTests.TZero

>If I did put the classpath to TZero, what would the relative classpath be
>to my test suite? My .jtt file is under Test_Harness/TavsTestSuite

Seems that location of the javatest.jar and Test_Harness.jar is not important, as they are pointed out from the config editor. .jtt identifies your test suite, it contains path to test descriptions for test finder to search, where your TZero.java is located:

>tests=SignalOperatorTests

With best regards,
Alexey

madridwitch
Offline
Joined: 2007-04-25

Hi, Alexey.

Thanks for the help. I did as you suggested, and using the fully qualified name, it worked.

Have a nice day.

Kindest regards,

Belinda

bkurotsu
Offline
Joined: 2004-12-13

To wrap up this thread...

An equivalent tutorial is being integrated in the trunk shortly, with source...