You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/08/25 13:57:42 UTC
svn commit: r436771 - in
/incubator/harmony/enhanced/classlib/trunk/modules/sound/src:
main/java/javax/sound/sampled/ main/java/javax/sound/sampled/spi/
test/java/org/apache/harmony/sound/tests/javax/sound/sampled/
test/java/org/apache/harmony/sound/te...
Author: mloenko
Date: Fri Aug 25 04:57:41 2006
New Revision: 436771
URL: http://svn.apache.org/viewvc?rev=436771&view=rev
Log:
more simple classes for sound module (and some stubs to make them compilable)
Added:
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFileFormat.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/Mixer.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileReader.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileWriter.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/FormatConversionProvider.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/MixerProvider.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/AudioFileWriterTest.java
incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/MixerProviderTest.java
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFileFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFileFormat.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFileFormat.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFileFormat.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled;
+
+public class AudioFileFormat {
+
+ public static class Type {
+
+ private String name;
+
+ private String extension;
+
+ public Type(String name, String extension) {
+ this.name = name;
+ this.extension = extension;
+ }
+
+ /*
+ * according to the spec it should return true when objects are same but
+ * RI seem to compare internals
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public final boolean equals(Object another) {
+ if (this == another) {
+ return true;
+ }
+
+ if (another == null || !(another instanceof Type)) {
+ return false;
+ }
+
+ Type obj = (Type) another;
+ return (name == null ? obj.name == null : name.equals(obj.name))
+ && (extension == null ? obj.extension == null : extension
+ .equals(obj.extension));
+ }
+
+ public String getExtension() {
+ return extension;
+ }
+
+ public final int hashCode() {
+ return name.hashCode() + extension.hashCode();
+ }
+
+ public final String toString() {
+ throw new Error("not yet implemented");
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioFormat.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled;
+
+public class AudioFormat {
+ public static class Encoding{}
+
+ public Encoding getEncoding() {
+ throw new Error("not yet implemented");
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioInputStream.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioInputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/AudioInputStream.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled;
+
+public class AudioInputStream {
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/Mixer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/Mixer.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/Mixer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/Mixer.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled;
+
+public interface Mixer {
+ static class Info{
+ private String name;
+ private String vendor;
+ private String description;
+ private String version;
+
+ public Info(String name, String vendor, String description, String version) {
+ this.name = name;
+ this.vendor = vendor;
+ this.description = description;
+ this.version = version;
+ }
+
+ public final boolean equals(Object another) {
+ return this == another;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public final int hashCode() {
+ return name.hashCode() + vendor.hashCode() + description.hashCode() + version.hashCode();
+ }
+
+ public String toString() {
+ throw new Error("not yet implemented");
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileReader.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileReader.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileReader.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled.spi;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+
+public abstract class AudioFileReader {
+
+ public abstract AudioFileFormat getAudioFileFormat(File file);
+
+ public abstract AudioFileFormat getAudioFileFormat(InputStream stream);
+
+ public abstract AudioFileFormat getAudioFileFormat(URL url);
+
+ public abstract AudioInputStream getAudioInputStream(File file);
+
+ public abstract AudioInputStream getAudioInputStream(InputStream stream);
+
+ public abstract AudioInputStream getAudioInputStream(URL url);
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileWriter.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileWriter.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/AudioFileWriter.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled.spi;
+
+import java.io.File;
+import java.io.OutputStream;
+
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioFileFormat;
+
+public abstract class AudioFileWriter {
+
+ public abstract AudioFileFormat.Type[] getAudioFileTypes();
+
+ public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);
+
+ public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
+ AudioFileFormat.Type[] supported = getAudioFileTypes();
+ for (int i = 0; i < supported.length; i++) {
+ if (fileType.equals(supported[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {
+ AudioFileFormat.Type[] supported = getAudioFileTypes(stream);
+ for (int i = 0; i < supported.length; i++) {
+ if (fileType.equals(supported[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out);
+
+ public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out);
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/FormatConversionProvider.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/FormatConversionProvider.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/FormatConversionProvider.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/FormatConversionProvider.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled.spi;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+
+public abstract class FormatConversionProvider {
+
+ public abstract AudioInputStream getAudioInputStream(
+ AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream);
+
+ public abstract AudioInputStream getAudioInputStream(
+ AudioFormat targetFormat, AudioInputStream sourceStream);
+
+ public abstract AudioFormat.Encoding[] getTargetEncodings(
+ AudioFormat sourceFormat);
+
+ public boolean isConversionSupported(AudioFormat.Encoding targetEncoding,
+ AudioFormat sourceFormat) {
+ AudioFormat.Encoding[] encodings = getTargetEncodings(sourceFormat);
+ for (int i = 0; i < encodings.length; i++) {
+ if (targetEncoding.equals(encodings[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public abstract AudioFormat[] getTargetEncodings(
+ AudioFormat.Encoding targetFormat, AudioFormat sourceFormat);
+
+ public boolean isConversionSupported(AudioFormat targetFormat,
+ AudioFormat sourceFormat) {
+ AudioFormat[] formats = getTargetEncodings(targetFormat.getEncoding(),
+ sourceFormat);
+ for (int i = 0; i < formats.length; i++) {
+ if (targetFormat.equals(formats[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public abstract AudioFormat.Encoding[] getSourceEncodings();
+
+ public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding) {
+ AudioFormat.Encoding[] encodings = getSourceEncodings();
+ for (int i = 0; i < encodings.length; i++) {
+ if (sourceEncoding.equals(encodings[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public abstract AudioFormat.Encoding[] getTargetEncodings();
+
+ public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding) {
+ AudioFormat.Encoding[] encodings = getTargetEncodings();
+ for (int i = 0; i < encodings.length; i++) {
+ if (targetEncoding.equals(encodings[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/MixerProvider.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/MixerProvider.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/MixerProvider.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/sampled/spi/MixerProvider.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.sound.sampled.spi;
+
+import javax.sound.sampled.Mixer;
+
+public abstract class MixerProvider {
+
+ public abstract Mixer getMixer(Mixer.Info info);
+
+ public abstract Mixer.Info[] getMixerInfo();
+
+ public boolean isMixerSupported(Mixer.Info info) {
+ Mixer.Info[] devices = getMixerInfo();
+ for (int i = 0; i < devices.length; i++) {
+ if (info.equals(devices[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/AudioFileWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/AudioFileWriterTest.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/AudioFileWriterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/AudioFileWriterTest.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.sampled.spi;
+
+import java.io.File;
+import java.io.OutputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.spi.AudioFileWriter;
+
+import junit.framework.TestCase;
+
+public class AudioFileWriterTest extends TestCase {
+
+ static AudioFileFormat.Type[] recorded;
+
+ /**
+ * @tests javax.sound.midi.sampled.AudioFileWriter#isFileTypeSupported(AudioFileFormat.Type)
+ */
+ public void testIsFileTypeSupported1() {
+ AudioFileWriter writer = new AudioFileWriter() {
+
+ public AudioFileFormat.Type[] getAudioFileTypes() {
+ return recorded;
+ }
+
+ public AudioFileFormat.Type[] getAudioFileTypes(
+ AudioInputStream stream) {
+ fail("what are doing here?");
+ return null;
+ }
+
+ public int write(AudioInputStream stream,
+ AudioFileFormat.Type fileType, File out) {
+ fail("what are doing here?");
+ return 0;
+ }
+
+ public int write(AudioInputStream stream,
+ AudioFileFormat.Type fileType, OutputStream out) {
+ fail("what are doing here?");
+ return 0;
+ }
+ };
+
+ recorded = new AudioFileFormat.Type[1];
+ recorded[0] = new AudioFileFormat.Type("1", "2");
+
+ assertTrue(writer.isFileTypeSupported(recorded[0]));
+
+ AudioFileFormat.Type similar = new AudioFileFormat.Type("1", "2");
+ assertTrue(writer.isFileTypeSupported(similar));
+
+ try {
+ writer.isFileTypeSupported(null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+
+ recorded = null;
+ try {
+ writer.isFileTypeSupported(similar);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+ }
+
+
+ /**
+ * @tests javax.sound.midi.sampled.AudioFileWriter#isFileTypeSupported(AudioFileFormat.Type,AudioInputStream)
+ */
+ public void testIsFileTypeSupported2() {
+ AudioFileWriter writer = new AudioFileWriter() {
+
+ public AudioFileFormat.Type[] getAudioFileTypes() {
+ fail("what are doing here?");
+ return null;
+ }
+
+ public AudioFileFormat.Type[] getAudioFileTypes(
+ AudioInputStream stream) {
+ return recorded;
+ }
+
+ public int write(AudioInputStream stream,
+ AudioFileFormat.Type fileType, File out) {
+ fail("what are doing here?");
+ return 0;
+ }
+
+ public int write(AudioInputStream stream,
+ AudioFileFormat.Type fileType, OutputStream out) {
+ fail("what are doing here?");
+ return 0;
+ }
+ };
+
+ recorded = new AudioFileFormat.Type[1];
+ recorded[0] = new AudioFileFormat.Type("1", "2");
+
+ assertTrue(writer.isFileTypeSupported(recorded[0], null));
+
+ AudioFileFormat.Type similar = new AudioFileFormat.Type("1", "2");
+ assertTrue(writer.isFileTypeSupported(similar, null));
+
+ try {
+ writer.isFileTypeSupported(null, null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+
+ recorded = null;
+ try {
+ writer.isFileTypeSupported(similar, null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/MixerProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/MixerProviderTest.java?rev=436771&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/MixerProviderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/spi/MixerProviderTest.java Fri Aug 25 04:57:41 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.sampled.spi;
+
+import javax.sound.sampled.Mixer;
+import javax.sound.sampled.spi.MixerProvider;
+
+import junit.framework.TestCase;
+
+public class MixerProviderTest extends TestCase {
+
+ static Mixer.Info[] recorded;
+
+ /**
+ * @tests javax.sound.midi.spi.MixerProvider#isMixerSupported(Mixer.Info)
+ */
+ public void testIsMixerSupported() {
+ MixerProvider myProvider = new MixerProvider() {
+
+ public Mixer getMixer(Mixer.Info info) {
+ fail("what are doing here?");
+ return null;
+ }
+
+ public Mixer.Info[] getMixerInfo() {
+ return recorded;
+ }
+ };
+
+ recorded = new Mixer.Info[1];
+ recorded[0] = new Mixer.Info("1", "2", "3", "4") {};
+ assertTrue(myProvider.isMixerSupported(recorded[0]));
+
+ Mixer.Info similar = new Mixer.Info("1", "2", "3", "4") {};
+ assertFalse(myProvider.isMixerSupported(similar));
+
+ try {
+ myProvider.isMixerSupported(null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+
+ recorded = null;
+ try {
+ myProvider.isMixerSupported(similar);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+ }
+}