List of usage examples for java.lang InternalError InternalError
public InternalError()
InternalError
with no detail message. From source file:org.pentaho.platform.web.http.api.resources.services.FileServiceTest.java
@Test public void testDoMoveFilesException() throws Exception { String destPathId = "/test"; String[] params = { "file1", "file2" }; RepositoryFileDto repositoryFileDto = mock(RepositoryFileDto.class); doReturn(destPathId).when(repositoryFileDto).getPath(); doReturn(repositoryFileDto).when(fileService.defaultUnifiedRepositoryWebService).getFile(destPathId); doThrow(new InternalError()).when(fileService.defaultUnifiedRepositoryWebService).moveFile(params[0], destPathId, null);/*from w w w .java2 s . co m*/ try { fileService.doMoveFiles(destPathId, StringUtils.join(params, ",")); fail(); //This line should never be reached } catch (Throwable e) { verify(fileService.getRepoWs(), times(1)).moveFile(params[0], destPathId, null); verify(fileService.getRepoWs(), times(0)).moveFile(params[1], destPathId, null); } }
From source file:org.pentaho.platform.web.http.api.resources.services.FileServiceTest.java
@Test public void testDoRestoreFilesException() throws Exception { String[] params = { "file1", "file2" }; doThrow(new InternalError()).when(fileService.defaultUnifiedRepositoryWebService).undeleteFile(params[0], null);/* w w w.jav a 2s . c o m*/ try { fileService.doRestoreFiles(StringUtils.join(params, ",")); fail(); //This line should never be reached } catch (InternalError e) { verify(fileService.getRepoWs(), times(1)).undeleteFile(params[0], null); verify(fileService.getRepoWs(), times(0)).undeleteFile(params[1], null); } }
From source file:com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.java
/** * Returns a shallow copy of this.//from w w w . ja v a2 s. c o m * <tt>AbstractConcurrentReadCache</tt> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map. */ public synchronized Object clone() { try { AbstractConcurrentReadCache t = (AbstractConcurrentReadCache) super.clone(); t.keySet = null; t.entrySet = null; t.values = null; Entry[] tab = table; t.table = new Entry[tab.length]; Entry[] ttab = t.table; for (int i = 0; i < tab.length; ++i) { Entry first = tab[i]; if (first != null) { ttab[i] = (Entry) (first.clone()); } } return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
private void createProximityAlertSetupDialog() { final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_proximity_alert_create, R.string.create_proximity_alert); Button setProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_create_alert_watcher_button); Button stopCurrentProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_stop_existing_alert_button); Button cancelButton = (Button) dialog.findViewById(R.id.create_proximity_alert_cancel_button); SeekBar seekbar = (SeekBar) dialog.findViewById(R.id.create_proximity_alert_seekBar); final EditText radiusEditText = (EditText) dialog.findViewById(R.id.create_proximity_alert_range_edit_text); final Switch formatSwitch = (Switch) dialog.findViewById(R.id.create_proximity_alert_format_switch); final double seekBarStepSize = (double) (getResources() .getInteger(R.integer.proximity_alert_maximum_warning_range_meters) - getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)) / 100; radiusEditText.setText(/* w w w.j ava 2s . c o m*/ String.valueOf(getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters))); formatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { buttonView.setText(getString(R.string.range_format_nautical_miles)); } else { buttonView.setText(getString(R.string.range_format_meters)); } } }); seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { String range = String.valueOf( (int) (getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters) + (seekBarStepSize * progress))); radiusEditText.setText(range); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); setProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String toastText; if (proximityAlertWatcher == null) { toastText = getString(R.string.proximity_alert_set); } else { toastText = getString(R.string.proximity_alert_replace); } if (proximityAlertWatcher != null) { proximityAlertWatcher.cancel(true); } mGpsLocationTracker = new GpsLocationTracker(getActivity()); double latitude, longitude; if (mGpsLocationTracker.canGetLocation()) { latitude = mGpsLocationTracker.getLatitude(); cachedLat = latitude; longitude = mGpsLocationTracker.getLongitude(); cachedLon = longitude; } else { mGpsLocationTracker.showSettingsAlert(); return; } if (formatSwitch.isChecked()) { cachedDistance = Double.valueOf(radiusEditText.getText().toString()) * getResources().getInteger(R.integer.meters_per_nautical_mile); } else { cachedDistance = Double.valueOf(radiusEditText.getText().toString()); } dialog.dismiss(); Response response; try { String apiName = "fishingfacility"; String format = "OLEX"; String filePath; String fileName = "collisionCheckToolsFile"; response = barentswatchApi.getApi().geoDataDownload(apiName, format); if (response == null) { Log.d(TAG, "RESPONSE == NULL"); throw new InternalError(); } if (fiskInfoUtility.isExternalStorageWritable()) { String directoryPath = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(); String directoryName = "FiskInfo"; filePath = directoryPath + "/" + directoryName + "/"; InputStream zippedInputStream = null; try { TypedInput responseInput = response.getBody(); zippedInputStream = responseInput.in(); zippedInputStream = new GZIPInputStream(zippedInputStream); InputSource inputSource = new InputSource(zippedInputStream); InputStream input = new BufferedInputStream(inputSource.getByteStream()); byte data[]; data = FiskInfoUtility.toByteArray(input); InputStream inputStream = new ByteArrayInputStream(data); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); FiskInfoPolygon2D serializablePolygon2D = new FiskInfoPolygon2D(); String line; boolean startSet = false; String[] convertedLine; List<Point> shape = new ArrayList<>(); while ((line = reader.readLine()) != null) { Point currPoint = new Point(); if (line.length() == 0 || line.equals("")) { continue; } if (Character.isLetter(line.charAt(0))) { continue; } convertedLine = line.split("\\s+"); if (line.length() > 150) { Log.d(TAG, "line " + line); } if (convertedLine[0].startsWith("3sl")) { continue; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && startSet) { if (shape.size() == 1) { // Point serializablePolygon2D.addPoint(shape.get(0)); shape = new ArrayList<>(); } else if (shape.size() == 2) { // line serializablePolygon2D.addLine(new Line(shape.get(0), shape.get(1))); shape = new ArrayList<>(); } else { serializablePolygon2D.addPolygon(new Polygon(shape)); shape = new ArrayList<>(); } startSet = false; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && !startSet) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); startSet = true; } else if (convertedLine[3].equalsIgnoreCase("Brunsirkel")) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); } } reader.close(); new FiskInfoUtility().serializeFiskInfoPolygon2D(filePath + fileName + "." + format, serializablePolygon2D); tools = serializablePolygon2D; } catch (IOException e) { e.printStackTrace(); } catch (ArrayIndexOutOfBoundsException e) { Log.e(TAG, "Error when trying to serialize file."); Toast error = Toast.makeText(getActivity(), "Ingen redskaper i omrdet du definerte", Toast.LENGTH_LONG); e.printStackTrace(); error.show(); return; } finally { try { if (zippedInputStream != null) { zippedInputStream.close(); } } catch (IOException e) { e.printStackTrace(); } } } else { Toast.makeText(v.getContext(), R.string.download_failed, Toast.LENGTH_LONG).show(); dialog.dismiss(); return; } } catch (Exception e) { Log.d(TAG, "Could not download tools file"); Toast.makeText(getActivity(), R.string.download_failed, Toast.LENGTH_LONG).show(); } runScheduledAlarm(getResources().getInteger(R.integer.zero), getResources().getInteger(R.integer.proximity_alert_interval_time_seconds)); Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show(); } }); if (proximityAlertWatcher != null) { TypedValue outValue = new TypedValue(); stopCurrentProximityAlertWatcherButton.setVisibility(View.VISIBLE); getResources().getValue(R.dimen.proximity_alert_dialog_button_text_size_small, outValue, true); float textSize = outValue.getFloat(); setProximityAlertWatcherButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setTextSize(textSize); cancelButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; dialog.dismiss(); } }); } cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog)); dialog.show(); }
From source file:SoftValuedHashMap.java
public Object clone() { try {/*from w ww . j a v a 2s .c om*/ ReferencedValueHashMap t = (ReferencedValueHashMap) super.clone(); t.table = new Entry[this.table.length]; for (int i = this.table.length; i-- > 0;) { t.table[i] = (this.table[i] != null) ? (Entry) this.table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
From source file:com.projity.pm.resource.ResourceImpl.java
public Object clone() { try {/*from ww w. j a v a2 s . c om*/ ResourceImpl resource = (ResourceImpl) super.clone(); resource.globalResource = (EnterpriseResource) globalResource.clone(); return resource; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
From source file:org.pentaho.platform.web.http.api.resources.services.FileServiceTest.java
@Test public void testDoGetFileAsInlineException() { /*//from ww w . j a v a 2s . co m * TEST 1 */ doReturn(true).when(fileService).isPath(anyString()); doReturn(false).when(fileService).isPathValid(anyString()); try { fileService.doGetFileAsInline("test"); fail(); } catch (IllegalArgumentException e) { // Excpected } catch (FileNotFoundException e) { fail(); } /* * TEST 2 */ doReturn(true).when(fileService).isPathValid(anyString()); doReturn(null).when(fileService.repository).getFile(anyString()); try { fileService.doGetFileAsInline("test"); fail(); } catch (FileNotFoundException e) { // Expected } /* * TEST 3 */ RepositoryFile mockFile = mock(RepositoryFile.class); doReturn(mockFile).when(fileService.repository).getFile(anyString()); RepositoryDownloadWhitelist mockWhiteList = mock(RepositoryDownloadWhitelist.class); doReturn(mockWhiteList).when(fileService).getWhitelist(); doReturn(false).when(mockWhiteList).accept(anyString()); IAuthorizationPolicy mockPolicy = mock(IAuthorizationPolicy.class); doReturn(mockPolicy).when(fileService).getPolicy(); doReturn(false).when(mockPolicy).isAllowed(anyString()); try { fileService.doGetFileAsInline("test"); fail(); } catch (IllegalArgumentException e) { // Excpected } catch (FileNotFoundException e) { fail(); } /* * TEST 4 */ doReturn(true).when(mockWhiteList).accept(anyString()); doThrow(new InternalError()).when(fileService.repository).getDataForRead(any(Serializable.class), any(Class.class)); try { fileService.doGetFileAsInline("test"); fail(); } catch (InternalError e) { // Excpected } catch (FileNotFoundException e) { fail(); } }
From source file:ConcurrentReaderHashMap.java
/** * Returns a shallow copy of this /*from w w w.j a va2 s .co m*/ * <tt>ConcurrentReaderHashMap</tt> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map. */ public synchronized Object clone() { try { ConcurrentReaderHashMap t = (ConcurrentReaderHashMap) super.clone(); t.keySet = null; t.entrySet = null; t.values = null; Entry[] tab = table; t.table = new Entry[tab.length]; Entry[] ttab = t.table; for (int i = 0; i < tab.length; ++i) { Entry first = null; for (Entry e = tab[i]; e != null; e = e.next) first = new Entry(e.hash, e.key, e.value, first); ttab[i] = first; } return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
From source file:org.pentaho.platform.web.http.api.resources.services.FileServiceTest.java
@Test public void testDoSetContentCreatorFileException() throws Exception { String param = "file1"; RepositoryFileDto repositoryFileDto = mock(RepositoryFileDto.class); Map<String, Serializable> fileMetadata = mock(Map.class); doReturn(param).when(repositoryFileDto).getId(); when(fileService.idToPath(param)).thenReturn("/file1"); doReturn(repositoryFileDto).when(fileService.defaultUnifiedRepositoryWebService).getFile("/file1"); when(fileService.getRepository().getFileMetadata(repositoryFileDto.getId())).thenThrow(new InternalError()); //failing in get try {//www .j a v a2s . c o m fileService.doSetContentCreator(param, repositoryFileDto); } catch (FileNotFoundException e) { fail(); } catch (InternalError e) { verify(fileMetadata, times(0)).put(PentahoJcrConstants.PHO_CONTENTCREATOR, param); verify(fileService.repository, times(0)).setFileMetadata(param, fileMetadata); } }
From source file:ConcurrentReaderHashMap.java
/** * Returns a shallow copy of this <tt>ConcurrentReaderHashMap</tt> * instance: the keys and values themselves are not cloned. * /* w ww . ja v a2s . c om*/ * @return a shallow copy of this map. */ public synchronized Object clone() throws CloneNotSupportedException { try { ConcurrentReaderHashMap t = (ConcurrentReaderHashMap) super.clone(); t.keySet = null; t.entrySet = null; t.values = null; Entry[] tab = table; t.table = new Entry[tab.length]; Entry[] ttab = t.table; for (int i = 0; i < tab.length; ++i) { Entry first = null; for (Entry e = tab[i]; e != null; e = e.next) { first = new Entry(e.hash, e.key, e.value, first); } ttab[i] = first; } return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }