Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma</groupId>
<artifactId>corporate-parent</artifactId>
<version>2.8.1</version>
<version>3.0.3</version>
<relativePath />
</parent>
<groupId>com.opengamma.sdk</groupId>
Expand Down Expand Up @@ -66,6 +66,10 @@

<!-- ==================================================================== -->
<properties>
<!-- corporate-parent 3.0.3 defaults to Java 21; this SDK must stay on Java 8 -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
<!-- Version -->
<logback-classic.version>1.2.13</logback-classic.version>
<!-- Properties for joda-beans-maven-plugin -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -15,9 +16,12 @@
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import org.joda.beans.Bean;
Expand All @@ -34,7 +38,7 @@ public class PortfolioDataFileTest {
public void test_ofString_small() {
PortfolioDataFile test = PortfolioDataFile.of("name.txt", "a=b");
assertThat(test.getName()).isEqualTo("name.txt.gz.base64");
assertThat(test.getData()).isEqualTo("H4sIAAAAAAAAAEu0TQIAzzAAfwMAAAA=");
assertThat(test.getData()).isEqualTo(Base64.getEncoder().encodeToString(gzip("a=b")));
}

@Test
Expand Down Expand Up @@ -101,12 +105,30 @@ public void test_ofBean_trade() {

//-------------------------------------------------------------------------
@Test
public void test_ofCombined() {
public void test_ofCombined() throws IOException {
Path path1 = Paths.get("src/test/resources/simple.xml");
Path path2 = Paths.get("src/test/resources/simple.xls");
PortfolioDataFile test = PortfolioDataFile.ofCombined(Arrays.asList(path1, path2));
assertThat(test.getName()).isEqualTo("JavaSDK.zip.base64");
assertThat(test.getData()).isEqualTo(Base64.getEncoder().encodeToString(zip(path1, path2)));
byte[] actualZipBytes = Base64.getDecoder().decode(test.getData());
assertThat(unzipEntries(actualZipBytes)).isEqualTo(unzipEntries(zip(path1, path2)));
}

private static Map<String, String> unzipEntries(byte[] zipBytes) throws IOException {
Map<String, String> entries = new LinkedHashMap<>();
try (ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(zipBytes))) {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[4096];
int len;
while ((len = zis.read(buf)) != -1) {
baos.write(buf, 0, len);
}
entries.put(entry.getName(), Base64.getEncoder().encodeToString(baos.toByteArray()));
}
}
return entries;
}

private static byte[] gzip(String str) {
Expand Down
6 changes: 5 additions & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma</groupId>
<artifactId>corporate-parent</artifactId>
<version>2.8.1</version>
<version>3.0.3</version>
<relativePath />
</parent>
<groupId>com.opengamma.sdk</groupId>
Expand Down Expand Up @@ -411,6 +411,10 @@

<!-- ==================================================================== -->
<properties>
<!-- corporate-parent 3.0.3 defaults to Java 21; this SDK must stay on Java 8 -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
<!-- Versions -->
<assertj.version>3.25.3</assertj.version>
<jcommander.version>1.82</jcommander.version>
Expand Down