Search in sources :

Example 16 with StopWatch

use of com.helger.commons.timing.StopWatch in project phoss-smp by phax.

the class MainCreateManyEndpoints method main.

public static void main(final String[] args) throws Throwable {
    final String sServerBasePath = "http://localhost:90";
    final WebScopeTestRule aRule = new WebScopeTestRule();
    aRule.before();
    try {
        final StopWatch aSWOverall = StopWatch.createdStarted();
        final ObjectFactory aObjFactory = new ObjectFactory();
        for (final EPredefinedDocumentTypeIdentifier aEDT : new EPredefinedDocumentTypeIdentifier[] { EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30, EPredefinedDocumentTypeIdentifier.CREDITNOTE_EN16931_PEPPOL_V30, EPredefinedDocumentTypeIdentifier.CROSSINDUSTRYINVOICE_CEN_EU_EN16931_2017, EPredefinedDocumentTypeIdentifier.INVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_1_2, EPredefinedDocumentTypeIdentifier.CREDITNOTE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_1_2, EPredefinedDocumentTypeIdentifier.CROSSINDUSTRYINVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_1_2, EPredefinedDocumentTypeIdentifier.INVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_0, EPredefinedDocumentTypeIdentifier.CREDITNOTE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_0, EPredefinedDocumentTypeIdentifier.CROSSINDUSTRYINVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_02, EPredefinedDocumentTypeIdentifier.INVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_0_CONFORMANT_XOEV_DE_KOSIT_EXTENSION_XRECHNUNG_2_0, EPredefinedDocumentTypeIdentifier.CREDITNOTE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_0_CONFORMANT_XOEV_DE_KOSIT_EXTENSION_XRECHNUNG_2_0, EPredefinedDocumentTypeIdentifier.CROSSINDUSTRYINVOICE_CEN_EU_EN16931_2017_COMPLIANT_XOEV_DE_KOSIT_STANDARD_XRECHNUNG_2_0_CONFORMANT_XOEV_DE_KOSIT_EXTENSION_XRECHNUNG_2_02 }) {
            final PeppolDocumentTypeIdentifier aDT = aEDT.getAsDocumentTypeIdentifier();
            final String sDT = aDT.getURIEncoded();
            final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
            for (int i = 0; i < 10_000; ++i) {
                final StopWatch aSW = StopWatch.createdStarted();
                final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
                final String sPI = aPI.getURIEncoded();
                final ServiceMetadataType aSM = new ServiceMetadataType();
                final ServiceInformationType aSI = new ServiceInformationType();
                aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI));
                aSI.setDocumentIdentifier(aDT);
                {
                    final ProcessListType aPL = new ProcessListType();
                    final ProcessType aProcess = new ProcessType();
                    aProcess.setProcessIdentifier(aProcID);
                    final ServiceEndpointList aSEL = new ServiceEndpointList();
                    final EndpointType aEndpoint = new EndpointType();
                    aEndpoint.setEndpointReference(W3CEndpointReferenceHelper.createEndpointReference("http://test.smpserver/as2"));
                    aEndpoint.setRequireBusinessLevelSignature(false);
                    aEndpoint.setCertificate("blacert");
                    aEndpoint.setServiceDescription("Unit test service");
                    aEndpoint.setTechnicalContactUrl("https://github.com/phax/phoss-smp");
                    aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_PEPPOL_AS4_V2.getID());
                    aSEL.addEndpoint(aEndpoint);
                    aProcess.setServiceEndpointList(aSEL);
                    aPL.addProcess(aProcess);
                    aSI.setProcessList(aPL);
                }
                aSM.setServiceInformation(aSI);
                try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
                    // Delete old - don't care about the result
                    if (false)
                        ClientBuilder.newClient().target(sServerBasePath).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
                    // Create a new
                    final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(aObjFactory.createServiceMetadata(aSM)));
                    _testResponseJerseyClient(aResponseMsg, 200);
                }
                aSW.stop();
                LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
            }
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : WebScoped(com.helger.web.scope.mgr.WebScoped) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) PeppolProcessIdentifier(com.helger.peppolid.peppol.process.PeppolProcessIdentifier) WebScopeTestRule(com.helger.web.scope.mock.WebScopeTestRule) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) EPredefinedDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.EPredefinedDocumentTypeIdentifier) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) StopWatch(com.helger.commons.timing.StopWatch) PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) Response(javax.ws.rs.core.Response) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) ObjectFactory(com.helger.xsds.peppol.smp1.ObjectFactory) PeppolDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ProcessListType(com.helger.xsds.peppol.smp1.ProcessListType) ServiceMetadataType(com.helger.xsds.peppol.smp1.ServiceMetadataType) ServiceEndpointList(com.helger.xsds.peppol.smp1.ServiceEndpointList)

