java.lang.RuntimeException Java Examples

The following examples show how to use java.lang.RuntimeException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsumerIrService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
ConsumerIrService(Context context) {
    mContext = context;
    PowerManager pm = (PowerManager)context.getSystemService(
            Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    mWakeLock.setReferenceCounted(true);

    mHasNativeHal = halOpen();
    if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
        if (!mHasNativeHal) {
            throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
        }
    } else if (mHasNativeHal) {
        throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
    }
}
 
Example #2
Source File: CipherInputStreamExceptions.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead600() throws Exception {
    System.out.println("Running cbc_shortRead600");

    // Encrypt 600 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 600);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #3
Source File: CipherInputStreamExceptions.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");

    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #4
Source File: SakaiScriptAddMemberToSiteWithRoleBatchTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testRemoveMemberFromSiteBatchNotExistingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("siteid", "site1");
	client.query("eids", "user1,nouser");
	client.query("roleid", "student");

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #5
Source File: CipherInputStreamExceptions.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortStream() throws Exception {
    Cipher c;
    AlgorithmParameters params;
    byte[] read = new byte[200];

    System.out.println("Running cbc_shortStream");

    // Encrypt 97 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 97);
    // Create stream with only 96 bytes of encrypted data
    CipherInputStream in = getStream("CBC", ct, 96);

    try {
        int size = in.read(read);
        in.close();
        if (size != 80) {
            throw new RuntimeException("Fail: CipherInputStream.read() " +
                    "returned " + size + ". Should have been 80");
        }
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #6
Source File: CipherInputStreamExceptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running supressUnreadCorrupt test");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #7
Source File: CipherInputStreamExceptions.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead600() throws Exception {
    System.out.println("Running cbc_shortRead600");

    // Encrypt 600 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 600);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #8
Source File: SakaiScriptChangeSiteMemberStatusTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testChangeSiteMemberStatusNotExitingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("siteid", "siteid");
	client.query("eid", "nouser");
	client.query("active", true);

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #9
Source File: CipherInputStreamExceptions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running supressUnreadCorrupt test");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #10
Source File: SakaiScriptSetUserPropertyTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testSetUserTimeZoneNotExistingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("eid", "nouser");
	client.query("key", "Company");
	client.query("value", "Apereo");

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #11
Source File: CipherInputStreamExceptions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortStream() throws Exception {
    Cipher c;
    AlgorithmParameters params;
    byte[] read = new byte[200];

    System.out.println("Running cbc_shortStream");

    // Encrypt 97 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 97);
    // Create stream with only 96 bytes of encrypted data
    CipherInputStream in = getStream("CBC", ct, 96);

    try {
        int size = in.read(read);
        in.close();
        if (size != 80) {
            throw new RuntimeException("Fail: CipherInputStream.read() " +
                    "returned " + size + ". Should have been 80");
        }
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #12
Source File: CipherInputStreamExceptions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");

    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #13
Source File: CipherInputStreamExceptions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead600() throws Exception {
    System.out.println("Running cbc_shortRead600");

    // Encrypt 600 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 600);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #14
Source File: CipherInputStreamExceptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_oneReadByteCorrupt() throws Exception {

        System.out.println("Running gcm_oneReadByteCorrupt test");

        // Encrypt 100 bytes with AES/GCM/PKCS5Padding
        byte[] ct = encryptedText("GCM", 100);
        // Corrupt the encrypted message
        ct = corruptGCM(ct);
        // Create stream for decryption
        CipherInputStream in = getStream("GCM", ct);

        try {
            in.read();
            System.out.println("  Fail. No exception thrown.");
        } catch (IOException e) {
            Throwable ec = e.getCause();
            if (ec instanceof AEADBadTagException) {
                System.out.println("  Pass.");
            } else {
                System.out.println("  Fail: " + ec.getMessage());
                throw new RuntimeException(ec);
            }
        }
    }
 
Example #15
Source File: SakaiScriptChangeSiteMemberStatusTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testChangeSiteMemberStatusNotExitingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("siteid", "siteid");
	client.query("eid", "nouser");
	client.query("active", true);

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #16
Source File: CipherInputStreamExceptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");

    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #17
Source File: CipherInputStreamExceptions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running supressUnreadCorrupt test");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #18
Source File: CipherInputStreamExceptions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_oneReadByte() throws Exception {

        System.out.println("Running gcm_oneReadByte test");

        // Encrypt 100 bytes with AES/GCM/PKCS5Padding
        byte[] ct = encryptedText("GCM", 100);
        // Create stream for decryption
        CipherInputStream in = getStream("GCM", ct);

        try {
            in.read();
            System.out.println("  Pass.");
        } catch (Exception e) {
            System.out.println("  Fail: " + e.getMessage());
            throw new RuntimeException(e.getCause());
        }
    }
 
Example #19
Source File: DemoServlet.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  try {
    HttpSession session = req.getSession(true);
    Storage storage = (Storage) session.getAttribute(Storage.class.getName());
    if (storage == null) {
      storage = new Storage();
      session.setAttribute(Storage.class.getName(), storage);
    }

    // create odata handler and configure it with EdmProvider and Processor
    OData odata = OData.newInstance();
    ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
    ODataHttpHandler handler = odata.createHandler(edm);
    handler.register(new DemoEntityCollectionProcessor(storage));
    handler.register(new DemoEntityProcessor(storage));
    handler.register(new DemoPrimitiveProcessor(storage));
    handler.register(new DemoActionProcessor(storage));
    
    // let the handler do the work
    handler.process(req, resp);
  } catch (RuntimeException e) {
    LOG.error("Server Error occurred in ExampleServlet", e);
    throw new ServletException(e);
  }
}
 
Example #20
Source File: CipherInputStreamExceptions.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortStream() throws Exception {
    Cipher c;
    AlgorithmParameters params;
    byte[] read = new byte[200];

    System.out.println("Running cbc_shortStream");

    // Encrypt 97 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 97);
    // Create stream with only 96 bytes of encrypted data
    CipherInputStream in = getStream("CBC", ct, 96);

    try {
        int size = in.read(read);
        in.close();
        if (size != 80) {
            throw new RuntimeException("Fail: CipherInputStream.read() " +
                    "returned " + size + ". Should have been 80");
        }
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #21
Source File: CipherInputStreamExceptions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");

    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #22
Source File: SakaiScriptRemoveMemberFromSiteBatchTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
	public void testRemoveMemberFromSiteBatchNotExistingSite() {
		WebClient client = WebClient.create(getFullEndpointAddress());
//MODIFY
		addClientMocks(client);

		// client call
		client.accept("text/plain");
		client.path("/" + getOperation());
		client.query("sessionid", SESSION_ID);
		client.query("siteid", "nosite");
		client.query("eids", "user1,nouser");

		// client result
		thrown.expect(RuntimeException.class);
		client.get(String.class);

	}
 
Example #23
Source File: RNFusedLocationModule.java    From react-native-geolocation-service with MIT License 6 votes vote down vote up
/**
 * Helper method to invoke success callback
 */
private void invokeSuccess(WritableMap data, boolean isSingleUpdate) {
  if (!isSingleUpdate) {
    getContext().getJSModule(RCTDeviceEventEmitter.class)
      .emit("geolocationDidChange", data);

    return;
  }

  try {
    if (mSuccessCallback != null) {
      mSuccessCallback.invoke(data);
    }

    clearCallbacks();
  } catch (RuntimeException e) {
    // Illegal callback invocation
    Log.w(TAG, e.getMessage());
  }
}
 
Example #24
Source File: RNFusedLocationModule.java    From react-native-geolocation-service with MIT License 6 votes vote down vote up
/**
 * Helper method to invoke error callback
 */
private void invokeError(int code, String message, boolean isSingleUpdate) {
  if (!isSingleUpdate) {
    getContext().getJSModule(RCTDeviceEventEmitter.class)
      .emit("geolocationError", LocationUtils.buildError(code, message));

    return;
  }

  try {
    if (mErrorCallback != null) {
      mErrorCallback.invoke(LocationUtils.buildError(code, message));
    }

    clearCallbacks();
  } catch (RuntimeException e) {
    // Illegal callback invocation
    Log.w(TAG, e.getMessage());
  }
}
 
Example #25
Source File: DemoServlet.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  try {
    HttpSession session = req.getSession(true);
    Storage storage = (Storage) session.getAttribute(Storage.class.getName());
    if (storage == null) {
      storage = new Storage();
      session.setAttribute(Storage.class.getName(), storage);
    }

    // create odata handler and configure it with EdmProvider and Processor
    OData odata = OData.newInstance();
    ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
    ODataHttpHandler handler = odata.createHandler(edm);
    handler.register(new DemoEntityCollectionProcessor(storage));
    handler.register(new DemoEntityProcessor(storage));
    handler.register(new DemoPrimitiveProcessor(storage));

    // let the handler do the work
    handler.process(req, resp);
  } catch (RuntimeException e) {
    LOG.error("Server Error occurred in ExampleServlet", e);
    throw new ServletException(e);
  }

}
 
Example #26
Source File: SakaiScriptAddMemberToSiteWithRoleBatchTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testRemoveMemberFromSiteBatchNotExistingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("siteid", "site1");
	client.query("eids", "user1,nouser");
	client.query("roleid", "student");

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #27
Source File: CipherInputStreamExceptions.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_oneReadByte() throws Exception {

        System.out.println("Running gcm_oneReadByte test");

        // Encrypt 100 bytes with AES/GCM/PKCS5Padding
        byte[] ct = encryptedText("GCM", 100);
        // Create stream for decryption
        CipherInputStream in = getStream("GCM", ct);

        try {
            in.read();
            System.out.println("  Pass.");
        } catch (Exception e) {
            System.out.println("  Fail: " + e.getMessage());
            throw new RuntimeException(e.getCause());
        }
    }
 
Example #28
Source File: DataBinderMapperImpl.java    From Android-POS with MIT License 6 votes vote down vote up
@Override
public ViewDataBinding getDataBinder(DataBindingComponent component, View[] views, int layoutId) {
  if(views == null || views.length == 0) {
    return null;
  }
  int localizedLayoutId = INTERNAL_LAYOUT_ID_LOOKUP.get(layoutId);
  if(localizedLayoutId > 0) {
    final Object tag = views[0].getTag();
    if(tag == null) {
      throw new RuntimeException("view must have a tag");
    }
    switch(localizedLayoutId) {
    }
  }
  return null;
}
 
Example #29
Source File: CipherInputStreamExceptions.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running supressUnreadCorrupt test");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
Example #30
Source File: SakaiScriptSetUserTimeZoneTest.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Test
public void testSetUserTimeZoneNotExistingUser() {
	WebClient client = WebClient.create(getFullEndpointAddress());

	addClientMocks(client);

	// client call
	client.accept("text/plain");
	client.path("/" + getOperation());
	client.query("sessionid", SESSION_ID);
	client.query("eid", "nouser");
	client.query("timeZoneId", "Europe/Oslo");

	// client result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}