List of usage examples for javax.activation FileDataSource FileDataSource
public FileDataSource(String name)
From source file:org.wso2.brs.rule.test.CarRentalServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadCarRentalService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String CarRentalServiceAAR = samplesDir + File.separator + "carrental.service/service/target/CarRentalService.aar"; log.info(CarRentalServiceAAR);// www. ja v a 2s .c om FileDataSource fileDataSource = new FileDataSource(CarRentalServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("CarRentalService.aar", dataHandler); }
From source file:org.wso2.brs.rule.test.HealthCareServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadHealthCareService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String HealthCareServiceAAR = samplesDir + File.separator + "healthcare.service/service/target/HealthCareService.aar"; log.info(HealthCareServiceAAR);//from ww w .ja va 2s. co m FileDataSource fileDataSource = new FileDataSource(HealthCareServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("HealthCareService.aar", dataHandler); }
From source file:org.wso2.brs.rule.test.InsuranceServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadInsuranceService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String InsuranceServiceAAR = samplesDir + File.separator + "insurance.service/service/target/InsuranceService.aar"; log.info(InsuranceServiceAAR);/*from ww w. j a va 2s. co m*/ FileDataSource fileDataSource = new FileDataSource(InsuranceServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("InsuranceService.aar", dataHandler); }
From source file:org.wso2.carbon.attachment.mgt.ui.SampleAttachmentMgtClient.java
private static String uploadAttachment() throws RemoteException, AttachmentMgtException { AttachmentMgtServiceStub stub = new AttachmentMgtServiceStub(); Options options = new Options(); options.setTo(new EndpointReference("http://127.0.0.1:9763/services/AttachmentMgtService/")); options.setProperty(Constants.Configuration.ENABLE_MTOM, Boolean.TRUE); stub._getServiceClient().setOptions(options); TAttachment att = new TAttachment(); //att.setId("ContentId"); //att.setCreatedTime(Calendar.getInstance()); att.setName("ContentName"); att.setCreatedBy("DenisAuthor"); att.setContentType("text/plain"); //FileDataSource dataSource = new FileDataSource(new File("/home/denis/Desktop/note.txt")); FileDataSource dataSource = new FileDataSource(new File("/home/denis/Desktop/fromSoapUI.xml")); DataHandler fileDataHandler = new DataHandler(dataSource); att.setContent(fileDataHandler);/*from www. j a va 2 s .com*/ String id = stub.add(att); if (log.isDebugEnabled()) { log.debug("Attachment uploaded with id: " + id); } return id; }
From source file:org.wso2.brs.rule.test.ShoppingServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadShoppingService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String ShoppingServiceAAR = samplesDir + File.separator + "shopping.service/service/target/ShoppingService.aar"; log.info(ShoppingServiceAAR);/* www.j av a2 s . co m*/ FileDataSource fileDataSource = new FileDataSource(ShoppingServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("ShoppingService.aar", dataHandler); }
From source file:org.paxle.core.doc.impl.jaxb.JaxbFileAdapter.java
/** * Converts the {@link File} into a {@link DataHandler} *//* ww w . ja va2 s . c o m*/ @Override public DataHandler marshal(File cDocFile) throws Exception { if (cDocFile == null) return null; return new DataHandler(new FileDataSource(cDocFile)); }
From source file:org.wso2.bps.integration.common.clients.bpmn.BPMNUploaderClient.java
private void deployPackage(String packageName, String resourceDir, BPMNUploaderServiceStub bpmnUploaderServiceStub) throws RemoteException, InterruptedException { String sampleArchiveName = packageName + ".bar"; log.info(resourceDir + File.separator + sampleArchiveName); DataSource BPMNDataSource = new FileDataSource(resourceDir + File.separator + sampleArchiveName); UploadedFileItem[] uploadedFileItems = new UploadedFileItem[1]; uploadedFileItems[0] = getUploadedFileItem(new DataHandler(BPMNDataSource), sampleArchiveName, "bar"); log.info("Deploying " + sampleArchiveName); bpmnUploaderServiceStub.uploadService(uploadedFileItems); }
From source file:org.onesec.raven.ivr.vmail.impl.VMailBoxNodeTest.java
@Test public void getNewMessagesCount() throws Exception { assertEquals(0, vbox.getNewMessagesCount()); vbox.addMessage(new NewVMailMessageImpl("123", "222", new Date(), new FileDataSource(testFile))); assertEquals(1, vbox.getNewMessagesCount()); vbox.addMessage(new NewVMailMessageImpl("123", "333", new Date(), new FileDataSource(testFile))); assertEquals(2, vbox.getNewMessagesCount()); }
From source file:org.wso2.carbon.esb.car.deployment.test.CAppDeactivateAndRestartTestCase.java
@BeforeClass(alwaysRun = true) protected void uploadCarFileTest() throws Exception { //start FTP server startFTPServer();//w w w . ja va 2s . c o m super.init(); serverConfigurationManager = new ServerConfigurationManager(context); //upload CAPP CarbonAppUploaderClient carbonAppUploaderClient = new CarbonAppUploaderClient( context.getContextUrls().getBackEndUrl(), sessionCookie); carbonAppUploaderClient.uploadCarbonAppArtifact(carFileName, new DataHandler(new FileDataSource( new File(getESBResourceLocation() + File.separator + "car" + File.separator + carFileName)))); log.info(carFileName + " uploaded successfully"); //deactivate proxy service serviceAdminClient = new ServiceAdminClient(context.getContextUrls().getBackEndUrl(), sessionCookie); isProxyDeployed(service); serviceAdminClient.stopService(service); //Wait and check till the service get deactivated maximum for ~20sec for (int i = 0; i < 20; i++) { if (!serviceAdminClient.getServicesData(service).getActive()) { break; } log.info("Wait to service get deactivated"); Thread.sleep(1000); } Assert.assertFalse(serviceAdminClient.getServicesData(service).getActive(), "Unable to stop service: " + service); serverConfigurationManager.restartGracefully(); super.init(); }
From source file:org.apache.synapse.samples.framework.clients.MTOMSwASampleClient.java
public SampleClientResult sendUsingMTOM(String fileName, String targetEPR) { clientResult = new SampleClientResult(); try {//from ww w .j a va 2 s . co m OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); log.info("Sending file : " + fileName + " as MTOM"); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ConfigurationContext configContext = ConfigurationContextFactory .createConfigurationContextFromFileSystem(configuration.getClientRepo(), configuration.getAxis2Xml()); serviceClient = new ServiceClient(configContext, null); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); OMText binaryNode = (OMText) response .getFirstChildWithName(new QName("http://services.samples", "response")) .getFirstChildWithName(new QName("http://services.samples", "image")).getFirstOMChild(); dataHandler = (DataHandler) binaryNode.getDataHandler(); InputStream is = dataHandler.getInputStream(); log.info("temp.dir: " + System.getProperty("java.io.tmpdir")); File tempFile = File.createTempFile("mtom-", ".gif"); FileOutputStream fos = new FileOutputStream(tempFile); BufferedOutputStream dest = new BufferedOutputStream(fos, 2048); byte data[] = new byte[2048]; int count; while ((count = is.read(data, 0, 2048)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); log.info("Saved response to file : " + tempFile.getAbsolutePath()); clientResult.incrementResponseCount(); } catch (Exception e) { log.error("Error invoking service", e); clientResult.setException(e); } return clientResult; }