Skip to content

Commit

Permalink
added JunitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekpanchal committed Nov 6, 2018
1 parent fe30cf8 commit 1ed9a02
Show file tree
Hide file tree
Showing 38 changed files with 176 additions and 2,395 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion JavaJoker/JavaJoker.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/classes/java/main" />
<output-test url="file://$MODULE_DIR$/build/classes/java/test" />
<exclude-output />
Expand Down
2 changes: 0 additions & 2 deletions JavaJoker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

sourceCompatibility = "7"
targetCompatibility = "7"
16 changes: 15 additions & 1 deletion JavaJoker/src/main/java/com/vivek/panchal/javajoker/Joker.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
package com.vivek.panchal.javajoker;

import java.util.Random;

public class Joker {

/*
Jokes copied and pasted from https://top-funny-jokes.com/
*/

private static final String[] jokesList = new String[]
{"Where did Lucy go after the explosion? Everywhere.",
"What´s the stupidest animal in the jungle? The polar bear.",
"My grandfather had the heart of lion and a lifetime ban from the New your city zoo.",
"Two mice chewing on a film roll. One of them says. I think the book was better.",
"What kind of bagel can fly? A plain bagel."
};

public String tellJoke() {
return "Microsoft gives you Windows, Linux gives you a home!";
return jokesList[new Random().nextInt(jokesList.length)];
}

}
76 changes: 48 additions & 28 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -87,68 +87,88 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/endpointsClientLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/endpointsDiscoveryDocsFromDependencies" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-core:2.1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore:4.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-gass-license-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-license-11.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.annotation:javax.annotation-api:1.2@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-26.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-2.2.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:common:1.0.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:multidex-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.google.oauth-client:google-oauth-client:1.23.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:rules-0.5" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.api-client:google-api-client:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:26.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.http-client:google-http-client-jackson2:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpclient:4.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-lite-license-11.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:rules-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement-license-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.http-client:google-http-client:1.23.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.0.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-gass-11.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor-1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support:multidex-instrumentation-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.findbugs:jsr305:3.0.2@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.1.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore:4.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-license-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.annotation:javax.annotation-api:1.2@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-25.2.0" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.google.api-client:google-api-client:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.http-client:google-http-client-jackson2:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-lite-license-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.http-client:google-http-client:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-25.2.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-lite-11.8.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-ads-11.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.http-client:google-http-client-android:1.23.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.guava:guava-jdk5:17.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.0.0" level="project" />
<orderEntry type="module" module-name="jokefactory" />
<orderEntry type="module" module-name="JavaJoker" />
</component>
Expand Down
23 changes: 17 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ buildscript {
}

android {
compileSdkVersion 26
buildToolsVersion "26.0.3"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.udacity.gradle.builditbigger"
minSdkVersion 20
targetSdkVersion 26
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand All @@ -36,7 +36,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
endpointsServer project(path: ':backend', configuration: 'endpoints')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.http-client:google-http-client-android:1.23.0'
Expand All @@ -47,7 +47,18 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})

implementation project(path: ':jokefactory')

androidTestImplementation('com.android.support.test:runner:1.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('com.android.support.test:rules:1.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
compile project(path: ':jokefactory')
implementation 'junit:junit:4.12'

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.udacity.gradle.builditbigger;

import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.concurrent.TimeUnit;

import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;


@RunWith(AndroidJUnit4.class)
public class EndPointAsyncTaskTest {

@Test
public void testDoInBackground() {
try {
MainActivity mainActivity = new MainActivity();
EndpointAsyncTask syncEndpoint = new EndpointAsyncTask(mainActivity);
syncEndpoint.execute();
String result = syncEndpoint.get(30, TimeUnit.SECONDS);

assertNotNull(result);
assertTrue(result.length() > 0);
} catch (Exception e) {
Log.e("Test:", " Timed out");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.udacity.gradle.builditbigger;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
Expand All @@ -17,8 +16,10 @@

class EndpointAsyncTask extends AsyncTask<Context, Void, String> {
private static MyApi myApiService = null;
@SuppressLint("StaticFieldLeak")
private Context context;
protected Context context;

public EndpointAsyncTask(MainActivity mainActivity) {
}

@Override
protected String doInBackground(Context... params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public void tellJoke(View view) {
// joker.tellJoke();
// Toast.makeText(this, joker.tellJoke(), Toast.LENGTH_SHORT).show();

new EndpointAsyncTask().execute(this);
// new EndpointAsyncTask().execute(this);
EndpointAsyncTask endpointAsyncTask = new EndpointAsyncTask(this);
endpointAsyncTask.execute();
}


Expand Down
2 changes: 1 addition & 1 deletion backend/backend.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/classes/java/main" />
<output-test url="file://$MODULE_DIR$/build/classes/java/test" />
<exclude-output />
Expand Down
2 changes: 0 additions & 2 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
implementation 'com.google.endpoints:endpoints-framework:2.0.9'
Expand Down
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions backend/build/dev-appserver-out/dev_appserver.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Warning: Google App Engine Java 7 runtime is deprecated.
Warning: See https://cloud.google.com/appengine/docs/deprecations/java7
Nov 06, 2018 9:41:00 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Nov 06, 2018 9:41:00 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value 'C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'D:\Udacity Projects\GradlePRojects\ud867-master\FinalProject\backend\build\exploded-backend\WEB-INF\appengine-web.xml'
Nov 06, 2018 9:41:00 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Nov 06, 2018 4:11:00 PM com.google.appengine.tools.development.IsolatedAppClassLoader checkWorkingDirectory
WARNING: Your working directory, (D:\Udacity Projects\GradlePRojects\ud867-master\FinalProject\backend) is not equal to your
web application root (D:\Udacity Projects\GradlePRojects\ud867-master\FinalProject\backend\build\exploded-backend)
You will not be able to access files from your working directory on the production server.

Nov 06, 2018 4:11:01 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Nov 06, 2018 4:11:02 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector@localhost:8080
Nov 06, 2018 4:11:02 PM com.google.appengine.tools.development.AbstractModule startup
INFO: Module instance default is running at http://localhost:8080/
Nov 06, 2018 4:11:02 PM com.google.appengine.tools.development.AbstractModule startup
INFO: The admin console is running at http://localhost:8080/_ah/admin
Nov 06, 2018 9:41:02 PM com.google.appengine.tools.development.DevAppServerImpl doStart
INFO: Dev App Server is now running
Nov 06, 2018 9:41:06 PM com.google.appengine.repackaged.com.google.protobuf.UnsafeUtil supportsUnsafeByteBufferOperations
WARNING: platform method missing - proto runtime falling back to safer methods: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc")
Nov 06, 2018 9:41:06 PM com.google.appengine.repackaged.com.google.protobuf.UnsafeUtil supportsUnsafeArrayOperations
WARNING: platform method missing - proto runtime falling back to safer methods: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc")
Binary file modified backend/build/distributions/backend-discoveryDocs.zip
Binary file not shown.
Loading

0 comments on commit 1ed9a02

Please sign in to comment.