aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/test1.c24
-rw-r--r--tests/test13.c11
-rw-r--r--tests/test2.c3
3 files changed, 22 insertions, 16 deletions
diff --git a/tests/test1.c b/tests/test1.c
index 97c6b3ebed..c21cfd371b 100644
--- a/tests/test1.c
+++ b/tests/test1.c
@@ -17,9 +17,8 @@ main (int argc, char**argv)
CamelMimePart *body_part;
CamelMimePart *attachment_part;
CamelStream *attachment_stream;
-
- /* FILE *output_file; */
CamelStream *stream;
+ CamelException *ex = camel_exception_new ();
gtk_init (&argc, &argv);
camel_init ();
@@ -28,10 +27,11 @@ main (int argc, char**argv)
attachment_stream = NULL;
} else {
if (argc == 2) {
- attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0);
+ attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0, ex);
if (attachment_stream == NULL) {
- fprintf (stderr, "Cannot open `%s'\n",
- argv[1]);
+ fprintf (stderr, "Cannot open `%s': %s\n",
+ argv[1],
+ camel_exception_get_description (ex));
return 1;
}
} else {
@@ -106,16 +106,22 @@ main (int argc, char**argv)
camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart));
- stream = camel_stream_fs_new_with_name ("mail1.test", O_WRONLY|O_TRUNC|O_CREAT, 0600);
+ stream = camel_stream_fs_new_with_name ("mail1.test", O_WRONLY|O_TRUNC|O_CREAT, 0600, ex);
if (!stream) {
- printf ("could not open output file");
+ printf ("Could not open output file: %s\n",
+ camel_exception_get_description (ex));
exit(2);
}
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message),
- stream);
- camel_stream_close (stream);
+ stream, ex);
+ camel_stream_flush (stream, ex);
gtk_object_unref (GTK_OBJECT (stream));
+ if (camel_exception_is_set (ex)) {
+ printf ("Oops. Failed. %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
gtk_object_unref (GTK_OBJECT (message));
gtk_object_unref (GTK_OBJECT (multipart));
diff --git a/tests/test13.c b/tests/test13.c
index f9fde1720f..3e191eddf5 100644
--- a/tests/test13.c
+++ b/tests/test13.c
@@ -40,7 +40,7 @@ dump_message_content(CamelDataWrapper *object)
left = 0;
if (stream) {
- while ( (len = camel_stream_read(stream, buffer+left, sizeof(buffer)-left)) > 0) {
+ while ( (len = camel_stream_read(stream, buffer+left, sizeof(buffer)-left, NULL)) > 0) {
fwrite(buffer, len, 1, stdout);
}
printf("\n");
@@ -95,7 +95,7 @@ main (int argc, char**argv)
message = camel_mime_message_new ();
- input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0);
+ input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0, NULL);
if (!input_stream) {
perror ("could not open input file\n");
printf ("You must create the file mail.test before running this test\n");
@@ -110,12 +110,11 @@ main (int argc, char**argv)
dump_message_content(CAMEL_DATA_WRAPPER (message));
- camel_stream_close (input_stream);
gtk_object_unref (GTK_OBJECT (input_stream));
- output_stream = camel_stream_fs_new_with_name ("mail2.test", O_WRONLY|O_CREAT|O_TRUNC, 0600);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream);
- camel_stream_close (output_stream);
+ output_stream = camel_stream_fs_new_with_name ("mail2.test", O_WRONLY|O_CREAT|O_TRUNC, 0600, NULL);
+ camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream, NULL);
+ camel_stream_flush (output_stream, NULL);
gtk_object_unref (GTK_OBJECT (output_stream));
//gtk_object_unref (GTK_OBJECT (message));
diff --git a/tests/test2.c b/tests/test2.c
index 2aa0ae93de..a6299357cb 100644
--- a/tests/test2.c
+++ b/tests/test2.c
@@ -12,6 +12,7 @@ main (int argc, char**argv)
{
CamelMimeMessage *message;
CamelStream *input_stream;
+ CamelException *ex = camel_exception_new ();
gtk_init (&argc, &argv);
camel_init ();
@@ -19,7 +20,7 @@ main (int argc, char**argv)
message = camel_mime_message_new ();
- input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0);
+ input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0, ex);
if (!input_stream) {
perror ("could not open input file\n");
printf ("You must create the file mail.test before running this test\n");