当前位置: 首页>>代码示例>>Java>>正文


Java StreamingOutput.write方法代码示例

本文整理汇总了Java中javax.ws.rs.core.StreamingOutput.write方法的典型用法代码示例。如果您正苦于以下问题:Java StreamingOutput.write方法的具体用法?Java StreamingOutput.write怎么用?Java StreamingOutput.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.StreamingOutput的用法示例。


在下文中一共展示了StreamingOutput.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDownloadDataBlobError

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testDownloadDataBlobError() throws Exception {
	final URL jarLocation = getBlobFile();
	InputStream openStream = null;
	try {
		// Get the JAR input
		openStream = jarLocation.openStream();

		// Proceed to the test
		resource.prepareData(openStream, 1);
		final StreamingOutput downloadLobFile = resource.downloadLobFile();
		final OutputStream output = Mockito.mock(OutputStream.class);
		Mockito.doThrow(new IOException()).when(output).write(ArgumentMatchers.any(byte[].class));

		downloadLobFile.write(output);
	} finally {
		IOUtils.closeQuietly(openStream);
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:20,代码来源:JpaBenchResourceTest.java

示例2: testDownloadDataBlob

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void testDownloadDataBlob() throws Exception {
	final URL jarLocation = getBlobFile();
	InputStream openStream = null;
	try {
		// Get the JAR input
		openStream = jarLocation.openStream();

		// Proceed to the test
		resource.prepareData(openStream, 1);
		final StreamingOutput downloadLobFile = resource.downloadLobFile();
		final ByteArrayOutputStream output = new ByteArrayOutputStream();
		downloadLobFile.write(output);
		org.junit.Assert.assertTrue(output.toByteArray().length > 3000000);
	} finally {
		IOUtils.closeQuietly(openStream);
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:19,代码来源:JpaBenchResourceTest.java

示例3: getStatusHistory

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getStatusHistory() throws Exception {
	final int subscription = getSubscription("MDA");
	final StreamingOutput csv = (StreamingOutput) resource.getStatusHistory(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
	final BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray()), "cp1252"));
	final String header = inputStreamReader.readLine();
	Assert.assertEquals("issueid;key;author;from;to;fromText;toText;date;dateTimestamp", header);
	String lastLine = inputStreamReader.readLine();
	Assert.assertEquals("11432;MDA-1;fdaugan;;1;;OPEN;2009/03/23 15:26:43;1237818403000", lastLine);
	lastLine = inputStreamReader.readLine();
	Assert.assertEquals("11437;MDA-4;xsintive;;1;;OPEN;2009/03/23 16:23:31;1237821811000", lastLine);
	lastLine = inputStreamReader.readLine();
	lastLine = inputStreamReader.readLine();
	lastLine = inputStreamReader.readLine();
	lastLine = inputStreamReader.readLine();
	Assert.assertEquals("11535;MDA-8;challer;;1;;OPEN;2009/04/01 14:20:29;1238588429000", lastLine);
	lastLine = inputStreamReader.readLine();
	lastLine = inputStreamReader.readLine();
	lastLine = inputStreamReader.readLine();
	Assert.assertEquals("11535;MDA-8;fdaugan;1;10024;OPEN;ASSIGNED;2009/04/09 09:45:16;1239263116000", lastLine);
	lastLine = inputStreamReader.readLine();
	Assert.assertEquals("11535;MDA-8;fdaugan;10024;3;ASSIGNED;IN PROGRESS;2009/04/09 09:45:30;1239263130000", lastLine);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:26,代码来源:JiraExportPluginResourceTest.java

示例4: getConsole

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getConsole() throws Exception {
	prepareMockHome();
	httpServer.stubFor(get(urlPathEqualTo("/api/vApp/vm-75aa69b4-8cff-40cd-9338-9abafc7d5935/screen"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_OK).withBody(IOUtils.toString(
					new ClassPathResource("mock-server/vcloud/vcloud-console.png").getInputStream(), StandardCharsets.UTF_8))));
	httpServer.start();

	final StreamingOutput imageStream = resource.getConsole(subscription);
	final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	imageStream.write(outputStream);
	Assert.assertTrue(outputStream.toByteArray().length > 1024);
}
 
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:14,代码来源:VCloudPluginResourceTest.java

示例5: getConsoleNotAvailable

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getConsoleNotAvailable() throws Exception {
	prepareMockHome();
	httpServer.stubFor(get(urlPathEqualTo("/api/vApp/vm-75aa69b4-8cff-40cd-9338-9abafc7d5935/screen"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
	httpServer.start();

	final StreamingOutput imageStream = resource.getConsole(subscription);
	final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	imageStream.write(outputStream);
	Assert.assertEquals(0, outputStream.toByteArray().length);
}
 
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:13,代码来源:VCloudPluginResourceTest.java

示例6: getConsoleError

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getConsoleError() throws Exception {
	prepareMockHome();
	httpServer.stubFor(get(urlPathEqualTo("/api/vApp/vm-75aa69b4-8cff-40cd-9338-9abafc7d5935/screen"))
			.willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT)));
	httpServer.start();

	final StreamingOutput imageStream = resource.getConsole(subscription);
	final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	imageStream.write(outputStream);
	Assert.assertEquals(0, outputStream.toByteArray().length);
}
 
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:13,代码来源:VCloudPluginResourceTest.java

示例7: getSimpleCsv

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getSimpleCsv() throws Exception {
	final int subscription = getSubscription("MDA");
	final StreamingOutput csv = (StreamingOutput) resource.getSimpleCsv(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
	final BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray()), "cp1252"));
	final String header = inputStreamReader.readLine();
	Assert.assertEquals("id;issue;status;statusText;type;typeText;priority;priorityText;resolution;resolutionText;"
			+ "created;createdTimestamp;reporter;assignee;dueDate;dueDateTimestamp;summary", header);
	final CsvBeanReader<CsvSimple> beanReader = new CsvBeanReader<>(inputStreamReader, CsvSimple.class, "id", "issue", "status", "statusText",
			"type", "typeText", "priority", "priorityText", "resolution", "resolutionText", "created", "createdTimestamp", "reporter", "assignee",
			"dueDate", "dueDateTimestamp", "summary");
	final CsvSimple issue = beanReader.read();
	Assert.assertEquals(11432, issue.getId());
	Assert.assertEquals("MDA-1", issue.getIssue());
	Assert.assertEquals("fdaugan", issue.getReporter());
	Assert.assertEquals("fdaugan", issue.getAssignee());
	Assert.assertEquals(1, issue.getType());
	Assert.assertEquals("Bug", issue.getTypeText());
	Assert.assertEquals(3, issue.getPriority());
	Assert.assertEquals("Major", issue.getPriorityText());
	Assert.assertEquals(6, issue.getStatus());
	Assert.assertEquals("CLOSED", issue.getStatusText());
	Assert.assertEquals(1, issue.getResolution());
	Assert.assertEquals("Fixed", issue.getResolutionText());
	Assert.assertEquals(getDate(2009, 03, 23, 15, 26, 43), issue.getCreated());
	Assert.assertEquals(1237818403000L, issue.getCreatedTimestamp());
	Assert.assertEquals("Mise à disposition d un update site pour RSM 7.0.0.4", issue.getSummary());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:31,代码来源:JiraExportPluginResourceTest.java

示例8: getSlaComputationsCsvWithCustomFields

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getSlaComputationsCsvWithCustomFields() throws Exception {
	final int subscription = getSubscription("MDA");
	final StreamingOutput csv = (StreamingOutput) resource.getSlaComputationsCsvWithCustomFields(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
	final BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray()), "cp1252"));
	final String header = inputStreamReader.readLine();
	Assert.assertEquals(
			"id;issue;status;statusText;type;typeText;priority;priorityText;resolution;resolutionText;created;createdTimestamp;reporter;assignee"
					+ ";dueDate;dueDateTimestamp;timeSpent(s);timeEstimate(s);timeEstimateInit(s);parent;components;N° DFE;Délai levée réserves (jrs)"
					+ ";Processus;cf-group;Date de livraison;Région;[SLA] Livraison(h:m:s);[SLA] Livraison(ms)"
					+ ";[SLA] Livraison(Start);[SLA] Livraison(Start timestamp);[SLA] Livraison(Stop);[SLA] Livraison(Stop timestamp)"
					+ ";[SLA] Livraison(Revised Due Date);[SLA] Livraison(Revised Due Date timestamp)"
					+ ";[SLA] Livraison(Revised Due Date distance h:m:s);[SLA] Livraison(Revised Due Date distance ms)"
					+ ";#Assigned;#Closed;#In Progress;#Open;#Reopened;#Resolved",
			header);
	String lastLine = inputStreamReader.readLine();
	Assert.assertTrue(lastLine.startsWith(
			"11432;MDA-1;6;CLOSED;1;Bug;3;Major;1;Fixed;2009/03/23 15:26:43;1237818403000;fdaugan;fdaugan;2009/03/24 00:00:00;1237849200000;12951;11951;10951;15114;;;;;;;;"));
	for (int i = 8; i-- > 0;) {
		lastLine = inputStreamReader.readLine();
	}
	Assert.assertTrue(lastLine.startsWith(
			"12706;MDA-41;1;OPEN;2;New Feature;4;Minor;;;2009/07/09 08:45:33;1247121933000;xsintive;fdaugan;;;;;;;Javascript,Java;\"V1.0\";1,25;\"Value\";;2014/01/30 16:57:00;\"E,A\";"));
	Assert.assertTrue(lastLine.endsWith(";0;1;1;2;1;0"));
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:28,代码来源:JiraExportPluginResourceTest.java

示例9: getSlaComputationsXls

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getSlaComputationsXls() throws Exception {
	final int subscription = getSubscription("MDA");
	final StreamingOutput csv = (StreamingOutput) resource.getSlaComputationsXls(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:8,代码来源:JiraExportPluginResourceTest.java

示例10: getSlaComputationsXlsNoMatchSla

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getSlaComputationsXlsNoMatchSla() throws Exception {
	final int subscription = getSubscription("MDA");
	repository.findBySubscriptionFetch(subscription).getSlas().get(0).setPriorities("TRIVIAL");
	em.flush();
	em.clear();
	final StreamingOutput csv = (StreamingOutput) resource.getSlaComputationsXls(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:11,代码来源:JiraExportPluginResourceTest.java

示例11: createChecksum

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
private StreamingOutput createChecksum(JavaIndexKey key, String filename, ChecksumWrapper checksumWrapper) 
{
	try
	{
		IndexArtifact ia = getStorage().getIndexArtifact(key, getPath());
		StreamingOutput so = getStorage().getArtifactStream(ia, checksumWrapper.getTargetFilename(filename));
   		ByteArrayOutputStream out = new ByteArrayOutputStream();
   		so.write(out);
   		
   		String checksum = checksumWrapper.getDigestString(out);
   		out.close();
   		
   		logger.info("[Warning] No checksum found, generated " + checksumWrapper.getType() + " Checksum : " + checksum);
   		
           StorageRequest sr = new StorageRequest.StorageRequestBuilder()
			                .length(checksum.length())
			                .stream(checksum.getBytes())
			                .filename(filename)
			                .build();

           addArtifactToStorage(key, sr);
           return sr.getStreamingOutput();
	}
	catch(IOException | IndexException e)
	{
   		logger.error("[ERROR] Could not generate checksum for : " + filename + ", " + e.getMessage());
		throw new NotFoundException();
	} 
}
 
开发者ID:Spedge,项目名称:hangar,代码行数:30,代码来源:JavaRepository.java

示例12: writeToOutputStream

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
private ByteArrayOutputStream writeToOutputStream(StreamingOutput output) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        try {
            output.write(outputStream);
        } finally {
            outputStream.close();
        }
    } catch (IOException e) {
        throw new InternalServerError("Failed to write content to output stream while signing response.", e);
    }
    return outputStream;
}
 
开发者ID:casid,项目名称:mazebert-ladder,代码行数:14,代码来源:SignedResponseStream.java

示例13: getResponseJson

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
private String getResponseJson() {
    StreamingOutput output = (StreamingOutput)presenterResponse.getEntity();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        output.write(outputStream);
    } catch (IOException e) {
        throw new RuntimeException("Failed to write to test output stream.", e);
    }

    return outputStream.toString();
}
 
开发者ID:casid,项目名称:mazebert-ladder,代码行数:12,代码来源:AbstractPresenterIT.java

示例14: connectorIconShouldHaveCorrectContentType

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void connectorIconShouldHaveCorrectContentType() throws IOException {
    try (MockWebServer mockWebServer = new MockWebServer(); final Buffer resultBuffer = new Buffer()) {
        mockWebServer.start();

        resultBuffer.writeAll(Okio.source(getClass().getResourceAsStream("test-image.png")));

        mockWebServer.enqueue(new MockResponse().setHeader(CONTENT_TYPE, "image/png").setBody(resultBuffer));

        final Connector connector = new Connector.Builder().id("connector-id").icon(mockWebServer.url("/u/23079786").toString())
            .build();
        when(dataManager.fetch(Connector.class, "connector-id")).thenReturn(connector);
        when(dataManager.fetchAll(Integration.class)).thenReturn(ListResult.of(Collections.emptyList()));

        final Response response = handler.getConnectorIcon("connector-id").get();

        assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK).as("Wrong status code");
        assertThat(response.getHeaderString(CONTENT_TYPE)).isEqualTo("image/png").as("Wrong content type");
        assertThat(response.getHeaderString(CONTENT_LENGTH)).isEqualTo("2018").as("Wrong content length");

        final StreamingOutput so = (StreamingOutput) response.getEntity();
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try (BufferedSink sink = Okio.buffer(Okio.sink(bos)); BufferedSource source = new Buffer();
            ImageInputStream iis = ImageIO.createImageInputStream(source.inputStream());) {
            so.write(sink.outputStream());
            source.readAll(sink);
            final Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
            if (readers.hasNext()) {
                final ImageReader reader = readers.next();
                try {
                    reader.setInput(iis);
                    final Dimension dimensions = new Dimension(reader.getWidth(0), reader.getHeight(0));
                    assertThat(dimensions.getHeight()).isEqualTo(106d).as("Wrong image height");
                    assertThat(dimensions.getWidth()).isEqualTo(106d).as("Wrong image width");
                } finally {
                    reader.dispose();
                }
            }
        }
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:42,代码来源:ConnectorHandlerTest.java

示例15: getSlaComputationsCsvFiltered

import javax.ws.rs.core.StreamingOutput; //导入方法依赖的package包/类
@Test
public void getSlaComputationsCsvFiltered() throws Exception {
	final int subscription = getSubscription("MDA");
	slaRepository.findBySubscription(subscription).get(0).setTypes("Bug,New Feature");
	slaRepository.findBySubscription(subscription).get(0).setPriorities("Blocker,Critical");
	slaRepository.findBySubscription(subscription).get(0).setResolutions("Fixed,Won't Fix");

	final StreamingOutput csv = (StreamingOutput) resource.getSlaComputationsCsv(subscription, "file1").getEntity();
	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	csv.write(out);
	final BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray()), "cp1252"));
	final String header = inputStreamReader.readLine();
	Assert.assertEquals(
			"id;issue;status;statusText;type;typeText;priority;priorityText;resolution;resolutionText;created;createdTimestamp;reporter;assignee"
					+ ";dueDate;dueDateTimestamp;[SLA] Livraison(h:m:s);[SLA] Livraison(ms);[SLA] Livraison(Start);[SLA] Livraison(Start timestamp)"
					+ ";[SLA] Livraison(Stop);[SLA] Livraison(Stop timestamp);[SLA] Livraison(Revised Due Date);[SLA] Livraison(Revised Due Date timestamp)"
					+ ";[SLA] Livraison(Revised Due Date distance h:m:s);[SLA] Livraison(Revised Due Date distance ms)"
					+ ";#Assigned;#Closed;#In Progress;#Open;#Reopened;#Resolved",
			header);
	final CsvBeanReader<CsvChange> beanReader = new CsvBeanReader<>(inputStreamReader, CsvChange.class, "id", "issue", "status", "statusText",
			"type", "typeText", "priority", "priorityText", "resolution", "resolutionText", "created", "createdTimestamp", "reporter", "assignee",
			"dueDate", "dueDateTimestamp", "slaLivraison", "slaLivraisonMs", "slaLivraisonStart", "slaLivraisonStartTimestamp",
			"slaLivraisonStop", "slaLivraisonStopTimestamp", "slaRevisedDueDate", "slaRevisedDueDateTimestamp", "slaRevisedDueDateDistance",
			"slaRevisedDueDateDistanceMs", "nbAssigned", "nbClosed", "nbInProgress", "nbOpen", "nbReopened", "nbResolved");
	CsvChange issue = beanReader.read();
	boolean issue174 = true;
	int count = 0;
	while (issue != null) {
		if (count == 0) {
			Assert.assertEquals(11432, issue.getId());
			Assert.assertEquals("MDA-1", issue.getIssue());
			Assert.assertEquals("fdaugan", issue.getReporter());
			Assert.assertEquals("fdaugan", issue.getAssignee());
			Assert.assertEquals(1, issue.getType());
			Assert.assertEquals("Bug", issue.getTypeText());
			Assert.assertEquals(3, issue.getPriority());
			Assert.assertEquals("Major", issue.getPriorityText());
			Assert.assertEquals(6, issue.getStatus());
			Assert.assertEquals("CLOSED", issue.getStatusText());
			Assert.assertEquals(1, issue.getResolution());
			Assert.assertEquals("Fixed", issue.getResolutionText());
			Assert.assertEquals(getDate(2009, 03, 23, 15, 26, 43), issue.getCreated());
			Assert.assertEquals(1237818403000L, issue.getCreatedTimestamp());
			Assert.assertNull(issue.getSlaLivraison());
			Assert.assertEquals(0, issue.getSlaLivraisonMs());
			Assert.assertEquals(1, issue.getNbClosed());
			Assert.assertEquals(1, issue.getNbOpen());
			Assert.assertEquals(1, issue.getNbResolved());
			Assert.assertEquals(0, issue.getNbReopened());
			Assert.assertEquals(0, issue.getNbInProgress());
			Assert.assertEquals(0, issue.getNbAssigned());
		}
		if (issue.getIssue().equals("MDA-174")) {
			issue174 = true;
			Assert.assertEquals(14825, issue.getId());
			Assert.assertEquals("MDA-174", issue.getIssue());
			Assert.assertEquals("rfumery", issue.getReporter());
			Assert.assertEquals("fdaugan", issue.getAssignee());
			Assert.assertEquals(2, issue.getType());
			Assert.assertEquals("New Feature", issue.getTypeText());
			Assert.assertEquals(3, issue.getPriority());
			Assert.assertEquals("Major", issue.getPriorityText());
			Assert.assertEquals(1, issue.getResolution());
			Assert.assertEquals("Fixed", issue.getResolutionText());
			Assert.assertEquals(6, issue.getStatus());
			Assert.assertEquals("CLOSED", issue.getStatusText());
			Assert.assertEquals(getDate(2009, 11, 30, 14, 59, 11), issue.getCreated());
			Assert.assertEquals(1259589551000L, issue.getCreatedTimestamp());
			Assert.assertNull(issue.getSlaLivraison());
			Assert.assertEquals(0, issue.getSlaLivraisonMs());
			Assert.assertEquals(1, issue.getNbClosed());
			Assert.assertEquals(1, issue.getNbOpen());
			Assert.assertEquals(1, issue.getNbResolved());
		}
		count++;
		issue = beanReader.read();
	}
	Assert.assertTrue(issue174);
	Assert.assertEquals(197, count);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:81,代码来源:JiraExportPluginResourceTest.java


注:本文中的javax.ws.rs.core.StreamingOutput.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。