Changeset 5549 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ConcurrentRestServiceTest.java
- Timestamp:
- 08/11/14 16:07:55 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ConcurrentRestServiceTest.java
r4098 r5549 1 1 package clarin.cmdi.componentregistry.rest; 2 2 3 import clarin.cmdi.componentregistry.RegistrySpace; 3 4 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase; 4 5 import clarin.cmdi.componentregistry.model.BaseDescription; … … 20 21 21 22 import org.junit.Before; 22 import org.junit.BeforeClass;23 23 import org.junit.Test; 24 24 import org.slf4j.Logger; … … 27 27 import org.springframework.jdbc.core.JdbcTemplate; 28 28 29 import static clarin.cmdi.componentregistry.rest.ComponentRegistryRestService. USERSPACE_PARAM;29 import static clarin.cmdi.componentregistry.rest.ComponentRegistryRestService.REGISTRY_SPACE_PARAM; 30 30 import static org.junit.Assert.*; 31 31 … … 58 58 List<Thread> ts = new ArrayList<Thread>(); 59 59 60 registerProfiles(ts, NR_OF_PROFILES, errors, false); 61 registerProfiles(ts, NR_OF_PROFILES, errors, true); 62 63 registerComponents(ts, NR_OF_COMPONENTS, errors, false); 64 registerComponents(ts, NR_OF_COMPONENTS, errors, true); 60 registerProfiles(ts, NR_OF_PROFILES, errors, RegistrySpace.PRIVATE); 61 //a profile can be first registered (created) only in private space, and then moved. 62 //registerProfiles(ts, NR_OF_PROFILES, errors, RegistrySpace.PUBLISHED); 63 64 registerComponents(ts, NR_OF_COMPONENTS, errors, RegistrySpace.PRIVATE); 65 //a profile can be first registered (created) only in private space, and then moved. 66 //registerComponents(ts, NR_OF_COMPONENTS, errors, RegistrySpace.PUBLISHED); 65 67 runAllThreads(ts); 66 68 if (errors.size() > 0) { … … 70 72 fail(); 71 73 } 72 assertProfiles(NR_OF_PROFILES, false);73 assertProfiles(NR_OF_PROFILES, true);74 75 assertComponents(NR_OF_COMPONENTS, false);76 assertComponents(NR_OF_COMPONENTS, true);77 } 78 79 private void assertProfiles(int nrOfProfiles, boolean userSpace) {74 assertProfiles(NR_OF_PROFILES, RegistrySpace.PRIVATE); 75 //assertProfiles(NR_OF_PROFILES, RegistrySpace.PUBLISHED); 76 77 assertComponents(NR_OF_COMPONENTS, RegistrySpace.PRIVATE); 78 //assertComponents(NR_OF_COMPONENTS, RegistrySpace.PUBLISHED); 79 } 80 81 private void assertProfiles(int nrOfProfiles, RegistrySpace registrySpace) { 80 82 List<ProfileDescription> response = getAuthenticatedResource( 81 83 getResource().path("/registry/profiles").queryParam( 82 USERSPACE_PARAM, "" + userSpace)).accept(84 REGISTRY_SPACE_PARAM, registrySpace.name())).accept( 83 85 MediaType.APPLICATION_XML).get(PROFILE_LIST_GENERICTYPE); 84 86 Collections.sort(response, descriptionComparator); … … 101 103 }; 102 104 103 private void assertComponents(int nrOfComponents, boolean userSpace) {105 private void assertComponents(int nrOfComponents, RegistrySpace registrySpace) { 104 106 List<ComponentDescription> cResponse = getAuthenticatedResource( 105 107 getResource().path("/registry/components").queryParam( 106 USERSPACE_PARAM, "" + userSpace)).accept(108 REGISTRY_SPACE_PARAM, registrySpace.name())).accept( 107 109 MediaType.APPLICATION_XML).get(COMPONENT_LIST_GENERICTYPE); 108 110 Collections.sort(cResponse, descriptionComparator); … … 128 130 129 131 private void registerProfiles(List<Thread> ts, int size, 130 final List<String> errors, boolean userSpace)132 final List<String> errors, RegistrySpace registrySpace) 131 133 throws InterruptedException { 132 134 for (int i = 0; i < size; i++) { … … 134 136 LOG.debug("Profile {} should be registered in {} and {}", 135 137 new Object[] { i + 1000, 136 userSpace ? "user space" : "public space",138 registrySpace.name(), 137 139 shouldDelete ? "ALSO DELETED" : "not deleted" }); 138 Thread thread = createThread("/registry/profiles/", userSpace,140 Thread thread = createThread("/registry/profiles/", registrySpace, 139 141 "Test Profile" + (i + 1000), shouldDelete, 140 142 RegistryTestHelper.getTestProfileContent(), errors); … … 144 146 145 147 private void registerComponents(List<Thread> ts, int size, 146 final List<String> errors, boolean userSpace)148 final List<String> errors, RegistrySpace registrySpace) 147 149 throws InterruptedException { 148 150 for (int i = 0; i < size; i++) { … … 150 152 LOG.debug("Component {} should be registered in {} and {}", 151 153 new Object[] { i + 1000, 152 userSpace ? "user space" : "public space",154 registrySpace.name(), 153 155 shouldDelete ? "ALSO DELETED" : "not deleted" }); 154 Thread thread = createThread("/registry/components/", userSpace,156 Thread thread = createThread("/registry/components/", registrySpace, 155 157 "Test Component" + (i + 1000), shouldDelete, 156 158 RegistryTestHelper.getComponentTestContent(), errors); … … 159 161 } 160 162 161 private Thread createThread(final String path, final boolean userSpace,163 private Thread createThread(final String path, final RegistrySpace registrySpace, 162 164 final String name, final boolean alsoDelete, InputStream content, 163 165 final List<String> errors) throws InterruptedException { … … 176 178 // System.out.println("THREAD STARTED"+Thread.currentThread().getName()); 177 179 RegisterResponse registerResponse = getAuthenticatedResource( 178 getResource().path(path).queryParam( 179 USERSPACE_PARAM, "" + userSpace)).type( 180 getResource().path(path)).type( 180 181 MediaType.MULTIPART_FORM_DATA).post( 181 182 RegisterResponse.class, form); … … 188 189 + "] REGISTERING DESCRIPTION " + name + " " 189 190 + registerResponse.getDescription().getId() 190 + (Boolean.valueOf(userSpace) ? " userspace" : "")191 + registrySpace.name() 191 192 + (alsoDelete ? " alsoDelete" : "")); 192 193 if (alsoDelete) { … … 197 198 + " " 198 199 + registerResponse.getDescription().getId() 199 + (Boolean.valueOf(userSpace) ? " userspace " 200 : "") 200 + registrySpace.name() 201 201 + (alsoDelete ? " alsoDelete" : "")); 202 202 ClientResponse response = getAuthenticatedResource( … … 205 205 + registerResponse 206 206 .getDescription() 207 .getId()).queryParam( 208 USERSPACE_PARAM, "" + userSpace)) 207 .getId())) 209 208 .delete(ClientResponse.class); 210 209 if (response.getStatus() != 200) {
Note: See TracChangeset
for help on using the changeset viewer.