-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from xenit-eu/master
Release 2.0.5
- Loading branch information
Showing
15 changed files
with
273 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
ext { | ||
alfrescoBaseWar = 'org.alfresco:content-services:6.2.0@war' | ||
alfrescoBaseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.2.0' | ||
alfrescoBaseWar = 'org.alfresco:content-services:6.2.1@war' | ||
alfrescoBaseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.2.1' | ||
|
||
postgresImage = 'postgres:10.1' | ||
} |
48 changes: 48 additions & 0 deletions
48
integration-tests/src/test/java/eu/xenit/dynamicextensionsalfresco/SpringProxyMagicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package eu.xenit.dynamicextensionsalfresco; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Integration tests that will cause Spring proxy magic to happen in Alfresco. Makes use of the '/greeting/...' | ||
* endpoints which are defined in the 'test-bundle' | ||
* <p> | ||
* Interesting read on Spring and CGLIB proxies: http://www.javabyexamples.com/cglib-proxying-in-spring-configuration | ||
*/ | ||
public class SpringProxyMagicTest extends RestAssuredTest { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(BehaviourTest.class); | ||
|
||
@Test | ||
public void triggerAndTestSpringProxyMagic() { | ||
logger.info("Test scenario: make use of a Bean which was initialized by an @Configuration annotated class." | ||
+ " By doing so, we try to proactively trigger a ClassNotFoundException for any of the Spring CGLIB" | ||
+ "related classes."); | ||
|
||
given() | ||
.log().ifValidationFails() | ||
.when() | ||
.get("s/dynamic-extensions/testing/greeting") | ||
.then() | ||
.log().ifValidationFails() | ||
.statusCode(200) | ||
.body(equalTo("\"Hello there, adventurer!\"")); | ||
|
||
for (int i = 0; i < 3; i++) { | ||
// Beans initialized via the @Bean annotation in an @Configuration class should only be initialized once | ||
given() | ||
.log().ifValidationFails() | ||
.when() | ||
.get("s/dynamic-extensions/testing/greeting/number-of-instances") | ||
.then() | ||
.log().ifValidationFails() | ||
.statusCode(200) | ||
.body(equalTo("1")); | ||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...n-tests/test-bundle/src/main/java/eu/xenit/de/testing/greeting/GreetingConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package eu.xenit.de.testing.greeting; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@SuppressWarnings("unused") | ||
public class GreetingConfiguration { | ||
|
||
@Bean | ||
public GreetingService greetingService() { | ||
return new GreetingService(); | ||
} | ||
|
||
@Bean | ||
public GreetingServiceWrapper greetingServiceWrapper() { | ||
return new GreetingServiceWrapper(greetingService()); | ||
} | ||
|
||
@Bean | ||
public GreetingServiceWrapper anotherGreetingServiceWrapper() { | ||
return new GreetingServiceWrapper(greetingService()); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...gration-tests/test-bundle/src/main/java/eu/xenit/de/testing/greeting/GreetingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package eu.xenit.de.testing.greeting; | ||
|
||
public class GreetingService { | ||
|
||
private static int numberOfInstances; | ||
|
||
public GreetingService() { | ||
numberOfInstances++; | ||
} | ||
|
||
public String getGreeting() { | ||
return "Hello there, adventurer!"; | ||
} | ||
|
||
public static int getNumberOfInstances() { | ||
return numberOfInstances; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...-tests/test-bundle/src/main/java/eu/xenit/de/testing/greeting/GreetingServiceWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package eu.xenit.de.testing.greeting; | ||
|
||
public class GreetingServiceWrapper { | ||
|
||
private final GreetingService greetingService; | ||
|
||
public GreetingServiceWrapper(GreetingService greetingService) { | ||
this.greetingService = greetingService; | ||
} | ||
|
||
public GreetingService getGreetingService() { | ||
return greetingService; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ation-tests/test-bundle/src/main/java/eu/xenit/de/testing/greeting/GreetingWebScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package eu.xenit.de.testing.greeting; | ||
|
||
import static eu.xenit.de.testing.Constants.TEST_WEBSCRIPTS_BASE_URI; | ||
import static eu.xenit.de.testing.Constants.TEST_WEBSCRIPTS_FAMILY; | ||
|
||
import com.github.dynamicextensionsalfresco.webscripts.annotations.Uri; | ||
import com.github.dynamicextensionsalfresco.webscripts.annotations.WebScript; | ||
import java.util.Objects; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@WebScript(families = TEST_WEBSCRIPTS_FAMILY, baseUri = TEST_WEBSCRIPTS_BASE_URI + "/greeting") | ||
@SuppressWarnings("unused") | ||
public class GreetingWebScript { | ||
|
||
private final GreetingService greetingService; | ||
|
||
@Autowired | ||
public GreetingWebScript( | ||
@Qualifier("greetingServiceWrapper") GreetingServiceWrapper first, | ||
@Qualifier("anotherGreetingServiceWrapper") GreetingServiceWrapper second) { | ||
|
||
if (!Objects.equals(first.getGreetingService(), second.getGreetingService())) { | ||
throw new IllegalStateException("Requiring only one GreetingService to rule them all"); | ||
} | ||
|
||
this.greetingService = first.getGreetingService(); | ||
} | ||
|
||
@Uri | ||
public ResponseEntity<String> getGreeting() { | ||
return new ResponseEntity<>(greetingService.getGreeting(), HttpStatus.OK); | ||
} | ||
|
||
@Uri("/number-of-instances") | ||
public ResponseEntity<Integer> getNumberOfInstances() { | ||
return new ResponseEntity<>(GreetingService.getNumberOfInstances(), HttpStatus.OK); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.