You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2005/02/02 21:10:26 UTC
cvs commit: db-ojb/src/test/org/apache/ojb/broker HsqldbShutdown.java AllTests.java
brj 2005/02/02 12:10:26
Modified: src/test/org/apache/ojb/broker AllTests.java
Added: src/test/org/apache/ojb/broker HsqldbShutdown.java
Log:
shutdown hsql after broker.AllTests
Revision Changes Path
1.60 +1 -1 db-ojb/src/test/org/apache/ojb/broker/AllTests.java
Index: AllTests.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- AllTests.java 2 Feb 2005 20:03:15 -0000 1.59
+++ AllTests.java 2 Feb 2005 20:10:26 -0000 1.60
@@ -128,7 +128,7 @@
suite.addTestSuite(NoPkReferenceTest.class);
// BRJ: ensure shutdown of hsqldb
- // suite.addTestSuite(HsqldbShutdown.class);
+ suite.addTestSuite(HsqldbShutdown.class);
return suite;
}
}
1.1 db-ojb/src/test/org/apache/ojb/broker/HsqldbShutdown.java
Index: HsqldbShutdown.java
===================================================================
package org.apache.ojb.broker;
/* Copyright 2003-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.ojb.broker.platforms.Platform;
import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
import org.apache.ojb.junit.PBTestCase;
/**
* Performs a shutdown of hsqldb.
*
* @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
* @version $Id: HsqldbShutdown.java,v 1.1 2005/02/02 20:10:26 brj Exp $
*/
public class HsqldbShutdown extends PBTestCase
{
public void testHsqldbShutdown()
{
Platform platform = broker.serviceConnectionManager().getSupportedPlatform();
if(platform instanceof PlatformHsqldbImpl)
{
Connection con = null;
Statement stmt = null;
try
{
con = broker.serviceConnectionManager().getConnection();
stmt = con.createStatement();
stmt.execute("shutdown");
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
stmt.close();
con.close();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
}
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/test/org/apache/ojb/broker HsqldbShutdown.java
AllTests.java - Added msg link
Posted by Michael Hart <mi...@baselinesols.com>.
Sorry - I forgot to include the link for the msg I sent to ojb-devel on
17/8/2004 regarding HSQLDB 1.7.2:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=ojb-dev@db.apache.org&msgId=1810598
Michael Hart wrote:
> Hey Guys,
>
> I see that this step to shutdown the HSQLDB has been added so that
> versions 1.7.2+ can be supported, which is great. I also note that there
> was a brief discussion last month about it as well (that I missed -
> thread titled "[OJB1.1] test suite and hsql").
>
> There's one slight hiccup with this method - although it's arguable
> whether it's a problem or not. If the HSQLDB is *not* running in
> "In-Process" mode (ie in a Server mode or similar), then it will be
> shutdown, possibly (probably) against the user's will. The default for
> the OJB JUnit tests is to create an HSQLDB using the "In-Process" mode,
> so it won't be a problem in this case - but if someone wants to test on
> an HSQLDB server, then it will shut the server down upon completion.
>
> I haven't got any really nice solution to this - I've queried the HSQL
> team about a way to use an SQL statement to conditionally shut the
> server down if it's in "In-Process" mode, but this seems to be
> impossible (at this stage anyway - see
> http://sourceforge.net/mailarchive/message.php?msg_id=9280558 for more
> details).
>
> However, I did outline a possible solution in an e-mail to this list on
> 17/8/2004 with the subject "Howto: OJB 1.0.0 + Torque 3.1 + HSQLDB
> 1.7.2" - basically by adding a few targets to the build-torque.xml file
> that check if the db being created is HSQLDB in "In-Process" mode and
> add shutdown statements if so. This means that people can then use this
> file to create their own HSQLDB databases as well, outside of the JUnit
> tests. It's a fairly ugly patch IMO, but it's arguably "more correct"
> than just patching the unit test files and shutting down regardless of
> the DB mode.
>
> HTH,
>
> Michael
>
> brj@apache.org wrote:
>
>> brj 2005/02/02 12:10:26
>>
>> Modified: src/test/org/apache/ojb/broker AllTests.java
>> Added: src/test/org/apache/ojb/broker HsqldbShutdown.java
>> Log:
>> shutdown hsql after broker.AllTests
>> Revision Changes Path
>> 1.60 +1 -1
>> db-ojb/src/test/org/apache/ojb/broker/AllTests.java
>> Index: AllTests.java
>> ===================================================================
>> RCS file:
>> /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
>> retrieving revision 1.59
>> retrieving revision 1.60
>> diff -u -r1.59 -r1.60
>> --- AllTests.java 2 Feb 2005 20:03:15 -0000 1.59
>> +++ AllTests.java 2 Feb 2005 20:10:26 -0000 1.60
>> @@ -128,7 +128,7 @@
>> suite.addTestSuite(NoPkReferenceTest.class);
>> // BRJ: ensure shutdown of hsqldb
>> - // suite.addTestSuite(HsqldbShutdown.class);
>> + suite.addTestSuite(HsqldbShutdown.class);
>> return suite;
>> }
>> }
>> 1.1
>> db-ojb/src/test/org/apache/ojb/broker/HsqldbShutdown.java
>> Index: HsqldbShutdown.java
>> ===================================================================
>> package org.apache.ojb.broker;
>> /* Copyright 2003-2004 The Apache Software Foundation
>> *
>> * Licensed under the Apache License, Version 2.0 (the "License");
>> * you may not use this file except in compliance with the License.
>> * You may obtain a copy of the License at
>> *
>> * http://www.apache.org/licenses/LICENSE-2.0
>> *
>> * Unless required by applicable law or agreed to in writing, software
>> * distributed under the License is distributed on an "AS IS" BASIS,
>> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> * See the License for the specific language governing permissions and
>> * limitations under the License.
>> */
>> import java.sql.Connection;
>> import java.sql.SQLException;
>> import java.sql.Statement;
>> import org.apache.ojb.broker.platforms.Platform;
>> import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
>> import org.apache.ojb.junit.PBTestCase;
>> /**
>> * Performs a shutdown of hsqldb.
>> *
>> * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
>> * @version $Id: HsqldbShutdown.java,v 1.1 2005/02/02 20:10:26 brj
>> Exp $
>> */
>> public class HsqldbShutdown extends PBTestCase
>> {
>> public void testHsqldbShutdown()
>> {
>> Platform platform =
>> broker.serviceConnectionManager().getSupportedPlatform();
>> if(platform instanceof PlatformHsqldbImpl)
>> {
>> Connection con = null;
>> Statement stmt = null;
>> try
>> {
>> con =
>> broker.serviceConnectionManager().getConnection();
>> stmt = con.createStatement();
>> stmt.execute("shutdown");
>> }
>> catch (Exception e)
>> {
>> e.printStackTrace();
>> }
>> finally
>> {
>> try
>> {
>> stmt.close();
>> con.close();
>> }
>> catch (SQLException e1)
>> {
>> e1.printStackTrace();
>> }
>> }
>> }
>> }
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: cvs commit: db-ojb/src/test/org/apache/ojb/broker HsqldbShutdown.java
AllTests.java
Posted by Michael Hart <mi...@baselinesols.com>.
Hey Guys,
I see that this step to shutdown the HSQLDB has been added so that
versions 1.7.2+ can be supported, which is great. I also note that there
was a brief discussion last month about it as well (that I missed -
thread titled "[OJB1.1] test suite and hsql").
There's one slight hiccup with this method - although it's arguable
whether it's a problem or not. If the HSQLDB is *not* running in
"In-Process" mode (ie in a Server mode or similar), then it will be
shutdown, possibly (probably) against the user's will. The default for
the OJB JUnit tests is to create an HSQLDB using the "In-Process" mode,
so it won't be a problem in this case - but if someone wants to test on
an HSQLDB server, then it will shut the server down upon completion.
I haven't got any really nice solution to this - I've queried the HSQL
team about a way to use an SQL statement to conditionally shut the
server down if it's in "In-Process" mode, but this seems to be
impossible (at this stage anyway - see
http://sourceforge.net/mailarchive/message.php?msg_id=9280558 for more
details).
However, I did outline a possible solution in an e-mail to this list on
17/8/2004 with the subject "Howto: OJB 1.0.0 + Torque 3.1 + HSQLDB
1.7.2" - basically by adding a few targets to the build-torque.xml file
that check if the db being created is HSQLDB in "In-Process" mode and
add shutdown statements if so. This means that people can then use this
file to create their own HSQLDB databases as well, outside of the JUnit
tests. It's a fairly ugly patch IMO, but it's arguably "more correct"
than just patching the unit test files and shutting down regardless of
the DB mode.
HTH,
Michael
brj@apache.org wrote:
> brj 2005/02/02 12:10:26
>
> Modified: src/test/org/apache/ojb/broker AllTests.java
> Added: src/test/org/apache/ojb/broker HsqldbShutdown.java
> Log:
> shutdown hsql after broker.AllTests
>
> Revision Changes Path
> 1.60 +1 -1 db-ojb/src/test/org/apache/ojb/broker/AllTests.java
>
> Index: AllTests.java
> ===================================================================
> RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
> retrieving revision 1.59
> retrieving revision 1.60
> diff -u -r1.59 -r1.60
> --- AllTests.java 2 Feb 2005 20:03:15 -0000 1.59
> +++ AllTests.java 2 Feb 2005 20:10:26 -0000 1.60
> @@ -128,7 +128,7 @@
> suite.addTestSuite(NoPkReferenceTest.class);
>
> // BRJ: ensure shutdown of hsqldb
> - // suite.addTestSuite(HsqldbShutdown.class);
> + suite.addTestSuite(HsqldbShutdown.class);
> return suite;
> }
> }
>
>
>
> 1.1 db-ojb/src/test/org/apache/ojb/broker/HsqldbShutdown.java
>
> Index: HsqldbShutdown.java
> ===================================================================
> package org.apache.ojb.broker;
>
> /* Copyright 2003-2004 The Apache Software Foundation
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> * You may obtain a copy of the License at
> *
> * http://www.apache.org/licenses/LICENSE-2.0
> *
> * Unless required by applicable law or agreed to in writing, software
> * distributed under the License is distributed on an "AS IS" BASIS,
> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> * See the License for the specific language governing permissions and
> * limitations under the License.
> */
>
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.sql.Statement;
>
> import org.apache.ojb.broker.platforms.Platform;
> import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
> import org.apache.ojb.junit.PBTestCase;
>
> /**
> * Performs a shutdown of hsqldb.
> *
> * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
> * @version $Id: HsqldbShutdown.java,v 1.1 2005/02/02 20:10:26 brj Exp $
> */
> public class HsqldbShutdown extends PBTestCase
> {
> public void testHsqldbShutdown()
> {
> Platform platform = broker.serviceConnectionManager().getSupportedPlatform();
>
> if(platform instanceof PlatformHsqldbImpl)
> {
> Connection con = null;
> Statement stmt = null;
>
> try
> {
> con = broker.serviceConnectionManager().getConnection();
> stmt = con.createStatement();
> stmt.execute("shutdown");
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> finally
> {
> try
> {
> stmt.close();
> con.close();
> }
> catch (SQLException e1)
> {
> e1.printStackTrace();
> }
> }
> }
>
> }
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org