* * 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.
* *
* *
******************************************************************************/
+
package org.onap.aaf.cadi.test;
import static junit.framework.Assert.assertEquals;
public class JU_Capacitor {
private Capacitor cap;
- public final static String TEST_DATA =
+ public final static String TEST_DATA =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" +
assertNull(curr_field.get(cap));
assertEquals(idx_field.get(cap), 0);
- for(int iter = 0; iter < 20; ++iter) {
- for(int i = 0; i < 20; ++i) {
+ for (int iter = 0; iter < 20; ++iter) {
+ for (int i = 0; i < 20; ++i) {
cap.put((byte)('a' + i));
}
cap.setForRead();
byte[] array = new byte[20];
- for(int i = 0; i < 20; ++i) {
+ for (int i = 0; i < 20; ++i) {
array[i]=(byte)cap.read();
}
assertEquals("abcdefghijklmnopqrst", new String(array));
cap.done();
}
- for(int i = 0; i < 500; i++) {
+ for (int i = 0; i < 500; i++) {
cap.put((byte)'a');
}
cap.setForRead();
byte[] array = new byte[500];
- for(int i = 0; i < 500; ++i) {
+ for (int i = 0; i < 500; ++i) {
array[i]=(byte)cap.read();
}
assertEquals((new String(array)).length(), 500);
@Test
public void availableTest() {
assertEquals(cap.available(), 0);
- for(int i = 0; i < 100; ++i) {
+ for (int i = 0; i < 100; ++i) {
cap.put((byte)'a');
}
// The Capacitor can hold 256 bytes. After reading 100 bytes,
byte[] a = b.getBytes();
byte[] c = new byte[b.length()]; // we want to use this to test reading offsets, etc
- for(int i = 0; i < a.length; i += 11) {
+ for (int i = 0; i < a.length; i += 11) {
cap.put(a, i, Math.min(11, a.length-i));
}
cap.reset();
int read;
- for(int i = 0; i < c.length; i += read) {
+ for (int i = 0; i < c.length; i += read) {
read = cap.read(c, i, Math.min(3, c.length-i));
}
- assertEquals(b, new String(c));
+ assertEquals(b, new String(c));
}
@Test