// Path: component/src/main/java/org/apache/camel/osgi/service/util/OsgiServiceList.java
// public class OsgiServiceList<E> extends OsgiServiceCollection<E> implements List<E>, RandomAccess {
// 
//     public OsgiServiceList(BundleContext context, String filter, ClassLoader classLoader,
//         OsgiProxyCreator proxyCreator) {
// 
//         super(context, filter, classLoader, proxyCreator, new DynamicList<E>());
//     }
// 
//     @Override
//     @SuppressWarnings("unchecked")
//     public E get(int index) {
//         return services.get(index);
//     }
// 
//     @Override
//     public int indexOf(Object o) {
//         return ((DynamicList<E>) services).indexOf(o);
//     }
// 
//     @Override
//     public int lastIndexOf(Object o) {
//         return ((DynamicList<E>) services).lastIndexOf(o);
//     }
// 
//     @Override
//     public ListIterator<E> listIterator() {
//         return listIterator(0);
//     }
// 
//     @Override
//     public ListIterator<E> listIterator(final int index) {
//         return new OsgiServiceListIterator(index);
//     }
// 
//     // TODO: implement me (sublist must be backed by this list)
//     @Override
//     public List<E> subList(int fromIndex, int toIndex) {
//         throw new UnsupportedOperationException();
//     }
// 
//     // mutators are forbidden
// 
//     @Override
//     public E remove(int index) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public E set(int index, Object o) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public void add(int index, Object o) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public boolean addAll(int index, Collection c) {
//         throw new UnsupportedOperationException();
//     }
// 
//     protected class OsgiServiceListIterator implements ListIterator<E> {
//         private final ListIterator<E> iter;
// 
//         @SuppressWarnings("unchecked")
//         public OsgiServiceListIterator(int index) {
//             iter = services.iterator(index);
//         }
// 
//         @Override
//         public E next() {
//             return iter.next();
//         }
// 
//         @Override
//         public E previous() {
//             return iter.previous();
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return iter.hasNext();
//         }
// 
//         @Override
//         public boolean hasPrevious() {
//             return iter.hasPrevious();
//         }
// 
//         @Override
//         public int nextIndex() {
//             return iter.nextIndex();
//         }
// 
//         @Override
//         public int previousIndex() {
//             return iter.previousIndex();
//         }
// 
//         // mutators are forbidden
// 
//         @Override
//         public void add(Object o) {
//             throw new UnsupportedOperationException();
//         }
// 
//         @Override
//         public void remove() {
//             throw new UnsupportedOperationException();
//         }
// 
//         @Override
//         public void set(Object o) {
//             throw new UnsupportedOperationException();
//         }
// 
//     }
// 
// }


import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.osgi.service.util.OsgiServiceList;
import org.apache.camel.processor.loadbalancer.LoadBalancer;
import org.apache.camel.util.ServiceHelper;
import org.junit.Test;
import org.mockito.Matchers;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceListener;
import java.util.Collections;
import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
/*
 * 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 org.apache.camel.osgi.service;




public class OsgiDefaultProducerTest {

    @Test
    public void testProcess() throws Exception {
        Processor processor = mock(Processor.class);

        OsgiDefaultProducer producer = createProducer(Collections.<String, Object>emptyMap());
        producer.processor = processor;

        Exchange exchange = mock(Exchange.class);
        producer.process(exchange);

        verify(processor).process(same(exchange));
    }

    @Test
    public void testCreateProcessor() throws Exception {
        OsgiDefaultProducer producer = createProducer(Collections.<String, Object>emptyMap());

        Processor processor = producer.createProcessor();
        assertThat(processor, instanceOf(OsgiDefaultLoadBalancer.class));
// Path: component/src/main/java/org/apache/camel/osgi/service/util/OsgiServiceList.java
// public class OsgiServiceList<E> extends OsgiServiceCollection<E> implements List<E>, RandomAccess {
// 
//     public OsgiServiceList(BundleContext context, String filter, ClassLoader classLoader,
//         OsgiProxyCreator proxyCreator) {
// 
//         super(context, filter, classLoader, proxyCreator, new DynamicList<E>());
//     }
// 
//     @Override
//     @SuppressWarnings("unchecked")
//     public E get(int index) {
//         return services.get(index);
//     }
// 
//     @Override
//     public int indexOf(Object o) {
//         return ((DynamicList<E>) services).indexOf(o);
//     }
// 
//     @Override
//     public int lastIndexOf(Object o) {
//         return ((DynamicList<E>) services).lastIndexOf(o);
//     }
// 
//     @Override
//     public ListIterator<E> listIterator() {
//         return listIterator(0);
//     }
// 
//     @Override
//     public ListIterator<E> listIterator(final int index) {
//         return new OsgiServiceListIterator(index);
//     }
// 
//     // TODO: implement me (sublist must be backed by this list)
//     @Override
//     public List<E> subList(int fromIndex, int toIndex) {
//         throw new UnsupportedOperationException();
//     }
// 
//     // mutators are forbidden
// 
//     @Override
//     public E remove(int index) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public E set(int index, Object o) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public void add(int index, Object o) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public boolean addAll(int index, Collection c) {
//         throw new UnsupportedOperationException();
//     }
// 
//     protected class OsgiServiceListIterator implements ListIterator<E> {
//         private final ListIterator<E> iter;
// 
//         @SuppressWarnings("unchecked")
//         public OsgiServiceListIterator(int index) {
//             iter = services.iterator(index);
//         }
// 
//         @Override
//         public E next() {
//             return iter.next();
//         }
// 
//         @Override
//         public E previous() {
//             return iter.previous();
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return iter.hasNext();
//         }
// 
//         @Override
//         public boolean hasPrevious() {
//             return iter.hasPrevious();
//         }
// 
//         @Override
//         public int nextIndex() {
//             return iter.nextIndex();
//         }
// 
//         @Override
//         public int previousIndex() {
//             return iter.previousIndex();
//         }
// 
//         // mutators are forbidden
// 
//         @Override
//         public void add(Object o) {
//             throw new UnsupportedOperationException();
//         }
// 
//         @Override
//         public void remove() {
//             throw new UnsupportedOperationException();
//         }
// 
//         @Override
//         public void set(Object o) {
//             throw new UnsupportedOperationException();
//         }
// 
//     }
// 
// }


// Path: component/src/test/java/org/apache/camel/osgi/service/OsgiDefaultProducerTest.java
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.osgi.service.util.OsgiServiceList;
import org.apache.camel.processor.loadbalancer.LoadBalancer;
import org.apache.camel.util.ServiceHelper;
import org.junit.Test;
import org.mockito.Matchers;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceListener;
import java.util.Collections;
import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;

/*
 * 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 org.apache.camel.osgi.service;




public class OsgiDefaultProducerTest {

    @Test
    public void testProcess() throws Exception {
        Processor processor = mock(Processor.class);

        OsgiDefaultProducer producer = createProducer(Collections.<String, Object>emptyMap());
        producer.processor = processor;

        Exchange exchange = mock(Exchange.class);
        producer.process(exchange);

        verify(processor).process(same(exchange));
    }

    @Test
    public void testCreateProcessor() throws Exception {
        OsgiDefaultProducer producer = createProducer(Collections.<String, Object>emptyMap());

        Processor processor = producer.createProcessor();
        assertThat(processor, instanceOf(OsgiDefaultLoadBalancer.class));
        assertThat(((LoadBalancer) processor).getProcessors(), instanceOf(OsgiServiceList.class));