Skip to content

Commit 8c28e66

Browse files
committed
Added test file
1 parent 8fb77ee commit 8c28e66

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (C) 2015-2024 Philip Helger (www.helger.com)
3+
* philip[at]helger[dot]com
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.helger.phase4.peppol.receivers;
18+
19+
import java.io.File;
20+
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
23+
import org.w3c.dom.Element;
24+
25+
import com.helger.peppol.sml.ESML;
26+
import com.helger.peppolid.IParticipantIdentifier;
27+
import com.helger.phase4.dump.AS4DumpManager;
28+
import com.helger.phase4.dump.AS4IncomingDumperFileBased;
29+
import com.helger.phase4.dump.AS4OutgoingDumperFileBased;
30+
import com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile;
31+
import com.helger.phase4.peppol.Phase4PeppolSender;
32+
import com.helger.phase4.sender.EAS4UserMessageSendResult;
33+
import com.helger.servlet.mock.MockServletContext;
34+
import com.helger.smpclient.peppol.SMPClientReadOnly;
35+
import com.helger.web.scope.mgr.WebScopeManager;
36+
import com.helger.xml.serialize.read.DOMReader;
37+
38+
/**
39+
* Example for sending something to the acube.io [IT] Test endpoint.
40+
*
41+
* @author Philip Helger
42+
*/
43+
public final class MainPhase4PeppolSenderGDP
44+
{
45+
private static final Logger LOGGER = LoggerFactory.getLogger (MainPhase4PeppolSenderGDP.class);
46+
47+
public static void send ()
48+
{
49+
try
50+
{
51+
final Element aPayloadElement = DOMReader.readXMLDOM (new File ("src/test/resources/external/examples/base-example.xml"))
52+
.getDocumentElement ();
53+
if (aPayloadElement == null)
54+
throw new IllegalStateException ("Failed to read XML file to be send");
55+
56+
// Start configuring here
57+
// 0106:32070687
58+
final IParticipantIdentifier aReceiverID = Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9998:gdp-edi");
59+
final EAS4UserMessageSendResult eResult;
60+
eResult = Phase4PeppolSender.builder ()
61+
.documentTypeID (Phase4PeppolSender.IF.createDocumentTypeIdentifierWithDefaultScheme ("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1"))
62+
.processID (Phase4PeppolSender.IF.createProcessIdentifierWithDefaultScheme ("urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"))
63+
.senderParticipantID (Phase4PeppolSender.IF.createParticipantIdentifierWithDefaultScheme ("9915:phase4-test-sender"))
64+
.receiverParticipantID (aReceiverID)
65+
.senderPartyID ("POP000306")
66+
.countryC1 ("AT")
67+
.payload (aPayloadElement)
68+
.smpClient (new SMPClientReadOnly (Phase4PeppolSender.URL_PROVIDER,
69+
aReceiverID,
70+
ESML.DIGIT_TEST))
71+
.rawResponseConsumer (new AS4RawResponseConsumerWriteToFile ())
72+
.sendMessageAndCheckForReceipt ();
73+
LOGGER.info ("Peppol send result: " + eResult);
74+
}
75+
catch (final Exception ex)
76+
{
77+
LOGGER.error ("Error sending Peppol message via AS4", ex);
78+
}
79+
}
80+
81+
public static void main (final String [] args)
82+
{
83+
WebScopeManager.onGlobalBegin (MockServletContext.create ());
84+
85+
// Dump (for debugging purpose only)
86+
AS4DumpManager.setIncomingDumper (new AS4IncomingDumperFileBased ());
87+
AS4DumpManager.setOutgoingDumper (new AS4OutgoingDumperFileBased ());
88+
89+
try
90+
{
91+
send ();
92+
}
93+
finally
94+
{
95+
WebScopeManager.onGlobalEnd ();
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)