Skip to content

Commit

Permalink
orcid-api-common
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Jan 19, 2023
1 parent 2de2280 commit dc09ebf
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">

<import resource="classpath*:orcid-core-context.xml"/>

<!-- As we have a Jersey endpoint, we need to create an extension to the
Spring MVC, so we use a delegator -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.ws.rs.core.HttpHeaders;

import org.junit.Test;
import org.orcid.api.common.analytics.APIEndpointParser;

import com.sun.jersey.core.header.InBoundHeaders;
import com.sun.jersey.server.impl.application.WebApplicationImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import com.sun.jersey.spi.container.ContainerResponse;

@RunWith(OrcidJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:orcid-core-context.xml" })
@ContextConfiguration(locations = { "classpath:test-orcid-api-common-context.xml" })
public class AnalyticsProcessTest {

@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.orcid.api.common.oauth.OrcidClientCredentialEndPointDelegator;
import org.orcid.core.oauth.openid.OpenIDConnectKeyService;
import org.orcid.core.utils.SecurityContextTestUtils;
import org.orcid.jaxb.model.message.ScopePathType;
Expand All @@ -46,7 +45,7 @@
import com.sun.jersey.core.util.MultivaluedMapImpl;

@RunWith(OrcidJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:orcid-core-context.xml", "classpath:orcid-oauth2-common-config.xml", "classpath*:orcid-oauth2-api-common-config.xml", "classpath:test-orcid-persistence-context.xml"})
@ContextConfiguration(locations = { "classpath:test-orcid-api-common-context.xml"})
public class OrcidClientCredentialEndPointDelegatorTest extends DBUnitTest {

private static final String CLIENT_ID_1 = "APP-5555555555555555";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.3.xsd">

<context:property-placeholder
location="classpath:/properties/test-core.properties,classpath:/properties/test-db.properties"
ignore-resource-not-found="true"
ignore-unresolvable="true" />

<import resource="classpath*:orcid-oauth2-common-config.xml"/>
<import resource="classpath*:orcid-oauth2-api-common-config.xml"/>

</beans>
2 changes: 0 additions & 2 deletions orcid-core/src/main/resources/orcid-core-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

<bean id="httpRequestUtils" class="org.orcid.core.utils.http.HttpRequestUtils" />
<bean id="identityProviderManager" class="org.orcid.core.manager.impl.IdentityProviderManagerImpl" />

<import resource="classpath*:orcid-core-cache-config.xml" />


<!-- Commenting out whilst the auditing is still being discussed -->
<!-- <import resource="classpath*:orcid-audit-context.xml" /> -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.springframework.test.context.ContextConfiguration;

@RunWith(OrcidJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:test-orcid-core-context.xml", "classpath:orcid-oauth2-common-config.xml", "classpath*:orcid-oauth2-api-common-config.xml" })
@ContextConfiguration(locations = { "classpath:test-orcid-core-context.xml", "classpath:orcid-oauth2-common-config.xml" })
public class OrcidRefreshTokenTokenGranterTest extends DBUnitTest {

private static final String CLIENT_ID_1 = "APP-5555555555555555";
Expand Down
35 changes: 33 additions & 2 deletions orcid-test/src/main/java/org/orcid/test/DBUnitTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.orcid.test;

import static org.junit.Assert.fail;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
Expand Down Expand Up @@ -33,6 +35,8 @@
@Ignore
public class DBUnitTest {

private static final String API_COMMON_CONTEXT = "classpath:test-orcid-api-common-context.xml";

private static final String PERSISTENCE_CONTEXT = "classpath:test-orcid-persistence-context.xml";

private static final String CORE_CONTEXT = "classpath:test-orcid-core-context.xml";
Expand All @@ -46,11 +50,38 @@ public class DBUnitTest {

private static ApplicationContext context;

static {
static {
Exception last = null;
try {
context = new ClassPathXmlApplicationContext(CORE_CONTEXT);
} catch (Exception e) {
context = new ClassPathXmlApplicationContext(PERSISTENCE_CONTEXT);
System.out.println("Unable to load context from " + CORE_CONTEXT);
last = e;
}

if(context == null) {
try {
context = new ClassPathXmlApplicationContext(PERSISTENCE_CONTEXT);
} catch (Exception e) {
System.out.println("Unable to load context from " + PERSISTENCE_CONTEXT);
last = e;
}
}

if(context == null) {
try {
context = new ClassPathXmlApplicationContext(API_COMMON_CONTEXT);
} catch (Exception e) {
System.out.println("Unable to load context from " + API_COMMON_CONTEXT);
last = e;
}
}

if(context == null) {
if(last != null) {
last.printStackTrace();
}
fail();
}
}

Expand Down

0 comments on commit dc09ebf

Please sign in to comment.