KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestAttachmentsSample


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package test.functional;
18
19 import junit.framework.TestCase;
20 import org.apache.axis.client.AdminClient;
21 import org.apache.axis.components.logger.LogFactory;
22 import org.apache.axis.utils.Options;
23 import org.apache.commons.logging.Log;
24 import samples.attachments.EchoAttachment;
25 import samples.attachments.TestRef;
26
27
28 /** Test the attachments sample code.
29  */

30 public class TestAttachmentsSample extends TestCase {
31     static Log log =
32             LogFactory.getLog(TestAttachmentsSample.class.getName());
33
34     public TestAttachmentsSample(String JavaDoc name) {
35         super(name);
36     }
37     
38     public void doTestDeploy () throws Exception JavaDoc {
39         AdminClient.main(new String JavaDoc[]{"samples/attachments/attachdeploy.wsdd" });
40         AdminClient.main(new String JavaDoc[]{"samples/attachments/testref.wsdd"});
41     }
42     
43     public void doTestAttachments1() throws Exception JavaDoc {
44         Options opts = new Options( new String JavaDoc[]{});
45         boolean res = new EchoAttachment(opts).echo(false, "samples/attachments/README");
46        assertEquals("Didn't process attachment correctly", res, true) ;
47     }
48
49     public void doTestAttachmentsD1() throws Exception JavaDoc {
50         Options opts = new Options( new String JavaDoc[]{});
51         boolean res = new EchoAttachment(opts).echo(true, "samples/attachments/README");
52        assertEquals("Didn't process attachment correctly", res, true) ;
53     }
54     
55     public void doTestAttachmentsDimeLeaveEmpty() throws Exception JavaDoc {
56         Options opts = new Options( new String JavaDoc[]{});
57         boolean res = new EchoAttachment(opts).echo(true, "samples/attachments/leaveempty.txt");
58        assertEquals("Didn't process attachment correctly", res, true) ;
59     }
60
61     public void doTestAttachments2() throws Exception JavaDoc {
62         Options opts = new Options( new String JavaDoc[]{});
63         boolean res = new EchoAttachment(opts).echoDir(false, "samples/attachments");
64         assertEquals("Didn't process attachments correctly", res, true);
65     }
66
67     public void doTestAttachmentsD2() throws Exception JavaDoc {
68         Options opts = new Options( new String JavaDoc[]{});
69         boolean res = new EchoAttachment(opts).echoDir(true, "samples/attachments");
70         assertEquals("Didn't process attachments correctly", res, true);
71     }
72
73     public void doTestAttachmentsTestRef() throws Exception JavaDoc {
74         Options opts = new Options( new String JavaDoc[]{});
75         boolean res = new TestRef(opts).testit();
76         assertEquals("Didn't process attachments correctly", res, true);
77     }
78     
79     public void doTestUndeploy () throws Exception JavaDoc {
80         AdminClient.main(new String JavaDoc[]{ "samples/attachments/attachundeploy.wsdd" });
81         AdminClient.main(new String JavaDoc[]{ "samples/attachments/testrefundeploy.wsdd" });
82     }
83
84     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
85         TestAttachmentsSample tester = new TestAttachmentsSample("tester");
86         tester.testAttachmentsService();
87     }
88
89     public void testAttachmentsService () throws Exception JavaDoc {
90         try {
91             log.info("Testing deployment...");
92             doTestDeploy();
93             log.info("Testing single file attachment...");
94             doTestAttachments1();
95             log.info("Testing multiple file attachments...");
96             doTestAttachments2();
97             log.info("Testing single file DIME attachment...");
98             doTestAttachmentsD1();
99             log.info("Testing multiple file DIME attachments...");
100             doTestAttachmentsD2();
101             log.info("Testing attachment references...");
102             doTestAttachmentsTestRef();
103             log.info("Testing undeployment...");
104             doTestUndeploy();
105             log.info("Test complete.");
106         }
107         catch( Exception JavaDoc e ) {
108             e.printStackTrace();
109             throw new Exception JavaDoc("Fault returned from test: "+e);
110         }
111     }
112     
113 }
114
115
116
Popular Tags