--------------------------------------
Roy-Smiths-Computer:scripts$ mysql < ../../sql/schema.sql; java -classpath $CLASSPATH:build TestAll
.hello
E
Time: 0.976
There was 1 error:
1) testDuplicate(TestVendor)java.lang.NoSuchMethodError: VendorData.<init>(Ljava/sql/Connection;Ljava/io/Reader;)V
at TestVendor.loadTestData(Unknown Source)
at TestVendor.testDuplicate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at TestAll.main(Unknown Source)
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
--------------------------------------
This happens inside of a Junit TestCase. The code that's getting executed is:
private void loadTestData (String data) throws SQLException
{
StringReader reader = new StringReader (data);
VendorData vendor = new VendorData (dbConnection, reader);
vendor.load (VendorData.NO_PRINT_SUMMARY);
}
Obviously, something is going wrong when I create an instance of my VendorData class, but
I have no idea what. Oddly enough, when I run the same test under ant, I get a different error:
-------------------------------------
Roy-Smiths-Computer:scripts$ ant test
Buildfile: build.xml
init:
compile:
[javac] Compiling 3 source files to /Users/roy/Muse/sandbox.tip/src/SnmpBugDb/data/scripts/build
test:
[java] .hello
[java] java.sql.SQLException: Invalid argument value, message from server: "Duplicate entry 'cisco' for key 2"
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
[java] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
etc...
-------------------------------------
This doesn't make any sense for a different reason. The code that's running at
that point is:
public void testDuplicate ()
{
System.out.println ("hello");
System.out.flush();
try {
loadTestData ("cisco, Cisco Systems\n" +
"cisco, Somebody Else\n");
fail ("expected SQLException");
}
catch (SQLException e) {
System.out.println ("caught it");
System.out.flush();
}
}
the loadTestData() call generates the SQLException (which I expect; I'm testing that
the unique column constraint is being enforced). But the exception should have been
caught, and it wasn't.
So, I'm left with two different errors, which happen when I run the same code in
different ways, neither of which I can explain!
At risk of stating the obvious, the above is just a roundabout way of
saying that VendorData has no constructor with the following
signature:
VendorData(java.sql.Connection,java.io.Reader)
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
OK, I figured out what was going on. Due to a bug in my .profile, my
$CLASSPATH ended up with a leading ":". I'm not sure of all the
ramifications of that, but one result was that the JVM was apparantly
finding an obsolete version of the class files in a different directory
(I changed my build directory structure a while ago and these were left
over from the old scheme).