/**
 * Copyright (C) 2011-2012 Ness Computing, Inc.
 *
 * 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 com.nesscomputing.testing.lessio;

import java.io.IOException;
import java.net.Inet4Address;

import org.junit.Before;
import org.junit.Test;

import com.kaching.platform.common.Option;
import com.nesscomputing.testing.lessio.AllowDNSResolution;
import com.nesscomputing.testing.lessio.LessIOSecurityManager;

public class AllowDNSResolutionTest extends LessIOSecurityManagerTestHelper {
  protected class DisallowedOperation implements RunnableWithException {
    public void run() throws IOException {
      Inet4Address.getByName("example.com");
    }
  }

  @AllowDNSResolution
  protected class AllowedOperation extends DisallowedOperation {
    @Override
    public void run() throws IOException {
      super.run();
    }
  }

  LessIOSecurityManager sm;

  @Before
  public void setupSecurityManager() {
    sm = new LessIOSecurityManager();
  }

  @Test
  public void testNonAnnotatedOperation() {
    assertDisallowed(sm, new DisallowedOperation());
  }

  @Test
  public void testAnnotatedOperations() {
    assertAllowed(sm, new AllowedOperation(),
        Option.<Class<? extends Exception>> none());
  }
}

@@ -1068,24 +1068,38 @@
 Exception %7B%0A
+    @Override%0A
     public v
@@ -1125,24 +1125,24 @@
 Exception %7B%0A
-
       Inet4A
@@ -1185,16 +1185,289 @@
  %7D%0A  %7D%0A%0A
+  protected class LocalhostOperation implements RunnableWithException %7B%0A    @Override%0A    public void run() throws IOException %7B%0A        Inet4Address.getByName(%22127.0.0.1%22);%0A        Inet4Address.getByName(%22localhost%22);%0A        Inet4Address.getByName(%22::1%22);%0A      %7D%0A    %7D%0A%0A
   @Allow
@@ -1801,24 +1801,24 @@
 eration() %7B%0A
-
     assertDi
@@ -1855,32 +1855,182 @@
 ration());%0A  %7D%0A%0A
+  @Test%0A  public void testNonAnnotatedLocalhost() %7B%0A    assertAllowed(sm, new LocalhostOperation(), Option.%3CClass%3C? extends Exception%3E%3E none());%0A  %7D%0A%0A
   @Test%0A  public

Add test to show that resolving localhost is not allowed by default