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: 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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: FocusCauseTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void  testCausedFocusEventDeserialization() throws
        Exception {
    for (int i = 0; i < causesIn.length; i++) {
        final String causeIn = causesIn[i];
        ObjectInputStream oi = new ObjectInputStream(new InputStream() {
            int cnt = 0;
            @Override
            public int read() throws IOException {
                if(cnt < data.length) {
                    return data[cnt++];
                } else if(cnt == data.length){
                    cnt++;
                    return causeIn.length();
                } else if(cnt - data.length - 1 < causeIn.length()) {
                    return causeIn.getBytes()[cnt++ - data.length - 1];
                }
                return -1;
            }
        });
        FocusEvent ev = (FocusEvent) oi.readObject();
        System.out.println(ev);
        if(ev.getCause() != causesOut[i]) {
            throw new RuntimeException("Wrong cause read :" +ev.getCause());
        }
    }
}
 
Example #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
Source File: ModifyAnonymous.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String argv[]) throws InterruptedException, RuntimeException {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }

    if (inst == null) {
        throw new RuntimeException("Instrumentation object was null");
    }

    new Thread() {
        public void run() {
            runTest();
        }
    }.start();

    // Test that NCDFE is not thrown for anonymous class:
    // ModifyAnonymous$InstanceMethodCallSiteApp$$Lambda$18
    try {
        ModifyAnonymous test = new ModifyAnonymous();
        InstanceMethodCallSiteApp.test();
    } catch (NoClassDefFoundError e) {
        throw new RuntimeException("FAILED: NoClassDefFoundError thrown for " + e.getMessage());
    }
    System.out.println("PASSED: NoClassDefFound error not thrown");
}
 
Example #18
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 #19
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);

}
 
Example #20
Source File: CipherInputStreamExceptions.java    From openjdk-jdk8u 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 #21
Source File: CipherInputStreamExceptions.java    From openjdk-jdk8u 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 #22
Source File: CipherInputStreamExceptions.java    From hottub 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 #23
Source File: CipherInputStreamExceptions.java    From openjdk-jdk8u 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 #24
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 DemoBatchProcessor(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 #25
Source File: CipherInputStreamExceptions.java    From openjdk-jdk8u 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 #26
Source File: CipherInputStreamExceptions.java    From openjdk-jdk8u-backup 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 #27
Source File: SakaiScriptRemoveMemberFromSiteBatchTest.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 result
	thrown.expect(RuntimeException.class);
	client.get(String.class);

}
 
Example #28
Source File: CipherInputStreamExceptions.java    From jdk8u-jdk 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 #29
Source File: CipherInputStreamExceptions.java    From hottub 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 #30
Source File: SakaiScriptAddMemberToSiteWithRoleBatchTest.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.query("roleid", "student");

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

	}