Example 17 with StopWatch

use of com.helger.commons.timing.StopWatch in project phoss-smp by phax.

the class MainCreateManyServiceGroups method main.

public static void main(final String[] args) throws Throwable {
    final String sServerBasePath = "http://localhost:90";
    final WebScopeTestRule aRule = new WebScopeTestRule();
    aRule.before();
    try {
        final ObjectFactory aObjFactory = new ObjectFactory();
        final StopWatch aSWOverall = StopWatch.createdStarted();
        for (int i = 0; i < 10_000; ++i) {
            final StopWatch aSW = StopWatch.createdStarted();
            final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
            final String sPI = aPI.getURIEncoded();
            final ServiceGroupType aSG = new ServiceGroupType();
            aSG.setParticipantIdentifier(aPI);
            aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
            try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
                // Delete old - don't care about the result
                if (false)
                    ClientBuilder.newClient().target(sServerBasePath).path(sPI).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
                // Create a new
                final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(sPI).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(aObjFactory.createServiceGroup(aSG)));
                _testResponseJerseyClient(aResponseMsg, 200);
            }
            aSW.stop();
            LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) WebScoped(com.helger.web.scope.mgr.WebScoped) Response(javax.ws.rs.core.Response) ObjectFactory(com.helger.xsds.peppol.smp1.ObjectFactory) ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) WebScopeTestRule(com.helger.web.scope.mock.WebScopeTestRule) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) StopWatch(com.helger.commons.timing.StopWatch)

Example 18 with StopWatch

use of com.helger.commons.timing.StopWatch in project phoss-smp by phax.

the class MainDeleteManyServiceGroups method main.

public static void main(final String[] args) throws Throwable {
    final String sServerBasePath = "http://localhost:90";
    final WebScopeTestRule aRule = new WebScopeTestRule();
    aRule.before();
    try {
        final StopWatch aSWOverall = StopWatch.createdStarted();
        for (int i = 0; i < 10_000; ++i) {
            final StopWatch aSW = StopWatch.createdStarted();
            final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
            final String sPI = aPI.getURIEncoded();
            try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
                // Delete old
                final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(sPI).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
                _testResponseJerseyClient(aResponseMsg, 200);
            }
            aSW.stop();
            LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) WebScoped(com.helger.web.scope.mgr.WebScoped) Response(javax.ws.rs.core.Response) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) WebScopeTestRule(com.helger.web.scope.mock.WebScopeTestRule) StopWatch(com.helger.commons.timing.StopWatch)

Example 19 with StopWatch

use of com.helger.commons.timing.StopWatch in project phoss-smp by phax.

the class MainReadFromFileBDXR1 method main.

public static void main(final String[] args) throws Throwable {
    final SMPServerRESTTestRule aRule = new SMPServerRESTTestRule(ClassPathResource.getAsFile("test-smp-server-xml-bdxr1.properties").getAbsolutePath());
    aRule.before();
    try {
        final String sServerBasePath = aRule.getFullURL();
        final StopWatch aSWOverall = StopWatch.createdStarted();
        // These values must match the values in the test file
        final IParticipantIdentifier aParticipantID = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:xxx");
        final IDocumentTypeIdentifier aDocTypeID = PeppolIdentifierFactory.INSTANCE.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");
        // Delete existing ServiceGroup (if exists)
        {
            final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(aParticipantID.getURIEncoded()).queryParam("delete-in-sml", Boolean.FALSE).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
            _testResponseJerseyClient(aResponseMsg, 200, 404);
        }
        {
            // Create a new ServiceGroup
            final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(aParticipantID.getURIEncoded()).queryParam("create-in-sml", Boolean.FALSE).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(new File("src/test/resources/rest-files/bdxr1-service-group.xml")));
            _testResponseJerseyClient(aResponseMsg, 200);
        }
        {
            // Add endpoint
            final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path(aParticipantID.getURIEncoded()).path("services").path(aDocTypeID.getURIEncoded()).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(new File("src/test/resources/rest-files/bdxr1-service-metadata.xml")));
            _testResponseJerseyClient(aResponseMsg, 200);
        }
        {
            // Add Business Card - no other format
            final Response aResponseMsg = ClientBuilder.newClient().target(sServerBasePath).path("businesscard").path(aParticipantID.getURIEncoded()).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(new File("src/test/resources/rest-files/peppol-business-card-v3.xml")));
            _testResponseJerseyClient(aResponseMsg, 200);
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : Response(javax.ws.rs.core.Response) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) File(java.io.File) SMPServerRESTTestRule(com.helger.phoss.smp.mock.SMPServerRESTTestRule) StopWatch(com.helger.commons.timing.StopWatch) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 20 with StopWatch

