You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/28 12:01:17 UTC
svn commit: r1439342 - in /syncope/trunk:
client/src/main/java/org/apache/syncope/client/services/proxy/
common/src/main/java/org/apache/syncope/common/services/
core/src/main/resources/ core/src/test/java/org/apache/syncope/core/rest/
core/src/test/ja...
Author: jbernhardt
Date: Mon Jan 28 11:01:17 2013
New Revision: 1439342
URL: http://svn.apache.org/viewvc?rev=1439342&view=rev
Log:
[SYNCOPE-231] Fixing CXF Tests
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/SchemaServiceProxy.java
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/SchemaService.java
syncope/trunk/core/src/main/resources/restContext.xml
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/SchemaServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/SchemaServiceProxy.java?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/SchemaServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/SchemaServiceProxy.java Mon Jan 28 11:01:17 2013
@@ -42,32 +42,32 @@ public class SchemaServiceProxy extends
@Override
public <T extends AbstractSchemaTO> Response create(final AttributableType kind, final SchemaType type,
final T schemaTO) {
- AbstractSchemaTO schema = getRestTemplate().postForObject(baseUrl + type + "/{kind}/create", schemaTO,
- getTOClass(type), kind);
- return Response.created(URI.create(baseUrl + type + "/" + kind + "/read/" + schema.getName() + ".json"))
- .build();
+ AbstractSchemaTO schema = getRestTemplate().postForObject(baseUrl + type.toSpringURL() + "/{kind}/create",
+ schemaTO, getTOClass(type), kind);
+ return Response.created(
+ URI.create(baseUrl + type.toSpringURL() + "/" + kind + "/read/" + schema.getName() + ".json")).build();
}
@Override
public void delete(final AttributableType kind, final SchemaType type, final String schemaName) {
- getRestTemplate().getForObject(baseUrl + type + "/{kind}/delete/{name}.json", getTOClass(type), kind,
- schemaName);
+ getRestTemplate().getForObject(baseUrl + type.toSpringURL() + "/{kind}/delete/{name}.json", getTOClass(type),
+ kind, schemaName);
}
@Override
public List<? extends AbstractSchemaTO> list(final AttributableType kind, final SchemaType type) {
switch (type) {
case NORMAL:
- return Arrays.asList(getRestTemplate().getForObject(baseUrl + type + "/{kind}/list.json",
+ return Arrays.asList(getRestTemplate().getForObject(baseUrl + type.toSpringURL() + "/{kind}/list.json",
SchemaTO[].class, kind));
case DERIVED:
- return Arrays.asList(getRestTemplate().getForObject(baseUrl + type + "/{kind}/list.json",
+ return Arrays.asList(getRestTemplate().getForObject(baseUrl + type.toSpringURL() + "/{kind}/list.json",
DerivedSchemaTO[].class, kind));
case VIRTUAL:
- return Arrays.asList(getRestTemplate().getForObject(baseUrl + type + "/{kind}/list.json",
+ return Arrays.asList(getRestTemplate().getForObject(baseUrl + type.toSpringURL() + "/{kind}/list.json",
VirtualSchemaTO[].class, kind));
default:
@@ -79,15 +79,15 @@ public class SchemaServiceProxy extends
public <T extends AbstractSchemaTO> T read(final AttributableType kind, final SchemaType type,
final String schemaName) {
- return (T) getRestTemplate().getForObject(baseUrl + type + "/{kind}/read/{name}.json", getTOClass(type), kind,
- schemaName);
+ return (T) getRestTemplate().getForObject(baseUrl + type.toSpringURL() + "/{kind}/read/{name}.json",
+ getTOClass(type), kind, schemaName);
}
@Override
public <T extends AbstractSchemaTO> void update(final AttributableType kind, final SchemaType type,
final String schemaName, final T schemaTO) {
- getRestTemplate().postForObject(baseUrl + type + "/{kind}/update", schemaTO, getTOClass(type), kind);
+ getRestTemplate().postForObject(baseUrl + type.toSpringURL() + "/{kind}/update", schemaTO, getTOClass(type), kind);
}
private Class<? extends AbstractSchemaTO> getTOClass(final SchemaType type) {
Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/SchemaService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/SchemaService.java?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/SchemaService.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/SchemaService.java Mon Jan 28 11:01:17 2013
@@ -46,41 +46,35 @@ public interface SchemaService {
this.name = name;
}
- @Override
- public String toString() {
+ // TODO remove once CXF migration is complete
+ public String toSpringURL() {
return name;
}
public static SchemaType fromString(String value) {
- return valueOf(value.toUpperCase());
+ return SchemaType.valueOf(value.toUpperCase());
}
}
@POST
<T extends AbstractSchemaTO> Response create(@PathParam("kind") AttributableType kind,
- @PathParam("type") SchemaType type,
- T schemaTO);
+ @PathParam("type") SchemaType type, T schemaTO);
@DELETE
@Path("{name}")
- void delete(@PathParam("kind") AttributableType kind,
- @PathParam("type") SchemaType type,
+ void delete(@PathParam("kind") AttributableType kind, @PathParam("type") SchemaType type,
@PathParam("name") String schemaName);
@GET
- List<? extends AbstractSchemaTO> list(@PathParam("kind") AttributableType kind,
- @PathParam("type") SchemaType type);
+ List<? extends AbstractSchemaTO> list(@PathParam("kind") AttributableType kind, @PathParam("type") SchemaType type);
@GET
@Path("{name}")
- <T extends AbstractSchemaTO> T read(@PathParam("kind") AttributableType kind,
- @PathParam("type") SchemaType type,
+ <T extends AbstractSchemaTO> T read(@PathParam("kind") AttributableType kind, @PathParam("type") SchemaType type,
@PathParam("name") String schemaName);
@PUT
@Path("{name}")
<T extends AbstractSchemaTO> void update(@PathParam("kind") AttributableType kind,
- @PathParam("type") SchemaType type,
- @PathParam("name") String schemaName,
- T schemaTO);
+ @PathParam("type") SchemaType type, @PathParam("name") String schemaName, T schemaTO);
}
Modified: syncope/trunk/core/src/main/resources/restContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Mon Jan 28 11:01:17 2013
@@ -74,6 +74,7 @@ under the License.
<ref bean="policyServiceImpl"/>
<ref bean="reportServiceImpl"/>
<ref bean="resourceServiceImpl"/>
+ <ref bean="roleServiceImpl"/>
<ref bean="schemaServiceImpl"/>
<ref bean="userRequestServiceImpl"/>
</jaxrs:serviceBeans>
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Mon Jan 28 11:01:17 2013
@@ -80,7 +80,7 @@ import org.springframework.test.context.
import org.springframework.web.client.RestTemplate;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
+@ContextConfiguration(locations = { "classpath:restClientContext.xml", "classpath:testJDBCContext.xml" })
public abstract class AbstractTest {
/**
@@ -93,8 +93,11 @@ public abstract class AbstractTest {
protected static final String ADMIN_UID = "admin";
protected static final String ADMIN_PWD = "password";
-
- private static final String DEFAULT_CONTENT_TYPE = "application/json";
+
+ public static final String CONTENT_TYPE_JSON = "application/json";
+ public static final String CONTENT_TYPE_XML = "text/xml";
+ public static final String DEFAULT_CONTENT_TYPE = CONTENT_TYPE_JSON;
+
private static final String ENV_KEY_CONTENT_TYPE = "jaxrsContentType";
@Autowired
@@ -115,7 +118,7 @@ public abstract class AbstractTest {
private boolean enabledCXF;
private String contentType;
-
+
protected UserService userService;
protected RoleService roleService;
@@ -143,7 +146,7 @@ public abstract class AbstractTest {
protected UserRequestService userRequestService;
protected PolicyService policyService;
-
+
@Before
public void setup() throws Exception {
if (!enabledCXF) {
@@ -188,6 +191,7 @@ public abstract class AbstractTest {
schemaService = new SchemaServiceProxy(BASE_URL, restTemplate);
userRequestService = new UserRequestServiceProxy(BASE_URL, restTemplate);
}
+
// END Spring MVC Initialization
// BEGIN CXF Initialization
@@ -208,15 +212,15 @@ public abstract class AbstractTest {
userRequestService = createServiceInstance(UserRequestService.class);
}
- protected <T> T createServiceInstance(Class<T> serviceClass) {
+ protected <T> T createServiceInstance(final Class<T> serviceClass) {
return createServiceInstance(serviceClass, ADMIN_UID);
}
- protected <T> T createServiceInstance(Class<T> serviceClass, String username) {
+ protected <T> T createServiceInstance(final Class<T> serviceClass, final String username) {
return createServiceInstance(serviceClass, username, ADMIN_PWD);
}
- protected <T> T createServiceInstance(Class<T> serviceClass, String username, String password) {
+ protected <T> T createServiceInstance(final Class<T> serviceClass, final String username, final String password) {
restClientFactory.setUsername(username);
restClientFactory.setPassword(password);
restClientFactory.setServiceClass(serviceClass);
@@ -225,14 +229,14 @@ public abstract class AbstractTest {
return serviceProxy;
}
- public WebClient createWebClient(String path) {
+ public WebClient createWebClient(final String path) {
WebClient wc = restClientFactory.createWebClient().to(BASE_URL, false);
wc.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE);
wc.path(path);
return wc;
}
- public void setupContentType(Client restClient) {
+ public void setupContentType(final Client restClient) {
if (contentType == null) {
String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
if ((envContentType != null) && (!envContentType.isEmpty())) {
@@ -243,6 +247,7 @@ public abstract class AbstractTest {
}
restClient.type(contentType).accept(contentType);
}
+
// END CXF Initialization
public <T> T getObject(final Response response, final Class<T> type, final Object serviceProxy) {
@@ -259,11 +264,11 @@ public abstract class AbstractTest {
return restTemplate.getForEntity(response.getLocation(), type).getBody();
}
- public void setEnabledCXF(boolean enabledCXF) {
+ public void setEnabledCXF(final boolean enabledCXF) {
this.enabledCXF = enabledCXF;
}
- public void setContentType(String contentType) {
+ public void setContentType(final String contentType) {
this.contentType = contentType;
}
@@ -274,7 +279,7 @@ public abstract class AbstractTest {
return webClient.get(type);
}
-
+
protected static String getUUIDString() {
return UUID.randomUUID().toString().substring(0, 8);
}
@@ -295,7 +300,7 @@ public abstract class AbstractTest {
@Parameters
public static Collection<Object[]> data() {
- Object[][] data = new Object[][]{{"application/json"}};
+ Object[][] data = new Object[][] { { "application/json" } };
return Arrays.asList(data);
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java Mon Jan 28 11:01:17 2013
@@ -24,8 +24,10 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.JVM)
public class EntitlementTestITCaseJAXRS extends AuthenticationTestITCase {
-
+
public EntitlementTestITCaseJAXRS() {
setEnabledCXF(true);
+ //JSON is currently not working (fix after CXF migration is complete)
+ setContentType(super.CONTENT_TYPE_XML);
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java?rev=1439342&r1=1439341&r2=1439342&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java Mon Jan 28 11:01:17 2013
@@ -24,8 +24,10 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.JVM)
public class SchemaTestITCaseJAXRS extends SchemaTestITCase {
-
+
public SchemaTestITCaseJAXRS() {
setEnabledCXF(true);
+ //JSON is currently not working (fix after CXF migration is complete)
+ setContentType(super.CONTENT_TYPE_XML);
}
}