Skip to content

Commit 508b867

Browse files
author
eugenp
committed
marhsalling work to be able to run the tests with different mime types
1 parent 95b8afb commit 508b867

23 files changed

Lines changed: 157 additions & 28 deletions

‎common/.settings/org.eclipse.wst.common.component‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
22
<wb-module deploy-name="rest-common">
33
<wb-resource deploy-path="/" source-path="/src/main/java"/>
4-
<wb-resource deploy-path="/" source-path="/src/test/java"/>
54
<property name="context-root" value="rest"/>
65
<property name="java-output-path" value="/rest-common/target/classes"/>
76
</wb-module>

‎common/src/main/java/org/rest/common/client/security/ClientAuthenticator.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import org.apache.http.auth.UsernamePasswordCredentials;
44
import org.apache.http.impl.client.DefaultHttpClient;
55
import org.rest.common.security.PreemptiveAuthHttpRequestFactory;
6+
import org.rest.common.spring.CommonSpringProfileUtil;
67
import org.springframework.context.annotation.Profile;
78
import org.springframework.stereotype.Component;
89
import org.springframework.web.client.RestTemplate;
910

1011
import com.google.common.base.Preconditions;
1112

1213
@Component
13-
@Profile("client")
14+
@Profile(CommonSpringProfileUtil.CLIENT)
1415
public class ClientAuthenticator {
1516

1617
public ClientAuthenticator() {

‎common/src/main/java/org/rest/common/client/template/CommonPaths.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package org.rest.common.client.template;
22

3+
import org.rest.common.spring.CommonSpringProfileUtil;
34
import org.springframework.beans.factory.InitializingBean;
45
import org.springframework.beans.factory.annotation.Autowired;
56
import org.springframework.context.annotation.Profile;
67
import org.springframework.core.env.Environment;
78
import org.springframework.stereotype.Component;
89

910
@Component
10-
@Profile("client")
11+
@Profile(CommonSpringProfileUtil.CLIENT)
1112
public final class CommonPaths implements InitializingBean {
1213

1314
@Autowired

‎common/src/main/java/org/rest/common/security/SpringSecurityUtil.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
public final class SpringSecurityUtil {
2121

2222
public static final String ANONYMOUS_USER = "anonymousUser";
23+
public static final String SEC_CLIENT = "sec_client";
2324

2425
private SpringSecurityUtil() {
2526
throw new AssertionError();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.rest.common.spring;
2+
3+
public final class CommonSpringProfileUtil {
4+
5+
// these 3 profiles are modeling the environments - deployed is active for any deployment, dev and production for these specific environments
6+
public static final String DEPLOYED = "deployed";
7+
public static final String DEV = "dev";
8+
9+
// common
10+
public static final String TEST = "test";
11+
public static final String CLIENT = "client";
12+
13+
private CommonSpringProfileUtil() {
14+
throw new AssertionError();
15+
}
16+
17+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.rest.sec.client.marshall;
2+
3+
import static org.rest.common.spring.CommonSpringProfileUtil.DEPLOYED;
4+
5+
import org.rest.common.client.marshall.IMarshaller;
6+
import org.springframework.beans.factory.FactoryBean;
7+
import org.springframework.context.annotation.Profile;
8+
import org.springframework.stereotype.Component;
9+
10+
@Component
11+
@Profile(DEPLOYED)
12+
public class MarshallerFactory implements FactoryBean<IMarshaller> {
13+
14+
public MarshallerFactory() {
15+
super();
16+
}
17+
18+
// API
19+
20+
@Override
21+
public IMarshaller getObject() {
22+
return new ProdJacksonMarshaller();
23+
}
24+
25+
@Override
26+
public Class<IMarshaller> getObjectType() {
27+
return IMarshaller.class;
28+
}
29+
30+
@Override
31+
public boolean isSingleton() {
32+
return true;
33+
}
34+
35+
}

‎sec/src/main/java/org/rest/sec/client/marshall/ProdJacksonMarshaller.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@
1010
import org.rest.sec.model.dto.User;
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
13-
import org.springframework.context.annotation.Profile;
1413
import org.springframework.http.MediaType;
15-
import org.springframework.stereotype.Component;
1614

1715
import com.fasterxml.jackson.core.JsonParseException;
1816
import com.fasterxml.jackson.core.type.TypeReference;
1917
import com.fasterxml.jackson.databind.JsonMappingException;
2018
import com.fasterxml.jackson.databind.ObjectMapper;
2119
import com.google.common.base.Preconditions;
2220

23-
@Component
24-
@Profile("production")
2521
public final class ProdJacksonMarshaller implements IMarshaller {
2622
private final Logger logger = LoggerFactory.getLogger(ProdJacksonMarshaller.class);
2723

‎sec/src/main/java/org/rest/sec/persistence/setup/SecuritySetup.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Set;
44

55
import org.rest.common.event.BeforeSetupEvent;
6+
import org.rest.common.spring.CommonSpringProfileUtil;
67
import org.rest.sec.model.Principal;
78
import org.rest.sec.model.Privilege;
89
import org.rest.sec.model.Role;
@@ -25,7 +26,7 @@
2526
import com.google.common.collect.Sets;
2627

2728
@Component
28-
@Profile("production")
29+
@Profile(CommonSpringProfileUtil.DEPLOYED)
2930
public class SecuritySetup implements ApplicationListener<ContextRefreshedEvent> {
3031
private final Logger logger = LoggerFactory.getLogger(SecuritySetup.class);
3132

‎sec/src/main/java/org/rest/sec/persistence/setup/SpringVerificationsBeforeSetupListener.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.google.common.base.Preconditions;
1515

1616
@Component
17-
@Profile("production")
17+
@Profile("dev")
1818
public final class SpringVerificationsBeforeSetupListener implements ApplicationListener<BeforeSetupEvent> {
1919
// private final Logger logger = LoggerFactory.getLogger(SpringVerificationsBeforeSetupListener.class);
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
spring.profiles.active=production
1+
spring.profiles.active=deployed

0 commit comments

Comments
 (0)