Monat: Oktober 2018

CDI DeltaSpike Partial-Bean

Blog

CDI DeltaSpike Partial-Bean

...@interface Error { String ...
...Error { String code(); ...
...{ String code(); ...
... String code(); String ...
...String code(); String message(); ...
...code(); String message(); ...
... String message(); Class<? ...
...String message(); Class<? extends ...
...message(); Class<? extends Throwable> ...
...Throwable> exceptionClass() ...
...exceptionClass() ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... default ...
... default RuntimeException.class; } Die ...
... default RuntimeException.class; } Die Attribute ...

Anzeigen

Hilfe bei Integrationstests

Blog

Hilfe bei Integrationstests

...und haben WarpUnit gefunden. // Wenn Web Services ...
...WorkingCageServiceImpl implements WorkingCageService { @Inject private ...
...{ @Inject private WorkingCage workingCage; ...
...private WorkingCage workingCage; public List<Task> getOpenTasks() ...
...List<Task> getOpenTasks() { return workingCage.getOpenTasks(); ...
... return workingCage.getOpenTasks(); } } Listing 2 public class ...
...class WorkingCage { public List<Task> getOpenTasks(){ ...
...public List<Task> getOpenTasks(){ List<Task> ...
...List<Task> getOpenTasks(){ List<Task> openTasks ...
...getOpenTasks(){ List<Task> openTasks = ...
...= new ArrayList<>(); openTasks.addAll(getOpenAppointments()); ...
...new ArrayList<>(); openTasks.addAll(getOpenAppointments()); ...
...ArrayList<>(); openTasks.addAll(getOpenAppointments()); ...
... openTasks.addAll(getOpenAppointments()); openTasks.addAll(getOpenDocuments()); ...
... openTasks.addAll(getOpenAppointments()); openTasks.addAll(getOpenDocuments()); ...
...openTasks.addAll(getOpenAppointments()); openTasks.addAll(getOpenDocuments()); ...
... openTasks.addAll(getOpenDocuments()); return ...
... openTasks.addAll(getOpenDocuments()); return openTasks; ...
...openTasks.addAll(getOpenDocuments()); return openTasks; ...
... return openTasks; } } Listing 3 @Inject WorkingCage workingCage; @Test public ...
...void testOpenRequests() { List<Request> openDocuments = ...
...openDocuments = workingCage. getOpenDocuments(); assertThat(...); } Listing 4 public class ...
...WorkingCageInsiderImpl implements WorkingCageInsider { @Inject WorkingCage ...
...{ @Inject WorkingCage workingCage; ...
... WorkingCage workingCage; public List<Request> getOpenAppointments ...
...getOpenAppointments () { return ...
...() { return workingCage.getOpenAppointments ...
...{ return workingCage.getOpenAppointments (); ...
...return workingCage.getOpenAppointments (); } } Listing 5 public class ...
...class ProxyStyleWorkingCageTest { @Test ...
...{ @Test ...
... @Test ...
...@Test ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... System.out.println("This ...
... System.out.println("This is ...
... System.out.println("This is printed ...
...in the JUnit public void testWorkingCageWithProxy() ...
...void testWorkingCageWithProxy() { ...
...testWorkingCageWithProxy() { ...
...{ ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... test ...
... test log"); WorkingCageInsider ...
... test log"); WorkingCageInsider proxyGate ...
...proxyGate = WarpUnit. ...
...= WarpUnit. ...
...WarpUnit. ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... List<Appointment> ...
... List<Appointment> appointments ...
... List<Appointment> appointments = ...
...appointments = proxyGate. builder() ...
...= proxyGate. builder() ...
...proxyGate. builder() ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... getOpenAppointments(); ...
... getOpenAppointments(); ...
... getOpenAppointments(); .primaryClass(WorkingCageInsiderImpl.class) ...
... getOpenAppointments(); .primaryClass(WorkingCageInsiderImpl.class) ...
...getOpenAppointments(); .primaryClass(WorkingCageInsiderImpl.class) ...
... .primaryClass(WorkingCageInsiderImpl.class) ...
....primaryClass(WorkingCageInsiderImpl.class) ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... Assert.assertEquals(1, ...
... Assert.assertEquals(1, appointments.size()); ...
... Assert.assertEquals(1, appointments.size()); ...
... Assert.assertEquals(1, appointments.size()); .includeInterface(true) ...
...appointments.size()); .includeInterface(true) ...
... .includeInterface(true) ...
....includeInterface(true) ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... } ...
... } ...
... } .createProxyGate(WorkingCageInsider.class); ...
... } .createProxyGate(WorkingCageInsider.class); ...
...} .createProxyGate(WorkingCageInsider.class); ...
... .createProxyGate(WorkingCageInsider.class); ...
....createProxyGate(WorkingCageInsider.class); ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... } Ein ...
... } Ein bisschen ...
... } Ein bisschen eleganter ...
...class LambdaStyleTest { @Inject WorkingCage ...
...{ @Inject WorkingCage workingCage; ...
... WorkingCage workingCage; @Test public ...
...workingCage; @Test public void testWorkingCage() ...
...void testWorkingCage() { WarpGate ...
...testWorkingCage() { WarpGate gate ...
...{ WarpGate gate = ...
...gate = WarpUnit.builder() ...
...= WarpUnit.builder() ...
...WarpUnit.builder() .primaryClass(LambdaStyleTest.class) ...
... .primaryClass(LambdaStyleTest.class) ...
... .primaryClass(LambdaStyleTest.class) ...
... .primaryClass(LambdaStyleTest.class) ...
... .primaryClass(LambdaStyleTest.class) ...
....primaryClass(LambdaStyleTest.class) .createGate(); List<Appointment> ...
... .createGate(); List<Appointment> appointments ...
... .createGate(); List<Appointment> appointments = ...
...gate.warp(() -> { ...
...-> { ...
...{ return ...
... return workingCage.getOpenAppointments(); ...
... return workingCage.getOpenAppointments(); ...
... return workingCage.getOpenAppointments(); }); ...
...return workingCage.getOpenAppointments(); }); ...
...workingCage.getOpenAppointments(); }); ...
... }); Assert.assertEquals(1, ...
... }); Assert.assertEquals(1, appointments.size()); ...
...}); Assert.assertEquals(1, appointments.size()); ...
... Assert.assertEquals(1, appointments.size()); } ...
...Assert.assertEquals(1, appointments.size()); } ...
...appointments.size()); } } Listing ...
... } } Listing 7 @Test public void ...
...void testNoDocuments() { WarpGate gate = ...
...gate = WarpUnit.builder() .primaryClass(DBTest.class) ...
...= WarpUnit.builder() .primaryClass(DBTest.class) ...
...WarpUnit.builder() .primaryClass(DBTest.class) ...
... .primaryClass(DBTest.class) .createGate(); ...
... .primaryClass(DBTest.class) .createGate(); ...
....primaryClass(DBTest.class) .createGate(); List<Document> ...
... .createGate(); List<Document> documents = ...
...gate.warp(() -> { return ...
...-> { return workingCage.getOpenDocuments(); ...
...{ return workingCage.getOpenDocuments(); ...
... return workingCage.getOpenDocuments(); }); ...
...workingCage.getOpenDocuments(); }); //Keine ...
... }); //Keine Dokumente ...
...}); //Keine Dokumente werden ...
...Dokumente werden zurückgeliefert, //da ...
...werden zurückgeliefert, //da es ...
...zurückgeliefert, //da es kein ...
...aktives Preference gibt Assert.assertEquals(0, ...
...Preference gibt Assert.assertEquals(0, documents.size()); ...
...gibt Assert.assertEquals(0, documents.size()); ...
... Assert.assertEquals(0, documents.size()); } // WAR-Deployments testen Bis zu ...
...new EntityManipulator()) { // Instanziieren von ...
...von JPA-Entity Preference. Preference preference = ...
...= new Preference(); preference.setPreferenceKey("med.open"); preference.setPreferenceValue("true"); ...
...Preference(); preference.setPreferenceKey("med.open"); preference.setPreferenceValue("true"); // ...
...preference.setPreferenceKey("med.open"); preference.setPreferenceValue("true"); // Hier wird ...
...an Server gesendet. // und von ...
...über JPA EntityManager. // in die ...
...die Datenbank eingespielt. manipulator.insertEntity(preference); WarpGate ...
...eingespielt. manipulator.insertEntity(preference); WarpGate gate = ...
...gate = WarpUnit.builder() .primaryClass(DBTest.class) ...
...= WarpUnit.builder() .primaryClass(DBTest.class) ...
...WarpUnit.builder() .primaryClass(DBTest.class) ...
... .primaryClass(DBTest.class) .createGate(); ...
... .primaryClass(DBTest.class) .createGate(); ...
....primaryClass(DBTest.class) .createGate(); List<Document> ...
... .createGate(); List<Document> documents = ...
...gate.warp(() -> { return ...
...-> { return workingCage.getOpenDocuments(); ...
...{ return workingCage.getOpenDocuments(); ...
... return workingCage.getOpenDocuments(); }); // ...
...workingCage.getOpenDocuments(); }); // Das Preference ...
...Das Preference med.open=true. // Somit wird ...
...Dokument geliefert. Assert.assertEquals(1, documents.size()); // Der erstellte ...
...wird am Ende // durch close() ...
...durch close() entfernt } ...
...close() entfernt } ...
...entfernt } } Listing ...
... } } Listing 9 @Test ...
... } Listing 9 @Test public void testOpenAndRestrictedDocuments() ...
...throws Exception { try (EntityManipulator manipulator ...
...new EntityManipulator()) { // ...
...EntityManipulator()) { // Ein ...
...{ // Ein Preference-Eintrag ...
...der Datenbank erstellt. Preference openPreference = ...
...= new Preference(); openPreference.setPreferenceKey("med.open"); openPreference.setPreferenceValue("true"); ...
...Preference(); openPreference.setPreferenceKey("med.open"); openPreference.setPreferenceValue("true"); manipulator.insertEntity(openPreference); ...
...openPreference.setPreferenceKey("med.open"); openPreference.setPreferenceValue("true"); manipulator.insertEntity(openPreference); // ...
...openPreference.setPreferenceValue("true"); manipulator.insertEntity(openPreference); // Ein bestehender ...
...aus der Datenbank // mithilfe einer ...
...einer HQL-Query geholt. Preference restrictedPreference = ...
...= 'med.restricted'", Preference.class); restrictedPreference.setPreferenceValue("true"); // ...
...Preference.class); restrictedPreference.setPreferenceValue("true"); // Hier wird ...
...an Server gesendet. // EntityManimulator ruft ...
...Methode merge() auf. // Dadurch wird ...
...der Datenbank aktualisiert. manipulator.updateEntity(restrictedPreference); WarpGate gate = ...
...gate = WarpUnit.builder() .primaryClass(DBTest.class) .createGate(); ...
...WarpUnit.builder() .primaryClass(DBTest.class) .createGate(); List<Document> ...
....primaryClass(DBTest.class) .createGate(); List<Document> documents = ...
...gate.warp(() -> { return workingCage.getOpenDocuments(); ...
... return workingCage.getOpenDocuments(); }); // Die beiden ...
...med.restricted sind true. // Somit werden ...
...beide Dokumente zurückgeliefert. Assert.assertEquals(2, documents.size()); ...
... Assert.assertEquals(2, documents.size()); // Der neue ...
...am Ende entfernt // Der aktualisierte ...
...am Ende zurückgesetzt } ...
...Ende zurückgesetzt } ...
...zurückgesetzt } } Listing ...
... } } Listing 10 <profile> ...
... } Listing 10 <profile> <id>warpunit</id> <dependencies> ...
...10 <profile> <id>warpunit</id> <dependencies> <dependency> ...
...<id>warpunit</id> <dependencies> <dependency> ...
...<dependencies> <dependency> <groupId>org.dcm4che</groupId> ...
... <dependency> <groupId>org.dcm4che</groupId> ...
...<dependency> <groupId>org.dcm4che</groupId> ...
... <groupId>org.dcm4che</groupId> <artifactId>warpunit-core</artifactId> ...
... <groupId>org.dcm4che</groupId> <artifactId>warpunit-core</artifactId> ...
...<groupId>org.dcm4che</groupId> <artifactId>warpunit-core</artifactId> ...
... <artifactId>warpunit-core</artifactId> <version>alpha-SNAPSHOT</version> ...
... <artifactId>warpunit-core</artifactId> <version>alpha-SNAPSHOT</version> ...
...<artifactId>warpunit-core</artifactId> <version>alpha-SNAPSHOT</version> </dependency> ...
... <version>alpha-SNAPSHOT</version> </dependency> </dependencies> ...
...<version>alpha-SNAPSHOT</version> </dependency> </dependencies> <properties> ...
...</dependency> </dependencies> <properties> ...
...</dependencies> <properties> <projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> ...
... <properties> <projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> ...
...<properties> <projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> ...
... <projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> </properties> ...
... <projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> </properties> ...
...<projectVersion>alpha-TEST-ONLY-SNAPSHOT</projectVersion> </properties> </profile> // Den ...
... </properties> </profile> // Den Test testen WarpUnit ...
...working-cage-ear-alpha-SNAPSHOT.ear auf WildFly oder JBoss EAP ...

Anzeigen

Geparden Breakout 2018 Mühlviertel 8000