Skip to content

Commit

Permalink
Adjust test after previous change and add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
centic9 committed Aug 28, 2024
1 parent d309159 commit b7f5a2f
Showing 1 changed file with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package org.dstadler.poiandroidtest.poitest;

import android.content.res.Resources;

import org.apache.commons.io.output.NullOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.poifs.crypt.TestSignatureInfo;
import org.apache.poi.ss.usermodel.Workbook;
import org.dstadler.poiandroidtest.poitest.dummy.DummyContent;
import org.dstadler.poiandroidtest.poitest.test.TestIssue28;
import org.dstadler.poiandroidtest.poitest.test.TestIssue75;
import org.dstadler.poiandroidtest.poitest.test.TestIssue84;
import org.dstadler.poiandroidtest.poitest.test.TestIssue89;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.io.InputStream;

import androidx.test.ext.junit.runners.AndroidJUnit4;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.fail;

/**
Expand All @@ -39,6 +47,26 @@ public void test28() throws IOException {
TestIssue28.saveExcelFile(NullOutputStream.INSTANCE);
}

@Ignore("Could not make reading the files from the raw resources work...")
@Test
public void test75() throws IOException {
Resources resources = getInstrumentation()
.getContext()
.getResources();

try (InputStream pictureStream = resources.openRawResource(R.raw.logo)) {
TestIssue75.saveExcelFile(pictureStream, NullOutputStream.INSTANCE, Workbook.PICTURE_TYPE_JPEG);
}

try (InputStream pictureStream = resources.openRawResource(R.raw.logo_png)) {
TestIssue75.saveExcelFile(pictureStream, NullOutputStream.INSTANCE, Workbook.PICTURE_TYPE_PNG);
}

try (InputStream pictureStream = resources.openRawResource(R.raw.logo_bmp)) {
TestIssue75.saveExcelFile(pictureStream, NullOutputStream.INSTANCE, Workbook.PICTURE_TYPE_DIB);
}
}

@Test
public void test84() throws IOException {
try {
Expand All @@ -51,11 +79,11 @@ public void test84() throws IOException {

@Test
public void test89() {
try {
TestIssue89.saveExcelFile(NullOutputStream.INSTANCE);
fail("Usually throws an exception because there are missing AWT classes");
} catch (NoClassDefFoundError e) {
// expected here
}
TestIssue89.saveExcelFile(NullOutputStream.INSTANCE);
}

@Test
public void testSignatureInfo() {
new TestSignatureInfo().testConstruct();
}
}

0 comments on commit b7f5a2f

Please sign in to comment.