package org.mozilla.javascript.tests;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.NativeJavaObject;
import org.mozilla.javascript.Scriptable;


public class JavaAdapterTest{
	Context cx=null;
	Scriptable topScope=null;
	@Before
	public void enterContext(){
		cx=Context.enter();
		topScope = cx.initStandardObjects();
	}
	@After
	public void exitContext() {
		cx.exit();
	}
	
	interface C {
		int methodInC(String str);
	}
	interface B extends C {
	}
	public abstract class A implements B{
	}
	@Test
	public void testOverrideMethodInMultiLayerInterface() throws NoSuchMethodException {
		String testCode =
	            "JavaAdapter(Packages."+A.class.getName()+",{methodInC:function(){}},null)";
		
		NativeJavaObject adapterObject=(NativeJavaObject)cx.evaluateString(topScope, testCode,"", 1, null);
		
		//if the method 'methodInC' is overrided from 'interface C',
		//its signature will be 'public int methodInC(java.lang.String)'  (expected result), 
		//otherwise if the method 'methodInC' is newly created by JavaAdapter,
		//its signature will be 'public java.lang.Object methodInC()'
		adapterObject.unwrap().getClass().getDeclaredMethod("methodInC", String.class);
	}
}

@@ -30,19 +30,17 @@
 t.tests;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -55,17 +55,16 @@
 t.After;
-%0D
 %0Aimport 
@@ -80,17 +80,16 @@
 .Before;
-%0D
 %0Aimport 
@@ -103,17 +103,16 @@
 it.Test;
-%0D
 %0Aimport 
@@ -142,17 +142,16 @@
 Context;
-%0D
 %0Aimport 
@@ -190,17 +190,16 @@
 aObject;
-%0D
 %0Aimport 
@@ -236,13 +236,10 @@
 ble;
-%0D%0A%0D%0A%0D
+%0A%0A
 %0Apub
@@ -264,17 +264,16 @@
 terTest%7B
-%0D
 %0A%09Contex
@@ -282,17 +282,16 @@
 cx=null;
-%0D
 %0A%09Script
@@ -309,17 +309,16 @@
 pe=null;
-%0D
 %0A%09@Befor
@@ -318,17 +318,16 @@
 %09@Before
-%0D
 %0A%09public
@@ -347,17 +347,16 @@
 ntext()%7B
-%0D
 %0A%09%09cx=Co
@@ -369,17 +369,16 @@
 enter();
-%0D
 %0A%09%09topSc
@@ -412,21 +412,19 @@
 s();
-%0D
 %0A%09%7D
-%0D
 %0A%09@After
 %0D%0A%09p
@@ -419,17 +419,16 @@
 %0A%09@After
-%0D
 %0A%09public
@@ -448,17 +448,16 @@
 text() %7B
-%0D
 %0A%09%09cx.ex
@@ -465,16 +465,13 @@
 t();
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09in
@@ -481,17 +481,16 @@
 face C %7B
-%0D
 %0A%09%09int m
@@ -510,21 +510,19 @@
 ng str);
-%0D
 %0A%09%7D
-%0D
 %0A%09interf
@@ -538,21 +538,19 @@
 ends C %7B
-%0D
 %0A%09%7D
-%0D
 %0A%09public
@@ -584,21 +584,18 @@
 s B%7B
-%0D
 %0A%09%7D
-%0D
 %0A%09@Test
-%0D
 %0A%09pu
@@ -676,17 +676,16 @@
 eption %7B
-%0D
 %0A%09%09Strin
@@ -696,17 +696,16 @@
 stCode =
-%0D
 %0A%09      
@@ -786,21 +786,19 @@
 ,null)%22;
-%0D
 %0A%09%09
-%0D
 %0A%09%09Nativ
@@ -895,13 +895,11 @@
 ll);
-%0D
 %0A%09%09
-%0D
 %0A%09%09/
@@ -957,17 +957,16 @@
 face C',
-%0D
 %0A%09%09//its
@@ -1045,17 +1045,16 @@
 esult), 
-%0D
 %0A%09%09//oth
@@ -1118,17 +1118,16 @@
 Adapter,
-%0D
 %0A%09%09//its
@@ -1182,17 +1182,16 @@
 odInC()'
-%0D
 %0A%09%09adapt
@@ -1268,13 +1268,10 @@
 ss);
-%0D
 %0A%09%7D
-%0D
 %0A%7D
-%0D
 %0A

Fix line endings in new JavaAdapterTest file. (#867)