@@ -142,9 +142,42 @@ public WireMockContainer withMapping(String name, String json) {
142142 * @param resourceJson Mapping definition file
143143 * @return this instance
144144 */
145+ public WireMockContainer withMappingFromResource (String name , Class <?> resource , String resourceJson ) {
146+ return withMapping (name , resource .getSimpleName () + "/" + resourceJson );
147+ }
148+
149+ /**
150+ * @deprecated use {@link #withMappingFromResource(String, Class, String)}
151+ */
152+ @ Deprecated
145153 public WireMockContainer withMapping (String name , Class <?> resource , String resourceJson ) {
154+ return withMappingFromResource (name , resource , resourceJson );
155+ }
156+
157+ /**
158+ * Loads mapping stub from the resource file
159+ * @param name Name of the mapping stub
160+ * @param resourceName Resource name and path
161+ * @return this instance
162+ */
163+ public WireMockContainer withMappingFromResource (String name , String resourceName ) {
164+ try {
165+ URL url = Resources .getResource (resourceName );
166+ String text = Resources .toString (url , StandardCharsets .UTF_8 );
167+ return withMapping (name , text );
168+ } catch (IOException ex ) {
169+ throw new IllegalArgumentException (ex );
170+ }
171+ }
172+
173+ /**
174+ * Loads mapping stub from the resource file
175+ * @param name Name of the mapping stub
176+ * @param url Resource file URL
177+ * @return this instance
178+ */
179+ public WireMockContainer withMappingFromResource (String name , URL url ) {
146180 try {
147- URL url = Resources .getResource (resource , resource .getSimpleName () + "/" + resourceJson );
148181 String text = Resources .toString (url , StandardCharsets .UTF_8 );
149182 return withMapping (name , text );
150183 } catch (IOException ex ) {
0 commit comments