use of com.helger.commons.timing.StopWatch in project phoss-smp by phax.

the class MainCreate1MillionServiceGroups method main.

public static void main(final String[] args) throws Throwable {
    final SMPServerRESTTestRule aRule = new SMPServerRESTTestRule(ClassPathResource.getAsFile("test-smp-server-mongodb.properties").getAbsolutePath());
    aRule.before();
    try {
        // Set the special PhotonSecurityManager factory
        PhotonSecurityManager.setFactory(new PhotonSecurityManagerFactoryMongoDB());
        final ObjectFactory aObjFactory = new ObjectFactory();
        final StopWatch aSWOverall = StopWatch.createdStarted();
        for (int i = 0; i < 1_000_000; ++i) {
            final StopWatch aSW = StopWatch.createdStarted();
            final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
            final String sPI = aPI.getURIEncoded();
            final ServiceGroupType aSG = new ServiceGroupType();
            aSG.setParticipantIdentifier(aPI);
            aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
            try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
                // Delete old - don't care about the result
                if (false)
                    ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
                // Create a new
                final Response aResponseMsg = ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(aObjFactory.createServiceGroup(aSG)));
                _testResponseJerseyClient(aResponseMsg, 200);
            }
            aSW.stop();
            LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
        }
        aSWOverall.stop();
        LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
    } finally {
        aRule.after();
    }
}
Also used : PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) WebScoped(com.helger.web.scope.mgr.WebScoped) Response(javax.ws.rs.core.Response) PhotonSecurityManagerFactoryMongoDB(com.helger.phoss.smp.backend.mongodb.PhotonSecurityManagerFactoryMongoDB) ObjectFactory(com.helger.xsds.peppol.smp1.ObjectFactory) ServiceMetadataReferenceCollectionType(com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType) MockHttpServletRequest(com.helger.servlet.mock.MockHttpServletRequest) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) SMPServerRESTTestRule(com.helger.phoss.smp.mock.SMPServerRESTTestRule) StopWatch(com.helger.commons.timing.StopWatch)

Aggregations

StopWatch (com.helger.commons.timing.StopWatch)29 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)7 Response (javax.ws.rs.core.Response)7 MockHttpServletRequest (com.helger.servlet.mock.MockHttpServletRequest)6 WebScoped (com.helger.web.scope.mgr.WebScoped)6 AS2Exception (com.helger.as2lib.exception.AS2Exception)5 IJsonObject (com.helger.json.IJsonObject)5 PeppolParticipantIdentifier (com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier)4 SMPServerRESTTestRule (com.helger.phoss.smp.mock.SMPServerRESTTestRule)4 EndpointType (com.helger.xsds.peppol.smp1.EndpointType)4 IOException (java.io.IOException)4 Nonnull (javax.annotation.Nonnull)4 WrappedAS2Exception (com.helger.as2lib.exception.WrappedAS2Exception)3 AS2Message (com.helger.as2lib.message.AS2Message)3 AS2NoModuleException (com.helger.as2lib.processor.AS2NoModuleException)3 HttpClientManager (com.helger.httpclient.HttpClientManager)3 ResponseHandlerByteArray (com.helger.httpclient.response.ResponseHandlerByteArray)3 JsonWriter (com.helger.json.serialize.JsonWriter)3 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)3 SMPBadRequestException (com.helger.phoss.smp.exception.SMPBadRequestException)3