Package org.springframework.core.io

Examples of org.springframework.core.io.ByteArrayResource


        template.sendSourceAndReceiveToResult(new StringSource(actual), result);
    }

    @Test(expected = AssertionError.class)
    public void xsdNonMatch() throws Exception {
        Resource schema = new ByteArrayResource(
                "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://example.com\" elementFormDefault=\"qualified\"><element name=\"request\"/></schema>".getBytes());

        server.expect(validPayload(schema));

        StringResult result = new StringResult();
View Full Code Here


    @Test
    public void withPayloadResource() throws Exception {
        String payload = "<payload xmlns='http://springframework.org'/>";
        ResponseCreator responseCreator =
                ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes("UTF-8")));

        WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);

        assertXMLEqual(payload, getPayloadAsString(response));
    }
View Full Code Here

    xmlBuilder.append("<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>");
    xmlBuilder.append("<soap:Header><header xmlns='http://springframework.org'/></soap:Header>");
    xmlBuilder.append("<soap:Body><payload xmlns='http://springframework.org'/></soap:Body>");
    xmlBuilder.append("</soap:Envelope>");
    String envelope = xmlBuilder.toString();
    ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new ByteArrayResource(envelope.getBytes("UTF-8")));
        WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);
        assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response));
    }
View Full Code Here

        assertNotNull("Invalid accept header", resultAccept);
    }

    @Override
    public void testWriteToTransportResponseAttachment() throws Exception {
        InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
        soapMessage.addAttachment("contentId", inputStreamSource, "text/plain");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        soapMessage.writeTo(tos);
        String contentType = tos.getHeaders().get("Content-Type");
View Full Code Here

        assertNotNull("Invalid accept header", resultAccept);
    }

    @Override
    public void testWriteToTransportResponseAttachment() throws Exception {
        InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
        soapMessage.addAttachment("contentId", inputStreamSource, "text/plain");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        soapMessage.writeTo(tos);
        String contentType = tos.getHeaders().get("Content-Type");
View Full Code Here

        "create table ${hiveconf:xxx} (key int, value string);";
    String script = "DROP TABLE IF EXISTS ${hiveconf:xxx};set zzz;set hiveconf:yyy;" +
        "create table ${hiveconf:xxx} (key int, value string);" +
        "LOAD DATA LOCAL INPATH '${hiveconf:data}' INTO TABLE ${hiveconf:xxx};" +
        "select count(1) from ${hiveconf:xxx};";
    Resource prep = new ByteArrayResource(prepScript.getBytes());
    Resource res = new ByteArrayResource(script.getBytes());
    Properties params = new Properties();
    params.put("xxx", "nonExisting");
    params.put("data", uri);
    params.put("zzz", "onions");
    params.put("yyy", "unleashed");
View Full Code Here

    assertEquals("10", run.get(2));
  }

  @Test
  public void testScriptParams() throws Exception {
    Resource res = new ByteArrayResource("set zzz;set hiveconf:yyy;".getBytes());
    Properties params = new Properties();
    params.put("zzz", "onions");
    params.put("yyy", "unleashed");

    List<String> run = template.executeScript(new HiveScript(res, params));
View Full Code Here

            + "\">"
            + config
            + "</server>";

        XmlBeanFactory factory = new XmlBeanFactory(
                new ByteArrayResource(completeConfig.getBytes()));
       
        return (FtpServer) factory.getBean("server");

    }
View Full Code Here

        } catch (TuboResourceException e) {
            throw new TuboResourceException("Tubo configuration can't be created",e);
        }
        //
        // create Bean Factory
        ByteArrayResource byteResource = new ByteArrayResource(stringResource.getBytes());
        BeanFactory beanFactory = new XmlBeanFactory(byteResource);
        //
        // get resource manager
        SpringResourceManagerImpl rm = null;
        try {
View Full Code Here

        engine.setContext((ScriptContext) EasyMock.anyObject());
        EasyMock.expect(engine.eval((Reader) EasyMock.anyObject())).andReturn(null);
        EasyMock.replay(engine);

        scriptedView.setEngineName("test-engine");
        scriptedView.setScript(new ByteArrayResource("test".getBytes(), "test script"));

        JComponent control = scriptedView.createControl();
        System.out.println(control);

        EasyMock.verify(engine);
View Full Code Here

TOP

Related Classes of org.springframework.core.io.ByteArrayResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.