From a65dd692c739e14fdb90bc29274ec9a17dfd25c7 Mon Sep 17 00:00:00 2001 From: Zach Wassall Date: Mon, 11 Jan 2016 15:49:52 -0500 Subject: [PATCH] Issue #2: Fixed to use new String(license.getText()). --- .../report/SampleReportDataLicenseText.java | 4 +- .../test/SampleReportDataLicenseTextTest.java | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 protex-sdk-examples/src/test/java/com/blackducksoftware/sdk/protex/client/examples/test/SampleReportDataLicenseTextTest.java diff --git a/protex-sdk-examples/src/main/java/com/blackducksoftware/sdk/protex/client/examples/report/SampleReportDataLicenseText.java b/protex-sdk-examples/src/main/java/com/blackducksoftware/sdk/protex/client/examples/report/SampleReportDataLicenseText.java index e4b4714..979e3fe 100644 --- a/protex-sdk-examples/src/main/java/com/blackducksoftware/sdk/protex/client/examples/report/SampleReportDataLicenseText.java +++ b/protex-sdk-examples/src/main/java/com/blackducksoftware/sdk/protex/client/examples/report/SampleReportDataLicenseText.java @@ -13,7 +13,7 @@ /** * This sample gathers the data to generate the report section "License Texts" - * + * * It demonstrates: * - How to get the license info for a Bill of Material (BOM) * - How to retrieve a license by ID (including the license text) @@ -100,7 +100,7 @@ public static void main(String[] args) throws Exception { if (license != null) { System.out.println("*** " + license.getName() + "*** "); - System.out.println(license.getText()); + System.out.println(new String(license.getText())); } } diff --git a/protex-sdk-examples/src/test/java/com/blackducksoftware/sdk/protex/client/examples/test/SampleReportDataLicenseTextTest.java b/protex-sdk-examples/src/test/java/com/blackducksoftware/sdk/protex/client/examples/test/SampleReportDataLicenseTextTest.java new file mode 100644 index 0000000..a40dee3 --- /dev/null +++ b/protex-sdk-examples/src/test/java/com/blackducksoftware/sdk/protex/client/examples/test/SampleReportDataLicenseTextTest.java @@ -0,0 +1,58 @@ +package com.blackducksoftware.sdk.protex.client.examples.test; + +import java.io.File; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.blackducksoftware.sdk.protex.client.examples.report.SampleReportDataLicenseText; +import com.blackducksoftware.sdk.protex.client.examples.test.type.AbstractSdkSampleTest; +import com.blackducksoftware.sdk.protex.client.examples.test.type.TestSources; +import com.blackducksoftware.sdk.protex.client.examples.test.type.Tests; +import com.blackducksoftware.sdk.protex.license.LicenseCategory; +import com.blackducksoftware.sdk.protex.project.AnalysisSourceLocation; +import com.blackducksoftware.sdk.protex.project.ProjectRequest; + +public class SampleReportDataLicenseTextTest extends AbstractSdkSampleTest { + + private String projectId; + + @BeforeClass + protected void createProject() throws Exception { + ProjectRequest projectRequest = new ProjectRequest(); + projectRequest.setName("SampleReportDataLicenseTextTest Project"); + + AnalysisSourceLocation sourceLocation = TestSources.getAnalysisSourceLocation(getProxy()); + + projectRequest.setAnalysisSourceLocation(sourceLocation); + projectRequest.setLicenseId("gpl20"); + + projectId = getProxy().getProjectApi().createProject(projectRequest, LicenseCategory.OPEN_SOURCE); + + TestSources.synchronousSourceScan(getProxy(), projectId, 1000); + } + + @Test(groups = { Tests.SOURCE_DEPENDENT_TEST }) + public void runSample() throws Exception { + File tempFile = File.createTempFile("thing", ".html"); + + String[] args = new String[4]; + args[0] = Tests.getServerUrl(); + args[1] = Tests.getServerUsername(); + args[2] = Tests.getServerPassword(); + args[3] = projectId; + + SampleReportDataLicenseText.main(args); + + tempFile.deleteOnExit(); + } + + @AfterClass(alwaysRun = true) + protected void deleteProject() throws Exception { + if (projectId != null) { + getProxy().getProjectApi().deleteProject(projectId); + } + } + +}