diff options
Diffstat (limited to 'wince/org.eclipse.tm.rapi.tests')
14 files changed, 0 insertions, 721 deletions
diff --git a/wince/org.eclipse.tm.rapi.tests/.classpath b/wince/org.eclipse.tm.rapi.tests/.classpath deleted file mode 100644 index ce7393340..000000000 --- a/wince/org.eclipse.tm.rapi.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/wince/org.eclipse.tm.rapi.tests/.cvsignore b/wince/org.eclipse.tm.rapi.tests/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/wince/org.eclipse.tm.rapi.tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/wince/org.eclipse.tm.rapi.tests/.project b/wince/org.eclipse.tm.rapi.tests/.project deleted file mode 100644 index c7a68a143..000000000 --- a/wince/org.eclipse.tm.rapi.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.tm.rapi.tests</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/wince/org.eclipse.tm.rapi.tests/.settings/org.eclipse.jdt.core.prefs b/wince/org.eclipse.tm.rapi.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 675d29eb2..000000000 --- a/wince/org.eclipse.tm.rapi.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,79 +0,0 @@ -#Fri Mar 28 14:14:24 CET 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/wince/org.eclipse.tm.rapi.tests/META-INF/MANIFEST.MF b/wince/org.eclipse.tm.rapi.tests/META-INF/MANIFEST.MF deleted file mode 100644 index a66f58878..000000000 --- a/wince/org.eclipse.tm.rapi.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-SymbolicName: org.eclipse.tm.rapi.tests -Bundle-Version: 0.1.0.qualifier -Bundle-Vendor: %providerName -Bundle-Localization: plugin -Require-Bundle: org.junit, - org.eclipse.tm.rapi;bundle-version="[0.1.0,1.0.0)" -Export-Package: org.eclipse.tm.rapi.tests -Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/wince/org.eclipse.tm.rapi.tests/about.html b/wince/org.eclipse.tm.rapi.tests/about.html deleted file mode 100644 index 02520f4f1..000000000 --- a/wince/org.eclipse.tm.rapi.tests/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> -<title>About</title> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>March 27, 2008</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> - -</body> -</html>
\ No newline at end of file diff --git a/wince/org.eclipse.tm.rapi.tests/build.properties b/wince/org.eclipse.tm.rapi.tests/build.properties deleted file mode 100644 index 2ccce9b24..000000000 --- a/wince/org.eclipse.tm.rapi.tests/build.properties +++ /dev/null @@ -1,18 +0,0 @@ -############################################################################### -# Copyright (c) 2008 Radoslav Gerganov and others -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Radoslav Gerganov - initial API and implementation -# Martin Oberhuber (Wind River) - add about.html -############################################################################### -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - about.html,\ - plugin.properties -src.includes = about.html diff --git a/wince/org.eclipse.tm.rapi.tests/plugin.properties b/wince/org.eclipse.tm.rapi.tests/plugin.properties deleted file mode 100644 index 58fa00144..000000000 --- a/wince/org.eclipse.tm.rapi.tests/plugin.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2008 Radoslav Gerganov and others -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Radoslav Gerganov - initial API and implementation -# Martin Oberhuber (Wind River) - Rename pluginName, add PII NLS tags -############################################################################### - -# NLS_MESSAGEFORMAT_NONE -# NLS_ENCODING=UTF-8 - -providerName = Eclipse.org -pluginName = RAPI2 Java wrapper unit tests (Incubation)
\ No newline at end of file diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/AllTests.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/AllTests.java deleted file mode 100644 index ff93fa92b..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/AllTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Unit tests for the Java wrappers of RAPI2. - * <b> - * Establishing an ActiveSync connection with a device or emulator is needed - * before running these tests. - * </b> - * @author Radoslav Gerganov - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for org.eclipse.tm.rapi"); - //$JUnit-BEGIN$ - suite.addTestSuite(RapiDesktopTest.class); - suite.addTestSuite(RapiEnumDevicesTest.class); - suite.addTestSuite(RapiDeviceTest.class); - suite.addTestSuite(RapiSessionTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDesktopTest.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDesktopTest.java deleted file mode 100644 index bd0ebb3a5..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDesktopTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import org.eclipse.tm.rapi.IRapiDesktop; -import org.eclipse.tm.rapi.RapiException; - -public class RapiDesktopTest extends RapiTestCase { - - protected void setUp() throws Exception { - super.setUp(); - } - - public void testGetInstance() throws RapiException { - desktop = IRapiDesktop.getInstance(); - assertNotNull("IRapiDesktop.getInstance() returned null", desktop); - } - - public void testEnumDevices() throws RapiException { - desktop = IRapiDesktop.getInstance(); - enumDevices = desktop.enumDevices(); - assertNotNull("IRapiDesktop.enumDevices() returned null", enumDevices); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDeviceTest.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDeviceTest.java deleted file mode 100644 index 2c0eaaa58..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiDeviceTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import org.eclipse.tm.rapi.IRapiDesktop; -import org.eclipse.tm.rapi.IRapiDevice; -import org.eclipse.tm.rapi.RapiConnectionInfo; -import org.eclipse.tm.rapi.RapiDeviceInfo; -import org.eclipse.tm.rapi.RapiException; - -public class RapiDeviceTest extends RapiTestCase { - - protected void setUp() throws Exception { - super.setUp(); - } - - IRapiDevice getDevice() throws RapiException { - desktop = IRapiDesktop.getInstance(); - enumDevices = desktop.enumDevices(); - return enumDevices.next(); - } - - public void testCreateSession() throws RapiException { - device = getDevice(); - session = device.createSession(); - assertNotNull("IRapiDevice.createSession() returned null", session); - } - - public void testGetConnectionInfo() throws RapiException { - device = getDevice(); - RapiConnectionInfo connectionInfo = device.getConnectionInfo(); - int connectionType = connectionInfo.connectionType; - assertTrue("Unknown connectionType: " + connectionType, - connectionType >= 0 && connectionType <= 3); - } - - public void testGetDeviceInfo() throws RapiException { - device = getDevice(); - RapiDeviceInfo deviceInfo = device.getDeviceInfo(); - assertNotNull("deviceInfo.id is null", deviceInfo.id); - assertNotNull("deviceInfo.name is null", deviceInfo.name); - assertNotNull("deviceInfo.platform is null", deviceInfo.platform); - //TODO: make some reasonable checks for the version numbers - } - - public void testIsConnected() throws RapiException { - device = getDevice(); - boolean connected = device.isConnected(); - assertTrue("device should be connected", connected); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiEnumDevicesTest.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiEnumDevicesTest.java deleted file mode 100644 index 84216a356..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiEnumDevicesTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import org.eclipse.tm.rapi.IRapiDesktop; -import org.eclipse.tm.rapi.RapiException; - -public class RapiEnumDevicesTest extends RapiTestCase { - - protected void setUp() throws Exception { - super.setUp(); - } - - public void testNext() throws RapiException { - desktop = IRapiDesktop.getInstance(); - enumDevices = desktop.enumDevices(); - device = enumDevices.next(); - assertNotNull("IRapiEnumDevices.next() returned null", device); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiSessionTest.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiSessionTest.java deleted file mode 100644 index 623639581..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiSessionTest.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import org.eclipse.tm.rapi.IRapiDesktop; -import org.eclipse.tm.rapi.IRapiSession; -import org.eclipse.tm.rapi.Rapi; -import org.eclipse.tm.rapi.RapiException; -import org.eclipse.tm.rapi.RapiFindData; - -public class RapiSessionTest extends RapiTestCase { - - private static final int TEMP_FILES_COUNT = 10; - private static final int TEST_FILE_SIZE = 8 * 1024; - private static final String TEST_FILE_NAME = "\\foo.bin"; - private static final int CHUNK_SIZE = 1024; - - private static final String TEST_DIR_NAME = "bar"; - - protected void setUp() throws Exception { - super.setUp(); - } - - /** - * Creates and initialize RAPI2 session - */ - void createInitSession() throws RapiException { - desktop = IRapiDesktop.getInstance(); - enumDevices = desktop.enumDevices(); - device = enumDevices.next(); - session = device.createSession(); - session.init(); - } - - /** - * Returns true if the first <code>len</code> bytes of the specified arrays - * are equal. - */ - boolean arraysEqual(byte[] arr1, byte[] arr2, int len) { - for (int i = 0 ; i < len ; i++) { - if (arr1[i] != arr2[i]) { - return false; - } - } - return true; - } - - /** - * Returns true if the specified <code>path</code> exists and it is a directory. - */ - boolean isDirectory(String path) { - int attr = session.getFileAttributes(path); - if (attr == -1) { - return false; - } - return (attr & Rapi.FILE_ATTRIBUTE_DIRECTORY) != 0; - } - - /** - * Returns true if the specified <code>path</code> exists and it is a file. - */ - boolean isFile(String path) { - int attr = session.getFileAttributes(path); - if (attr == -1) { - return false; - } - return (attr & Rapi.FILE_ATTRIBUTE_DIRECTORY) == 0; - } - - /** - * Tests reading and writing files on the device. - */ - public void testReadWriteFiles() throws RapiException { - createInitSession(); - - // generate random file content - byte[] content = new byte[TEST_FILE_SIZE]; - for (int i = 0 ; i < content.length ; i++) { - content[i] = (byte)(Math.random() * 131); - } - - // write the test file at once - int handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_WRITE, - Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); - session.writeFile(handle, content); - session.closeHandle(handle); - - // try to read the whole file - handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_READ, - Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL); - byte[] contentRead = new byte[TEST_FILE_SIZE]; - int br = session.readFile(handle, contentRead); - session.closeHandle(handle); - assertTrue("Different file content", arraysEqual(content, contentRead, br)); - - // write the test file by chunks - handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_WRITE, - Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); - int off = 0; - for (int i = 0 ; i < TEST_FILE_SIZE / CHUNK_SIZE ; i++) { - session.writeFile(handle, content, off, CHUNK_SIZE); - off += CHUNK_SIZE; - } - session.closeHandle(handle); - - // read the test file by chunks - handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_READ, - Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL); - byte[] contentRead2 = new byte[TEST_FILE_SIZE]; - off = 0; - int bytesToRead = TEST_FILE_SIZE; - while (bytesToRead > 0) { - int len = CHUNK_SIZE < bytesToRead ? CHUNK_SIZE : bytesToRead; - br = session.readFile(handle, contentRead2, off, len); - off += br; - bytesToRead -= br; - } - session.closeHandle(handle); - assertTrue("Different file content", arraysEqual(content, contentRead2, TEST_FILE_SIZE)); - - // delete the test file - session.deleteFile(TEST_FILE_NAME); - } - - /** - * Tests creating and removing directories on the device. - */ - public void testCreateRemoveDirectories() throws RapiException { - createInitSession(); - try { - session.removeDirectory(TEST_DIR_NAME); - } catch (RapiException re) { - // ignore - } - session.createDirectory(TEST_DIR_NAME); - assertTrue("Failed to create directory: " + TEST_DIR_NAME, isDirectory(TEST_DIR_NAME)); - session.removeDirectory(TEST_DIR_NAME); - assertFalse("Failed to remove directory: " + TEST_DIR_NAME, isDirectory(TEST_DIR_NAME)); - } - - /** - * Utility method for creating files. - */ - void createFile(IRapiSession session, String fileName) throws RapiException { - int handle = session.createFile(fileName, Rapi.GENERIC_WRITE, - Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); - session.writeFile(handle, "spam".getBytes()); - session.closeHandle(handle); - } - - /** - * Tests copying, moving and deleting files on the device. - */ - public void testCopyMoveDeleteFiles() throws RapiException { - createInitSession(); - - // create test file - createFile(session, TEST_FILE_NAME); - - // make a copy - String copy = TEST_FILE_NAME + "1"; - session.copyFile(TEST_FILE_NAME, copy); - assertTrue("The copied file doesn't exist: " + copy, isFile(copy)); - - // delete the test file - session.deleteFile(TEST_FILE_NAME); - assertFalse("Failed to delete file: " + TEST_FILE_NAME, isFile(TEST_FILE_NAME)); - - // rename the copy - session.moveFile(copy, TEST_FILE_NAME); - assertTrue("Failed to move file, existing file: " + copy + " new file: " + TEST_FILE_NAME, - isFile(TEST_FILE_NAME)); - assertFalse("Failed to move file, existing file: " + copy + " new file: " + TEST_FILE_NAME, - isFile(copy)); - - // delete test file - session.deleteFile(TEST_FILE_NAME); - } - - /** - * Utility method for creating a bunch of files. - */ - void createTempFiles() throws RapiException { - for (int i = 0 ; i < TEMP_FILES_COUNT ; i++) { - createFile(session, TEST_FILE_NAME + i); - } - } - - /** - * Tests finding files using {@link IRapiSession#findFirstFile(String, RapiFindData)} - */ - public void testFindFiles() throws RapiException { - createInitSession(); - createTempFiles(); - int filesFound = 0; - RapiFindData findData = new RapiFindData(); - int fh = session.findFirstFile(TEST_FILE_NAME + "?", findData); - while (findData != null) { - filesFound++; - findData = session.findNextFile(fh); - } - session.findClose(fh); - assertTrue("Found " + filesFound + " , expected " + TEMP_FILES_COUNT, - filesFound == TEMP_FILES_COUNT); - // clean up - for (int i = 0 ; i < TEMP_FILES_COUNT ; i++) { - session.deleteFile(TEST_FILE_NAME + i); - } - } - - /** - * Tests finding files using {@link IRapiSession#findAllFiles(String, int)} - */ - public void testFindAllFiles() throws RapiException { - createInitSession(); - createTempFiles(); - RapiFindData[] faf = session.findAllFiles(TEST_FILE_NAME + "?", Rapi.FAF_NAME); - int filesFound = faf.length; - assertTrue("Found " + filesFound + " , expected " + TEMP_FILES_COUNT, - filesFound == TEMP_FILES_COUNT); - // clean up - for (int i = 0 ; i < TEMP_FILES_COUNT ; i++) { - session.deleteFile(TEST_FILE_NAME + i); - } - } - - /** - * Tests getting and setting file attributes - */ - public void testGetSetFileAttributes() throws RapiException { - createInitSession(); - // create test file - createFile(session, TEST_FILE_NAME); - - session.setFileAttributes(TEST_FILE_NAME, Rapi.FILE_ATTRIBUTE_READONLY); - int attr = session.getFileAttributes(TEST_FILE_NAME); - assertTrue("Wrong file attributes, expected FILE_ATTRIBUTE_READONLY", - (attr & Rapi.FILE_ATTRIBUTE_READONLY) != 0); - - session.setFileAttributes(TEST_FILE_NAME, Rapi.FILE_ATTRIBUTE_ARCHIVE); - attr = session.getFileAttributes(TEST_FILE_NAME); - assertTrue("Wrong file attributes, expected FILE_ATTRIBUTE_ARCHIVE", - (attr & Rapi.FILE_ATTRIBUTE_ARCHIVE) != 0); - - //clean up - session.deleteFile(TEST_FILE_NAME); - } - - /** - * Tests getting file size using {@link IRapiSession#getFileSize(int)} - */ - public void testGetFileSize() throws RapiException { - createInitSession(); - // create test file - int handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_WRITE, - Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); - session.writeFile(handle, "spam".getBytes()); - assertTrue("Wrong file size, expected size 4 bytes", 4 == session.getFileSize(handle)); - session.closeHandle(handle); - //clean up - session.deleteFile(TEST_FILE_NAME); - } - - /** - * Tests getting and setting file times - */ - public void testGetSetFileTime() throws RapiException { - createInitSession(); - - // now + 1h - long d = System.currentTimeMillis() + 3600000; - - // create file and set last access time to d - int handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_WRITE, - Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); - session.writeFile(handle, "spam".getBytes()); - session.setFileLastWriteTime(handle, d); - session.closeHandle(handle); - // get file last write time and compare to d - handle = session.createFile(TEST_FILE_NAME, Rapi.GENERIC_READ, - Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL); - long lwTime = session.getFileLastWriteTime(handle); - // the precision of setLastWriteTime should be about 1-2sec - assertTrue("Too big difference for lastWriteTime, expected: " + d - + " returned: " + lwTime, Math.abs(lwTime - d) <= 5000); - session.closeHandle(handle); - - //clean up - session.deleteFile(TEST_FILE_NAME); - } - - protected void tearDown() throws Exception { - if (session != null) { - session.uninit(); - } - super.tearDown(); - } - -} diff --git a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiTestCase.java b/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiTestCase.java deleted file mode 100644 index ec2d49404..000000000 --- a/wince/org.eclipse.tm.rapi.tests/src/org/eclipse/tm/rapi/tests/RapiTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Radoslav Gerganov - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.rapi.tests; - -import org.eclipse.tm.rapi.IRapiDesktop; -import org.eclipse.tm.rapi.IRapiDevice; -import org.eclipse.tm.rapi.IRapiEnumDevices; -import org.eclipse.tm.rapi.IRapiSession; -import org.eclipse.tm.rapi.Rapi; - -import junit.framework.TestCase; - -public class RapiTestCase extends TestCase { - - protected IRapiDesktop desktop = null; - protected IRapiEnumDevices enumDevices = null; - protected IRapiDevice device = null; - protected IRapiSession session = null; - - protected void setUp() throws Exception { - super.setUp(); - desktop = null; - enumDevices = null; - device = null; - session = null; - Rapi.initialize(Rapi.COINIT_MULTITHREADED); - } - - protected void tearDown() throws Exception { - super.tearDown(); - if (desktop != null) { - desktop.release(); - } - if (enumDevices != null) { - enumDevices.release(); - } - if (device != null) { - device.release(); - } - if (session != null) { - session.release(); - } - Rapi.uninitialize(); - } - -} |