/*******************************************************************************
 * Copyright 2016 Darren Blaber
 *
 * 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.
 *
 * 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.da4.urlminimizer.junit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.HashMap;

import org.da4.urlminimizer.UrlMinimizer;
import org.da4.urlminimizer.vo.ConfigVO;
import org.junit.Before;
import org.junit.Test;

public class TestUrlMinimizer {

	static UrlMinimizer mini = null;
	ConfigVO config = null;

	@Before
	public void setUp() throws Exception {
		if (mini == null)
			mini = new UrlMinimizer("/home/dmb/urlmini.xml");
		config = mini.getConfig();
	}

	// @Test
	// public void testUrlMinimizer() {
	// fail("Not yet implemented");
	// }

	@Test
	public void testMinimize() {
		String small = mini.minimize("http://google.com",new HashMap<String,String>());
		System.out.println("small url: " + small);
		assertEquals(config.getRootUrl() + "xyz", small);
		for (int i = 0; i < 100; i++) {
			small = mini.minimize("http://google2.com" + i,new HashMap<String,String>());
			System.out.println("small url" + i + ": " + small);
			assertNotNull(small);
		}
	}

	@Test
	public void testMaximize() {
		String small = mini.maximize("xyz", new HashMap<String,String>());
		System.out.println("big url: " + small);
		assertEquals("http://google.com", small);

		small = mini.maximize("68", new HashMap<String,String>());
		System.out.println("big url2: " + small);
		assertNotNull(small);
	}

}

@@ -1272,16 +1272,78 @@
 imizer;%0A
+import org.da4.urlminimizer.exception.AliasDisabledException;%0A
 import o
@@ -1375,16 +1375,16 @@
 nfigVO;%0A
-
 import o
@@ -1789,24 +1789,54 @@
 stMinimize()
+ throws AliasDisabledException
  %7B%0A%09%09String 
@@ -2207,32 +2207,32 @@
 %0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A
-
 %09public void tes
@@ -2242,16 +2242,46 @@
 ximize()
+ throws AliasDisabledException
  %7B%0A%09%09Str

Allow testcase to pass