Skip to content

Commit

Permalink
The test can now be run multiple times if you have configured passwor…
Browse files Browse the repository at this point in the history
…dless ssh to tri-test-niab82
  • Loading branch information
frjtrifork committed Apr 11, 2012
1 parent 5ece655 commit 8cca192
Showing 1 changed file with 25 additions and 7 deletions.
Expand Up @@ -26,10 +26,16 @@

package dk.nsi.stamdata.cpr.pvit;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Stage;
import dk.nsi.stamdata.cpr.ComponentController;
import dk.nsi.stamdata.dgws.DGWSHeaderUtil;
import dk.nsi.stamdata.dgws.SecurityWrapper;
import dk.nsi.stamdata.guice.GuiceTestRunner;
import dk.nsi.stamdata.jaxws.generated.*;
import org.hibernate.Session;
import org.hisrc.hifaces20.testing.webappenvironment.testing.junit4.AbstractWebAppEnvironmentJUnit4Test;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Ignore;
Expand All @@ -39,6 +45,9 @@
import javax.xml.namespace.QName;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
Expand All @@ -51,27 +60,28 @@
@RunWith(GuiceTestRunner.class)
public class StamdataPersonLookupWithSubscriptionNSPSupport {



final String endpoint = "http://tri-test-niab82:8080/stamdata-cpr-ws/service/StamdataPersonLookupWithSubscription";
public static final String[] CLIENT_CVRS = { "12345678", "22334455", "33445566", "44556677"};


final String endpoint = "http://tri-test-niab82:8080/stamdata-cpr-ws/service/StamdataPersonLookupWithSubscription";

private StamdataPersonLookupWithSubscription client;

@Before
public void setUp() throws Exception
{
client = createClient(endpoint);
//TODO: See https://wall.trifork.com/display/tripub/Trifork+VM%27er+til+SDM+og+BRS for info on how to get the private key to allow passwordless ssh
//TODO: This should never be done like this, but this test is only intented to be used while troubleshooting nspsuppport-48

ProcessBuilder processBuilder = new ProcessBuilder("ssh", "nsp", "/pack/mysql/bin/mysql -u root -pnspnetic register_notifications -N -e \"DELETE FROM State WHERE cvr='22334455';\"");

client = createClient(endpoint);
}


@Test
public void doQuery() throws Exception {
CprAbbsRequestType query = new CprAbbsRequestType();
DateTime dt = new DateTime(2012, 2, 9, 10, 0);
DateTime dt = DateTime.now();
query.setSince(dt.toGregorianCalendar());
for (String clientCvr : CLIENT_CVRS) {
SecurityWrapper headers = createHeaders(clientCvr);
Expand All @@ -81,7 +91,15 @@ public void doQuery() throws Exception {
List<PersonInformationStructureType> personInformationStructure = response.getPersonInformationStructure();
assertNotNull("PersonInformationStructure should never be null, it should at least be an empty list", personInformationStructure);
System.out.println("getSubscribedPersonDetails - using CVR: " + clientCvr + ", since: " + dt.toString() + " ---> Fandt " + personInformationStructure.size() + " opdaterede personer");
} catch (Exception e) {
for (PersonInformationStructureType personInformationStructureType : personInformationStructure) {
System.out.println("\t- Person[ CPR: " + personInformationStructureType.getCurrentPersonCivilRegistrationIdentifier() + ", " +
"Navn: " + personInformationStructureType.getRegularCPRPerson().getSimpleCPRPerson().getPersonNameStructure().getPersonGivenName() + " " +
personInformationStructureType.getRegularCPRPerson().getSimpleCPRPerson().getPersonNameStructure().getPersonMiddleName() + " " +
personInformationStructureType.getRegularCPRPerson().getSimpleCPRPerson().getPersonNameStructure().getPersonSurnameName()
+ " ]"
);
}
} catch (DGWSFault e) {
e.printStackTrace(System.err);
fail("Failed getting subscribedPersonDetails - using CVR: " + clientCvr + " Exception: " + e.getMessage());

Expand Down

0 comments on commit 8cca192

Please sign in to comment.