/*
 * Copyright 2014-2017 the original author or authors.
 *
 * 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.springframework.cloud.stream.binder.kafka;

import java.util.List;

import org.springframework.cloud.stream.binder.AbstractTestBinder;
import org.springframework.cloud.stream.binder.ExtendedConsumerProperties;
import org.springframework.cloud.stream.binder.ExtendedProducerProperties;
import org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties;
import org.springframework.cloud.stream.binder.kafka.properties.KafkaProducerProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.codec.Codec;
import org.springframework.integration.codec.kryo.KryoRegistrar;
import org.springframework.integration.codec.kryo.PojoCodec;
import org.springframework.integration.tuple.TupleKryoRegistrar;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Registration;

/**
 * @author Soby Chacko
 * @author Gary Russell
 */
public abstract class AbstractKafkaTestBinder extends
		AbstractTestBinder<KafkaMessageChannelBinder, ExtendedConsumerProperties<KafkaConsumerProperties>, ExtendedProducerProperties<KafkaProducerProperties>> {

	private ApplicationContext applicationContext;

	@Override
	public void cleanup() {
		// do nothing - the rule will take care of that
	}

	protected final void setApplicationContext(ApplicationContext context) {
		this.applicationContext = context;
	}

	public ApplicationContext getApplicationContext() {
		return this.applicationContext;
	}

	protected static Codec getCodec() {
		return new PojoCodec(new TupleRegistrar());
	}

	private static class TupleRegistrar implements KryoRegistrar {
		private final TupleKryoRegistrar delegate = new TupleKryoRegistrar();

		@Override
		public void registerTypes(Kryo kryo) {
			this.delegate.registerTypes(kryo);
		}

		@Override
		public List<Registration> getRegistrations() {
			return this.delegate.getRegistrations();
		}
	}

}


@@ -674,32 +674,8 @@
 a;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -737,16 +737,16 @@
 Binder;%0A
+
 import o
@@ -1176,73 +1176,8 @@
 ec;%0A
-import org.springframework.integration.codec.kryo.KryoRegistrar;%0A
 impo
@@ -1303,95 +1303,8 @@
 r;%0A%0A
-import com.esotericsoftware.kryo.Kryo;%0Aimport com.esotericsoftware.kryo.Registration;%0A%0A
 /**%0A
@@ -1975,24 +1975,28 @@
 ec(new Tuple
+Kryo
 Registrar())
@@ -2000,354 +2000,8 @@
 ());
-%0A%09%7D%0A%0A%09private static class TupleRegistrar implements KryoRegistrar %7B%0A%09%09private final TupleKryoRegistrar delegate = new TupleKryoRegistrar();%0A%0A%09%09@Override%0A%09%09public void registerTypes(Kryo kryo) %7B%0A%09%09%09this.delegate.registerTypes(kryo);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public List%3CRegistration%3E getRegistrations() %7B%0A%09%09%09return this.delegate.getRegistrations();%0A%09%09%7D
 %0A%09%7D%0A

Remove Tuple Kryo Registrar Wrapper