From ffa863557a963b0a57e6c38d38879415ac004c39 Mon Sep 17 00:00:00 2001 From: Christopher Broderick Date: Sat, 8 Sep 2018 17:23:17 +0100 Subject: [PATCH] Release version updates --- Bundle/pom.xml | 2 +- Remote/pom.xml | 2 +- Server/pom.xml | 2 +- .../org/openas2/app/FilenameParsingTest.java | 91 +++++++++++++++++++ pom.xml | 2 +- 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 Server/src/test/java/org/openas2/app/FilenameParsingTest.java diff --git a/Bundle/pom.xml b/Bundle/pom.xml index f13e79f2..ab6f64af 100644 --- a/Bundle/pom.xml +++ b/Bundle/pom.xml @@ -6,7 +6,7 @@ net.sf.openas2 OpenAS2 - 2.6.0 + 2.6.1 openas2-osgi diff --git a/Remote/pom.xml b/Remote/pom.xml index 10d65851..b494c03b 100644 --- a/Remote/pom.xml +++ b/Remote/pom.xml @@ -4,7 +4,7 @@ net.sf.openas2 OpenAS2 - 2.6.0 + 2.6.1 4.0.0 diff --git a/Server/pom.xml b/Server/pom.xml index 7576dfa0..76e2b52d 100644 --- a/Server/pom.xml +++ b/Server/pom.xml @@ -6,7 +6,7 @@ net.sf.openas2 OpenAS2 - 2.6.0 + 2.6.1 openas2-server diff --git a/Server/src/test/java/org/openas2/app/FilenameParsingTest.java b/Server/src/test/java/org/openas2/app/FilenameParsingTest.java new file mode 100644 index 00000000..da34227e --- /dev/null +++ b/Server/src/test/java/org/openas2/app/FilenameParsingTest.java @@ -0,0 +1,91 @@ +package org.openas2.app; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.openas2.TestResource; +import org.openas2.XMLSession; +import org.openas2.message.AS2Message; +import org.openas2.message.FileAttribute; +import org.openas2.message.Message; +import org.openas2.partner.Partnership; +import org.openas2.partner.PartnershipFactory; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +@RunWith(MockitoJUnitRunner.class) + +public class FilenameParsingTest { + private static final TestResource RESOURCE = TestResource.forGroup("SingleServerTest"); + private static String myCompanyOid = "MyCompany_OID"; + private static String myPartnerOid = "PartnerA_OID"; + private static String testFileNamePart1 = "abc"; + private static String testFileNamePart2 = "123"; + private static String testFileName = testFileNamePart1 + "-" + testFileNamePart2 + ".txt"; + private static String fileNameRegex = "([^-]*)-([^.]*).txt"; + private static String attribNamesFromFileName1 = "X-attribute1"; + private static String attribNamesFromFileName2 = "Y-attribute2"; + private static String attribNamesFromFileName = attribNamesFromFileName1 + "," + attribNamesFromFileName2; + private static String subjectAttrib = "First part filename: $attributes." + attribNamesFromFileName1 + + "$ Second part filename: $attributes." + attribNamesFromFileName2 + "$"; + private static String expectedSubject = "First part filename: " + testFileNamePart1 + + " Second part filename: " + testFileNamePart2; + + // private static File openAS2AHome; + private static XMLSession session; + private static Message msg; + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @BeforeClass + public static void setup() throws Exception { + try { + System.setProperty("org.apache.commons.logging.Log", "org.openas2.logging.Log"); + //System.setProperty("org.openas2.logging.defaultlog", "TRACE"); + FilenameParsingTest.session = new XMLSession(RESOURCE.get("MyCompany", "config", "config.xml").getAbsolutePath()); + msg = new AS2Message(); + msg.setAttribute(FileAttribute.MA_FILENAME, testFileName); + PartnershipFactory pf = session.getPartnershipFactory(); + Partnership myPartnership = msg.getPartnership(); + myPartnership.setSenderID(Partnership.PID_AS2, myCompanyOid); + myPartnership.setReceiverID(Partnership.PID_AS2, myPartnerOid); + myPartnership.setSenderID(Partnership.PID_AS2, myCompanyOid); + + + Partnership configuredPartnership = pf.getPartnership(myPartnership, false); + configuredPartnership.setAttribute(Partnership.PAIB_VALUES_REGEX_ON_FILENAME, fileNameRegex); + configuredPartnership.setAttribute(Partnership.PAIB_NAMES_FROM_FILENAME, attribNamesFromFileName); + configuredPartnership.setAttribute(Partnership.PA_SUBJECT, subjectAttrib); + // update the message's partnership with any stored information + pf.updatePartnership(msg, true); + + } catch (Throwable e) { + // aid for debugging JUnit tests + System.err.println("ERROR occurred: " + ExceptionUtils.getStackTrace(e)); + throw new Exception(e); + } + } + + @AfterClass + public static void tearDown() throws Exception { + session = null; + } + + @Test + public void shouldHaveAddedAttributes() throws Exception { + assertThat("Verify 1st attribute added from filename", msg.getAttribute(attribNamesFromFileName1), + equalTo(testFileNamePart1)); + assertThat("Verify 2nd attribute added from filename", msg.getAttribute(attribNamesFromFileName2), + equalTo(testFileNamePart2)); + assertThat("Verify message subject", msg.getSubject(), + equalTo(expectedSubject)); + } + +} diff --git a/pom.xml b/pom.xml index 3093dcb9..85cf0e4e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.sf.openas2 OpenAS2 - 2.6.0 + 2.6.1 OpenAS2 pom