|
| 1 | +/* |
| 2 | + * Copyright 2015 Time Warner Cable, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.twcable.grabbit.server.services |
| 18 | + |
| 19 | +import com.twcable.grabbit.GrabbitConfiguration |
| 20 | +import com.twcable.grabbit.client.services.ClientService |
| 21 | +import com.twcable.grabbit.client.services.impl.DefaultClientService |
| 22 | +import com.twcable.grabbit.jcr.AbstractJcrSpec |
| 23 | +import com.twcable.jackalope.impl.sling.SimpleResourceResolverFactory |
| 24 | +import com.twcable.jackalope.impl.sling.SlingRepositoryImpl |
| 25 | +import org.apache.sling.jcr.api.SlingRepository |
| 26 | +import org.springframework.context.ApplicationContext |
| 27 | +import org.springframework.context.ConfigurableApplicationContext |
| 28 | +import org.springframework.context.support.ClassPathXmlApplicationContext |
| 29 | +import org.springframework.context.support.StaticApplicationContext |
| 30 | +import spock.lang.Subject |
| 31 | + |
| 32 | +@Subject(ServerService) |
| 33 | +class ClientServiceSpec extends AbstractJcrSpec { |
| 34 | + |
| 35 | + SlingRepository slingRepository |
| 36 | + |
| 37 | + ConfigurableApplicationContext appCtx |
| 38 | + |
| 39 | + ClientService syncClientService |
| 40 | + |
| 41 | + |
| 42 | + def setup() { |
| 43 | + slingRepository = new SlingRepositoryImpl() |
| 44 | + |
| 45 | + ApplicationContext parentAppCtx = new StaticApplicationContext() |
| 46 | + parentAppCtx.beanFactory.registerSingleton("slingRepository", slingRepository) |
| 47 | + parentAppCtx.beanFactory.registerSingleton("resourceResolverFactory", new SimpleResourceResolverFactory(slingRepository)) |
| 48 | + parentAppCtx.refresh() |
| 49 | + appCtx = new ClassPathXmlApplicationContext(["META-INF/spring/client-batch-job.xml", "META-INF/spring/client-workflow-on-step.xml", "META-INF/spring/client-workflow-off-step.xml"] as String[], parentAppCtx) |
| 50 | + |
| 51 | + syncClientService = new DefaultClientService(slingRepository: slingRepository, |
| 52 | + configurableApplicationContext: appCtx) |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | + def "Service initiate a grab and return jobs"() { |
| 57 | + when: |
| 58 | + def jobIds = syncClientService.initiateGrab(new GrabbitConfiguration("admin", "adminPass", "testbox", "4502", false, [new GrabbitConfiguration.PathConfiguration("/content/test", [], [], false)]), "admin") |
| 59 | + |
| 60 | + then: |
| 61 | + jobIds.size() == 1 |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments