java: Standardize Java test numbering.

This commit is contained in:
Richard W.M. Jones
2013-05-01 08:36:16 +01:00
parent ad1e9e7eac
commit 02fbf566e8
6 changed files with 77 additions and 29 deletions

View File

@@ -38,10 +38,11 @@ java_sources = \
java_tests = \
Bindtests.java \
t/GuestFS005Load.java \
t/GuestFS010Basic.java \
t/GuestFS080OptArgs.java \
t/GuestFS400Events.java
t/GuestFS020Create.java \
t/GuestFS070OptArgs.java \
t/GuestFS100Launch.java \
t/GuestFS410CloseEvent.java \
t/GuestFS420LogMessages.java
EXTRA_DIST = \
$(java_sources) \

View File

@@ -18,7 +18,7 @@
import com.redhat.et.libguestfs.*;
public class GuestFS005Load {
public class GuestFS020Create {
public static void main (String[] argv)
{
try {

View File

@@ -20,7 +20,7 @@ import java.io.*;
import java.util.HashMap;
import com.redhat.et.libguestfs.*;
public class GuestFS080OptArgs
public class GuestFS070OptArgs
{
public static void main (String[] argv)
{

View File

@@ -20,7 +20,7 @@ import java.io.*;
import java.util.Map;
import com.redhat.et.libguestfs.*;
public class GuestFS010Basic
public class GuestFS100Launch
{
public static void main (String[] argv)
{

View File

@@ -0,0 +1,59 @@
/* libguestfs Java bindings
* Copyright (C) 2013 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import java.io.*;
import java.util.HashMap;
import com.redhat.et.libguestfs.*;
public class GuestFS410CloseEvent
{
static class CloseInvoked implements EventCallback
{
private int close_invoked = 0;
public void event (long event, int eh, String buffer, long[] array)
{
close_invoked++;
}
public int getCloseInvoked ()
{
return close_invoked;
}
}
public static void main (String[] argv)
{
try {
GuestFS g = new GuestFS ();
// Check that the close event is invoked.
CloseInvoked ci = new CloseInvoked ();
g.set_event_callback (ci, GuestFS.EVENT_CLOSE);
// Close the handle.
assert ci.getCloseInvoked() == 0;
g.close ();
assert ci.getCloseInvoked() == 1;
}
catch (Exception exn) {
System.err.println (exn);
System.exit (1);
}
}
}

View File

@@ -20,10 +20,12 @@ import java.io.*;
import java.util.HashMap;
import com.redhat.et.libguestfs.*;
public class GuestFS400Events
public class GuestFS420LogMessages
{
static class PrintEvent implements EventCallback
static class LogEvent implements EventCallback
{
private int log_invoked = 0;
public void event (long event, int eh, String buffer, long[] array)
{
String msg = "event=" + GuestFS.eventToString (event) + " " +
@@ -40,22 +42,13 @@ public class GuestFS400Events
}
System.out.println ("java event logged: " + msg);
}
}
static class CloseInvoked extends PrintEvent
{
private int close_invoked = 0;
public void event (long event, int eh, String buffer, long[] array)
{
super.event (event, eh, buffer, array);
close_invoked++;
log_invoked++;
}
public int getCloseInvoked ()
public int getLogInvoked ()
{
return close_invoked;
return log_invoked;
}
}
@@ -66,14 +59,11 @@ public class GuestFS400Events
// Grab all messages into an event handler that just
// prints each event.
g.set_event_callback (new PrintEvent (),
LogEvent le = new LogEvent ();
g.set_event_callback (le,
GuestFS.EVENT_APPLIANCE|GuestFS.EVENT_LIBRARY|
GuestFS.EVENT_TRACE);
// Check that the close event is invoked.
CloseInvoked ci = new CloseInvoked ();
g.set_event_callback (ci, GuestFS.EVENT_CLOSE);
// Now make sure we see some messages.
g.set_trace (true);
g.set_verbose (true);
@@ -82,10 +72,8 @@ public class GuestFS400Events
g.add_drive_ro ("/dev/null");
g.set_autosync (true);
// Close the handle.
assert ci.getCloseInvoked() == 0;
g.close ();
assert ci.getCloseInvoked() == 1;
assert le.getLogInvoked() > 0;
}
catch (Exception exn) {
System.err.println (exn);