01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: *
22: *
23: * $Id: TestFtpConsumer.java 3655 2006-12-12 07:52:59Z jzhang $
24: */
25: package com.bostechcorp.cbesb.runtime.component.ftp;
26:
27: import java.io.File;
28: import java.net.URI;
29: import java.net.URL;
30:
31: import javax.jbi.messaging.RobustInOnly;
32:
33: import junit.framework.TestCase;
34:
35: import org.apache.servicemix.client.DefaultServiceMixClient;
36: import org.apache.servicemix.jbi.container.JBIContainer;
37:
38: public class TestFtpConsumer extends TestCase {
39:
40: protected JBIContainer container = new JBIContainer();
41:
42: protected void setUp() throws Exception {
43: container.setUseMBeanServer(false);
44: container.setCreateMBeanServer(false);
45: container.setEmbedded(true);
46: container.setCreateJmxConnector(false);
47: container.init();
48: }
49:
50: protected void tearDown() throws Exception {
51: if (container != null) {
52: container.shutDown();
53: }
54: }
55:
56: public void testInOnlyCase1() throws Exception {
57: runTestCase("consumer/ftpconsumer.wsdl");
58: }
59:
60: private void runTestCase(String consumer) throws Exception {
61: // Ftp Component
62: FtpComponent component = new FtpComponent();
63: container.activateComponent(component, "FtpComponent");
64: container.start();
65:
66: // Deploy SU
67: URL url = getClass().getClassLoader().getResource(consumer);
68: File path = new File(new URI(url.toString()));
69: path = path.getParentFile();
70: component.getServiceUnitManager().deploy("consumer",
71: path.getAbsolutePath());
72: component.getServiceUnitManager().start("consumer");
73:
74: // Call it
75: DefaultServiceMixClient client = new DefaultServiceMixClient(
76: container);
77: RobustInOnly inOnly = client.createRobustInOnlyExchange();
78:
79: client.sendSync(inOnly);
80: }
81: }
|