Skip to content

Commit

Permalink
updated build files, fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsguy committed Apr 30, 2016
1 parent f466275 commit 982e666
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 143 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
/***
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/

package com.commonsware.android.unittest;

import android.support.test.runner.AndroidJUnit4;
import junit.framework.Assert;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -29,12 +25,12 @@ public class ItemTests {
private static final String URL="https://commonsware.com";

@Test
public void iCanHazString() {
Item item=new Item();
public void iCanHazString() {
Item item=new Item();

item.title=TITLE;
item.link=URL;

Assert.assertEquals(TITLE, item.toString());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/***
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/

package com.commonsware.android.unittest;

Expand All @@ -27,38 +27,38 @@

@RunWith(AndroidJUnit4.class)
public class SOTests {
private CountDownLatch responseLatch;
private CountDownLatch responseLatch;
private SOQuestions questions;

@Before
public void setUp() {
responseLatch=new CountDownLatch(1);
}
@Before
public void setUp() {
responseLatch=new CountDownLatch(1);
}

@Test(timeout=3000)
public void fetchQuestions() throws InterruptedException {
RestAdapter restAdapter=
new RestAdapter.Builder()
public void fetchQuestions() throws InterruptedException {
RestAdapter restAdapter=
new RestAdapter.Builder()
.setEndpoint("https://api.stackexchange.com")
.build();
StackOverflowInterface so=
restAdapter.create(StackOverflowInterface.class);
.build();
StackOverflowInterface so=
restAdapter.create(StackOverflowInterface.class);

so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions soQuestions,
Response response) {
so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions soQuestions,
Response response) {
questions=soQuestions;
responseLatch.countDown();
}
}

@Override
public void failure(RetrofitError error) {
@Override
public void failure(RetrofitError error) {
responseLatch.countDown();
}
});
}
});

responseLatch.await();
responseLatch.await();

Assert.assertNotNull(questions);
Assert.assertEquals(30, questions.items.size());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/***
Copyright (c) 2008-2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/

package com.commonsware.android.unittest;

Expand All @@ -32,21 +32,21 @@ static public void doThisFirstOnlyOnce() {

@Before
public void doThisFirst() {
// do initialization here, run on every test method
}
// do initialization here, run on every test method
}

@After
public void doThisLast() {
// do termination here, run on every test method
}
// do termination here, run on every test method
}

@AfterClass
static public void doThisLastOnlyOnce() {
// do termination here, run once for all SillyTest tests
}

@Test
public void thisIsReallySilly() {
public void thisIsReallySilly() {
Assert.assertEquals("bit got flipped by cosmic rays", 1, 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
/***
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/

package com.commonsware.android.unittest;

import junit.framework.Assert;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class ItemTests {
private static final String TITLE="this is a title";
private static final String URL="https://commonsware.com";

@Test
public void iCanHazString() {
Item item=new Item();
public void iCanHazString() {
Item item=new Item();

item.title=TITLE;
item.link=URL;

Assert.assertEquals(TITLE, item.toString());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/***
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/
Copyright (c) 2016 CommonsWare, LLC
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.
From _The Busy Coder's Guide to Android Development_
https://commonsware.com/Android
*/

package com.commonsware.android.unittest;

Expand All @@ -24,38 +24,38 @@
import retrofit.client.Response;

public class SOTests {
private CountDownLatch responseLatch;
private CountDownLatch responseLatch;
private SOQuestions questions;

@Before
public void setUp() {
responseLatch=new CountDownLatch(1);
}
@Before
public void setUp() {
responseLatch=new CountDownLatch(1);
}

@Test(timeout=30000)
public void fetchQuestions() throws InterruptedException {
RestAdapter restAdapter=
new RestAdapter.Builder()
public void fetchQuestions() throws InterruptedException {
RestAdapter restAdapter=
new RestAdapter.Builder()
.setEndpoint("https://api.stackexchange.com")
.build();
StackOverflowInterface so=
restAdapter.create(StackOverflowInterface.class);
.build();
StackOverflowInterface so=
restAdapter.create(StackOverflowInterface.class);

so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions soQuestions,
Response response) {
so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions soQuestions,
Response response) {
questions=soQuestions;
responseLatch.countDown();
}
}

@Override
public void failure(RetrofitError error) {
@Override
public void failure(RetrofitError error) {
responseLatch.countDown();
}
});
}
});

responseLatch.await();
responseLatch.await();

Assert.assertNotNull(questions);
Assert.assertEquals(30, questions.items.size());
Expand Down
Loading

0 comments on commit 982e666

Please sign in to comment.