11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2017 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package org .springframework .scripting .bsh ;
1818
19+ import java .io .IOException ;
1920import java .util .Arrays ;
2021import java .util .Collection ;
2122
4748public class BshScriptFactoryTests {
4849
4950 @ Test
50- public void staticScript () throws Exception {
51+ public void staticScript () {
5152 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
5253
5354 assertTrue (Arrays .asList (ctx .getBeanNamesForType (Calculator .class )).contains ("calculator" ));
@@ -75,7 +76,7 @@ public void staticScript() throws Exception {
7576 }
7677
7778 @ Test
78- public void staticScriptWithNullReturnValue () throws Exception {
79+ public void staticScriptWithNullReturnValue () {
7980 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
8081 assertTrue (Arrays .asList (ctx .getBeanNamesForType (Messenger .class )).contains ("messengerWithConfig" ));
8182
@@ -86,7 +87,7 @@ public void staticScriptWithNullReturnValue() throws Exception {
8687 }
8788
8889 @ Test
89- public void staticScriptWithTwoInterfacesSpecified () throws Exception {
90+ public void staticScriptWithTwoInterfacesSpecified () {
9091 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
9192 assertTrue (Arrays .asList (ctx .getBeanNamesForType (Messenger .class )).contains ("messengerWithConfigExtra" ));
9293
@@ -100,7 +101,7 @@ public void staticScriptWithTwoInterfacesSpecified() throws Exception {
100101 }
101102
102103 @ Test
103- public void staticWithScriptReturningInstance () throws Exception {
104+ public void staticWithScriptReturningInstance () {
104105 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
105106 assertTrue (Arrays .asList (ctx .getBeanNamesForType (Messenger .class )).contains ("messengerInstance" ));
106107
@@ -114,7 +115,7 @@ public void staticWithScriptReturningInstance() throws Exception {
114115 }
115116
116117 @ Test
117- public void staticScriptImplementingInterface () throws Exception {
118+ public void staticScriptImplementingInterface () {
118119 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
119120 assertTrue (Arrays .asList (ctx .getBeanNamesForType (Messenger .class )).contains ("messengerImpl" ));
120121
@@ -128,7 +129,7 @@ public void staticScriptImplementingInterface() throws Exception {
128129 }
129130
130131 @ Test
131- public void staticPrototypeScript () throws Exception {
132+ public void staticPrototypeScript () {
132133 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bshContext.xml" , getClass ());
133134 ConfigurableMessenger messenger = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
134135 ConfigurableMessenger messenger2 = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
@@ -147,7 +148,7 @@ public void staticPrototypeScript() throws Exception {
147148 }
148149
149150 @ Test
150- public void nonStaticScript () throws Exception {
151+ public void nonStaticScript () {
151152 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bshRefreshableContext.xml" , getClass ());
152153 Messenger messenger = (Messenger ) ctx .getBean ("messenger" );
153154
@@ -165,7 +166,7 @@ public void nonStaticScript() throws Exception {
165166 }
166167
167168 @ Test
168- public void nonStaticPrototypeScript () throws Exception {
169+ public void nonStaticPrototypeScript () {
169170 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bshRefreshableContext.xml" , getClass ());
170171 ConfigurableMessenger messenger = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
171172 ConfigurableMessenger messenger2 = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
@@ -189,7 +190,7 @@ public void nonStaticPrototypeScript() throws Exception {
189190 }
190191
191192 @ Test
192- public void scriptCompilationException () throws Exception {
193+ public void scriptCompilationException () {
193194 try {
194195 new ClassPathXmlApplicationContext ("org/springframework/scripting/bsh/bshBrokenContext.xml" );
195196 fail ("Must throw exception for broken script file" );
@@ -200,7 +201,7 @@ public void scriptCompilationException() throws Exception {
200201 }
201202
202203 @ Test
203- public void scriptThatCompilesButIsJustPlainBad () throws Exception {
204+ public void scriptThatCompilesButIsJustPlainBad () throws IOException {
204205 ScriptSource script = mock (ScriptSource .class );
205206 final String badScript = "String getMessage() { throw new IllegalArgumentException(); }" ;
206207 given (script .getScriptAsString ()).willReturn (badScript );
@@ -217,7 +218,7 @@ public void scriptThatCompilesButIsJustPlainBad() throws Exception {
217218 }
218219
219220 @ Test
220- public void ctorWithNullScriptSourceLocator () throws Exception {
221+ public void ctorWithNullScriptSourceLocator () {
221222 try {
222223 new BshScriptFactory (null , Messenger .class );
223224 fail ("Must have thrown exception by this point." );
@@ -227,27 +228,27 @@ public void ctorWithNullScriptSourceLocator() throws Exception {
227228 }
228229
229230 @ Test
230- public void ctorWithEmptyScriptSourceLocator () throws Exception {
231+ public void ctorWithEmptyScriptSourceLocator () {
231232 try {
232- new BshScriptFactory ("" , new Class <?>[] { Messenger .class } );
233+ new BshScriptFactory ("" , Messenger .class );
233234 fail ("Must have thrown exception by this point." );
234235 }
235236 catch (IllegalArgumentException expected ) {
236237 }
237238 }
238239
239240 @ Test
240- public void ctorWithWhitespacedScriptSourceLocator () throws Exception {
241+ public void ctorWithWhitespacedScriptSourceLocator () {
241242 try {
242- new BshScriptFactory ("\n " , new Class <?>[] { Messenger .class } );
243+ new BshScriptFactory ("\n " , Messenger .class );
243244 fail ("Must have thrown exception by this point." );
244245 }
245246 catch (IllegalArgumentException expected ) {
246247 }
247248 }
248249
249250 @ Test
250- public void resourceScriptFromTag () throws Exception {
251+ public void resourceScriptFromTag () {
251252 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("bsh-with-xsd.xml" , getClass ());
252253 TestBean testBean = (TestBean ) ctx .getBean ("testBean" );
253254
@@ -286,7 +287,7 @@ public void resourceScriptFromTag() throws Exception {
286287 }
287288
288289 @ Test
289- public void prototypeScriptFromTag () throws Exception {
290+ public void prototypeScriptFromTag () {
290291 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bsh-with-xsd.xml" , getClass ());
291292 ConfigurableMessenger messenger = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
292293 ConfigurableMessenger messenger2 = (ConfigurableMessenger ) ctx .getBean ("messengerPrototype" );
@@ -302,23 +303,23 @@ public void prototypeScriptFromTag() throws Exception {
302303 }
303304
304305 @ Test
305- public void inlineScriptFromTag () throws Exception {
306+ public void inlineScriptFromTag () {
306307 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bsh-with-xsd.xml" , getClass ());
307308 Calculator calculator = (Calculator ) ctx .getBean ("calculator" );
308309 assertNotNull (calculator );
309310 assertFalse (calculator instanceof Refreshable );
310311 }
311312
312313 @ Test
313- public void refreshableFromTag () throws Exception {
314+ public void refreshableFromTag () {
314315 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bsh-with-xsd.xml" , getClass ());
315316 Messenger messenger = (Messenger ) ctx .getBean ("refreshableMessenger" );
316317 assertEquals ("Hello World!" , messenger .getMessage ());
317318 assertTrue ("Messenger should be Refreshable" , messenger instanceof Refreshable );
318319 }
319320
320321 @ Test
321- public void applicationEventListener () throws Exception {
322+ public void applicationEventListener () {
322323 ApplicationContext ctx = new ClassPathXmlApplicationContext ("bsh-with-xsd.xml" , getClass ());
323324 Messenger eventListener = (Messenger ) ctx .getBean ("eventListener" );
324325 ctx .publishEvent (new MyEvent (ctx ));
0 commit comments