Permalink
Browse files

New test for GORFX main service

  • Loading branch information...
1 parent 37458d2 commit 1bab6a733bb3f145c07db5c0a01cd1ff8481e243 Jörg Bachmann committed Apr 25, 2012
@@ -1,80 +0,0 @@
-package de.zib.gndms.gndmc.dspace.Test;
-
-/*
- * Copyright 2008-2011 Zuse Institute Berlin (ZIB)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import de.zib.gndms.gndmc.dspace.SliceKindClient;
-import org.springframework.http.ResponseEntity;
-import org.testng.AssertJUnit;
-import org.testng.annotations.Test;
-
-import de.zib.gndms.logic.model.dspace.SliceKindConfiguration;
-
-/**
- * Tests the DSpaceClient.
- *
- * @author Ulrike Golas
- */
-
-public class SliceKindClientTest {
- /**
- * Tests the constructors.
- */
- @Test
- public final void testConstructor() {
-
- SliceKindClient scl = new SliceKindClient();
- AssertJUnit.assertNotNull(scl);
-
- String a = "test";
- scl = new SliceKindClient(a);
-
- AssertJUnit.assertEquals(a, scl.getServiceURL());
- }
-
- /**
- * Tests the request methods.
- */
- @Test
- public final void testBehavior() {
- String a = "test";
- SliceKindClient scl = new SliceKindClient(a);
-
- MockRestTemplate mockTemplate = new MockRestTemplate();
- mockTemplate.setServiceURL(a);
- scl.setRestTemplate(mockTemplate);
-
- String dn = "me";
- String subspace = "testSubspace";
- String sliceKind = "testSliceKind";
- ResponseEntity<?> res;
-
- res = scl.getSliceKindInfo(subspace, sliceKind, dn);
- AssertJUnit.assertNotNull(res);
-
- String uri = "testuri";
- String permission = "345";
- SliceKindConfiguration config = new SliceKindConfiguration(uri, permission, null);
- //res = scl.createSlice(subspace, sliceKind, config, dn);
- //AssertJUnit.assertNotNull(res);
-
- //res = scl.createSlice(subspace, sliceKind, config, dn);
- //AssertJUnit.assertNotNull(res);
-
- res = scl.deleteSliceKind(subspace, sliceKind, dn);
- AssertJUnit.assertNotNull(res);
- }
-}
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008-2012 Zuse Institute Berlin (ZIB)
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package de.zib.gndms.gndmc.gorfx.Test;
+
+import de.zib.gndms.common.rest.Facets;
+import de.zib.gndms.common.rest.Specifier;
+import de.zib.gndms.gndmc.gorfx.GORFXClient;
+import de.zib.gndms.taskflows.failure.client.FailureTaskFlowMeta;
+import de.zib.gndms.taskflows.failure.client.model.FailureOrder;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.LinkedMultiValueMap;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @date: 25.04.12
+ * @time: 12:11
+ * @author: Jörg Bachmann
+ * @email: bachmann@zib.de
+ */
+public class GORFXClientTest {
+ final ApplicationContext context;
+
+ private GORFXClient gorfxClient;
+
+ final private String serviceUrl;
+ final private String admindn;
+
+
+ @Parameters( { "serviceUrl", "admindn" } )
+ public GORFXClientTest( final String serviceUrl, @Optional( "root" ) final String admindn ) {
+ this.serviceUrl = serviceUrl;
+ this.admindn = admindn;
+
+ this.context = new ClassPathXmlApplicationContext( "classpath:META-INF/client-context.xml" );
+ }
+
+
+ @BeforeClass( groups = { "GORFXServiceTest" } )
+ public void init() {
+ gorfxClient = ( GORFXClient )context.getAutowireCapableBeanFactory().createBean(
+ GORFXClient.class,
+ AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true );
+ gorfxClient.setServiceURL(serviceUrl);
+
+ //restTemplate = ( RestTemplate )context.getAutowireCapableBeanFactory().getBean( "restTemplate" );
+ }
+
+
+ @Test( groups = { "GORFXServiceTest" } )
+ public void listFacets() {
+ ResponseEntity< Facets > gorfxFacets;
+ gorfxFacets = gorfxClient.listAvailableFacets( admindn );
+
+ Assert.assertNotNull( gorfxFacets );
+ Assert.assertEquals( gorfxFacets.getStatusCode(), HttpStatus.OK );
+ }
+
+
+ @Test( groups = { "GORFXServiceTest" } )
+ public void listTaskFlows() {
+ ResponseEntity< List< String > > responseEntity = gorfxClient.listTaskFlows( admindn );
+
+ Assert.assertNotNull( responseEntity );
+ Assert.assertEquals( responseEntity.getStatusCode(), HttpStatus.OK );
+ }
+
+
+
+ @Test( groups = { "GORFXServiceTest" }, dependsOnMethods = { "listFacets", "listTaskFlows" } )
+ public void createTaskFlow() {
+ // create TaskFlow
+ {
+ FailureOrder order = new FailureOrder();
+ order.setMessage( "TESTING TaskFlow creation" );
+ order.setWhere( FailureOrder.FailurePlace.NOWHERE );
+
+ ResponseEntity<Specifier< Facets > > responseEntity = gorfxClient.createTaskFlow(
+ FailureTaskFlowMeta.TASK_FLOW_TYPE_KEY,
+ order,
+ admindn,
+ "GORFXTaskFlowTEST",
+ new LinkedMultiValueMap< String, String >()
+ );
+
+ Assert.assertNotNull( responseEntity );
+ Assert.assertEquals( responseEntity.getStatusCode(), HttpStatus.CREATED );
+ }
+
+ // get TaskFlow Info
+ //{
+ // ResponseEntity< TaskFlowInfo > responseEntity = gorfxClient.getTaskFlowInfo(
+ // FailureTaskFlowMeta.TASK_FLOW_TYPE_KEY, admindn );
+ //
+ // Assert.assertNotNull( responseEntity );
+ // Assert.assertEquals( responseEntity.getStatusCode(), HttpStatus.OK );
+ //}
+ }
+}

0 comments on commit 1bab6a7

Please sign in to comment.