ServiceReference<String> ref = Mockito.mock( ServiceReference.class );
ServiceReference<String> ref2 = Mockito.mock( ServiceReference.class );
when( mockContext.getServiceReferences( String.class, null ) ).thenReturn( Arrays.asList( ref, ref2 ) );
when( mockContext.getServiceReferences( Integer.class, null ) )
.thenThrow( new InvalidSyntaxException( "bad", "call" ) );
when( mockContext.getService( ref ) ).thenReturn( "SomeString" );
when( mockContext.getService( ref2 ) ).thenReturn( "SomeString2" );
OSGIObjectFactory factory = new OSGIObjectFactory( mockContext );
List<String> actual = factory.getAll( String.class, session );