use of com.helger.smpclient.peppol.SMPClient in project peppol-commons by phax.
the class MainCheckIfSMPIsWorking method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Ensure that the service group does not exist
LOGGER.info("Ensuring that the service group is not existing!");
if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null) {
LOGGER.info("Deleting existing service group for init");
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Finished deletion of service group");
}
// Create, read and delete the service group
LOGGER.info("Creating the new service group");
aClient.saveServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Retrieving the service group");
final ServiceGroupType aSGT = aClient.getServiceGroup(PARTICIPANT_ID);
if (!SimpleParticipantIdentifier.wrap(aSGT.getParticipantIdentifier()).equals(PARTICIPANT_ID))
throw new IllegalStateException("Participant identifiers are not equal!");
LOGGER.info("Deleting the service group again");
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Checking if the service group is really deleted");
if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null)
throw new IllegalStateException("Deletion of the service group failed!");
LOGGER.info("Seems like the SMP is working as expected!");
}
use of com.helger.smpclient.peppol.SMPClient in project peppol-commons by phax.
the class MainSMPServiceGroupCompleteList method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Get the service group reference list
final CompleteServiceGroupType aCompleteServiceGroup = aClient.getCompleteServiceGroupOrNull(PARTICIPANT_ID);
if (aCompleteServiceGroup == null)
LOGGER.error("Failed to get complete service group for " + PARTICIPANT_ID);
else {
LOGGER.info(SMPDebugHelper.getAsString(aCompleteServiceGroup.getServiceGroup()));
for (final ServiceMetadataType aServiceMetadata : aCompleteServiceGroup.getServiceMetadata()) LOGGER.info(SMPDebugHelper.getAsString(aServiceMetadata));
}
LOGGER.info("Done");
}
use of com.helger.smpclient.peppol.SMPClient in project peppol-commons by phax.
the class MainSMPServiceGroupDelete method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Delete the service group
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Done");
}
use of com.helger.smpclient.peppol.SMPClient in project peppol-commons by phax.
the class MainSMPServiceGroupReferenceList method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final String SMP_USERNAME = MockSMPClientConfig.getSMPUserName();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Get the service group reference list
final ServiceGroupReferenceListType aServiceGroupReferenceList = aClient.getServiceGroupReferenceListOrNull(SMP_USERNAME, SMP_CREDENTIALS);
if (aServiceGroupReferenceList == null)
LOGGER.error("Failed to get complete service group for " + SMP_USERNAME);
else {
LOGGER.info("All service groups owned by " + SMP_USERNAME + ":");
for (final ServiceGroupReferenceType aServiceGroupReference : aServiceGroupReferenceList.getServiceGroupReference()) LOGGER.info(" " + aServiceGroupReference.getHref());
}
LOGGER.info("Done");
}
use of com.helger.smpclient.peppol.SMPClient in project phoss-smp by phax.
the class ServiceGroupInterfaceTest method testCreateAndDeleteServiceGroupSMPClient.
@Test
public void testCreateAndDeleteServiceGroupSMPClient() throws SMPClientException {
// Lower case version
final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:de203827312");
// Upper case version
final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:DE203827312");
final ServiceGroupType aSG = new ServiceGroupType();
aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final SMPClient aSMPClient = new MockSMPClient();
// GET
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
try {
// PUT 1 - create
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
// Both regular and upper case must work
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// PUT 2 - overwrite
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
// Both regular and upper case must work
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// DELETE 1
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
// Both must be deleted
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
} finally {
// DELETE 2
try {
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
// Both must be deleted
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
}
}
Aggregations